summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-26 23:25:14 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-26 23:25:14 +0000
commit3af863ac1a4a40cf7885858873cc549fac9e4f8a (patch)
tree3b76750ceb0604f361a8f507ed17fcca5029b2c7
parent6c2e218eeb4337cc8cd31059b8715ea342403248 (diff)
downloadchromium_src-3af863ac1a4a40cf7885858873cc549fac9e4f8a.zip
chromium_src-3af863ac1a4a40cf7885858873cc549fac9e4f8a.tar.gz
chromium_src-3af863ac1a4a40cf7885858873cc549fac9e4f8a.tar.bz2
Change the window level of Mac panels so they don't occlude the IME candidate window.
BUG=114070 TEST=manual Review URL: https://chromiumcodereview.appspot.com/9836094 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129044 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/panels/panel_browser_window_cocoa.h12
-rw-r--r--chrome/browser/ui/panels/panel_browser_window_cocoa.mm14
-rw-r--r--chrome/browser/ui/panels/panel_window_controller_cocoa.mm29
3 files changed, 51 insertions, 4 deletions
diff --git a/chrome/browser/ui/panels/panel_browser_window_cocoa.h b/chrome/browser/ui/panels/panel_browser_window_cocoa.h
index 250b4e2..dd3ceac 100644
--- a/chrome/browser/ui/panels/panel_browser_window_cocoa.h
+++ b/chrome/browser/ui/panels/panel_browser_window_cocoa.h
@@ -10,6 +10,8 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/tabs/tab_strip_model_observer.h"
#include "chrome/browser/ui/panels/native_panel.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
#include "ui/gfx/rect.h"
class Browser;
@@ -21,7 +23,8 @@ class Panel;
// interact with this object when it needs to manipulate the window.
class PanelBrowserWindowCocoa : public NativePanel,
- public TabStripModelObserver {
+ public TabStripModelObserver,
+ public content::NotificationObserver {
public:
PanelBrowserWindowCocoa(Browser* browser, Panel* panel,
const gfx::Rect& bounds);
@@ -77,6 +80,11 @@ class PanelBrowserWindowCocoa : public NativePanel,
bool foreground) OVERRIDE;
virtual void TabDetachedAt(TabContentsWrapper* contents, int index) OVERRIDE;
+ // Overridden from NotificationObserver.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
Panel* panel() { return panel_.get(); }
Browser* browser() const { return browser_.get(); }
@@ -128,6 +136,8 @@ class PanelBrowserWindowCocoa : public NativePanel,
// priority NSWindowLevel, so we distinguish between the two scenarios.
bool activation_requested_by_browser_;
+ content::NotificationRegistrar registrar_;
+
DISALLOW_COPY_AND_ASSIGN(PanelBrowserWindowCocoa);
};
diff --git a/chrome/browser/ui/panels/panel_browser_window_cocoa.mm b/chrome/browser/ui/panels/panel_browser_window_cocoa.mm
index 3fdb3fd..17defb4 100644
--- a/chrome/browser/ui/panels/panel_browser_window_cocoa.mm
+++ b/chrome/browser/ui/panels/panel_browser_window_cocoa.mm
@@ -17,7 +17,9 @@
#import "chrome/browser/ui/panels/panel_utils_cocoa.h"
#import "chrome/browser/ui/panels/panel_window_controller_cocoa.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+#include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/native_web_keyboard_event.h"
+#include "content/public/browser/notification_source.h"
using content::WebContents;
@@ -51,6 +53,10 @@ PanelBrowserWindowCocoa::PanelBrowserWindowCocoa(Browser* browser,
activation_requested_by_browser_(false) {
controller_ = [[PanelWindowControllerCocoa alloc] initWithBrowserWindow:this];
browser_->tabstrip_model()->AddObserver(this);
+ registrar_.Add(
+ this,
+ chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE,
+ content::Source<Panel>(panel_.get()));
}
PanelBrowserWindowCocoa::~PanelBrowserWindowCocoa() {
@@ -328,6 +334,14 @@ void PanelBrowserWindowCocoa::TabDetachedAt(TabContentsWrapper* contents,
[controller_ tabDetached:contents->web_contents()];
}
+void PanelBrowserWindowCocoa::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK_EQ(chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, type);
+ [controller_ updateWindowLevel];
+}
+
// NativePanelTesting implementation.
class NativePanelTestingCocoa : public NativePanelTesting {
public:
diff --git a/chrome/browser/ui/panels/panel_window_controller_cocoa.mm b/chrome/browser/ui/panels/panel_window_controller_cocoa.mm
index 9f8a309c..c39a28d 100644
--- a/chrome/browser/ui/panels/panel_window_controller_cocoa.mm
+++ b/chrome/browser/ui/panels/panel_window_controller_cocoa.mm
@@ -1042,9 +1042,32 @@ enum {
- (void)updateWindowLevel {
if (![self isWindowLoaded])
return;
- BOOL onTop = windowShim_->panel()->always_on_top() &&
- !windowShim_->panel()->manager()->is_full_screen();
- [[self window] setLevel:(onTop ? NSStatusWindowLevel : NSNormalWindowLevel)];
+ // Make sure we don't draw on top of a window in full screen mode.
+ if (windowShim_->panel()->manager()->is_full_screen() ||
+ !windowShim_->panel()->always_on_top()) {
+ [[self window] setLevel:NSNormalWindowLevel];
+ return;
+ }
+ // If we simply use NSStatusWindowLevel (25) for all docked panel windows,
+ // IME composition windows for things like CJK languages appear behind panels.
+ // Pre 10.7, IME composition windows have a window level of 19, which is
+ // lower than the dock at level 20. Since we want panels to appear on top of
+ // the dock, it is impossible to enforce an ordering where IME > panel > dock,
+ // since IME < dock.
+ // On 10.7, IME composition windows and the dock both live at level 20, so we
+ // use the same window level for panels. Since newly created windows appear at
+ // the top of their window level, panels are typically on top of the dock, and
+ // the IME composition window correctly draws over the panel.
+ // An autohide dock causes problems though: since it's constantly being
+ // revealed, it ends up drawing on top of other windows at the same level.
+ // While this is OK for expanded panels, it makes minimized panels impossible
+ // to activate. As a result, we still use NSStatusWindowLevel for minimized
+ // panels, since it's impossible to compose IME text in them anyway.
+ if (windowShim_->panel()->IsMinimized()) {
+ [[self window] setLevel:NSStatusWindowLevel];
+ return;
+ }
+ [[self window] setLevel:NSDockWindowLevel];
}
- (void)enableResizeByMouse:(BOOL)enable {