XQuartz: Make a call to activateIgnoringOtherApps in our NSApplicationActivatedEventType handler

In addition, this change will not call into the X11 activation unless an X11
window was active when we deactivated.  We can't rely on the event and current
key windows because the key window will be nil until activated, and the event
will only reference the window if the window was clicked (whereas it will be
nil if we activated via dock or cmd-tab).

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
This commit is contained in:
Jeremy Huddleston 2011-06-21 21:14:46 -07:00
parent 9d568450b1
commit c8b80a82d9

View File

@ -338,18 +338,21 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
case NSAppKitDefined: case NSAppKitDefined:
switch ([e subtype]) { switch ([e subtype]) {
static BOOL x_was_active = NO;
case NSApplicationActivatedEventType: case NSApplicationActivatedEventType:
for_x = NO; for_x = NO;
if ([self modalWindow] == nil) { if ([e window] == nil && x_was_active) {
BOOL order_all_windows = YES, workspaces, ok; BOOL order_all_windows = YES, workspaces, ok;
for_appkit = NO; for_appkit = NO;
/* FIXME: hack to avoid having to pass the event to appkit, /* FIXME: This is a hack to avoid passing the event to AppKit which
which would cause it to raise one of its windows. */ * would result in it raising one of its windows.
*/
_appFlags._active = YES; _appFlags._active = YES;
[self activateX:YES]; X11ApplicationSetFrontProcess();
/* Get the Spaces preference for SwitchOnActivate */ /* Get the Spaces preference for SwitchOnActivate */
(void)CFPreferencesAppSynchronize(CFSTR("com.apple.dock")); (void)CFPreferencesAppSynchronize(CFSTR("com.apple.dock"));
workspaces = CFPreferencesGetAppBooleanValue(CFSTR("workspaces"), CFSTR("com.apple.dock"), &ok); workspaces = CFPreferencesGetAppBooleanValue(CFSTR("workspaces"), CFSTR("com.apple.dock"), &ok);
@ -370,8 +373,9 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
* If there are no active windows, and there are minimized windows, we should * If there are no active windows, and there are minimized windows, we should
* be restoring one of them. * be restoring one of them.
*/ */
if ([e data2] & 0x10) // 0x10 is set when we use cmd-tab or the dock icon if ([e data2] & 0x10) { // 0x10 (bfCPSOrderAllWindowsForward) is set when we use cmd-tab or the dock icon
DarwinSendDDXEvent(kXquartzBringAllToFront, 1, order_all_windows); DarwinSendDDXEvent(kXquartzBringAllToFront, 1, order_all_windows);
}
} }
break; break;
@ -381,7 +385,10 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
case NSApplicationDeactivatedEventType: case NSApplicationDeactivatedEventType:
for_x = NO; for_x = NO;
[self activateX:NO];
x_was_active = _x_active;
if(_x_active)
[self activateX:NO];
break; break;
} }
break; break;