diff options
author | marha <marha@users.sourceforge.net> | 2009-10-05 15:13:41 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2009-10-05 15:13:41 +0000 |
commit | 78db264e7992131e0781bdfa5ede821305262b2d (patch) | |
tree | 7461ae9dab5bf69f056250fc233c1ada393dc957 /xorg-server/hw/xquartz/darwinEvents.c | |
parent | 1d2fa791e7eb383cf2818bb2e33da546edbeade9 (diff) | |
parent | 77a4732b0637493966889fe3545966fdc12a1b5e (diff) | |
download | vcxsrv-78db264e7992131e0781bdfa5ede821305262b2d.tar.gz vcxsrv-78db264e7992131e0781bdfa5ede821305262b2d.tar.bz2 vcxsrv-78db264e7992131e0781bdfa5ede821305262b2d.zip |
svn merge https://vcxsrv.svn.sourceforge.net/svnroot/vcxsrv/branches/released .
Diffstat (limited to 'xorg-server/hw/xquartz/darwinEvents.c')
-rw-r--r-- | xorg-server/hw/xquartz/darwinEvents.c | 246 |
1 files changed, 115 insertions, 131 deletions
diff --git a/xorg-server/hw/xquartz/darwinEvents.c b/xorg-server/hw/xquartz/darwinEvents.c index 4822af479..421efcedf 100644 --- a/xorg-server/hw/xquartz/darwinEvents.c +++ b/xorg-server/hw/xquartz/darwinEvents.c @@ -43,6 +43,7 @@ in this Software without prior written authorization from The Open Group. #include "windowstr.h" #include "pixmapstr.h" #include "inputstr.h" +#include "eventstr.h" #include "mi.h" #include "scrnintstr.h" #include "mipointer.h" @@ -71,7 +72,7 @@ in this Software without prior written authorization from The Open Group. #include "applewmExt.h" /* FIXME: Abstract this better */ -void QuartzModeEQInit(void); +extern Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev); int darwin_all_modifier_flags = 0; // last known modifier state int darwin_all_modifier_mask = 0; @@ -84,7 +85,7 @@ static pthread_mutex_t fd_add_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t fd_add_ready_cond = PTHREAD_COND_INITIALIZER; static pthread_t fd_add_tid = NULL; -static EventList *darwinEvents = NULL; +static EventListPtr darwinEvents = NULL; static pthread_mutex_t mieq_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t mieq_ready_cond = PTHREAD_COND_INITIALIZER; @@ -190,89 +191,98 @@ static void DarwinUpdateModifiers( be moved into their own individual functions and set as handlers using mieqSetHandler. */ -static void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) { - int i; - +static void DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr dev) { + XQuartzEvent *e = &(ie->xquartz_event); + TA_SERVER(); -// DEBUG_LOG("DarwinEventHandler(%d, %p, %p, %d)\n", screenNum, xe, dev, nevents); - for (i=0; i<nevents; i++) { - switch(xe[i].u.u.type) { - case kXquartzControllerNotify: - DEBUG_LOG("kXquartzControllerNotify\n"); - AppleWMSendEvent(AppleWMControllerNotify, - AppleWMControllerNotifyMask, - xe[i].u.clientMessage.u.l.longs0, - xe[i].u.clientMessage.u.l.longs1); - break; - - case kXquartzPasteboardNotify: - DEBUG_LOG("kXquartzPasteboardNotify\n"); - AppleWMSendEvent(AppleWMPasteboardNotify, - AppleWMPasteboardNotifyMask, - xe[i].u.clientMessage.u.l.longs0, - xe[i].u.clientMessage.u.l.longs1); - break; - - case kXquartzActivate: - DEBUG_LOG("kXquartzActivate\n"); - QuartzShow(xe[i].u.keyButtonPointer.rootX, - xe[i].u.keyButtonPointer.rootY); - AppleWMSendEvent(AppleWMActivationNotify, - AppleWMActivationNotifyMask, - AppleWMIsActive, 0); - break; - - case kXquartzDeactivate: - DEBUG_LOG("kXquartzDeactivate\n"); - AppleWMSendEvent(AppleWMActivationNotify, - AppleWMActivationNotifyMask, - AppleWMIsInactive, 0); + switch(e->subtype) { + case kXquartzControllerNotify: + DEBUG_LOG("kXquartzControllerNotify\n"); + AppleWMSendEvent(AppleWMControllerNotify, + AppleWMControllerNotifyMask, + e->data[0], + e->data[1]); + break; + + case kXquartzPasteboardNotify: + DEBUG_LOG("kXquartzPasteboardNotify\n"); + AppleWMSendEvent(AppleWMPasteboardNotify, + AppleWMPasteboardNotifyMask, + e->data[0], + e->data[1]); + break; + + case kXquartzActivate: + DEBUG_LOG("kXquartzActivate\n"); + QuartzShow(); + AppleWMSendEvent(AppleWMActivationNotify, + AppleWMActivationNotifyMask, + AppleWMIsActive, 0); + break; + + case kXquartzDeactivate: + DEBUG_LOG("kXquartzDeactivate\n"); + AppleWMSendEvent(AppleWMActivationNotify, + AppleWMActivationNotifyMask, + AppleWMIsInactive, 0); + QuartzHide(); + break; + + case kXquartzReloadPreferences: + DEBUG_LOG("kXquartzReloadPreferences\n"); + AppleWMSendEvent(AppleWMActivationNotify, + AppleWMActivationNotifyMask, + AppleWMReloadPreferences, 0); + break; + + case kXquartzToggleFullscreen: + DEBUG_LOG("kXquartzToggleFullscreen\n"); + if (quartzEnableRootless) + QuartzSetFullscreen(!quartzHasRoot); + else if (quartzHasRoot) QuartzHide(); - break; - - case kXquartzReloadPreferences: - DEBUG_LOG("kXquartzReloadPreferences\n"); - AppleWMSendEvent(AppleWMActivationNotify, - AppleWMActivationNotifyMask, - AppleWMReloadPreferences, 0); - break; - - case kXquartzToggleFullscreen: - DEBUG_LOG("kXquartzToggleFullscreen\n"); - if (quartzEnableRootless) - QuartzSetFullscreen(!quartzHasRoot); - else if (quartzHasRoot) - QuartzHide(); - else - QuartzShow(xe[i].u.keyButtonPointer.rootX, - xe[i].u.keyButtonPointer.rootY); - break; - - case kXquartzSetRootless: - DEBUG_LOG("kXquartzSetRootless\n"); - QuartzSetRootless(xe[i].u.clientMessage.u.l.longs0); - if (!quartzEnableRootless && !quartzHasRoot) - QuartzHide(); - break; - - case kXquartzSetRootClip: - QuartzSetRootClip((Bool)xe[i].u.clientMessage.u.l.longs0); - break; - - case kXquartzQuit: - GiveUp(0); - break; - - case kXquartzSpaceChanged: - DEBUG_LOG("kXquartzSpaceChanged\n"); - QuartzSpaceChanged(xe[i].u.clientMessage.u.l.longs0); - break; - - default: - ErrorF("Unknown application defined event type %d.\n", xe[i].u.u.type); - } - } + else + QuartzShow(); + break; + + case kXquartzSetRootless: + DEBUG_LOG("kXquartzSetRootless\n"); + QuartzSetRootless(e->data[0]); + if (!quartzEnableRootless && !quartzHasRoot) + QuartzHide(); + break; + + case kXquartzSetRootClip: + QuartzSetRootClip((Bool)e->data[0]); + break; + + case kXquartzQuit: + GiveUp(0); + break; + + case kXquartzSpaceChanged: + DEBUG_LOG("kXquartzSpaceChanged\n"); + QuartzSpaceChanged(e->data[0]); + break; + + case kXquartzListenOnOpenFD: + ErrorF("Calling ListenOnOpenFD() for new fd: %d\n", (int)e->data[0]); + ListenOnOpenFD((int)e->data[0], 1); + break; + + case kXquartzReloadKeymap: + DarwinKeyboardReloadHandler(); + break; + + case kXquartzDisplayChanged: + QuartzUpdateScreens(); + break; + + default: + if(!QuartzModeEventHandler(screenNum, e, dev)) + ErrorF("Unknown application defined event type %d.\n", e->subtype); + } } void DarwinListenOnOpenFD(int fd) { @@ -298,16 +308,6 @@ static void DarwinProcessFDAdditionQueue_thread(void *args) { } } -static void kXquartzListenOnOpenFDHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) { - size_t i; - TA_SERVER(); - - for (i=0; i<nevents; i++) { - ErrorF("Calling ListenOnOpenFD() for new fd: %d\n", (int)xe[i].u.clientMessage.u.l.longs0); - ListenOnOpenFD((int)xe[i].u.clientMessage.u.l.longs0, 1); - } -} - Bool DarwinEQInit(void) { int *p; @@ -320,23 +320,7 @@ Bool DarwinEQInit(void) { } mieqInit(); - mieqSetHandler(kXquartzReloadKeymap, DarwinKeyboardReloadHandler); - mieqSetHandler(kXquartzActivate, DarwinEventHandler); - mieqSetHandler(kXquartzDeactivate, DarwinEventHandler); - mieqSetHandler(kXquartzReloadPreferences, DarwinEventHandler); - mieqSetHandler(kXquartzSetRootClip, DarwinEventHandler); - mieqSetHandler(kXquartzQuit, DarwinEventHandler); - mieqSetHandler(kXquartzReadPasteboard, QuartzReadPasteboard); - mieqSetHandler(kXquartzWritePasteboard, QuartzWritePasteboard); - mieqSetHandler(kXquartzToggleFullscreen, DarwinEventHandler); - mieqSetHandler(kXquartzSetRootless, DarwinEventHandler); - mieqSetHandler(kXquartzSpaceChanged, DarwinEventHandler); - mieqSetHandler(kXquartzControllerNotify, DarwinEventHandler); - mieqSetHandler(kXquartzPasteboardNotify, DarwinEventHandler); - mieqSetHandler(kXquartzDisplayChanged, QuartzDisplayChangedHandler); - mieqSetHandler(kXquartzListenOnOpenFD, kXquartzListenOnOpenFDHandler); - - QuartzModeEQInit(); + mieqSetHandler(ET_XQuartz, DarwinEventHandler); /* Note that this *could* cause a potential async issue, since we're checking * darwinEvents without holding the lock, but darwinEvents is only ever set @@ -364,16 +348,16 @@ Bool DarwinEQInit(void) { * Read and process events from the event queue until it is empty. */ void ProcessInputEvents(void) { - xEvent xe; - int x = sizeof(xe); + char nullbyte; + int x = sizeof(nullbyte); TA_SERVER(); mieqProcessInputEvents(); // Empty the signaling pipe - while (x == sizeof(xe)) { - x = read(darwinEventReadFD, &xe, sizeof(xe)); + while (x == sizeof(nullbyte)) { + x = read(darwinEventReadFD, &nullbyte, sizeof(nullbyte)); } } @@ -382,7 +366,7 @@ void ProcessInputEvents(void) { static void DarwinPokeEQ(void) { char nullbyte=0; // <daniels> oh, i ... er ... christ. - write(darwinEventWriteFD, &nullbyte, 1); + write(darwinEventWriteFD, &nullbyte, sizeof(nullbyte)); } /* Convert from Appkit pointer input values to X input values: @@ -476,7 +460,7 @@ void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, floa darwinEvents_lock(); { num_events = GetPointerEvents(darwinEvents, pDev, ev_type, ev_button, POINTER_ABSOLUTE, 0, pDev==darwinTabletCurrent?5:2, valuators); - for(i=0; i<num_events; i++) mieqEnqueue (pDev, darwinEvents[i].event); + for(i=0; i<num_events; i++) mieqEnqueue (pDev, (InternalEvent*)darwinEvents[i].event); if(num_events > 0) DarwinPokeEQ(); } darwinEvents_unlock(); } @@ -491,7 +475,7 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) { darwinEvents_lock(); { num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE); - for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard,darwinEvents[i].event); + for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard, (InternalEvent*)darwinEvents[i].event); if(num_events > 0) DarwinPokeEQ(); } darwinEvents_unlock(); } @@ -519,7 +503,7 @@ void DarwinSendProximityEvents(int ev_type, float pointer_x, float pointer_y) { darwinEvents_lock(); { num_events = GetProximityEvents(darwinEvents, pDev, ev_type, 0, 5, valuators); - for(i=0; i<num_events; i++) mieqEnqueue (pDev,darwinEvents[i].event); + for(i=0; i<num_events; i++) mieqEnqueue (pDev, (InternalEvent*)darwinEvents[i].event); if(num_events > 0) DarwinPokeEQ(); } darwinEvents_unlock(); } @@ -529,13 +513,14 @@ void DarwinSendProximityEvents(int ev_type, float pointer_x, float pointer_y) { void DarwinSendScrollEvents(float count_x, float count_y, float pointer_x, float pointer_y, float pressure, float tilt_x, float tilt_y) { + int sign_x, sign_y; if(!darwinEvents) { DEBUG_LOG("DarwinSendScrollEvents called before darwinEvents was initialized\n"); return; } - int sign_x = count_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE; - int sign_y = count_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE; + sign_x = count_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE; + sign_y = count_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE; count_x = fabs(count_x); count_y = fabs(count_y); @@ -566,27 +551,26 @@ void DarwinUpdateModKeys(int flags) { * Send the X server thread a message by placing it on the event queue. */ void DarwinSendDDXEvent(int type, int argc, ...) { - xEvent xe; - INT32 *argv; - int i, max_args; + XQuartzEvent e; + int i; va_list args; - memset(&xe, 0, sizeof(xe)); - xe.u.u.type = type; - xe.u.clientMessage.u.l.type = type; - - argv = &xe.u.clientMessage.u.l.longs0; - max_args = 4; + memset(&e, 0, sizeof(e)); + e.header = ET_Internal; + e.type = ET_XQuartz; + e.length = sizeof(e); + e.time = GetTimeInMillis(); + e.subtype = type; - if (argc > 0 && argc <= max_args) { + if (argc > 0 && argc < XQUARTZ_EVENT_MAXARGS) { va_start (args, argc); for (i = 0; i < argc; i++) - argv[i] = (int) va_arg (args, int); + e.data[i] = (uint32_t) va_arg (args, uint32_t); va_end (args); } darwinEvents_lock(); { - mieqEnqueue(NULL, &xe); + mieqEnqueue(NULL, (InternalEvent*)&e); DarwinPokeEQ(); } darwinEvents_unlock(); } |