Commit 4d1a4542 authored by ben@chromium.org's avatar ben@chromium.org

Revert 177209 - Enable the FocusController on DesktopAura too.

http://crbug.com/162100
R=sky@chromium.org
Review URL: https://codereview.chromium.org/11885030

TBR=ben@chromium.org
Review URL: https://codereview.chromium.org/11969020

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177226 0039d316-1c4b-4281-b951-d872f2087c98
parent ea2f0bfe
......@@ -357,8 +357,6 @@
'widget/desktop_aura/desktop_drag_drop_client_win.h',
'widget/desktop_aura/desktop_drop_target_win.cc',
'widget/desktop_aura/desktop_drop_target_win.h',
'widget/desktop_aura/desktop_focus_rules.cc',
'widget/desktop_aura/desktop_focus_rules.h',
'widget/desktop_aura/desktop_layout_manager.cc',
'widget/desktop_aura/desktop_layout_manager.h',
'widget/desktop_aura/desktop_native_widget_aura.cc',
......
// Copyright (c) 2012 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/root_window.h"
#include "ui/aura/window.h"
namespace views {
DesktopFocusRules::DesktopFocusRules() {}
DesktopFocusRules::~DesktopFocusRules() {}
bool DesktopFocusRules::SupportsChildActivation(aura::Window* window) const {
// In Desktop-Aura, only children of the RootWindow are activatable.
return window->GetRootWindow() == window;
}
} // namespace views
// Copyright (c) 2012 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.
#ifndef UI_VIEWS_WIDGET_DESKTOP_FOCUS_RULES_H_
#define UI_VIEWS_WIDGET_DESKTOP_FOCUS_RULES_H_
#include "ui/views/corewm/base_focus_rules.h"
namespace views {
class DesktopFocusRules : public corewm::BaseFocusRules {
public:
DesktopFocusRules();
virtual ~DesktopFocusRules();
private:
// Overridden from corewm::BaseFocusRules:
virtual bool SupportsChildActivation(aura::Window* window) const OVERRIDE;
DISALLOW_COPY_AND_ASSIGN(DesktopFocusRules);
};
} // namespace views
#endif // UI_VIEWS_WIDGET_DESKTOP_FOCUS_RULES_H_
......@@ -628,10 +628,23 @@ void DesktopNativeWidgetAura::OnWindowActivated(aura::Window* gained_active,
restore_focus_on_activate_ = false;
GetWidget()->GetFocusManager()->RestoreFocusedView();
} else if (lost_active == window_ && GetWidget()->HasFocusManager()) {
DCHECK(!restore_focus_on_activate_);
restore_focus_on_activate_ = true;
// Pass in false so that ClearNativeFocus() isn't invoked.
GetWidget()->GetFocusManager()->StoreFocusedView(false);
// If we're losing focus to a window that is a top level (such as a bubble)
// store the focus. Such a window shares the same RootWindowHost, so that
// such a change won't trigger an activation change (which calls
// StoreFocusedView()). Without this the focused view is never told it lost
// focus.
aura::Window* focused_window =
aura::client::GetFocusClient(window_)->GetFocusedWindow();
if (focused_window && focused_window != window_) {
Widget* focused_widget = Widget::GetWidgetForNativeWindow(focused_window);
if (focused_widget && focused_widget != GetWidget() &&
focused_widget->is_top_level()) {
DCHECK(!restore_focus_on_activate_);
restore_focus_on_activate_ = true;
// Pass in false so that ClearNativeFocus() isn't invoked.
GetWidget()->GetFocusManager()->StoreFocusedView(false);
}
}
}
}
......
......@@ -23,13 +23,10 @@
#include "ui/base/x/x11_util.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/corewm/compound_event_filter.h"
#include "ui/views/corewm/corewm_switches.h"
#include "ui/views/corewm/focus_controller.h"
#include "ui/views/ime/input_method.h"
#include "ui/views/widget/desktop_aura/desktop_activation_client.h"
#include "ui/views/widget/desktop_aura/desktop_cursor_client.h"
#include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h"
#include "ui/views/widget/desktop_aura/desktop_focus_rules.h"
#include "ui/views/widget/desktop_aura/desktop_layout_manager.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/desktop_aura/desktop_screen_position_client.h"
......@@ -94,10 +91,6 @@ DesktopRootWindowHostLinux::DesktopRootWindowHostLinux(
DesktopRootWindowHostLinux::~DesktopRootWindowHostLinux() {
root_window_->ClearProperty(kHostForRootWindow);
if (corewm::UseFocusController()) {
aura::client::SetFocusClient(root_window_, NULL);
aura::client::SetActivationClient(root_window_, NULL);
}
}
// static
......@@ -221,17 +214,10 @@ aura::RootWindow* DesktopRootWindowHostLinux::InitRootWindow(
// messages to us.
X11DesktopHandler::get();
if (corewm::UseFocusController()) {
corewm::FocusController* focus_controller =
new corewm::FocusController(new DesktopFocusRules);
focus_client_.reset(focus_controller);
aura::client::SetFocusClient(root_window_, focus_controller);
aura::client::SetActivationClient(root_window_, focus_controller);
} else {
focus_client_.reset(new aura::FocusManager);
aura::client::SetFocusClient(root_window_, focus_client_.get());
activation_client_.reset(new DesktopActivationClient(root_window_));
}
focus_client_.reset(new aura::FocusManager);
aura::client::SetFocusClient(root_window_, focus_client_.get());
activation_client_.reset(new DesktopActivationClient(root_window_));
dispatcher_client_.reset(new DesktopDispatcherClient);
aura::client::SetDispatcherClient(root_window_,
......
......@@ -19,15 +19,12 @@
#include "ui/native_theme/native_theme_aura.h"
#include "ui/native_theme/native_theme_win.h"
#include "ui/views/corewm/compound_event_filter.h"
#include "ui/views/corewm/corewm_switches.h"
#include "ui/views/corewm/focus_controller.h"
#include "ui/views/corewm/input_method_event_filter.h"
#include "ui/views/ime/input_method_bridge.h"
#include "ui/views/widget/desktop_aura/desktop_activation_client.h"
#include "ui/views/widget/desktop_aura/desktop_cursor_client.h"
#include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h"
#include "ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h"
#include "ui/views/widget/desktop_aura/desktop_focus_rules.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/desktop_aura/desktop_screen_position_client.h"
#include "ui/views/widget/root_view.h"
......@@ -57,10 +54,6 @@ DesktopRootWindowHostWin::DesktopRootWindowHostWin(
}
DesktopRootWindowHostWin::~DesktopRootWindowHostWin() {
if (corewm::UseFocusController()) {
aura::client::SetFocusClient(root_window_, NULL);
aura::client::SetActivationClient(root_window_, NULL);
}
}
// static
......@@ -125,17 +118,10 @@ aura::RootWindow* DesktopRootWindowHostWin::Init(
capture_client_.reset(new aura::client::DefaultCaptureClient(root_window_));
aura::client::SetCaptureClient(root_window_, capture_client_.get());
if (corewm::UseFocusController()) {
corewm::FocusController* focus_controller =
new corewm::FocusController(new DesktopFocusRules);
focus_client_.reset(focus_controller);
aura::client::SetFocusClient(root_window_, focus_controller);
aura::client::SetActivationClient(root_window_, focus_controller);
} else {
focus_client_.reset(new aura::FocusManager);
aura::client::SetFocusClient(root_window_, focus_client_.get());
activation_client_.reset(new DesktopActivationClient(root_window_));
}
focus_client_.reset(new aura::FocusManager);
aura::client::SetFocusClient(root_window_, focus_client_.get());
activation_client_.reset(new DesktopActivationClient(root_window_));
dispatcher_client_.reset(new DesktopDispatcherClient);
aura::client::SetDispatcherClient(root_window_,
......
......@@ -1161,7 +1161,7 @@ TEST_F(WidgetTest, FocusChangesOnBubble) {
contents_view->RequestFocus();
EXPECT_TRUE(contents_view->HasFocus());
// Show a bubble.
// Show a buble.
BubbleDelegateView* bubble_delegate_view =
new BubbleDelegateView(contents_view, BubbleBorder::TOP_LEFT);
bubble_delegate_view->set_focusable(true);
......
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