summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@freedesktop.org>2008-05-15 05:49:43 -0700
committerJeremy Huddleston <jeremyhu@freedesktop.org>2008-05-17 14:56:30 -0700
commit1d09deaa6e5a75420ea4f24f6b5533f0ebc3ba28 (patch)
tree4989ce91ecb5eecdaa158dbe77762fa893263f3b /hw
parentadc62f62b9f08aa6633718989ab61b61e3c1e8e2 (diff)
XQuartz: Made DarwinSendDDXEvent a little more robust to context switching diring server init.
(cherry picked from commit 5626b0949b1a6bdd2fa3ec2ef53a688084349b87)
Diffstat (limited to 'hw')
-rw-r--r--hw/xquartz/X11Application.m4
-rw-r--r--hw/xquartz/darwinEvents.c26
2 files changed, 15 insertions, 15 deletions
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 9367c9fa1..50a30fbf5 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -59,11 +59,9 @@
int X11EnableKeyEquivalents = TRUE;
int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
-extern int darwinFakeButtons, input_check_flag;
+extern int darwinFakeButtons;
extern Bool enable_stereo;
-extern xEvent *darwinEvents;
-
X11Application *X11App;
#define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 154709448..7376c5796 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -76,12 +76,10 @@ in this Software without prior written authorization from The Open Group.
/* FIXME: Abstract this better */
void QuartzModeEQInit(void);
-int input_check_zero, input_check_flag;
-
static int old_flags = 0; // last known modifier state
-xEvent *darwinEvents = NULL;
-pthread_mutex_t darwinEvents_mutex = PTHREAD_MUTEX_INITIALIZER;
+static xEvent *darwinEvents = NULL;
+static pthread_mutex_t darwinEvents_mutex = PTHREAD_MUTEX_INITIALIZER;
static inline void darwinEvents_lock(void) {
int err;
@@ -307,11 +305,6 @@ static void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, in
}
Bool DarwinEQInit(void) {
- if (!darwinEvents)
- darwinEvents = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
- if (!darwinEvents)
- FatalError("Couldn't allocate event buffer\n");
-
mieqInit();
mieqSetHandler(kXquartzReloadKeymap, DarwinKeyboardReloadHandler);
mieqSetHandler(kXquartzActivate, DarwinEventHandler);
@@ -328,6 +321,11 @@ Bool DarwinEQInit(void) {
mieqSetHandler(kXquartzDisplayChanged, QuartzDisplayChangedHandler);
QuartzModeEQInit();
+
+ if (!darwinEvents)
+ darwinEvents = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+ if (!darwinEvents)
+ FatalError("Couldn't allocate event buffer\n");
return TRUE;
}
@@ -354,7 +352,6 @@ void ProcessInputEvents(void) {
Dispatch() event loop to check out event queue */
static void DarwinPokeEQ(void) {
char nullbyte=0;
- input_check_flag++;
// <daniels> oh, i ... er ... christ.
write(darwinEventWriteFD, &nullbyte, 1);
}
@@ -567,8 +564,13 @@ void DarwinSendDDXEvent(int type, int argc, ...) {
va_end (args);
}
- darwinEvents_lock();
+ /* If we're called from something other than the X server thread, we need
+ * to wait for the X server to setup darwinEvents.
+ */
+ while(darwinEvents == NULL) {
+ usleep(250000);
+ }
+
mieqEnqueue(darwinPointer, &xe);
DarwinPokeEQ();
- darwinEvents_unlock();
}