From 96d6df5da9cddedf4931bf8e17f96e242467c661 Mon Sep 17 00:00:00 2001 From: marha Date: Wed, 27 Apr 2011 06:58:32 +0000 Subject: xserver libX11 libxtrans mesa pixman xkeyboard-config git update 27 Apr 2011 --- xorg-server/hw/xquartz/X11Application.m | 78 +++++++++++++++++++++++++-------- 1 file changed, 60 insertions(+), 18 deletions(-) (limited to 'xorg-server/hw/xquartz/X11Application.m') diff --git a/xorg-server/hw/xquartz/X11Application.m b/xorg-server/hw/xquartz/X11Application.m index 3521517a2..e56bf0cf3 100644 --- a/xorg-server/hw/xquartz/X11Application.m +++ b/xorg-server/hw/xquartz/X11Application.m @@ -61,6 +61,12 @@ extern int xpbproxy_run (void); #define XSERVER_VERSION "?" #endif +#ifdef HAVE_LIBDISPATCH +#include + +static dispatch_queue_t eventTranslationQueue; +#endif + /* Stuck modifier / button state... force release when we context switch */ static NSEventType keyState[NUM_KEYCODES]; @@ -385,7 +391,15 @@ static void message_kit_thread (SEL selector, NSObject *arg) { if (for_appkit) [super sendEvent:e]; - if (for_x) [self sendX11NSEvent:e]; + if (for_x) { +#ifdef HAVE_LIBDISPATCH + dispatch_async(eventTranslationQueue, ^{ +#endif + [self sendX11NSEvent:e]; +#ifdef HAVE_LIBDISPATCH + }); +#endif + } } - (void) set_window_menu:(NSArray *)list { @@ -950,7 +964,7 @@ environment the next time you start X11?", @"Startup xinitrc dialog"); [X11App prefs_synchronize]; } -static inline pthread_t create_thread(void *func, void *arg) { +static inline pthread_t create_thread(void *(*func)(void *), void *arg) { pthread_attr_t attr; pthread_t tid; @@ -999,6 +1013,11 @@ void X11ApplicationMain (int argc, char **argv, char **envp) { aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) - NSMaxY([[NSScreen mainScreen] visibleFrame]); +#ifdef HAVE_LIBDISPATCH + eventTranslationQueue = dispatch_queue_create(LAUNCHD_ID_PREFIX".X11.NSEventsToX11EventsQueue", NULL); + assert(eventTranslationQueue != NULL); +#endif + /* Set the key layout seed before we start the server */ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 last_key_layout = TISCopyCurrentKeyboardLayoutInputSource(); @@ -1079,13 +1098,29 @@ static const char *untrusted_str(NSEvent *e) { #endif - (void) sendX11NSEvent:(NSEvent *)e { - NSPoint location = NSZeroPoint, tilt = NSZeroPoint; + NSPoint location = NSZeroPoint; int ev_button, ev_type; - float pressure = 0.0; + static float pressure = 0.0; // static so ProximityOut will have the value from the previous tablet event + static NSPoint tilt; // static so ProximityOut will have the value from the previous tablet event + static DeviceIntPtr darwinTabletCurrent = NULL; + static BOOL needsProximityIn = NO; // Do we do need to handle a pending ProximityIn once we have pressure/tilt? DeviceIntPtr pDev; int modifierFlags; BOOL isMouseOrTabletEvent, isTabletEvent; +#ifdef HAVE_LIBDISPATCH + static dispatch_once_t once_pred; + dispatch_once(&once_pred, ^{ + tilt = NSZeroPoint; + darwinTabletCurrent = darwinTabletStylus; + }); +#else + if(!darwinTabletCurrent) { + tilt = NSZeroPoint; + darwinTabletCurrent = darwinTabletStylus; + } +#endif + isMouseOrTabletEvent = [e type] == NSLeftMouseDown || [e type] == NSOtherMouseDown || [e type] == NSRightMouseDown || [e type] == NSLeftMouseUp || [e type] == NSOtherMouseUp || [e type] == NSRightMouseUp || [e type] == NSLeftMouseDragged || [e type] == NSOtherMouseDragged || [e type] == NSRightMouseDragged || @@ -1207,19 +1242,14 @@ static const char *untrusted_str(NSEvent *e) { darwinTabletCurrent=darwinTabletCursor; break; } - - /* NSTabletProximityEventSubtype doesn't encode pressure ant tilt - * So we just pretend the motion was caused by the mouse. Hopefully - * we'll have a better solution for this in the future (like maybe - * NSTabletProximityEventSubtype will come from NSTabletPoint - * rather than NSMouseMoved. - pressure = [e pressure]; - tilt = [e tilt]; - pDev = darwinTabletCurrent; - */ - DarwinSendProximityEvents([e isEnteringProximity] ? ProximityIn : ProximityOut, - location.x, location.y); + if([e isEnteringProximity]) + needsProximityIn = YES; + else + DarwinSendProximityEvents(darwinTabletCurrent, ProximityOut, + location.x, location.y, pressure, + tilt.x, tilt.y); + return; } if ([e type] == NSTabletPoint || [e subtype] == NSTabletPointEventSubtype) { @@ -1227,6 +1257,14 @@ static const char *untrusted_str(NSEvent *e) { tilt = [e tilt]; pDev = darwinTabletCurrent; + + if(needsProximityIn) { + DarwinSendProximityEvents(darwinTabletCurrent, ProximityIn, + location.x, location.y, pressure, + tilt.x, tilt.y); + + needsProximityIn = NO; + } } if(!XQuartzServerVisible && noTestExtensions) { @@ -1280,8 +1318,12 @@ static const char *untrusted_str(NSEvent *e) { break; } - DarwinSendProximityEvents([e isEnteringProximity] ? ProximityIn : ProximityOut, - location.x, location.y); + if([e isEnteringProximity]) + needsProximityIn = YES; + else + DarwinSendProximityEvents(darwinTabletCurrent, ProximityOut, + location.x, location.y, pressure, + tilt.x, tilt.y); break; case NSScrollWheel: -- cgit v1.2.3