Ken Thomases : winemac: Allow Command-[Shift-] Tab to switch apps even when the displays are captured.
Alexandre Julliard
julliard at winehq.org
Mon Mar 25 14:19:38 CDT 2013
Module: wine
Branch: master
Commit: 6ee486644a4313366fa7c95b93d371ef3e04255a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6ee486644a4313366fa7c95b93d371ef3e04255a
Author: Ken Thomases <ken at codeweavers.com>
Date: Sun Mar 17 22:40:59 2013 -0500
winemac: Allow Command-[Shift-]Tab to switch apps even when the displays are captured.
---
dlls/winemac.drv/cocoa_app.m | 56 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
index a417674..b14c550 100644
--- a/dlls/winemac.drv/cocoa_app.m
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -672,6 +672,49 @@ int macdrv_err_on;
[self setApplicationIconImage:nsimage];
}
+ - (void) handleCommandTab
+ {
+ if ([self isActive])
+ {
+ NSRunningApplication* thisApp = [NSRunningApplication currentApplication];
+ NSRunningApplication* app;
+ NSRunningApplication* otherValidApp = nil;
+
+ if ([originalDisplayModes count])
+ {
+ CGRestorePermanentDisplayConfiguration();
+ CGReleaseAllDisplays();
+ [originalDisplayModes removeAllObjects];
+ }
+
+ for (app in [[NSWorkspace sharedWorkspace] runningApplications])
+ {
+ if (![app isEqual:thisApp] && !app.terminated &&
+ app.activationPolicy == NSApplicationActivationPolicyRegular)
+ {
+ if (!app.hidden)
+ {
+ // There's another visible app. Just hide ourselves and let
+ // the system activate the other app.
+ [self hide:self];
+ return;
+ }
+
+ if (!otherValidApp)
+ otherValidApp = app;
+ }
+ }
+
+ // Didn't find a visible GUI app. Try the Finder or, if that's not
+ // running, the first hidden GUI app. If even that doesn't work, we
+ // just fail to switch and remain the active app.
+ app = [[NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.finder"] lastObject];
+ if (!app) app = otherValidApp;
+ [app unhide];
+ [app activateWithOptions:0];
+ }
+ }
+
/*
* ---------- Cursor clipping methods ----------
*
@@ -1084,6 +1127,19 @@ int macdrv_err_on;
// Make sure next mouse move event starts over from an absolute baseline.
forceNextMouseMoveAbsolute = TRUE;
}
+ else if (type == NSKeyDown && ![anEvent isARepeat] && [anEvent keyCode] == kVK_Tab)
+ {
+ NSUInteger modifiers = [anEvent modifierFlags];
+ if ((modifiers & NSCommandKeyMask) &&
+ !(modifiers & (NSControlKeyMask | NSAlternateKeyMask)))
+ {
+ // Command-Tab and Command-Shift-Tab would normally be intercepted
+ // by the system to switch applications. If we're seeing it, it's
+ // presumably because we've captured the displays, preventing
+ // normal application switching. Do it manually.
+ [self handleCommandTab];
+ }
+ }
}
More information about the wine-cvs
mailing list