Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Unified Diff: ui/base/cocoa/focus_window_set.mm

Issue 23737003: Mac: Fix window raising for multiple desktops (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix PlatformAppReopenWithWindows test Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/app_controller_mac_browsertest.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/cocoa/focus_window_set.mm
diff --git a/ui/base/cocoa/focus_window_set.mm b/ui/base/cocoa/focus_window_set.mm
index 553db6fe3be597fe14f157d8623852e1f714d14e..c6669eedfda035c113f1cdc2234439f0efa420d5 100644
--- a/ui/base/cocoa/focus_window_set.mm
+++ b/ui/base/cocoa/focus_window_set.mm
@@ -8,22 +8,44 @@
namespace ui {
+// This attempts to match OS X's native behavior, namely that a window
+// is only ever deminiaturized if ALL windows on ALL workspaces are
+// miniaturized. (This callback runs before AppKit picks its own
+// window to deminiaturize, so we get to pick one from the right set.)
+//
+// In addition, limit to the windows on the current
+// workspace. Otherwise we jump spaces haphazardly.
+//
+// NOTE: This is not perfect. If clicking the dock icon resulted in
+// switching spaces, isOnActiveSpace gives the answer for the PREVIOUS
+// space. This means that we actually raise the wrong space's
+// windows. This seems to still work okay.
+//
+// However, if we decide to deminiaturize a window instead, that
+// results in switching spaces and switching back. Fortunately, this
+// only happens if, say, space 1 contains an app, space 2 contains a
+// miniaturized browser. We click the icon, OS X switches to space 1,
+// we deminiaturize the browser, and that triggers switching back.
void FocusWindowSet(const std::set<NSWindow*>& windows) {
NSArray* ordered_windows = [NSApp orderedWindows];
NSWindow* frontmost_window = nil;
NSWindow* frontmost_miniaturized_window = nil;
+ bool all_miniaturized = true;
for (int i = [ordered_windows count] - 1; i >= 0; i--) {
NSWindow* win = [ordered_windows objectAtIndex:i];
if (windows.find(win) != windows.end()) {
- if ([win isVisible]) {
- [win orderFront:nil];
- frontmost_window = win;
- } else if ([win isMiniaturized]) {
+ if ([win isMiniaturized]) {
frontmost_miniaturized_window = win;
+ } else if ([win isVisible]) {
+ all_miniaturized = false;
jackhou1 2013/09/02 06:07:23 Could this be: } else if ([win isVisible])
davidben 2013/09/03 20:01:53 That seems to cause it to get a bit confused. If f
+ if ([win isOnActiveSpace]) {
+ [win orderFront:nil];
+ frontmost_window = win;
+ }
}
}
}
- if (!frontmost_window && frontmost_miniaturized_window) {
+ if (all_miniaturized && frontmost_miniaturized_window) {
[frontmost_miniaturized_window deminiaturize:nil];
frontmost_window = frontmost_miniaturized_window;
}
« no previous file with comments | « chrome/browser/app_controller_mac_browsertest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698