From: Jay Freeman (saurik) Date: Mon, 14 Jul 2014 01:38:54 +0000 (-0700) Subject: Send [0.0,1.0) x,y coordinates, to system client. X-Git-Tag: v0.9.3402~1 X-Git-Url: https://git.saurik.com/veency.git/commitdiff_plain/0f34ed18759593d9fc234e86a3930f0df06540ee Send [0.0,1.0) x,y coordinates, to system client. --- diff --git a/Tweak.mm b/Tweak.mm index 04f9b01..e0377fe 100644 --- a/Tweak.mm +++ b/Tweak.mm @@ -66,8 +66,6 @@ MSClassHook(UIApplication) @interface CAWindowServerDisplay : NSObject - (mach_port_t) clientPortAtPosition:(CGPoint)position; -- (unsigned) contextIdAtPosition:(CGPoint)position; -- (mach_port_t) taskPortOfContextId:(unsigned)context; @end @interface CAWindowServer : NSObject @@ -98,14 +96,6 @@ MSClassHook(UIApplication) - (void) removeStatusBarItem:(NSString *)item; @end -@interface BKHIDClientConnectionManager : NSObject -- (IOHIDEventSystemConnectionRef) clientForTaskPort:(mach_port_t)port; -@end - -@interface BKAccessibility : NSObject -+ (BKHIDClientConnectionManager *) _eventRoutingClientConnectionManager; -@end - typedef void *CoreSurfaceBufferRef; extern CFStringRef kCoreSurfaceBufferGlobal; @@ -643,27 +633,16 @@ static void VNCPointerNew(int buttons, int x, int y, CGPoint location, int diff, fingerm = kIOHIDDigitizerEventRange | kIOHIDDigitizerEventTouch; } else return; - CAWindowServer *server([CAWindowServer serverIfRunning]); - if (server == nil) - return; - - CAWindowServerDisplay *display([[server displays] objectAtIndex:0]); - if (display == nil) - return; - - unsigned context([display contextIdAtPosition:CGPointMake(x, y)]); - mach_port_t port([display taskPortOfContextId:context]); - if (port == MACH_PORT_NULL) - return; + // XXX: avoid division in VNCPointer() + x *= ratio_; + y *= ratio_; - IOHIDEventSystemConnectionRef connection([[$BKAccessibility _eventRoutingClientConnectionManager] clientForTaskPort:port]); - if (connection == NULL) - return; - - // XXX: I guess this isn't ambiguous, and it works IOHIDFloat xf(x); IOHIDFloat yf(y); + xf /= width_; + yf /= height_; + IOHIDEventRef hand(IOHIDEventCreateDigitizerEvent(kCFAllocatorDefault, mach_absolute_time(), kIOHIDDigitizerTransducerTypeHand, 1<<22, 1, handm, 0, xf, yf, 0, 0, 0, 0, 0, 0)); IOHIDEventSetIntegerValue(hand, kIOHIDEventFieldIsBuiltIn, true); IOHIDEventSetIntegerValue(hand, kIOHIDEventFieldDigitizerIsDisplayIntegrated, true); @@ -672,9 +651,7 @@ static void VNCPointerNew(int buttons, int x, int y, CGPoint location, int diff, IOHIDEventAppendEvent(hand, finger); CFRelease(finger); - VNCSetSender(hand); - IOHIDEventSystemConnectionDispatchEvent(connection, hand); - CFRelease(hand); + VNCSendHIDEvent(hand); } GSEventRef (*$GSEventCreateKeyEvent)(int, CGPoint, CFStringRef, CFStringRef, id, UniChar, short, short);