moved and renamed QuartzMessageServerThread to

DarwinSendDDXEvent to make more clear what it actually does.
(cherry picked from commit bee2b377ef)
This commit is contained in:
Ben Byer 2008-03-31 22:55:24 -07:00 committed by Jeremy Huddleston
parent c1be4e3379
commit e9e2d88436
7 changed files with 60 additions and 58 deletions

View File

@ -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);
}

View File

@ -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) ;

View File

@ -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

View File

@ -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);
}

View File

@ -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 */

View File

@ -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);
}

View File

@ -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: