OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/panels/panel_window_controller_cocoa.h" | 5 #include "chrome/browser/ui/panels/panel_window_controller_cocoa.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 else | 1012 else |
1013 [NSApp deactivate]; | 1013 [NSApp deactivate]; |
1014 } | 1014 } |
1015 | 1015 |
1016 - (void)preventBecomingKeyWindow:(BOOL)prevent { | 1016 - (void)preventBecomingKeyWindow:(BOOL)prevent { |
1017 canBecomeKeyWindow_ = !prevent; | 1017 canBecomeKeyWindow_ = !prevent; |
1018 } | 1018 } |
1019 | 1019 |
1020 - (void)fullScreenModeChanged:(bool)isFullScreen { | 1020 - (void)fullScreenModeChanged:(bool)isFullScreen { |
1021 [self updateWindowLevel]; | 1021 [self updateWindowLevel]; |
| 1022 |
| 1023 // The full-screen window is in normal level and changing the panel window to |
| 1024 // same normal level will not move it below the full-screen window. Thus we |
| 1025 // need to reorder the panel window. |
| 1026 if (isFullScreen) |
| 1027 [[self window] orderBack]; |
| 1028 else |
| 1029 [[self window] orderFront]; |
1022 } | 1030 } |
1023 | 1031 |
1024 - (BOOL)canBecomeKeyWindow { | 1032 - (BOOL)canBecomeKeyWindow { |
1025 // Panel can only gain focus if it is expanded. Minimized panels do not | 1033 // Panel can only gain focus if it is expanded. Minimized panels do not |
1026 // participate in Cmd-~ rotation. | 1034 // participate in Cmd-~ rotation. |
1027 // TODO(dimich): If it will be ever desired to expand/focus the Panel on | 1035 // TODO(dimich): If it will be ever desired to expand/focus the Panel on |
1028 // keyboard navigation or via main menu, the care should be taken to avoid | 1036 // keyboard navigation or via main menu, the care should be taken to avoid |
1029 // cases when minimized Panel is getting keyboard input, invisibly. | 1037 // cases when minimized Panel is getting keyboard input, invisibly. |
1030 return canBecomeKeyWindow_; | 1038 return canBecomeKeyWindow_; |
1031 } | 1039 } |
1032 | 1040 |
1033 - (int)numPanels { | 1041 - (int)numPanels { |
1034 return windowShim_->panel()->manager()->num_panels(); | 1042 return windowShim_->panel()->manager()->num_panels(); |
1035 } | 1043 } |
1036 | 1044 |
1037 - (BOOL)activationRequestedByBrowser { | 1045 - (BOOL)activationRequestedByBrowser { |
1038 return windowShim_->ActivationRequestedByBrowser(); | 1046 return windowShim_->ActivationRequestedByBrowser(); |
1039 } | 1047 } |
1040 | 1048 |
1041 - (void)updateWindowLevel { | 1049 - (void)updateWindowLevel { |
1042 if (![self isWindowLoaded]) | 1050 if (![self isWindowLoaded]) |
1043 return; | 1051 return; |
1044 // Make sure we don't draw on top of a window in full screen mode. | 1052 // Make sure we don't draw on top of a window in full screen mode. |
1045 if (windowShim_->panel()->manager()->is_full_screen() || | 1053 Panel* panel = windowShim_->panel(); |
1046 !windowShim_->panel()->always_on_top()) { | 1054 if (panel->manager()->display_settings_provider()->is_full_screen() || |
| 1055 !panel->always_on_top()) { |
1047 [[self window] setLevel:NSNormalWindowLevel]; | 1056 [[self window] setLevel:NSNormalWindowLevel]; |
1048 return; | 1057 return; |
1049 } | 1058 } |
1050 // If we simply use NSStatusWindowLevel (25) for all docked panel windows, | 1059 // If we simply use NSStatusWindowLevel (25) for all docked panel windows, |
1051 // IME composition windows for things like CJK languages appear behind panels. | 1060 // IME composition windows for things like CJK languages appear behind panels. |
1052 // Pre 10.7, IME composition windows have a window level of 19, which is | 1061 // Pre 10.7, IME composition windows have a window level of 19, which is |
1053 // lower than the dock at level 20. Since we want panels to appear on top of | 1062 // lower than the dock at level 20. Since we want panels to appear on top of |
1054 // the dock, it is impossible to enforce an ordering where IME > panel > dock, | 1063 // the dock, it is impossible to enforce an ordering where IME > panel > dock, |
1055 // since IME < dock. | 1064 // since IME < dock. |
1056 // On 10.7, IME composition windows and the dock both live at level 20, so we | 1065 // On 10.7, IME composition windows and the dock both live at level 20, so we |
1057 // use the same window level for panels. Since newly created windows appear at | 1066 // use the same window level for panels. Since newly created windows appear at |
1058 // the top of their window level, panels are typically on top of the dock, and | 1067 // the top of their window level, panels are typically on top of the dock, and |
1059 // the IME composition window correctly draws over the panel. | 1068 // the IME composition window correctly draws over the panel. |
1060 // An autohide dock causes problems though: since it's constantly being | 1069 // An autohide dock causes problems though: since it's constantly being |
1061 // revealed, it ends up drawing on top of other windows at the same level. | 1070 // revealed, it ends up drawing on top of other windows at the same level. |
1062 // While this is OK for expanded panels, it makes minimized panels impossible | 1071 // While this is OK for expanded panels, it makes minimized panels impossible |
1063 // to activate. As a result, we still use NSStatusWindowLevel for minimized | 1072 // to activate. As a result, we still use NSStatusWindowLevel for minimized |
1064 // panels, since it's impossible to compose IME text in them anyway. | 1073 // panels, since it's impossible to compose IME text in them anyway. |
1065 if (windowShim_->panel()->IsMinimized()) { | 1074 if (panel->IsMinimized()) { |
1066 [[self window] setLevel:NSStatusWindowLevel]; | 1075 [[self window] setLevel:NSStatusWindowLevel]; |
1067 return; | 1076 return; |
1068 } | 1077 } |
1069 [[self window] setLevel:NSDockWindowLevel]; | 1078 [[self window] setLevel:NSDockWindowLevel]; |
1070 } | 1079 } |
1071 | 1080 |
1072 - (void)enableResizeByMouse:(BOOL)enable { | 1081 - (void)enableResizeByMouse:(BOOL)enable { |
1073 if (![self isWindowLoaded]) | 1082 if (![self isWindowLoaded]) |
1074 return; | 1083 return; |
1075 [[self window] invalidateCursorRectsForView:overlayView_]; | 1084 [[self window] invalidateCursorRectsForView:overlayView_]; |
1076 } | 1085 } |
1077 | 1086 |
1078 - (BOOL)isActivationByClickingTitlebarEnabled { | 1087 - (BOOL)isActivationByClickingTitlebarEnabled { |
1079 return !windowShim_->panel()->always_on_top(); | 1088 return !windowShim_->panel()->always_on_top(); |
1080 } | 1089 } |
1081 | 1090 |
1082 @end | 1091 @end |
OLD | NEW |