xserver: Branch 'master' - 13 commits
Jeremy Huddleston
jeremyhu at kemper.freedesktop.org
Wed Apr 2 17:48:45 PDT 2008
dix/main.c | 14
hw/xquartz/Makefile.am | 2
hw/xquartz/X11Application.m | 505 +++++++++++++++-----------------
hw/xquartz/X11Controller.m | 32 +-
hw/xquartz/darwin.c | 2
hw/xquartz/darwin.h | 14
hw/xquartz/darwinEvents.c | 353 +++++++++++-----------
hw/xquartz/darwinEvents.h | 4
hw/xquartz/darwinKeyboard.c | 20 -
hw/xquartz/darwinKeyboard.h | 2
hw/xquartz/quartz.c | 153 ---------
hw/xquartz/quartz.h | 2
hw/xquartz/quartzCocoa.m | 3
hw/xquartz/quartzCursor.c | 646 ------------------------------------------
hw/xquartz/quartzCursor.h | 42 --
hw/xquartz/quartzKeyboard.h | 1
hw/xquartz/quartzPasteboard.c | 10
hw/xquartz/quartzPasteboard.h | 4
hw/xquartz/xpr/xprCursor.c | 4
hw/xquartz/xpr/xprScreen.c | 9
20 files changed, 503 insertions(+), 1319 deletions(-)
New commits:
commit c737d04c758e03e32f692a31ed2a665ccbafa931
Author: Ben Byer <bbyer at apple.com>
Date: Tue Apr 1 00:40:46 2008 -0700
The AppKit thread should not be calling directly into the X server
functions to change state when the keyboard is reloaded; instead,
pass it as an event.
(cherry picked from commit 7e653f806ff5508aace059312156f319a9ed4479)
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index 01e6f41..df92d8b 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -91,13 +91,8 @@ extern int darwinMainScreenY;
* Special ddx events understood by the X server
*/
enum {
- kXquartzUpdateModifiers // update all modifier keys
+ kXquartzReloadKeymap // Reload system keymap
= LASTEvent+1, // (from X.h list of event names)
- kXquartzUpdateButtons, // update state of mouse buttons 2 and up
- kXquartzScrollWheel, // scroll wheel event
- /*
- * Quartz-specific events -- not used in IOKit mode
- */
kXquartzActivate, // restore X drawing and cursor
kXquartzDeactivate, // clip X drawing and switch to Aqua cursor
kXquartzSetRootClip, // enable or disable drawing to the X screen
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index b6cd3f2..3afbaf8 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -289,6 +289,7 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
FatalError("Couldn't allocate event buffer\n");
mieqInit();
+ mieqSetHandler(kXquartzReloadKeymap, DarwinKeyboardReloadHandler);
mieqSetHandler(kXquartzActivate, DarwinEventHandler);
mieqSetHandler(kXquartzDeactivate, DarwinEventHandler);
mieqSetHandler(kXquartzSetRootClip, DarwinEventHandler);
@@ -322,7 +323,7 @@ void ProcessInputEvents(void) {
// Empty the signaling pipe
int x = sizeof(xe);
while (x == sizeof(xe)) {
- DEBUG_LOG("draining pipe\n");
+// DEBUG_LOG("draining pipe\n");
x = read(darwinEventReadFD, &xe, sizeof(xe));
}
}
@@ -412,8 +413,8 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
this_seed = QuartzSystemKeymapSeed();
if (this_seed != last_seed) {
- last_seed = this_seed;
- DarwinKeyboardReload(darwinKeyboard);
+ last_seed = this_seed;
+ DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
}
}
diff --git a/hw/xquartz/darwinKeyboard.c b/hw/xquartz/darwinKeyboard.c
index 355d9f0..6f2758e 100644
--- a/hw/xquartz/darwinKeyboard.c
+++ b/hw/xquartz/darwinKeyboard.c
@@ -850,16 +850,18 @@ static Bool InitModMap(register KeyClassPtr keyc) {
}
-void DarwinKeyboardReload(DeviceIntPtr pDev) {
+void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) {
KeySymsRec keySyms;
-
+ if (dev == NULL) dev = darwinKeyboard;
+
+ DEBUG_LOG("DarwinKeyboardReloadHandler(%p)\n", dev);
DarwinLoadKeyboardMapping(&keySyms);
- if (SetKeySymsMap(&pDev->key->curKeySyms, &keySyms)) {
+ if (SetKeySymsMap(&dev->key->curKeySyms, &keySyms)) {
/* now try to update modifiers. */
- memmove(pDev->key->modifierMap, keyInfo.modMap, MAP_LENGTH);
- InitModMap(pDev->key);
+ memmove(dev->key->modifierMap, keyInfo.modMap, MAP_LENGTH);
+ InitModMap(dev->key);
} else DEBUG_LOG("SetKeySymsMap=0\n");
SendMappingNotify(MappingKeyboard, MIN_KEYCODE, NUM_KEYCODES, 0);
diff --git a/hw/xquartz/darwinKeyboard.h b/hw/xquartz/darwinKeyboard.h
index 5cf64c7..762f659 100644
--- a/hw/xquartz/darwinKeyboard.h
+++ b/hw/xquartz/darwinKeyboard.h
@@ -31,7 +31,7 @@
/* Provided for darwinEvents.c */
extern darwinKeyboardInfo keyInfo;
-void DarwinKeyboardReload(DeviceIntPtr pDev);
+void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents);
void DarwinKeyboardInit(DeviceIntPtr pDev);
int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
int DarwinModifierNXKeyToNXKeycode(int key, int side);
diff --git a/hw/xquartz/quartzKeyboard.h b/hw/xquartz/quartzKeyboard.h
index 8131b56..4f495bb 100644
--- a/hw/xquartz/quartzKeyboard.h
+++ b/hw/xquartz/quartzKeyboard.h
@@ -46,7 +46,6 @@ typedef struct darwinKeyboardInfo_struct {
} darwinKeyboardInfo;
/* These functions need to be implemented by Xquartz, XDarwin, etc. */
-void DarwinKeyboardReload(DeviceIntPtr pDev);
Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info);
unsigned int QuartzSystemKeymapSeed(void);
commit 15b0084f1ab23042190d8beeb3f088b92dee5a10
Author: Ben Byer <bbyer at apple.com>
Date: Mon Mar 31 23:31:25 2008 -0700
formatting cleanup for X11Application.m (no code changes)
(cherry picked from commit eb083d3f68f459d90417558da1ed00729b749950)
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 28bb529..2844fca 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -166,171 +166,170 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
static TSMDocumentID x11_document;
DEBUG_LOG("state=%d, _x_active=%d, \n", state, _x_active)
if (state) {
- DarwinSendDDXEvent(kXquartzActivate, 0);
-
- if (!_x_active) {
- if (x11_document == 0 && darwinKeymapFile == NULL) {
- OSType types[1];
- types[0] = kUnicodeDocument;
- NewTSMDocument (1, types, &x11_document, 0);
- }
-
- if (x11_document != 0) ActivateTSMDocument (x11_document);
- }
+ DarwinSendDDXEvent(kXquartzActivate, 0);
+
+ if (!_x_active) {
+ if (x11_document == 0 && darwinKeymapFile == NULL) {
+ OSType types[1];
+ types[0] = kUnicodeDocument;
+ NewTSMDocument (1, types, &x11_document, 0);
+ }
+
+ if (x11_document != 0) ActivateTSMDocument (x11_document);
+ }
} else {
- DarwinSendDDXEvent(kXquartzDeactivate, 0);
-
- if (_x_active && x11_document != 0)
- DeactivateTSMDocument (x11_document);
- }
-
- _x_active = state;
+ DarwinSendDDXEvent(kXquartzDeactivate, 0);
+
+ if (_x_active && x11_document != 0)
+ DeactivateTSMDocument (x11_document);
+ }
+
+ _x_active = state;
}
- (void) became_key:(NSWindow *)win {
- [self activateX:NO];
+ [self activateX:NO];
}
- (void) sendEvent:(NSEvent *)e {
- NSEventType type;
- BOOL for_appkit, for_x;
-
- type = [e type];
-
- /* By default pass down the responder chain and to X. */
- for_appkit = YES;
- for_x = YES;
-
- switch (type) {
- case NSLeftMouseDown: case NSRightMouseDown: case NSOtherMouseDown:
- case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp:
- if ([e window] != nil) {
- /* Pointer event has an (AppKit) window. Probably something for the kit. */
- for_x = NO;
- if (_x_active) [self activateX:NO];
- } else if ([self modalWindow] == nil) {
- /* Must be an X window. Tell appkit it doesn't have focus. */
- WindowPtr pWin = xprGetXWindowFromAppKit([e windowNumber]);
- if (pWin) RootlessReorderWindow(pWin);
- for_appkit = NO;
-
- if ([self isActive]) {
- [self deactivate];
-
- if (!_x_active && quartzProcs->IsX11Window([e window],
- [e windowNumber]))
- [self activateX:YES];
- }
- }
- break;
-
- case NSKeyDown: case NSKeyUp:
- if (_x_active) {
- static int swallow_up;
-
- /* No kit window is focused, so send it to X. */
- for_appkit = NO;
- if (type == NSKeyDown) {
- /* Before that though, see if there are any global
- shortcuts bound to it. */
-
- if (X11EnableKeyEquivalents
- && [[self mainMenu] performKeyEquivalent:e]) {
- swallow_up = [e keyCode];
- for_x = NO;
- } else if (!quartzEnableRootless
- && ([e modifierFlags] & ALL_KEY_MASKS)
- == (NSCommandKeyMask | NSAlternateKeyMask)
- && ([e keyCode] == 0 /*a*/
- || [e keyCode] == 53 /*Esc*/)) {
- swallow_up = 0;
- for_x = NO;
+ NSEventType type;
+ BOOL for_appkit, for_x;
+
+ type = [e type];
+
+ /* By default pass down the responder chain and to X. */
+ for_appkit = YES;
+ for_x = YES;
+
+ switch (type) {
+ case NSLeftMouseDown: case NSRightMouseDown: case NSOtherMouseDown:
+ case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp:
+ if ([e window] != nil) {
+ /* Pointer event has an (AppKit) window. Probably something for the kit. */
+ for_x = NO;
+ if (_x_active) [self activateX:NO];
+ } else if ([self modalWindow] == nil) {
+ /* Must be an X window. Tell appkit it doesn't have focus. */
+ WindowPtr pWin = xprGetXWindowFromAppKit([e windowNumber]);
+ if (pWin) RootlessReorderWindow(pWin);
+ for_appkit = NO;
+
+ if ([self isActive]) {
+ [self deactivate];
+ if (!_x_active && quartzProcs->IsX11Window([e window],
+ [e windowNumber]))
+ [self activateX:YES];
+ }
+ }
+ break;
+
+ case NSKeyDown: case NSKeyUp:
+ if (_x_active) {
+ static int swallow_up;
+
+ /* No kit window is focused, so send it to X. */
+ for_appkit = NO;
+ if (type == NSKeyDown) {
+ /* Before that though, see if there are any global
+ shortcuts bound to it. */
+
+ if (X11EnableKeyEquivalents
+ && [[self mainMenu] performKeyEquivalent:e]) {
+ swallow_up = [e keyCode];
+ for_x = NO;
+ } else if (!quartzEnableRootless
+ && ([e modifierFlags] & ALL_KEY_MASKS)
+ == (NSCommandKeyMask | NSAlternateKeyMask)
+ && ([e keyCode] == 0 /*a*/
+ || [e keyCode] == 53 /*Esc*/)) {
+ swallow_up = 0;
+ for_x = NO;
#ifdef DARWIN_DDX_MISSING
- DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
+ DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
#endif
+ }
+ } else {
+ /* If we saw a key equivalent on the down, don't pass
+ the up through to X. */
+
+ if (swallow_up != 0 && [e keyCode] == swallow_up) {
+ swallow_up = 0;
+ for_x = NO;
+ }
+ }
+ } else for_x = NO;
+ break;
+
+ case NSFlagsChanged:
+ /* For the l33t X users who remap modifier keys to normal keysyms. */
+ if (!_x_active) for_x = NO;
+ break;
+
+ case NSAppKitDefined:
+ switch ([e subtype]) {
+ case NSApplicationActivatedEventType:
+ for_x = NO;
+ if ([self modalWindow] == nil) {
+ for_appkit = NO;
+
+ /* FIXME: hack to avoid having to pass the event to appkit,
+ which would cause it to raise one of its windows. */
+ _appFlags._active = YES;
+
+ [self activateX:YES];
+ if ([e data2] & 0x10) X11ApplicationSetFrontProcess();
+ }
+ break;
+
+ case 18: /* ApplicationDidReactivate */
+ if (quartzHasRoot) for_appkit = NO;
+ break;
+
+ case NSApplicationDeactivatedEventType:
+ for_x = NO;
+ [self activateX:NO];
+ break;
+ }
+ break;
+
+ default: break; /* for gcc */
}
- } else {
- /* If we saw a key equivalent on the down, don't pass
- the up through to X. */
-
- if (swallow_up != 0 && [e keyCode] == swallow_up) {
- swallow_up = 0;
- for_x = NO;
- }
- }
- } else for_x = NO;
- break;
-
- case NSFlagsChanged:
- /* For the l33t X users who remap modifier keys to normal keysyms. */
- if (!_x_active) for_x = NO;
- break;
-
- case NSAppKitDefined:
- switch ([e subtype]) {
- case NSApplicationActivatedEventType:
- for_x = NO;
- if ([self modalWindow] == nil) {
- for_appkit = NO;
-
- /* FIXME: hack to avoid having to pass the event to appkit,
- which would cause it to raise one of its windows. */
- _appFlags._active = YES;
-
- [self activateX:YES];
- if ([e data2] & 0x10) X11ApplicationSetFrontProcess();
- }
- break;
-
- case 18: /* ApplicationDidReactivate */
- if (quartzHasRoot) for_appkit = NO;
- break;
-
- case NSApplicationDeactivatedEventType:
- for_x = NO;
- [self activateX:NO];
- break;
- }
- break;
-
- default: break; /* for gcc */
- }
-
- if (for_appkit) [super sendEvent:e];
-
- if (for_x) send_nsevent (type, e);
+
+ if (for_appkit) [super sendEvent:e];
+
+ if (for_x) send_nsevent (type, e);
}
- (void) set_window_menu:(NSArray *)list {
- [_controller set_window_menu:list];
+ [_controller set_window_menu:list];
}
- (void) set_window_menu_check:(NSNumber *)n {
- [_controller set_window_menu_check:n];
+ [_controller set_window_menu_check:n];
}
- (void) set_apps_menu:(NSArray *)list {
- [_controller set_apps_menu:list];
+ [_controller set_apps_menu:list];
}
- (void) set_front_process:unused {
- [NSApp activateIgnoringOtherApps:YES];
+ [NSApp activateIgnoringOtherApps:YES];
- if ([self modalWindow] == nil)
- [self activateX:YES];
+ if ([self modalWindow] == nil)
+ [self activateX:YES];
}
- (void) set_can_quit:(NSNumber *)state {
- [_controller set_can_quit:[state boolValue]];
+ [_controller set_can_quit:[state boolValue]];
}
- (void) server_ready:unused {
- [_controller server_ready];
+ [_controller server_ready];
}
- (void) show_hide_menubar:(NSNumber *)state {
- if ([state boolValue]) ShowMenuBar ();
- else HideMenuBar ();
+ if ([state boolValue]) ShowMenuBar ();
+ else HideMenuBar ();
}
@@ -348,57 +347,57 @@ static void cfrelease (CFAllocatorRef a, const void *b) {
}
static CFMutableArrayRef nsarray_to_cfarray (NSArray *in) {
- CFMutableArrayRef out;
- CFArrayCallBacks cb;
- NSObject *ns;
- const CFTypeRef *cf;
- int i, count;
-
- memset (&cb, 0, sizeof (cb));
- cb.version = 0;
- cb.retain = cfretain;
- cb.release = cfrelease;
-
- count = [in count];
- out = CFArrayCreateMutable (NULL, count, &cb);
-
- for (i = 0; i < count; i++) {
- ns = [in objectAtIndex:i];
-
- if ([ns isKindOfClass:[NSArray class]])
- cf = (CFTypeRef) nsarray_to_cfarray ((NSArray *) ns);
- else
- cf = CFRetain ((CFTypeRef) ns);
-
- CFArrayAppendValue (out, cf);
- CFRelease (cf);
- }
-
- return out;
+ CFMutableArrayRef out;
+ CFArrayCallBacks cb;
+ NSObject *ns;
+ const CFTypeRef *cf;
+ int i, count;
+
+ memset (&cb, 0, sizeof (cb));
+ cb.version = 0;
+ cb.retain = cfretain;
+ cb.release = cfrelease;
+
+ count = [in count];
+ out = CFArrayCreateMutable (NULL, count, &cb);
+
+ for (i = 0; i < count; i++) {
+ ns = [in objectAtIndex:i];
+
+ if ([ns isKindOfClass:[NSArray class]])
+ cf = (CFTypeRef) nsarray_to_cfarray ((NSArray *) ns);
+ else
+ cf = CFRetain ((CFTypeRef) ns);
+
+ CFArrayAppendValue (out, cf);
+ CFRelease (cf);
+ }
+
+ return out;
}
static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
- NSMutableArray *out;
- const CFTypeRef *cf;
- NSObject *ns;
- int i, count;
-
- count = CFArrayGetCount (in);
- out = [[NSMutableArray alloc] initWithCapacity:count];
-
- for (i = 0; i < count; i++) {
- cf = CFArrayGetValueAtIndex (in, i);
-
- if (CFGetTypeID (cf) == CFArrayGetTypeID ())
- ns = cfarray_to_nsarray ((CFArrayRef) cf);
- else
- ns = [(id)cf retain];
-
- [out addObject:ns];
- [ns release];
- }
-
- return out;
+ NSMutableArray *out;
+ const CFTypeRef *cf;
+ NSObject *ns;
+ int i, count;
+
+ count = CFArrayGetCount (in);
+ out = [[NSMutableArray alloc] initWithCapacity:count];
+
+ for (i = 0; i < count; i++) {
+ cf = CFArrayGetValueAtIndex (in, i);
+
+ if (CFGetTypeID (cf) == CFArrayGetTypeID ())
+ ns = cfarray_to_nsarray ((CFArrayRef) cf);
+ else
+ ns = [(id)cf retain];
+
+ [out addObject:ns];
+ [ns release];
+ }
+
+ return out;
}
- (CFPropertyListRef) prefs_get:(NSString *)key {
@@ -855,86 +854,68 @@ convert_flags (unsigned int nsflags) {
return xflags;
}
-
-// This code should probably be merged with that in XDarwin's XServer.m - BB
static void send_nsevent (NSEventType type, NSEvent *e) {
- // static unsigned int button_state = 0;
- NSRect screen;
- NSPoint location;
- NSWindow *window;
- int pointer_x, pointer_y, ev_button, ev_type;
- float pressure, tilt_x, tilt_y;
-
- // int num_events=0, i=0, state;
- // xEvent xe;
-
- /* convert location to global top-left coordinates */
- location = [e locationInWindow];
- window = [e window];
- screen = [[[NSScreen screens] objectAtIndex:0] frame];
-
+ NSRect screen;
+ NSPoint location;
+ NSWindow *window;
+ int pointer_x, pointer_y, ev_button, ev_type;
+ float pressure, tilt_x, tilt_y;
+
+ /* convert location to global top-left coordinates */
+ location = [e locationInWindow];
+ window = [e window];
+ screen = [[[NSScreen screens] objectAtIndex:0] frame];
+
if (window != nil) {
- NSRect frame = [window frame];
- pointer_x = location.x + frame.origin.x;
- pointer_y = (((screen.origin.y + screen.size.height)
- - location.y) - frame.origin.y);
- } else {
- pointer_x = location.x;
- pointer_y = (screen.origin.y + screen.size.height) - location.y;
- }
-
- pointer_y -= aquaMenuBarHeight;
- // state = convert_flags ([e modifierFlags]);
-
- pressure = 0; // for tablets
- tilt_x = 0;
- tilt_y = 0;
-
- switch (type) {
- case NSLeftMouseDown: ev_button=1; ev_type=ButtonPress; goto handle_mouse;
- case NSOtherMouseDown: ev_button=2; ev_type=ButtonPress; goto handle_mouse;
- case NSRightMouseDown: ev_button=3; ev_type=ButtonPress; goto handle_mouse;
- case NSLeftMouseUp: ev_button=1; ev_type=ButtonRelease; goto handle_mouse;
- case NSOtherMouseUp: ev_button=2; ev_type=ButtonRelease; goto handle_mouse;
- case NSRightMouseUp: ev_button=3; ev_type=ButtonRelease; goto handle_mouse;
- case NSLeftMouseDragged: ev_button=1; ev_type=MotionNotify; goto handle_mouse;
- case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto handle_mouse;
- case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto handle_mouse;
- case NSTabletPoint:
- pressure = [e pressure];
- tilt_x = [e tilt].x;
- tilt_y = [e tilt].y; // fall through
- case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse;
- handle_mouse:
-
- /* I'm not sure the below code is necessary or useful (-bb)
- if(ev_type==ButtonPress) {
- if (!quartzProcs->IsX11Window([e window], [e windowNumber])) {
- fprintf(stderr, "Dropping event because it's not a window\n");
- break;
+ NSRect frame = [window frame];
+ pointer_x = location.x + frame.origin.x;
+ pointer_y = (((screen.origin.y + screen.size.height)
+ - location.y) - frame.origin.y);
+ } else {
+ pointer_x = location.x;
+ pointer_y = (screen.origin.y + screen.size.height) - location.y;
}
- button_state |= (1 << ev_button);
- DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y);
- } else if (ev_type==ButtonRelease && (button_state & (1 << ev_button)) == 0) break;
- */
-
- // if ([e subtype] == NSTabletPointEventSubtype) pressure = [e pressure];
- DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y,
- pressure, tilt_x, tilt_y);
- break;
- case NSScrollWheel:
- DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y,
- pressure, tilt_x, tilt_y);
- break;
-
- case NSKeyDown: // do we need to translate these keyCodes?
- case NSKeyUp:
- DarwinSendKeyboardEvents((type == NSKeyDown)?KeyPress:KeyRelease, [e keyCode]);
- break;
-
- case NSFlagsChanged:
- DarwinUpdateModKeys([e modifierFlags]);
- break;
- default: break; /* for gcc */
- }
+
+ pointer_y -= aquaMenuBarHeight;
+
+ pressure = 0; // for tablets
+ tilt_x = 0;
+ tilt_y = 0;
+
+ switch (type) {
+ case NSLeftMouseDown: ev_button=1; ev_type=ButtonPress; goto handle_mouse;
+ case NSOtherMouseDown: ev_button=2; ev_type=ButtonPress; goto handle_mouse;
+ case NSRightMouseDown: ev_button=3; ev_type=ButtonPress; goto handle_mouse;
+ case NSLeftMouseUp: ev_button=1; ev_type=ButtonRelease; goto handle_mouse;
+ case NSOtherMouseUp: ev_button=2; ev_type=ButtonRelease; goto handle_mouse;
+ case NSRightMouseUp: ev_button=3; ev_type=ButtonRelease; goto handle_mouse;
+ case NSLeftMouseDragged: ev_button=1; ev_type=MotionNotify; goto handle_mouse;
+ case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto handle_mouse;
+ case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto handle_mouse;
+ case NSTabletPoint:
+ pressure = [e pressure];
+ tilt_x = [e tilt].x;
+ tilt_y = [e tilt].y; // fall through
+ case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse;
+ handle_mouse:
+
+// if ([e subtype] == NSTabletPointEventSubtype) pressure = [e pressure];
+ DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y,
+ pressure, tilt_x, tilt_y);
+ break;
+
+ case NSScrollWheel:
+ DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y,
+ pressure, tilt_x, tilt_y);
+ break;
+
+ case NSKeyDown: case NSKeyUp:
+ DarwinSendKeyboardEvents((type == NSKeyDown)?KeyPress:KeyRelease, [e keyCode]);
+ break;
+
+ case NSFlagsChanged:
+ DarwinUpdateModKeys([e modifierFlags]);
+ break;
+ default: break; /* for gcc */
+ }
}
commit e9e2d88436597875f102085d216dc0a8fce1450a
Author: Ben Byer <bbyer at apple.com>
Date: Mon Mar 31 22:55:24 2008 -0700
moved and renamed QuartzMessageServerThread to
DarwinSendDDXEvent to make more clear what it actually does.
(cherry picked from commit bee2b377efc930e25017636e5112093a3a6549c7)
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 147b4b4..28bb529 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -1,6 +1,6 @@
/* X11Application.m -- subclass of NSApplication to multiplex events
- Copyright (c) 2002-2007 Apple Inc.
+ Copyright (c) 2002-2008 Apple Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
@@ -166,7 +166,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
static TSMDocumentID x11_document;
DEBUG_LOG("state=%d, _x_active=%d, \n", state, _x_active)
if (state) {
- QuartzMessageServerThread (kXquartzActivate, 0);
+ DarwinSendDDXEvent(kXquartzActivate, 0);
if (!_x_active) {
if (x11_document == 0 && darwinKeymapFile == NULL) {
@@ -178,10 +178,10 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
if (x11_document != 0) ActivateTSMDocument (x11_document);
}
} else {
- QuartzMessageServerThread (kXquartzDeactivate, 0);
+ DarwinSendDDXEvent(kXquartzDeactivate, 0);
if (_x_active && x11_document != 0)
- DeactivateTSMDocument (x11_document);
+ DeactivateTSMDocument (x11_document);
}
_x_active = state;
@@ -246,7 +246,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
swallow_up = 0;
for_x = NO;
#ifdef DARWIN_DDX_MISSING
- QuartzMessageServerThread (kXquartzToggleFullscreen, 0);
+ DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
#endif
}
} else {
@@ -271,7 +271,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
case NSApplicationActivatedEventType:
for_x = NO;
if ([self modalWindow] == nil) {
- for_appkit = NO;
+ for_appkit = NO;
/* FIXME: hack to avoid having to pass the event to appkit,
which would cause it to raise one of its windows. */
@@ -654,7 +654,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
/* This will end up at the end of the responder chain. */
- (void) copy:sender {
- QuartzMessageServerThread (kXquartzPasteboardNotify, 1,
+ DarwinSendDDXEvent(kXquartzPasteboardNotify, 1,
AppleWMCopyToPasteboard);
}
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index aa9fa94..5bf4f4d 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -1,6 +1,6 @@
/* X11Controller.m -- connect the IB ui, also the NSApp delegate
- Copyright (c) 2002-2007 Apple Inc. All rights reserved.
+ Copyright (c) 2002-2008 Apple Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
@@ -103,7 +103,7 @@
{
[NSApp activateIgnoringOtherApps:YES];
- QuartzMessageServerThread (kXquartzControllerNotify, 2,
+ DarwinSendDDXEvent(kXquartzControllerNotify, 2,
AppleWMWindowMenuItem, [sender tag]);
}
@@ -254,7 +254,7 @@
[self remove_window_menu];
[self install_window_menu:list];
- QuartzMessageServerThread (kXquartzControllerNotify, 1,
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1,
AppleWMWindowMenuNotify);
}
@@ -539,20 +539,20 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
- (void) hide_window:sender
{
if ([X11App x_active])
- QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMHideWindow);
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMHideWindow);
else
NSBeep (); /* FIXME: something here */
}
- (IBAction)bring_to_front:sender
{
- QuartzMessageServerThread(kXquartzControllerNotify, 1, AppleWMBringAllToFront);
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMBringAllToFront);
}
- (IBAction)close_window:sender
{
if ([X11App x_active])
- QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMCloseWindow);
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMCloseWindow);
else
[[NSApp keyWindow] performClose:sender];
}
@@ -560,7 +560,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
- (IBAction)minimize_window:sender
{
if ([X11App x_active])
- QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMMinimizeWindow);
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMMinimizeWindow);
else
[[NSApp keyWindow] performMiniaturize:sender];
}
@@ -568,19 +568,19 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
- (IBAction)zoom_window:sender
{
if ([X11App x_active])
- QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMZoomWindow);
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMZoomWindow);
else
[[NSApp keyWindow] performZoom:sender];
}
- (IBAction) next_window:sender
{
- QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMNextWindow);
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMNextWindow);
}
- (IBAction) previous_window:sender
{
- QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMPreviousWindow);
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMPreviousWindow);
}
- (IBAction) enable_fullscreen_changed:sender
@@ -588,7 +588,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
int value = ![enable_fullscreen intValue];
#ifdef DARWIN_DDX_MISSING
- QuartzMessageServerThread (kXquartzSetRootless, 1, value);
+ DarwinSendDDXEvent(kXquartzSetRootless, 1, value);
#endif
[NSApp prefs_set_boolean:@PREFS_ROOTLESS value:value];
@@ -598,7 +598,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
- (IBAction) toggle_fullscreen:sender
{
#ifdef DARWIN_DDX_MISSING
- QuartzMessageServerThread (kXquartzToggleFullscreen, 0);
+ DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
#endif
}
@@ -661,7 +661,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
- (IBAction) quit:sender
{
- QuartzMessageServerThread (kXquartzQuit, 0);
+ DarwinSendDDXEvent(kXquartzQuit, 0);
}
- (IBAction) x11_help:sender
@@ -684,12 +684,12 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
- (void) applicationDidHide:(NSNotification *)notify
{
- QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMHideAll);
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMHideAll);
}
- (void) applicationDidUnhide:(NSNotification *)notify
{
- QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMShowAll);
+ DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMShowAll);
}
- (NSApplicationTerminateReply) applicationShouldTerminate:sender
@@ -717,7 +717,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
[X11App prefs_synchronize];
/* shutdown the X server, it will exit () for us. */
- QuartzMessageServerThread (kXquartzQuit, 0);
+ DarwinSendDDXEvent(kXquartzQuit, 0);
/* In case it doesn't, exit anyway after a while. */
while (sleep (10) != 0) ;
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index 8c3cabb..01e6f41 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2008 Apple, Inc.
* Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -120,6 +121,8 @@ enum {
kXquartzWindowMoved, // window has moved on screen
};
+void DarwinSendDDXEvent(int type, int argc, ...);
+
#define ENABLE_DEBUG_LOG 1
#ifdef ENABLE_DEBUG_LOG
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 28a712d..b6cd3f2 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -476,3 +476,31 @@ void DarwinUpdateModKeys(int flags) {
DarwinUpdateModifiers(KeyPress, ~old_flags & flags);
old_flags = flags;
}
+
+
+/*
+ * DarwinSendDDXEvent
+ * 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;
+ 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;
+
+ if (argc > 0 && argc <= max_args) {
+ va_start (args, argc);
+ for (i = 0; i < argc; i++)
+ argv[i] = (int) va_arg (args, int);
+ va_end (args);
+ }
+
+ mieqEnqueue(NULL, &xe);
+}
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index 1d8e92a..7c56be9 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2008 Apple, Inc.
* Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -43,4 +44,5 @@ void DarwinUpdateModKeys(int flags);
void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev,
int nevents);
+
#endif /* _DARWIN_EVENTS_H */
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index a65bd37..96dc021 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -373,34 +373,3 @@ void QuartzSpaceChanged(uint32_t space_id) {
/* Do something special here, so we don't depend on quartz-wm for spaces to work... */
DEBUG_LOG("Space Changed (%u) ... do something interesting...\n", space_id);
}
-
-/*
- * QuartzMessageServerThread
- * Send the X server thread a message by placing it on the event queue.
- */
-void
-QuartzMessageServerThread(
- int type,
- int argc, ...)
-{
- xEvent xe;
- INT32 *argv;
- int i, max_args;
- 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;
-
- if (argc > 0 && argc <= max_args) {
- va_start (args, argc);
- for (i = 0; i < argc; i++)
- argv[i] = (int) va_arg (args, int);
- va_end (args);
- }
-
- mieqEnqueue(NULL, &xe);
-}
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index 5e14473..91bf25a 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -68,7 +68,7 @@ static void eventHandler(unsigned int type, const void *arg,
switch (type) {
case XP_EVENT_DISPLAY_CHANGED:
DEBUG_LOG("XP_EVENT_DISPLAY_CHANGED\n");
- QuartzMessageServerThread(kXquartzDisplayChanged, 0);
+ DarwinSendDDXEvent(kXquartzDisplayChanged, 0);
break;
case XP_EVENT_WINDOW_STATE_CHANGED:
@@ -76,7 +76,7 @@ static void eventHandler(unsigned int type, const void *arg,
const xp_window_state_event *ws_arg = arg;
DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: id=%d, state=%d\n", ws_arg->id, ws_arg->state);
- QuartzMessageServerThread(kXquartzWindowState, 2,
+ DarwinSendDDXEvent(kXquartzWindowState, 2,
ws_arg->id, ws_arg->state);
} else {
DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: ignored\n");
@@ -88,7 +88,7 @@ static void eventHandler(unsigned int type, const void *arg,
if (arg_size == sizeof(xp_window_id)) {
xp_window_id id = * (xp_window_id *) arg;
WindowPtr pWin = xprGetXWindow(id);
- QuartzMessageServerThread(kXquartzWindowMoved, 1, pWin);
+ DarwinSendDDXEvent(kXquartzWindowMoved, 1, pWin);
}
break;
@@ -111,7 +111,7 @@ static void eventHandler(unsigned int type, const void *arg,
ErrorF("XP_EVENT_SPACE_CHANGED\n");
if(arg_size == sizeof(uint32_t)) {
uint32_t space_id = *(uint32_t *)arg;
- QuartzMessageServerThread(kXquartzSpaceChanged, 1, space_id);
+ DarwinSendDDXEvent(kXquartzSpaceChanged, 1, space_id);
}
break;
default:
commit c1be4e3379d8780dff20390939b657ca0973995a
Author: Ben Byer <bbyer at apple.com>
Date: Mon Mar 31 21:04:37 2008 -0700
shovelling code around ...
(cherry picked from commit 2143182ba49195bbb2e9163ea6872fd68e7a4a85)
diff --git a/dix/main.c b/dix/main.c
index db43473..8f6507f 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -113,6 +113,9 @@ Equipment Corporation.
#include "dispatch.h" /* InitProcVectors() */
#endif
+#include <pthread.h>
+pthread_key_t threadname_key=0;
+
#ifdef DPMSExtension
#define DPMS_SERVER
#include <X11/extensions/dpms.h>
@@ -248,6 +251,17 @@ main(int argc, char *argv[], char *envp[])
char *xauthfile;
HWEventQueueType alwaysCheckForInput[2];
+ if(threadname_key == 0) ErrorF("pthread_key_create returned %d\n", pthread_key_create(&threadname_key, NULL));
+ ErrorF("threadname_key = %d\n", threadname_key);
+ if(pthread_getspecific(threadname_key) == NULL) {
+ char *nameptr = malloc(32);
+ sprintf(nameptr, "main thread %d", random());
+ // strcpy(nameptr, "main thread");
+ ErrorF("calling: pthread_setspecific(%d, %s)=%d\n", threadname_key, nameptr, pthread_setspecific(threadname_key, nameptr));
+ if (pthread_getspecific(threadname_key) != NULL) ErrorF("current thread: %s\n", (char *)pthread_getspecific(threadname_key));
+ } else {
+ if (pthread_getspecific(threadname_key) != NULL) ErrorF("thread was already: %s\n", (char *)pthread_getspecific(threadname_key));
+ }
display = "0";
InitGlobals();
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 230050f..28a712d 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -52,6 +52,11 @@ in this Software without prior written authorization from The Open Group.
#include <unistd.h>
#include <IOKit/hidsystem/IOLLEvent.h>
+#define _APPLEWM_SERVER_
+#include "applewmExt.h"
+#include <X11/extensions/applewm.h>
+
+
/* Fake button press/release for scroll wheel move. */
#define SCROLLWHEELUPFAKE 4
#define SCROLLWHEELDOWNFAKE 5
@@ -177,14 +182,103 @@ static void DarwinSimulateMouseClick(
DarwinUpdateModifiers(KeyPress, modifierMask);
}
+/* Generic handler for Xquartz-specifc events. When possible, these should
+ be moved into their own individual functions and set as handlers using
+ mieqSetHandler. */
+
void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) {
int i;
DEBUG_LOG("DarwinEventHandler(%d, %p, %p, %d)\n", screenNum, xe, dev, nevents);
for (i=0; i<nevents; i++) {
- if (xe[i].u.u.type == kXquartzDeactivate)
- DarwinReleaseModifiers();
- QuartzProcessEvent(&xe[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");
+ DarwinReleaseModifiers();
+ AppleWMSendEvent(AppleWMActivationNotify,
+ AppleWMActivationNotifyMask,
+ AppleWMIsInactive, 0);
+ QuartzHide();
+ break;
+
+ case kXquartzWindowState:
+ DEBUG_LOG("kXquartzWindowState\n");
+ RootlessNativeWindowStateChanged(xe[i].u.clientMessage.u.l.longs0,
+ xe[i].u.clientMessage.u.l.longs1);
+ break;
+
+ case kXquartzWindowMoved:
+ DEBUG_LOG("kXquartzWindowMoved\n");
+ RootlessNativeWindowMoved ((WindowPtr)xe[i].u.clientMessage.u.l.longs0);
+ break;
+
+ case kXquartzToggleFullscreen:
+ DEBUG_LOG("kXquartzToggleFullscreen\n");
+#ifdef DARWIN_DDX_MISSING
+ if (quartzEnableRootless) QuartzSetFullscreen(!quartzHasRoot);
+ else if (quartzHasRoot) QuartzHide();
+ else QuartzShow();
+#else
+ // ErrorF("kXquartzToggleFullscreen not implemented\n");
+#endif
+ break;
+
+ case kXquartzSetRootless:
+ DEBUG_LOG("kXquartzSetRootless\n");
+#ifdef DARWIN_DDX_MISSING
+ QuartzSetRootless(xe[i].u.clientMessage.u.l.longs0);
+ if (!quartzEnableRootless && !quartzHasRoot) QuartzHide();
+#else
+ // ErrorF("kXquartzSetRootless not implemented\n");
+#endif
+ break;
+
+ case kXquartzSetRootClip:
+ QuartzSetRootClip((BOOL)xe[i].u.clientMessage.u.l.longs0);
+ break;
+
+ case kXquartzQuit:
+ GiveUp(0);
+ break;
+
+ case kXquartzBringAllToFront:
+ DEBUG_LOG("kXquartzBringAllToFront\n");
+ RootlessOrderAllWindows();
+ 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);
+ }
}
}
@@ -199,14 +293,14 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
mieqSetHandler(kXquartzDeactivate, DarwinEventHandler);
mieqSetHandler(kXquartzSetRootClip, DarwinEventHandler);
mieqSetHandler(kXquartzQuit, DarwinEventHandler);
- mieqSetHandler(kXquartzReadPasteboard, DarwinEventHandler);
- mieqSetHandler(kXquartzWritePasteboard, DarwinEventHandler);
+ mieqSetHandler(kXquartzReadPasteboard, QuartzReadPasteboard);
+ mieqSetHandler(kXquartzWritePasteboard, QuartzWritePasteboard);
mieqSetHandler(kXquartzToggleFullscreen, DarwinEventHandler);
mieqSetHandler(kXquartzSetRootless, DarwinEventHandler);
mieqSetHandler(kXquartzSpaceChanged, DarwinEventHandler);
mieqSetHandler(kXquartzControllerNotify, DarwinEventHandler);
mieqSetHandler(kXquartzPasteboardNotify, DarwinEventHandler);
- mieqSetHandler(kXquartzDisplayChanged, DarwinEventHandler);
+ mieqSetHandler(kXquartzDisplayChanged, QuartzDisplayChangedHandler);
mieqSetHandler(kXquartzWindowState, DarwinEventHandler);
mieqSetHandler(kXquartzWindowMoved, DarwinEventHandler);
diff --git a/hw/xquartz/darwinKeyboard.c b/hw/xquartz/darwinKeyboard.c
index 8d1ee8e..355d9f0 100644
--- a/hw/xquartz/darwinKeyboard.c
+++ b/hw/xquartz/darwinKeyboard.c
@@ -730,6 +730,14 @@ static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
* it to an equivalent X keyboard map and modifier map.
*/
static void DarwinLoadKeyboardMapping(KeySymsRec *keySyms) {
+ void* callstack[128];
+ int i, frames = backtrace(callstack, 128);
+ char** strs = backtrace_symbols(callstack, frames);
+ for (i = 0; i < frames; ++i) {
+ ErrorF("%s\n", strs[i]);
+ }
+ free(strs);
+
memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
/* TODO: Clean this up
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index ec211cf..a65bd37 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -232,17 +232,17 @@ RREditConnectionInfo (ScreenPtr pScreen)
#endif
/*
- * QuartzUpdateScreens
+ * QuartzDisplayChangeHandler
* Adjust for screen arrangement changes.
*/
-static void QuartzUpdateScreens(void)
+void QuartzDisplayChangedHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents)
{
ScreenPtr pScreen;
WindowPtr pRoot;
int x, y, width, height, sx, sy;
xEvent e;
- DEBUG_LOG("QuartzUpdateScreens()\n");
+ DEBUG_LOG("QuartzDisplayChangedHandler()\n");
if (noPseudoramiXExtension || screenInfo.numScreens != 1)
{
/* FIXME: if not using Xinerama, we have multiple screens, and
@@ -308,7 +308,7 @@ static void QuartzUpdateScreens(void)
* Calls mode specific screen resume to restore the X clip regions
* (if needed) and the X server cursor state.
*/
-static void QuartzShow(
+void QuartzShow(
int x, // cursor location
int y )
{
@@ -331,7 +331,7 @@ static void QuartzShow(
* hidden. Calls mode specific screen suspend to set X clip regions to
* prevent drawing (if needed) and restore the Aqua cursor.
*/
-static void QuartzHide(void)
+void QuartzHide(void)
{
int i;
@@ -350,7 +350,7 @@ static void QuartzHide(void)
* QuartzSetRootClip
* Enable or disable rendering to the X screen.
*/
-static void QuartzSetRootClip(
+void QuartzSetRootClip(
BOOL enable)
{
int i;
@@ -369,7 +369,7 @@ static void QuartzSetRootClip(
* QuartzSpaceChanged
* Unmap offscreen windows, map onscreen windows
*/
-static void QuartzSpaceChanged(uint32_t space_id) {
+void QuartzSpaceChanged(uint32_t space_id) {
/* Do something special here, so we don't depend on quartz-wm for spaces to work... */
DEBUG_LOG("Space Changed (%u) ... do something interesting...\n", space_id);
}
@@ -404,112 +404,3 @@ QuartzMessageServerThread(
mieqEnqueue(NULL, &xe);
}
-
-
-/*
- * QuartzProcessEvent
- * Process Quartz specific events.
- */
-void QuartzProcessEvent(xEvent *xe) {
- switch (xe->u.u.type) {
- case kXquartzControllerNotify:
- DEBUG_LOG("kXquartzControllerNotify\n");
- AppleWMSendEvent(AppleWMControllerNotify,
- AppleWMControllerNotifyMask,
- xe->u.clientMessage.u.l.longs0,
- xe->u.clientMessage.u.l.longs1);
- break;
-
- case kXquartzPasteboardNotify:
- DEBUG_LOG("kXquartzPasteboardNotify\n");
- AppleWMSendEvent(AppleWMPasteboardNotify,
- AppleWMPasteboardNotifyMask,
- xe->u.clientMessage.u.l.longs0,
- xe->u.clientMessage.u.l.longs1);
- break;
-
- case kXquartzActivate:
- DEBUG_LOG("kXquartzActivate\n");
- QuartzShow(xe->u.keyButtonPointer.rootX,
- xe->u.keyButtonPointer.rootY);
- AppleWMSendEvent(AppleWMActivationNotify,
- AppleWMActivationNotifyMask,
- AppleWMIsActive, 0);
- break;
-
- case kXquartzDeactivate:
- DEBUG_LOG("kXquartzDeactivate\n");
- AppleWMSendEvent(AppleWMActivationNotify,
- AppleWMActivationNotifyMask,
- AppleWMIsInactive, 0);
- QuartzHide();
- break;
-
- case kXquartzDisplayChanged:
- DEBUG_LOG("kXquartzDisplayChanged\n");
- QuartzUpdateScreens();
- break;
-
- case kXquartzWindowState:
- DEBUG_LOG("kXquartzWindowState\n");
- RootlessNativeWindowStateChanged(xe->u.clientMessage.u.l.longs0,
- xe->u.clientMessage.u.l.longs1);
- break;
-
- case kXquartzWindowMoved:
- DEBUG_LOG("kXquartzWindowMoved\n");
- RootlessNativeWindowMoved ((WindowPtr)xe->u.clientMessage.u.l.longs0);
- break;
-
- case kXquartzToggleFullscreen:
- DEBUG_LOG("kXquartzToggleFullscreen\n");
-#ifdef DARWIN_DDX_MISSING
- if (quartzEnableRootless) QuartzSetFullscreen(!quartzHasRoot);
- else if (quartzHasRoot) QuartzHide();
- else QuartzShow();
-#else
- // ErrorF("kXquartzToggleFullscreen not implemented\n");
-#endif
- break;
-
- case kXquartzSetRootless:
- DEBUG_LOG("kXquartzSetRootless\n");
-#ifdef DARWIN_DDX_MISSING
- QuartzSetRootless(xe->u.clientMessage.u.l.longs0);
- if (!quartzEnableRootless && !quartzHasRoot) QuartzHide();
-#else
- // ErrorF("kXquartzSetRootless not implemented\n");
-#endif
- break;
-
- case kXquartzSetRootClip:
- QuartzSetRootClip((BOOL)xe->u.clientMessage.u.l.longs0);
- break;
-
- case kXquartzQuit:
- GiveUp(0);
- break;
-
-#if 0
- case kXquartzReadPasteboard:
- QuartzReadPasteboard();
- break;
-
- case kXquartzWritePasteboard:
- QuartzWritePasteboard();
- break;
-#endif
-
- case kXquartzBringAllToFront:
- DEBUG_LOG("kXquartzBringAllToFront\n");
- RootlessOrderAllWindows();
- break;
-
- case kXquartzSpaceChanged:
- DEBUG_LOG("kXquartzSpaceChanged\n");
- QuartzSpaceChanged(xe->u.clientMessage.u.l.longs0);
- break;
- default:
- ErrorF("Unknown application defined event type %d.\n", xe->u.u.type);
- }
-}
diff --git a/hw/xquartz/quartz.h b/hw/xquartz/quartz.h
index fbe308a..ffe06f9 100644
--- a/hw/xquartz/quartz.h
+++ b/hw/xquartz/quartz.h
@@ -130,5 +130,5 @@ void QuartzInitOutput(int argc,char **argv);
void QuartzInitInput(int argc, char **argv);
void QuartzGiveUp(void);
void QuartzProcessEvent(xEvent *xe);
-
+void QuartzDisplayChangedHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents);
#endif
commit 985c631b2e1f113039e6e620f030505435fd9815
Author: Ben Byer <bbyer at apple.com>
Date: Mon Mar 31 20:18:58 2008 -0700
just a bit of juggling headers around -- we're preparing
to call our Xquartz-specific event handlers directly
as mieqHandlers
(cherry picked from commit 4aedba5aa727e22316e8ca456f7218bea9ee0313)
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 8f2511d..002ea41 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -880,7 +880,7 @@ void AbortDDX( void )
*/
void
-xf86SetRootClip (ScreenPtr pScreen, BOOL enable)
+xf86SetRootClip (ScreenPtr pScreen, int enable)
{
WindowPtr pWin = WindowTable[pScreen->myNum];
WindowPtr pChild;
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index 9384b9d..8c3cabb 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -54,7 +54,7 @@ typedef struct {
void DarwinPrintBanner(void);
int DarwinParseModifierList(const char *constmodifiers);
void DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo);
-void xf86SetRootClip (ScreenPtr pScreen, BOOL enable);
+void xf86SetRootClip (ScreenPtr pScreen, int enable);
#define SCREEN_PRIV(pScreen) ((DarwinFramebufferPtr) \
dixLookupPrivate(&pScreen->devPrivates, darwinScreenKey))
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 5dfdeeb..ec211cf 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -33,6 +33,7 @@
#endif
#include "quartzCommon.h"
+#include "inputstr.h"
#include "quartz.h"
#include "darwin.h"
#include "darwinEvents.h"
@@ -489,6 +490,7 @@ void QuartzProcessEvent(xEvent *xe) {
GiveUp(0);
break;
+#if 0
case kXquartzReadPasteboard:
QuartzReadPasteboard();
break;
@@ -496,6 +498,7 @@ void QuartzProcessEvent(xEvent *xe) {
case kXquartzWritePasteboard:
QuartzWritePasteboard();
break;
+#endif
case kXquartzBringAllToFront:
DEBUG_LOG("kXquartzBringAllToFront\n");
diff --git a/hw/xquartz/quartzCocoa.m b/hw/xquartz/quartzCocoa.m
index 53e3f08..d8f9c69 100644
--- a/hw/xquartz/quartzCocoa.m
+++ b/hw/xquartz/quartzCocoa.m
@@ -37,13 +37,14 @@
#endif
#include "quartzCommon.h"
+#include "inputstr.h"
#include "quartzPasteboard.h"
#define BOOL xBOOL
#include "darwin.h"
-#undef BOOL
#include <Cocoa/Cocoa.h>
+#undef BOOL
#include "pseudoramiX.h"
diff --git a/hw/xquartz/quartzPasteboard.c b/hw/xquartz/quartzPasteboard.c
index 0bf84f5..d47047c 100644
--- a/hw/xquartz/quartzPasteboard.c
+++ b/hw/xquartz/quartzPasteboard.c
@@ -34,6 +34,8 @@
#include <dix-config.h>
#endif
+#include "misc.h"
+#include "inputstr.h"
#include "quartzPasteboard.h"
#include <X11/Xatom.h>
@@ -76,8 +78,8 @@ static char * QuartzReadCutBuffer(void)
}
// Write X cut buffer to Mac OS X pasteboard
-// Called by ProcessInputEvents() in response to request from X server thread.
-void QuartzWritePasteboard(void)
+// Called by mieqProcessInputEvents() in response to request from X server thread.
+void QuartzWritePasteboard(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents)
{
char *text;
text = QuartzReadCutBuffer();
@@ -90,8 +92,8 @@ void QuartzWritePasteboard(void)
#define strequal(a, b) (0 == strcmp((a), (b)))
// Read Mac OS X pasteboard into X cut buffer
-// Called by ProcessInputEvents() in response to request from X server thread.
-void QuartzReadPasteboard(void)
+// Called by mieqProcessInputEvents() in response to request from X server thread.
+void QuartzReadPasteboard(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents)
{
char *oldText = QuartzReadCutBuffer();
char *text = QuartzReadCocoaPasteboard();
diff --git a/hw/xquartz/quartzPasteboard.h b/hw/xquartz/quartzPasteboard.h
index d6a8ee8..b51cd88 100644
--- a/hw/xquartz/quartzPasteboard.h
+++ b/hw/xquartz/quartzPasteboard.h
@@ -34,11 +34,11 @@
#define _QUARTZPASTEBOARD_H
// Aqua->X
-void QuartzReadPasteboard(void);
+void QuartzReadPasteboard(int, xEventPtr, DeviceIntPtr, int);
char * QuartzReadCocoaPasteboard(void); // caller must free string
// X->Aqua
-void QuartzWritePasteboard(void);
+void QuartzWritePasteboard(int, xEventPtr, DeviceIntPtr, int);
void QuartzWriteCocoaPasteboard(char *text);
#endif /* _QUARTZPASTEBOARD_H */
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index b653a6e..5e14473 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -32,6 +32,7 @@
#endif
#include "quartzCommon.h"
+#include "inputstr.h"
#include "quartz.h"
#include "xpr.h"
#include "pseudoramiX.h"
commit 89f1d880e83e32b72d35c4dbd6795defa6efa847
Author: Ben Byer <bbyer at apple.com>
Date: Mon Mar 31 19:47:28 2008 -0700
nuke DarwinEventQueue
(cherry picked from commit 1e0ec02202eeaffae480048b91bf02140ee29f8a)
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 5b037d2..230050f 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -56,28 +56,10 @@ in this Software without prior written authorization from The Open Group.
#define SCROLLWHEELUPFAKE 4
#define SCROLLWHEELDOWNFAKE 5
-#define QUEUE_SIZE 256
-
-typedef struct _Event {
- xEvent event;
- ScreenPtr pScreen;
-} EventRec, *EventPtr;
-
int input_check_zero, input_check_flag;
static int old_flags = 0; // last known modifier state
-typedef struct _EventQueue {
- HWEventQueueType head, tail; /* long for SetInputCheck */
- CARD32 lastEventTime; /* to avoid time running backwards */
- Bool lastMotion;
- EventRec events[QUEUE_SIZE]; /* static allocation for signals */
- DevicePtr pKbd, pPtr; /* device pointer, to get funcs */
- ScreenPtr pEnqueueScreen; /* screen events are being delivered to */
- ScreenPtr pDequeueScreen; /* screen events are being dispatched to */
-} EventQueueRec, *EventQueuePtr;
-
-static EventQueueRec darwinEventQueue;
xEvent *darwinEvents = NULL;
/*
@@ -231,21 +213,6 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
return TRUE;
}
-
-/*
- * DarwinEQEnqueue
- * Must be thread safe with ProcessInputEvents.
- * DarwinEQEnqueue - called from event gathering thread
- * ProcessInputEvents - called from X server thread
- * DarwinEQEnqueue should never be called from more than one thread.
- *
- * This should be deprecated in favor of miEQEnqueue -- BB
- */
-void DarwinEQEnqueue(const xEventPtr e) {
- mieqEnqueue(NULL, e);
- DarwinPokeEQ();
-}
-
/*
* ProcessInputEvents
* Read and process events from the event queue until it is empty.
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 971c9b2..5dfdeeb 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -401,7 +401,7 @@ QuartzMessageServerThread(
va_end (args);
}
- DarwinEQEnqueue(&xe);
+ mieqEnqueue(NULL, &xe);
}
commit 8944b77ec0c18476a25ba3179bcc45b338be22b8
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Wed Apr 2 17:47:42 2008 -0700
continue with gutting darwinEvents.c
(cherry picked from commit c34fce7051b996633291dddc061b696ff737f3fb)
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 46f5675..5b037d2 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -78,7 +78,7 @@ typedef struct _EventQueue {
} EventQueueRec, *EventQueuePtr;
static EventQueueRec darwinEventQueue;
-xEvent *darwinEvents;
+xEvent *darwinEvents = NULL;
/*
* DarwinPressModifierMask
@@ -207,8 +207,11 @@ void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int neven
}
Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
+ if (!darwinEvents)
+ darwinEvents = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+ if (!darwinEvents)
+ FatalError("Couldn't allocate event buffer\n");
- darwinEvents = (xEvent *)malloc(sizeof(xEvent) * GetMaximumEventsNum());
mieqInit();
mieqSetHandler(kXquartzActivate, DarwinEventHandler);
mieqSetHandler(kXquartzDeactivate, DarwinEventHandler);
@@ -225,13 +228,6 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
mieqSetHandler(kXquartzWindowState, DarwinEventHandler);
mieqSetHandler(kXquartzWindowMoved, DarwinEventHandler);
- darwinEventQueue.head = darwinEventQueue.tail = 0;
- darwinEventQueue.lastEventTime = GetTimeInMillis ();
- darwinEventQueue.pKbd = pKbd;
- darwinEventQueue.pPtr = pPtr;
- darwinEventQueue.pEnqueueScreen = screenInfo.screens[0];
- darwinEventQueue.pDequeueScreen = darwinEventQueue.pEnqueueScreen;
- SetInputCheck(&input_check_zero, &input_check_flag);
return TRUE;
}
@@ -255,8 +251,6 @@ void DarwinEQEnqueue(const xEventPtr e) {
* Read and process events from the event queue until it is empty.
*/
void ProcessInputEvents(void) {
- EventRec *e;
- int x, y;
xEvent xe;
// button number and modifier mask of currently pressed fake button
input_check_flag=0;
@@ -265,92 +259,11 @@ void ProcessInputEvents(void) {
mieqProcessInputEvents();
// Empty the signaling pipe
- x = sizeof(xe);
- while (x == sizeof(xe))
- x = read(darwinEventReadFD, &xe, sizeof(xe));
-
- while (darwinEventQueue.head != darwinEventQueue.tail)
- {
- if (screenIsSaved == SCREEN_SAVER_ON)
- dixSaveScreens (serverClient, SCREEN_SAVER_OFF, ScreenSaverReset);
-
- e = &darwinEventQueue.events[darwinEventQueue.head];
- xe = e->event;
-
- // Shift from global screen coordinates to coordinates relative to
- // the origin of the current screen.
- xe.u.keyButtonPointer.rootX -= darwinMainScreenX +
- dixScreenOrigins[miPointerCurrentScreen()->myNum].x;
- xe.u.keyButtonPointer.rootY -= darwinMainScreenY +
- dixScreenOrigins[miPointerCurrentScreen()->myNum].y;
-
- /* ErrorF("old rootX = (%d,%d) darwinMainScreen = (%d,%d) dixScreenOrigins[%d]=(%d,%d)\n",
- xe.u.keyButtonPointer.rootX, xe.u.keyButtonPointer.rootY,
- darwinMainScreenX, darwinMainScreenY,
- miPointerCurrentScreen()->myNum,
- dixScreenOrigins[miPointerCurrentScreen()->myNum].x,
- dixScreenOrigins[miPointerCurrentScreen()->myNum].y); */
-
- //Assumption - screen switching can only occur on motion events
-
- if (e->pScreen != darwinEventQueue.pDequeueScreen)
- {
- darwinEventQueue.pDequeueScreen = e->pScreen;
- x = xe.u.keyButtonPointer.rootX;
- y = xe.u.keyButtonPointer.rootY;
- if (darwinEventQueue.head == QUEUE_SIZE - 1)
- darwinEventQueue.head = 0;
- else
- ++darwinEventQueue.head;
- NewCurrentScreen (darwinEventQueue.pDequeueScreen, x, y);
- }
- else
- {
- if (darwinEventQueue.head == QUEUE_SIZE - 1)
- darwinEventQueue.head = 0;
- else
- ++darwinEventQueue.head;
- switch (xe.u.u.type) {
- case KeyPress:
- case KeyRelease:
- ErrorF("Unexpected Keyboard event in DarwinProcessInputEvents\n");
- break;
-
- case ButtonPress:
- ErrorF("Unexpected ButtonPress event in DarwinProcessInputEvents\n");
- break;
-
- case ButtonRelease:
- ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
- break;
-
- case MotionNotify:
- ErrorF("Unexpected MotionNotify event in DarwinProcessInputEvents\n");
- break;
-
- case kXquartzUpdateModifiers:
- ErrorF("Unexpected kXquartzUpdateModifiers event in DarwinProcessInputEvents\n");
- break;
-
- case kXquartzUpdateButtons:
- ErrorF("Unexpected kXquartzUpdateButtons event in DarwinProcessInputEvents\n");
- break;
-
- case kXquartzScrollWheel:
- ErrorF("Unexpected kXquartzScrollWheel event in DarwinProcessInputEvents\n");
- break;
-
- case kXquartzDeactivate:
- DarwinReleaseModifiers();
- // fall through
- default:
- // Check for mode specific event
- QuartzProcessEvent(&xe);
- }
- }
+ int x = sizeof(xe);
+ while (x == sizeof(xe)) {
+ DEBUG_LOG("draining pipe\n");
+ x = read(darwinEventReadFD, &xe, sizeof(xe));
}
-
- // miPointerUpdate();
}
/* Sends a null byte down darwinEventWriteFD, which will cause the
@@ -368,6 +281,10 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
static int darwinFakeMouseButtonMask = 0;
int i, num_events;
+ if(!darwinEvents) {
+ ErrorF("DarwinSendPointerEvents called before darwinEvents was initialized\n");
+ return;
+ }
/* I can't find a spec for this, but at least GTK expects that tablets are
just like mice, except they have either one or three extra valuators, in this
order:
@@ -421,6 +338,11 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
void DarwinSendKeyboardEvents(int ev_type, int keycode) {
int i, num_events;
+ if(!darwinEvents) {
+ ErrorF("DarwinSendKeyboardEvents called before darwinEvents was initialized\n");
+ return;
+ }
+
if (old_flags == 0 && darwinSyncKeymap && darwinKeymapFile == NULL) {
/* See if keymap has changed. */
@@ -447,6 +369,11 @@ void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y,
tilt_x * INT32_MAX * 1.0f,
tilt_y * INT32_MAX * 1.0f};
+ if(!darwinEvents) {
+ ErrorF("DarwinSendProximityvents called before darwinEvents was initialized\n");
+ return;
+}
+
num_events = GetProximityEvents(darwinEvents, darwinPointer, ev_type,
0, 5, valuators);
@@ -465,6 +392,11 @@ void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y,
tilt_x * INT32_MAX * 1.0f,
tilt_y * INT32_MAX * 1.0f};
+ if(!darwinEvents) {
+ ErrorF("DarwinSendScrollEvents called before darwinEvents was initialized\n");
+ return;
+ }
+
for (count = fabs(count); count > 0.0; count = count - 1.0f) {
int num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button,
POINTER_ABSOLUTE, 0, 5, valuators);
commit aa6d12e93e8661da841192ef7c3aa7c6a7731c7f
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Wed Apr 2 17:46:59 2008 -0700
turns out we weren't actually using these files. oops
(cherry picked from commit bfec44d7b4baf0ad0aae55c8209bc60ac93c5b58)
diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index 99d23eb..0753824 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -50,8 +50,6 @@ EXTRA_DIST = \
quartz.h \
quartzAudio.h \
quartzCommon.h \
- quartzCursor.c \
- quartzCursor.h \
quartzForeground.h \
quartzKeyboard.h \
quartzPasteboard.h
diff --git a/hw/xquartz/quartzCursor.c b/hw/xquartz/quartzCursor.c
deleted file mode 100644
index 10e671a..0000000
--- a/hw/xquartz/quartzCursor.c
+++ /dev/null
@@ -1,646 +0,0 @@
-/**************************************************************
- *
- * Support for using the Quartz Window Manager cursor
- *
- * Copyright (c) 2001-2003 Torrey T. Lyons and Greg Parker.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name(s) of the above copyright
- * holders shall not be used in advertising or otherwise to promote the sale,
- * use or other dealings in this Software without prior written authorization.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartzCommon.h"
-#include "quartzCursor.h"
-#include "darwin.h"
-
-#include <pthread.h>
-
-#include "mi.h"
-#include "scrnintstr.h"
-#include "cursorstr.h"
-#include "mipointrst.h"
-#include "globals.h"
-
-// Size of the QuickDraw cursor
-#define CURSORWIDTH 16
-#define CURSORHEIGHT 16
-
-typedef struct {
- int qdCursorMode;
- int qdCursorVisible;
- int useQDCursor;
- QueryBestSizeProcPtr QueryBestSize;
- miPointerSpriteFuncPtr spriteFuncs;
-} QuartzCursorScreenRec, *QuartzCursorScreenPtr;
-
-static DevPrivateKey darwinCursorScreenKey = &darwinCursorScreenKey;
-static CursorPtr quartzLatentCursor = NULL;
-static QD_Cursor gQDArrow; // QuickDraw arrow cursor
-
-// Cursor for the main thread to set (NULL = arrow cursor).
-static CCrsrHandle currentCursor = NULL;
-static pthread_mutex_t cursorMutex;
-static pthread_cond_t cursorCondition;
-
-#define CURSOR_PRIV(pScreen) ((QuartzCursorScreenPtr) \
- dixLookupPrivate(&pScreen->devPrivates, darwinCursorScreenKey))
-
-#define HIDE_QD_CURSOR(pScreen, visible) \
- if (visible) { \
- int ix; \
- for (ix = 0; ix < QUARTZ_PRIV(pScreen)->displayCount; ix++) { \
- CGDisplayHideCursor(QUARTZ_PRIV(pScreen)->displayIDs[ix]); \
- } \
- visible = FALSE; \
- } ((void)0)
-
-#define SHOW_QD_CURSOR(pScreen, visible) \
- { \
- int ix; \
- for (ix = 0; ix < QUARTZ_PRIV(pScreen)->displayCount; ix++) { \
- CGDisplayShowCursor(QUARTZ_PRIV(pScreen)->displayIDs[ix]); \
- } \
- visible = TRUE; \
- } ((void)0)
-
-#define CHANGE_QD_CURSOR(cursorH) \
- if (!quartzServerQuitting) { \
- /* Acquire lock and tell the main thread to change cursor */ \
- pthread_mutex_lock(&cursorMutex); \
- currentCursor = (CCrsrHandle) (cursorH); \
- QuartzMessageMainThread(kQuartzCursorUpdate, NULL, 0); \
- \
- /* Wait for the main thread to change the cursor */ \
- pthread_cond_wait(&cursorCondition, &cursorMutex); \
- pthread_mutex_unlock(&cursorMutex); \
- } ((void)0)
-
-
-/*
- * MakeQDCursor helpers: CTAB_ENTER, interleave
- */
-
-// Add a color entry to a ctab
-#define CTAB_ENTER(ctab, index, r, g, b) \
- ctab->ctTable[index].value = index; \
- ctab->ctTable[index].rgb.red = r; \
- ctab->ctTable[index].rgb.green = g; \
- ctab->ctTable[index].rgb.blue = b
-
-// Make an unsigned short by interleaving the bits of bytes c1 and c2.
-// High bit of c1 is first; low bit of c2 is last.
-// Interleave is a built-in INTERCAL operator.
-static unsigned short
-interleave(
- unsigned char c1,
- unsigned char c2 )
-{
- return
- ((c1 & 0x80) << 8) | ((c2 & 0x80) << 7) |
- ((c1 & 0x40) << 7) | ((c2 & 0x40) << 6) |
- ((c1 & 0x20) << 6) | ((c2 & 0x20) << 5) |
- ((c1 & 0x10) << 5) | ((c2 & 0x10) << 4) |
- ((c1 & 0x08) << 4) | ((c2 & 0x08) << 3) |
- ((c1 & 0x04) << 3) | ((c2 & 0x04) << 2) |
- ((c1 & 0x02) << 2) | ((c2 & 0x02) << 1) |
- ((c1 & 0x01) << 1) | ((c2 & 0x01) << 0) ;
-}
-
-/*
- * MakeQDCursor
- * Make a QuickDraw color cursor from the given X11 cursor.
- * Warning: This code is nasty. Color cursors were meant to be read
- * from resources; constructing the structures programmatically is messy.
- */
-/*
- QuickDraw cursor representation:
- Our color cursor is a 2 bit per pixel pixmap.
- Each pixel's bits are (source<<1 | mask) from the original X cursor pixel.
- The cursor's color table maps the colors like this:
- (2-bit value | X result | colortable | Mac result)
- 00 | transparent | white | transparent (white outside mask)
- 01 | back color | back color | back color
- 10 | undefined | black | invert background (just for fun)
- 11 | fore color | fore color | fore color
-*/
-static CCrsrHandle
-MakeQDCursor(
- CursorPtr pCursor )
-{
- CCrsrHandle result;
- CCrsrPtr curs;
- int i, w, h;
- unsigned short rowMask;
- PixMap *pix;
- ColorTable *ctab;
- unsigned short *image;
-
- result = (CCrsrHandle) NewHandleClear(sizeof(CCrsr));
- if (!result) return NULL;
- HLock((Handle)result);
- curs = *result;
-
- // Initialize CCrsr
- curs->crsrType = 0x8001; // 0x8000 = b&w, 0x8001 = color
- curs->crsrMap = (PixMapHandle) NewHandleClear(sizeof(PixMap));
- if (!curs->crsrMap) goto pixAllocFailed;
- HLock((Handle)curs->crsrMap);
- pix = *curs->crsrMap;
- curs->crsrData = NULL; // raw cursor image data (set below)
- curs->crsrXData = NULL; // QD's processed data
- curs->crsrXValid = 0; // zero means QD must re-process cursor data
- curs->crsrXHandle = NULL; // reserved
- memset(curs->crsr1Data, 0, CURSORWIDTH*CURSORHEIGHT/8); // b&w data
- memset(curs->crsrMask, 0, CURSORWIDTH*CURSORHEIGHT/8); // b&w & color mask
- curs->crsrHotSpot.h = min(CURSORWIDTH, pCursor->bits->xhot); // hot spot
- curs->crsrHotSpot.v = min(CURSORHEIGHT, pCursor->bits->yhot); // hot spot
- curs->crsrXTable = 0; // reserved
- curs->crsrID = GetCTSeed(); // unique ID from Color Manager
-
- // Set the b&w data and mask
- w = min(pCursor->bits->width, CURSORWIDTH);
- h = min(pCursor->bits->height, CURSORHEIGHT);
- rowMask = ~((1 << (CURSORWIDTH - w)) - 1);
- for (i = 0; i < h; i++) {
- curs->crsr1Data[i] = rowMask &
- ((pCursor->bits->source[i*4]<<8) | pCursor->bits->source[i*4+1]);
- curs->crsrMask[i] = rowMask &
- ((pCursor->bits->mask[i*4]<<8) | pCursor->bits->mask[i*4+1]);
- }
-
- // Set the color data and mask
- // crsrMap: defines bit depth and size and colortable only
- pix->rowBytes = (CURSORWIDTH * 2 / 8) | 0x8000; // last bit on means PixMap
- SetRect(&pix->bounds, 0, 0, CURSORWIDTH, CURSORHEIGHT); // see TN 1020
- pix->pixelSize = 2;
- pix->cmpCount = 1;
- pix->cmpSize = 2;
- // pix->pmTable set below
-
- // crsrData is the pixel data. crsrMap's baseAddr is not used.
- curs->crsrData = NewHandleClear(CURSORWIDTH*CURSORHEIGHT * 2 / 8);
- if (!curs->crsrData) goto imageAllocFailed;
- HLock((Handle)curs->crsrData);
- image = (unsigned short *) *curs->crsrData;
- // Pixel data is just 1-bit data and mask interleaved (see above)
- for (i = 0; i < h; i++) {
- unsigned char s, m;
- s = pCursor->bits->source[i*4] & (rowMask >> 8);
- m = pCursor->bits->mask[i*4] & (rowMask >> 8);
- image[2*i] = interleave(s, m);
- s = pCursor->bits->source[i*4+1] & (rowMask & 0x00ff);
- m = pCursor->bits->mask[i*4+1] & (rowMask & 0x00ff);
- image[2*i+1] = interleave(s, m);
- }
-
- // Build the color table (entries described above)
- // NewPixMap allocates a color table handle.
- pix->pmTable = (CTabHandle) NewHandleClear(sizeof(ColorTable) + 3
- * sizeof(ColorSpec));
- if (!pix->pmTable) goto ctabAllocFailed;
- HLock((Handle)pix->pmTable);
- ctab = *pix->pmTable;
- ctab->ctSeed = GetCTSeed();
- ctab->ctFlags = 0;
- ctab->ctSize = 3; // color count - 1
- CTAB_ENTER(ctab, 0, 0xffff, 0xffff, 0xffff);
- CTAB_ENTER(ctab, 1, pCursor->backRed, pCursor->backGreen,
- pCursor->backBlue);
- CTAB_ENTER(ctab, 2, 0x0000, 0x0000, 0x0000);
- CTAB_ENTER(ctab, 3, pCursor->foreRed, pCursor->foreGreen,
- pCursor->foreBlue);
-
- HUnlock((Handle)pix->pmTable); // ctab
- HUnlock((Handle)curs->crsrData); // image data
- HUnlock((Handle)curs->crsrMap); // pix
- HUnlock((Handle)result); // cursor
-
- return result;
-
- // "What we have here is a failure to allocate"
-ctabAllocFailed:
- HUnlock((Handle)curs->crsrData);
- DisposeHandle((Handle)curs->crsrData);
-imageAllocFailed:
- HUnlock((Handle)curs->crsrMap);
- DisposeHandle((Handle)curs->crsrMap);
-pixAllocFailed:
- HUnlock((Handle)result);
- DisposeHandle((Handle)result);
- return NULL;
-}
-
-
-/*
- * FreeQDCursor
- * Destroy a QuickDraw color cursor created with MakeQDCursor().
- * The cursor must not currently be on screen.
- */
-static void FreeQDCursor(CCrsrHandle cursHandle)
-{
- CCrsrPtr curs;
- PixMap *pix;
-
- HLock((Handle)cursHandle);
- curs = *cursHandle;
- HLock((Handle)curs->crsrMap);
- pix = *curs->crsrMap;
- DisposeHandle((Handle)pix->pmTable);
- HUnlock((Handle)curs->crsrMap);
- DisposeHandle((Handle)curs->crsrMap);
- DisposeHandle((Handle)curs->crsrData);
- HUnlock((Handle)cursHandle);
- DisposeHandle((Handle)cursHandle);
-}
-
-
-/*
-===========================================================================
-
- Pointer sprite functions
-
-===========================================================================
-*/
-
-/*
- * QuartzRealizeCursor
- * Convert the X cursor representation to QuickDraw format if possible.
- */
-Bool
-QuartzRealizeCursor(
- ScreenPtr pScreen,
- CursorPtr pCursor )
-{
- CCrsrHandle qdCursor;
- QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
- if(!pCursor || !pCursor->bits)
- return FALSE;
-
- // if the cursor is too big we use a software cursor
- if ((pCursor->bits->height > CURSORHEIGHT) ||
- (pCursor->bits->width > CURSORWIDTH) || !ScreenPriv->useQDCursor)
- {
- if (quartzRootless) {
- // rootless can't use a software cursor
- return TRUE;
- } else {
- return (*ScreenPriv->spriteFuncs->RealizeCursor)
- (pScreen, pCursor);
- }
- }
-
- // make new cursor image
- qdCursor = MakeQDCursor(pCursor);
- if (!qdCursor) return FALSE;
-
- // save the result
- dixSetPrivate(&pCursor->devPrivates, pScreen, qdCursor);
-
- return TRUE;
-}
-
-
-/*
- * QuartzUnrealizeCursor
- * Free the storage space associated with a realized cursor.
- */
-Bool
-QuartzUnrealizeCursor(
- ScreenPtr pScreen,
- CursorPtr pCursor )
-{
- QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
- if ((pCursor->bits->height > CURSORHEIGHT) ||
- (pCursor->bits->width > CURSORWIDTH) || !ScreenPriv->useQDCursor)
- {
- if (quartzRootless) {
- return TRUE;
- } else {
- return (*ScreenPriv->spriteFuncs->UnrealizeCursor)
- (pScreen, pCursor);
- }
- } else {
- CCrsrHandle oldCursor = dixLookupPrivate(&pCursor->devPrivates,
- pScreen);
- if (currentCursor != oldCursor) {
- // This should only fail when quitting, in which case we just leak.
- FreeQDCursor(oldCursor);
- }
- dixSetPrivate(&pCursor->devPrivates, pScreen, NULL);
- return TRUE;
- }
-}
-
-
-/*
- * QuartzSetCursor
- * Set the cursor sprite and position.
- * Use QuickDraw cursor if possible.
- */
-static void
-QuartzSetCursor(
- ScreenPtr pScreen,
- CursorPtr pCursor,
- int x,
- int y)
-{
- QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
- quartzLatentCursor = pCursor;
-
- // Don't touch Mac OS cursor if X is hidden!
- if (!quartzServerVisible)
- return;
-
- if (!pCursor) {
- // Remove the cursor completely.
- HIDE_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
- if (! ScreenPriv->qdCursorMode)
- (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
- }
- else if ((pCursor->bits->height <= CURSORHEIGHT) &&
- (pCursor->bits->width <= CURSORWIDTH) && ScreenPriv->useQDCursor)
- {
- // Cursor is small enough to use QuickDraw directly.
- if (! ScreenPriv->qdCursorMode) // remove the X cursor
- (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
- ScreenPriv->qdCursorMode = TRUE;
-
- CHANGE_QD_CURSOR(dixLookupPrivate(&pCursor->devPrivates, pScreen));
- SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
- }
- else if (quartzRootless) {
- // Rootless can't use a software cursor, so we just use Mac OS arrow.
- CHANGE_QD_CURSOR(NULL);
- SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
- }
- else {
- // Cursor is too big for QuickDraw. Use X software cursor.
- HIDE_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
- ScreenPriv->qdCursorMode = FALSE;
- (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, pCursor, x, y);
- }
-}
-
-
-/*
- * QuartzReallySetCursor
- * Set the QuickDraw cursor. Called from the main thread since changing the
- * cursor with QuickDraw is not thread safe on dual processor machines.
- */
-void
-QuartzReallySetCursor()
-{
- pthread_mutex_lock(&cursorMutex);
-
- if (currentCursor) {
- SetCCursor(currentCursor);
- } else {
- SetCursor(&gQDArrow);
- }
-
- pthread_cond_signal(&cursorCondition);
- pthread_mutex_unlock(&cursorMutex);
-}
-
-
-/*
- * QuartzMoveCursor
- * Move the cursor. This is a noop for QuickDraw.
- */
-static void
-QuartzMoveCursor(
- ScreenPtr pScreen,
- int x,
- int y)
-{
- QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
- // only the X cursor needs to be explicitly moved
- if (!ScreenPriv->qdCursorMode)
- (*ScreenPriv->spriteFuncs->MoveCursor)(pScreen, x, y);
-}
-
-
-static miPointerSpriteFuncRec quartzSpriteFuncsRec = {
- QuartzRealizeCursor,
- QuartzUnrealizeCursor,
- QuartzSetCursor,
- QuartzMoveCursor
-};
-
-
-/*
-===========================================================================
-
- Pointer screen functions
-
-===========================================================================
-*/
-
-/*
- * QuartzCursorOffScreen
- */
-static Bool QuartzCursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
-{
- return FALSE;
-}
-
-
-/*
- * QuartzCrossScreen
- */
-static void QuartzCrossScreen(ScreenPtr pScreen, Bool entering)
-{
- return;
-}
-
-
-/*
- * QuartzWarpCursor
- * Change the cursor position without generating an event or motion history.
- * The input coordinates (x,y) are in pScreen-local X11 coordinates.
- *
- */
-static void
-QuartzWarpCursor(
- ScreenPtr pScreen,
- int x,
- int y)
-{
- static int neverMoved = TRUE;
-
- if (neverMoved) {
- // Don't move the cursor the first time. This is the jump-to-center
- // initialization, and it's annoying because we may still be in MacOS.
- neverMoved = FALSE;
- return;
- }
-
- if (quartzServerVisible) {
- CGDisplayErr cgErr;
- CGPoint cgPoint;
- // Only need to do this for one display. Any display will do.
- CGDirectDisplayID cgID = QUARTZ_PRIV(pScreen)->displayIDs[0];
- CGRect cgRect = CGDisplayBounds(cgID);
-
- // Convert (x,y) to CoreGraphics screen-local CG coordinates.
- // This is necessary because the X11 screen and CG screen may not
- // coincide. (e.g. X11 screen may be moved to dodge the menu bar)
-
- // Make point in X11 global coordinates
- cgPoint = CGPointMake(x + dixScreenOrigins[pScreen->myNum].x,
- y + dixScreenOrigins[pScreen->myNum].y);
- // Shift to CoreGraphics global screen coordinates
- cgPoint.x += darwinMainScreenX;
- cgPoint.y += darwinMainScreenY;
- // Shift to CoreGraphics screen-local coordinates
- cgPoint.x -= cgRect.origin.x;
- cgPoint.y -= cgRect.origin.y;
-
- cgErr = CGDisplayMoveCursorToPoint(cgID, cgPoint);
- if (cgErr != CGDisplayNoErr) {
- ErrorF("Could not set cursor position with error code 0x%x.\n",
- cgErr);
- }
- }
-
- miPointerWarpCursor(pScreen, x, y);
- miPointerUpdate();
-}
-
-
-static miPointerScreenFuncRec quartzScreenFuncsRec = {
- QuartzCursorOffScreen,
- QuartzCrossScreen,
- QuartzWarpCursor,
- NULL,
- NULL
-};
-
-
-/*
-===========================================================================
-
- Other screen functions
-
-===========================================================================
-*/
-
-/*
- * QuartzCursorQueryBestSize
- * Handle queries for best cursor size
- */
-static void
-QuartzCursorQueryBestSize(
- int class,
- unsigned short *width,
- unsigned short *height,
- ScreenPtr pScreen)
-{
- QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
- if (class == CursorShape) {
- *width = CURSORWIDTH;
- *height = CURSORHEIGHT;
- } else {
- (*ScreenPriv->QueryBestSize)(class, width, height, pScreen);
- }
-}
-
-
-/*
- * QuartzInitCursor
- * Initialize cursor support
- */
-Bool
-QuartzInitCursor(
- ScreenPtr pScreen )
-{
- QuartzCursorScreenPtr ScreenPriv;
- miPointerScreenPtr PointPriv;
- DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
-
- // initialize software cursor handling (always needed as backup)
- if (!miDCInitialize(pScreen, &quartzScreenFuncsRec)) {
- return FALSE;
- }
-
- ScreenPriv = xcalloc( 1, sizeof(QuartzCursorScreenRec) );
- if (!ScreenPriv) return FALSE;
-
- CURSOR_PRIV(pScreen) = ScreenPriv;
-
- // override some screen procedures
- ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
- pScreen->QueryBestSize = QuartzCursorQueryBestSize;
-
- // initialize QuickDraw cursor handling
- GetQDGlobalsArrow(&gQDArrow);
- PointPriv = (miPointerScreenPtr)
- dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
-
- ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
- PointPriv->spriteFuncs = &quartzSpriteFuncsRec;
-
- if (!quartzRootless)
- ScreenPriv->useQDCursor = QuartzFSUseQDCursor(dfb->colorBitsPerPixel);
- else
- ScreenPriv->useQDCursor = TRUE;
- ScreenPriv->qdCursorMode = TRUE;
- ScreenPriv->qdCursorVisible = TRUE;
-
- // initialize cursor mutex lock
- pthread_mutex_init(&cursorMutex, NULL);
-
- // initialize condition for waiting
- pthread_cond_init(&cursorCondition, NULL);
-
- return TRUE;
-}
-
-
-// X server is hiding. Restore the Aqua cursor.
-void QuartzSuspendXCursor(
- ScreenPtr pScreen )
-{
- QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
- CHANGE_QD_CURSOR(NULL);
- SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
-}
-
-
-// X server is showing. Restore the X cursor.
-void QuartzResumeXCursor(
- ScreenPtr pScreen,
- int x,
- int y )
-{
- QuartzSetCursor(pScreen, quartzLatentCursor, x, y);
-}
diff --git a/hw/xquartz/quartzCursor.h b/hw/xquartz/quartzCursor.h
deleted file mode 100644
index 56a0209..0000000
--- a/hw/xquartz/quartzCursor.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * quartzCursor.h
- *
- * External interface for Quartz hardware cursor
- *
- * Copyright (c) 2001 Torrey T. Lyons and Greg Parker.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name(s) of the above copyright
- * holders shall not be used in advertising or otherwise to promote the sale,
- * use or other dealings in this Software without prior written authorization.
- */
-
-#ifndef QUARTZCURSOR_H
-#define QUARTZCURSOR_H
-
-#include "screenint.h"
-
-Bool QuartzInitCursor(ScreenPtr pScreen);
-void QuartzReallySetCursor(void);
-void QuartzSuspendXCursor(ScreenPtr pScreen);
-void QuartzResumeXCursor(ScreenPtr pScreen, int x, int y);
-
-#endif
commit 6c5962e44730395f81cdb333322c9ad5242c32d4
Author: Ben Byer <bbyer at apple.com>
Date: Mon Mar 31 18:15:18 2008 -0700
remove vestigal DarwinEQPointerPost etc
(cherry picked from commit a25704c423598d596fd7f2ed4290d4b860bd5d5f)
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index f7b1419..46f5675 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -251,23 +251,6 @@ void DarwinEQEnqueue(const xEventPtr e) {
}
/*
- * DarwinEQPointerPost
- * Post a pointer event. Used by the mipointer.c routines.
- */
-void DarwinEQPointerPost(DeviceIntPtr pdev, xEventPtr e) {
- (*darwinEventQueue.pPtr->processInputProc)
- (e, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
-}
-
-
-void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX) {
- darwinEventQueue.pEnqueueScreen = pScreen;
- if (fromDIX)
- darwinEventQueue.pDequeueScreen = pScreen;
-}
-
-
-/*
* ProcessInputEvents
* Read and process events from the event queue until it is empty.
*/
diff --git a/hw/xquartz/quartzCursor.c b/hw/xquartz/quartzCursor.c
index f82ccd3..10e671a 100644
--- a/hw/xquartz/quartzCursor.c
+++ b/hw/xquartz/quartzCursor.c
@@ -539,8 +539,8 @@ static miPointerScreenFuncRec quartzScreenFuncsRec = {
QuartzCursorOffScreen,
QuartzCrossScreen,
QuartzWarpCursor,
- DarwinEQPointerPost,
- DarwinEQSwitchScreen
+ NULL,
+ NULL
};
diff --git a/hw/xquartz/xpr/xprCursor.c b/hw/xquartz/xpr/xprCursor.c
index e084ef9..2ad8d6f 100644
--- a/hw/xquartz/xpr/xprCursor.c
+++ b/hw/xquartz/xpr/xprCursor.c
@@ -320,8 +320,8 @@ static miPointerScreenFuncRec quartzScreenFuncsRec = {
QuartzCursorOffScreen,
QuartzCrossScreen,
QuartzWarpCursor,
- DarwinEQPointerPost,
- DarwinEQSwitchScreen
+ NULL,
+ NULL
};
commit c6f0d5d1e51326e5110d27918d834eb0096df7db
Author: Ben Byer <bbyer at apple.com>
Date: Mon Mar 31 17:48:09 2008 -0700
gut darwinEQEnqueue, and make it just call mieqEnqueue (for the moment)
(cherry picked from commit a9e081a60ca227c0d96d4613075d97d6b762366a)
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index ce21ff5..f7b1419 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -199,7 +199,11 @@ void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int neven
int i;
DEBUG_LOG("DarwinEventHandler(%d, %p, %p, %d)\n", screenNum, xe, dev, nevents);
- for (i=0; i<nevents; i++) QuartzProcessEvent(&xe[i]);
+ for (i=0; i<nevents; i++) {
+ if (xe[i].u.u.type == kXquartzDeactivate)
+ DarwinReleaseModifiers();
+ QuartzProcessEvent(&xe[i]);
+ }
}
Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
@@ -242,40 +246,10 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
* This should be deprecated in favor of miEQEnqueue -- BB
*/
void DarwinEQEnqueue(const xEventPtr e) {
- HWEventQueueType oldtail, newtail;
-
- oldtail = darwinEventQueue.tail;
-
- // mieqEnqueue() collapses successive motion events into one event.
- // This is difficult to do in a thread-safe way and rarely useful.
-
- newtail = oldtail + 1;
- if (newtail == QUEUE_SIZE) newtail = 0;
- /* Toss events which come in late */
- if (newtail == darwinEventQueue.head) return;
-
- darwinEventQueue.events[oldtail].event = *e;
-
- /*
- * Make sure that event times don't go backwards - this
- * is "unnecessary", but very useful
- */
- if (e->u.keyButtonPointer.time < darwinEventQueue.lastEventTime &&
- darwinEventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000)
- {
- darwinEventQueue.events[oldtail].event.u.keyButtonPointer.time =
- darwinEventQueue.lastEventTime;
- }
- darwinEventQueue.events[oldtail].pScreen = darwinEventQueue.pEnqueueScreen;
-
- // Update the tail after the event is prepared
- darwinEventQueue.tail = newtail;
-
- // Signal there is an event ready to handle
- DarwinPokeEQ();
+ mieqEnqueue(NULL, e);
+ DarwinPokeEQ();
}
-
/*
* DarwinEQPointerPost
* Post a pointer event. Used by the mipointer.c routines.
commit 5b6c273eaa53d7b554d69c2b4865988068e73a26
Author: Ben Byer <bbyer at apple.com>
Date: Mon Mar 31 17:08:45 2008 -0700
add prototype for DarwinEventHandler
(cherry picked from commit 9a03ae33c4f9de830f15eabf3b994882ead7c000)
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index b4ff9fd..ce21ff5 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -204,8 +204,6 @@ void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int neven
Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
- void mieqSetHandler(int event, mieqHandler handler);
-
darwinEvents = (xEvent *)malloc(sizeof(xEvent) * GetMaximumEventsNum());
mieqInit();
mieqSetHandler(kXquartzActivate, DarwinEventHandler);
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index 4960614..1d8e92a 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -41,4 +41,6 @@ void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y,
float pressure, float tilt_x, float tilt_y);
void DarwinUpdateModKeys(int flags);
+void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev,
+ int nevents);
#endif /* _DARWIN_EVENTS_H */
commit 3713be8b470b1ac0fcb4f1e4c6b79c526b2196db
Author: Ben Byer <bbyer at apple.com>
Date: Mon Mar 31 16:30:16 2008 -0700
add logging of current thread ID to DEBUG_LOG macro
(cherry picked from commit 5848510cc5a8091b30230ab920d904ca6b159480)
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index bd1b9a4..9384b9d 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -125,7 +125,7 @@ enum {
#ifdef ENABLE_DEBUG_LOG
extern FILE *debug_log_fp;
#define DEBUG_LOG_NAME "x11-debug.txt"
-#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args ); fflush(debug_log_fp);
+#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%x:%s:%s:%d " msg, pthread_self(), __FILE__, __FUNCTION__, __LINE__, ##args ); fflush(debug_log_fp);
#else
#define DEBUG_LOG(msg, args...)
#endif
commit 1400a51ae70d8e498d9ae3975f58ba7c1768ca6f
Author: Ben Byer <bbyer at apple.com>
Date: Mon Mar 31 16:24:01 2008 -0700
Begin to move all of our Xquartz DDX-specific event handlers
to miEQ, in preparation to remove the DDX-specific code entirely.
(cherry picked from commit 3f4447b95f73a82b3aa0f7b0d1640aba5fb0d1bc)
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 2a28b1a..b4ff9fd 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -195,10 +195,34 @@ static void DarwinSimulateMouseClick(
DarwinUpdateModifiers(KeyPress, modifierMask);
}
+void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) {
+ int i;
+
+ DEBUG_LOG("DarwinEventHandler(%d, %p, %p, %d)\n", screenNum, xe, dev, nevents);
+ for (i=0; i<nevents; i++) QuartzProcessEvent(&xe[i]);
+}
Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
+
+ void mieqSetHandler(int event, mieqHandler handler);
+
darwinEvents = (xEvent *)malloc(sizeof(xEvent) * GetMaximumEventsNum());
mieqInit();
+ mieqSetHandler(kXquartzActivate, DarwinEventHandler);
+ mieqSetHandler(kXquartzDeactivate, DarwinEventHandler);
+ mieqSetHandler(kXquartzSetRootClip, DarwinEventHandler);
+ mieqSetHandler(kXquartzQuit, DarwinEventHandler);
+ mieqSetHandler(kXquartzReadPasteboard, DarwinEventHandler);
+ mieqSetHandler(kXquartzWritePasteboard, DarwinEventHandler);
+ mieqSetHandler(kXquartzToggleFullscreen, DarwinEventHandler);
+ mieqSetHandler(kXquartzSetRootless, DarwinEventHandler);
+ mieqSetHandler(kXquartzSpaceChanged, DarwinEventHandler);
+ mieqSetHandler(kXquartzControllerNotify, DarwinEventHandler);
+ mieqSetHandler(kXquartzPasteboardNotify, DarwinEventHandler);
+ mieqSetHandler(kXquartzDisplayChanged, DarwinEventHandler);
+ mieqSetHandler(kXquartzWindowState, DarwinEventHandler);
+ mieqSetHandler(kXquartzWindowMoved, DarwinEventHandler);
+
darwinEventQueue.head = darwinEventQueue.tail = 0;
darwinEventQueue.lastEventTime = GetTimeInMillis ();
darwinEventQueue.pKbd = pKbd;
More information about the xorg-commit
mailing list