Commit b4a05271 authored by sky@chromium.org's avatar sky@chromium.org

Fixes bug that resulted in status bubble getting hidden

Interesting enough this was happening because of a focus bug. Turns
out a FocusController associated with one DesktopNativeWidgetAura
could attempt to focus an aura::Window in a different
DesktopNativeWidgetAura. When this happened it would move the
content_window on top of the status bar.

We should only activate windows within the same root.

BUG=345698
TEST=covered by unit test, see bug as well.
R=ben@chromium.org

Review URL: https://codereview.chromium.org/186733011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255714 0039d316-1c4b-4281-b951-d872f2087c98
parent a0e69b93
...@@ -775,6 +775,7 @@ ...@@ -775,6 +775,7 @@
'view_model_unittest.cc', 'view_model_unittest.cc',
'view_model_utils_unittest.cc', 'view_model_utils_unittest.cc',
'view_unittest.cc', 'view_unittest.cc',
'widget/desktop_aura/desktop_focus_rules_unittest.cc',
'widget/desktop_aura/desktop_native_widget_aura_unittest.cc', 'widget/desktop_aura/desktop_native_widget_aura_unittest.cc',
'widget/desktop_aura/desktop_window_tree_host_win_unittest.cc', 'widget/desktop_aura/desktop_window_tree_host_win_unittest.cc',
'widget/desktop_aura/desktop_screen_x11_unittest.cc', 'widget/desktop_aura/desktop_screen_x11_unittest.cc',
......
...@@ -14,6 +14,14 @@ DesktopFocusRules::DesktopFocusRules(aura::Window* content_window) ...@@ -14,6 +14,14 @@ DesktopFocusRules::DesktopFocusRules(aura::Window* content_window)
DesktopFocusRules::~DesktopFocusRules() {} DesktopFocusRules::~DesktopFocusRules() {}
bool DesktopFocusRules::CanActivateWindow(aura::Window* window) const {
if (!BaseFocusRules::CanActivateWindow(window))
return false;
// Never activate a window that is not a child of the root window. Transients
// spanning different DesktopNativeWidgetAuras may trigger this.
return !window || content_window_->GetRootWindow()->Contains(window);
}
bool DesktopFocusRules::SupportsChildActivation(aura::Window* window) const { bool DesktopFocusRules::SupportsChildActivation(aura::Window* window) const {
// In Desktop-Aura, only the content_window or children of the RootWindow are // In Desktop-Aura, only the content_window or children of the RootWindow are
// activatable. // activatable.
......
...@@ -16,6 +16,7 @@ class DesktopFocusRules : public corewm::BaseFocusRules { ...@@ -16,6 +16,7 @@ class DesktopFocusRules : public corewm::BaseFocusRules {
private: private:
// Overridden from corewm::BaseFocusRules: // Overridden from corewm::BaseFocusRules:
virtual bool CanActivateWindow(aura::Window* window) const OVERRIDE;
virtual bool SupportsChildActivation(aura::Window* window) const OVERRIDE; virtual bool SupportsChildActivation(aura::Window* window) const OVERRIDE;
virtual bool IsWindowConsideredVisibleForActivation( virtual bool IsWindowConsideredVisibleForActivation(
aura::Window* window) const OVERRIDE; aura::Window* window) const OVERRIDE;
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/widget/desktop_aura/desktop_focus_rules.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_layer_type.h"
#include "ui/views/corewm/window_util.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/widget.h"
namespace views {
namespace {
scoped_ptr<Widget> CreateDesktopWidget() {
scoped_ptr<Widget> widget(new Widget);
Widget::InitParams params = Widget::InitParams(
Widget::InitParams::TYPE_WINDOW);
params.bounds = gfx::Rect(0, 0, 200, 200);
params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.native_widget = new DesktopNativeWidgetAura(widget.get());
widget->Init(params);
return widget.Pass();
}
} // namespace
typedef ViewsTestBase DesktopFocusRulesTest;
// Verifies we don't attempt to activate a window in another widget.
TEST_F(DesktopFocusRulesTest, DontFocusWindowsInOtherHierarchies) {
// Two widgets (each with a DesktopNativeWidgetAura). |w2| has a child Window
// |w2_child| that is not focusable. |w2_child|'s has a transient parent in
// |w1|.
scoped_ptr<views::Widget> w1(CreateDesktopWidget());
scoped_ptr<views::Widget> w2(CreateDesktopWidget());
aura::test::TestWindowDelegate w2_child_delegate;
w2_child_delegate.set_can_focus(false);
aura::Window* w2_child = new aura::Window(&w2_child_delegate);
w2_child->Init(aura::WINDOW_LAYER_SOLID_COLOR);
w2->GetNativeView()->AddChild(w2_child);
views::corewm::AddTransientChild(w1->GetNativeView(), w2_child);
aura::client::GetFocusClient(w2->GetNativeView())->FocusWindow(w2_child);
aura::Window* focused =
aura::client::GetFocusClient(w2->GetNativeView())->GetFocusedWindow();
EXPECT_TRUE((focused == NULL) || w2->GetNativeView()->Contains(focused));
views::corewm::RemoveTransientChild(w1->GetNativeView(), w2_child);
w1.reset();
w2.reset();
}
} // namespace views
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment