From e9e2d88436597875f102085d216dc0a8fce1450a Mon Sep 17 00:00:00 2001 From: Ben Byer Date: Mon, 31 Mar 2008 22:55:24 -0700 Subject: [PATCH] moved and renamed QuartzMessageServerThread to DarwinSendDDXEvent to make more clear what it actually does. (cherry picked from commit bee2b377efc930e25017636e5112093a3a6549c7) --- hw/xquartz/X11Application.m | 14 +++++++------- hw/xquartz/X11Controller.m | 32 ++++++++++++++++---------------- hw/xquartz/darwin.h | 3 +++ hw/xquartz/darwinEvents.c | 28 ++++++++++++++++++++++++++++ hw/xquartz/darwinEvents.h | 2 ++ hw/xquartz/quartz.c | 31 ------------------------------- hw/xquartz/xpr/xprScreen.c | 8 ++++---- 7 files changed, 60 insertions(+), 58 deletions(-) diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m index 147b4b4c0..28bb52995 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 aa9fa94be..5bf4f4d52 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 8c3cabbd1..01e6f41f2 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 28a712dab..b6cd3f2b0 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 1d8e92a7b..7c56be9c8 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 a65bd3748..96dc021a6 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 5e144731d..91bf25ac2 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: