diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-03 22:17:40 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-03 22:17:40 +0000 |
commit | a8bb9670c4e3e91c5f081a272a6d51ed8ee76d8f (patch) | |
tree | 77ecaf1ab0b57487accad841b2806aaeb1041f18 /ui/aura | |
parent | 986afae849b2403e0b3b159e9bc567aec6624aaa (diff) | |
download | chromium_src-a8bb9670c4e3e91c5f081a272a6d51ed8ee76d8f.zip chromium_src-a8bb9670c4e3e91c5f081a272a6d51ed8ee76d8f.tar.gz chromium_src-a8bb9670c4e3e91c5f081a272a6d51ed8ee76d8f.tar.bz2 |
aura: Ask the WindowDelegate before a Window is Focus()ed.
. In aura, before a window is focused, ask the delegate if it can be focused.
. Make a popup RWHVA non-focusable.
This is to prevent the focus from moving from the main web-page to the combobox (which causes the combobox to get destroyed). This fixes an issue where comboboxes in the login screen could not be used properly.
BUG=105786
TEST=manually
Review URL: http://codereview.chromium.org/8770011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112909 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura')
-rw-r--r-- | ui/aura/demo/demo_main.cc | 1 | ||||
-rw-r--r-- | ui/aura/test/test_window_delegate.cc | 4 | ||||
-rw-r--r-- | ui/aura/test/test_window_delegate.h | 1 | ||||
-rw-r--r-- | ui/aura/window.cc | 3 | ||||
-rw-r--r-- | ui/aura/window_delegate.h | 3 |
5 files changed, 10 insertions, 2 deletions
diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc index f8337ec..0795067 100644 --- a/ui/aura/demo/demo_main.cc +++ b/ui/aura/demo/demo_main.cc @@ -53,6 +53,7 @@ class DemoWindowDelegate : public aura::WindowDelegate { virtual ui::TouchStatus OnTouchEvent(aura::TouchEvent* event) OVERRIDE { return ui::TOUCH_STATUS_END; } + virtual bool CanFocus() OVERRIDE { return true; } virtual bool ShouldActivate(aura::Event* event) OVERRIDE { return true; } virtual void OnActivated() OVERRIDE {} virtual void OnLostActive() OVERRIDE {} diff --git a/ui/aura/test/test_window_delegate.cc b/ui/aura/test/test_window_delegate.cc index 4244879..4a4f778 100644 --- a/ui/aura/test/test_window_delegate.cc +++ b/ui/aura/test/test_window_delegate.cc @@ -56,6 +56,10 @@ ui::TouchStatus TestWindowDelegate::OnTouchEvent(TouchEvent* event) { return ui::TOUCH_STATUS_UNKNOWN; } +bool TestWindowDelegate::CanFocus() { + return true; +} + bool TestWindowDelegate::ShouldActivate(Event* event) { return true; } diff --git a/ui/aura/test/test_window_delegate.h b/ui/aura/test/test_window_delegate.h index febe663..08f1d6f 100644 --- a/ui/aura/test/test_window_delegate.h +++ b/ui/aura/test/test_window_delegate.h @@ -30,6 +30,7 @@ class TestWindowDelegate : public WindowDelegate { virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; virtual bool OnMouseEvent(MouseEvent* event) OVERRIDE; virtual ui::TouchStatus OnTouchEvent(TouchEvent* event) OVERRIDE; + virtual bool CanFocus() OVERRIDE; virtual bool ShouldActivate(Event* event) OVERRIDE; virtual void OnActivated() OVERRIDE; virtual void OnLostActive() OVERRIDE; diff --git a/ui/aura/window.cc b/ui/aura/window.cc index d54a67e..c243997 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc @@ -368,8 +368,7 @@ bool Window::HasFocus() const { // propagation of events that would otherwise be targeted at windows behind it. // We then perform this same check on every window up to the root. bool Window::CanFocus() const { - // TODO(beng): Figure out how to consult the delegate wrt. focusability also. - if (!IsVisible() || !parent_) + if (!IsVisible() || !parent_ || (delegate_ && !delegate_->CanFocus())) return false; Windows::const_iterator i = std::find(parent_->children().begin(), diff --git a/ui/aura/window_delegate.h b/ui/aura/window_delegate.h index 034ad8e..f865511 100644 --- a/ui/aura/window_delegate.h +++ b/ui/aura/window_delegate.h @@ -52,6 +52,9 @@ class AURA_EXPORT WindowDelegate { virtual ui::TouchStatus OnTouchEvent(TouchEvent* event) = 0; + // Returns true of the window can be focused. + virtual bool CanFocus() = 0; + // Returns true if the window should be activated. |event| is either the mouse // event supplied if the activation is the result of a mouse, or the touch // event if the activation is the result of a touch, or NULL if activation is |