diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-05 22:14:52 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-05 22:14:52 +0000 |
commit | 37533821562c1f1c48c5c89f6161175b4e6ad569 (patch) | |
tree | 30dea38eb263292d4a853e9af9ee5379e38a246a /ui/views/widget | |
parent | d2066ecd0fc75fb50a737e6d4b36a8d652bff6c5 (diff) | |
download | chromium_src-37533821562c1f1c48c5c89f6161175b4e6ad569.zip chromium_src-37533821562c1f1c48c5c89f6161175b4e6ad569.tar.gz chromium_src-37533821562c1f1c48c5c89f6161175b4e6ad569.tar.bz2 |
Remove old activation code and disable-focus-controller flags
BUG=285339,285364
Review URL: https://chromiumcodereview.appspot.com/23874013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221529 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/widget')
10 files changed, 24 insertions, 354 deletions
diff --git a/ui/views/widget/desktop_aura/desktop_activation_client.cc b/ui/views/widget/desktop_aura/desktop_activation_client.cc deleted file mode 100644 index dc8f062..0000000 --- a/ui/views/widget/desktop_aura/desktop_activation_client.cc +++ /dev/null @@ -1,190 +0,0 @@ -// 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_activation_client.h" - -#include "base/auto_reset.h" -#include "base/compiler_specific.h" -#include "ui/aura/client/activation_delegate.h" -#include "ui/aura/client/activation_change_observer.h" -#include "ui/aura/client/focus_client.h" -#include "ui/aura/root_window.h" -#include "ui/aura/window.h" - -namespace views { - -namespace { - -aura::Window* FindFocusableWindowFor(aura::Window* window) { - while (window && !window->CanFocus()) - window = window->parent(); - return window; -} - -} // namespace - -DesktopActivationClient::DesktopActivationClient(aura::RootWindow* root_window) - : root_window_(root_window), - current_active_(NULL), - updating_activation_(false), - observer_manager_(this) { - aura::client::GetFocusClient(root_window_)->AddObserver(this); - aura::client::SetActivationClient(root_window_, this); - root_window->AddPreTargetHandler(this); -} - -DesktopActivationClient::~DesktopActivationClient() { - root_window_->RemovePreTargetHandler(this); - aura::client::GetFocusClient(root_window_)->RemoveObserver(this); - aura::client::SetActivationClient(root_window_, NULL); -} - -void DesktopActivationClient::AddObserver( - aura::client::ActivationChangeObserver* observer) { - observers_.AddObserver(observer); -} - -void DesktopActivationClient::RemoveObserver( - aura::client::ActivationChangeObserver* observer) { - observers_.RemoveObserver(observer); -} - -void DesktopActivationClient::ActivateWindow(aura::Window* window) { - // Prevent recursion when called from focus. - if (updating_activation_) - return; - - base::AutoReset<bool> in_activate_window(&updating_activation_, true); - // Nothing may actually have changed. - if (current_active_ == window) - return; - // The stacking client may impose rules on what window configurations can be - // activated or deactivated. - if (window && !CanActivateWindow(window)) - return; - // Switch internal focus before we change the activation. Will probably cause - // recursion. - if (window && - !window->Contains(aura::client::GetFocusClient(window)-> - GetFocusedWindow())) { - aura::client::GetFocusClient(window)->FocusWindow(window); - } - - aura::Window* old_active = current_active_; - current_active_ = window; - if (window && !observer_manager_.IsObserving(window)) - observer_manager_.Add(window); - - FOR_EACH_OBSERVER(aura::client::ActivationChangeObserver, - observers_, - OnWindowActivated(window, old_active)); - aura::client::ActivationChangeObserver* observer = - aura::client::GetActivationChangeObserver(old_active); - if (observer) - observer->OnWindowActivated(window, old_active); - observer = aura::client::GetActivationChangeObserver(window); - if (observer) - observer->OnWindowActivated(window, old_active); -} - -void DesktopActivationClient::DeactivateWindow(aura::Window* window) { - if (window == current_active_) - current_active_ = NULL; -} - -aura::Window* DesktopActivationClient::GetActiveWindow() { - return current_active_; -} - -aura::Window* DesktopActivationClient::GetActivatableWindow( - aura::Window* window) { - aura::Window* parent = window->parent(); - aura::Window* child = window; - while (parent) { - if (CanActivateWindow(child)) - return child; - // If |child| isn't activatable, but has transient parent, trace - // that path instead. - if (child->transient_parent()) - return GetActivatableWindow(child->transient_parent()); - parent = parent->parent(); - child = child->parent(); - } - return NULL; -} - -aura::Window* DesktopActivationClient::GetToplevelWindow(aura::Window* window) { - aura::Window* parent = window->parent(); - aura::Window* child = window; - aura::Window* root = child->GetRootWindow(); - while (parent) { - if (parent == root) - return child; - parent = parent->parent(); - child = child->parent(); - } - return NULL; -} - -bool DesktopActivationClient::OnWillFocusWindow(aura::Window* window, - const ui::Event* event) { - return CanActivateWindow(GetActivatableWindow(window)); -} - -void DesktopActivationClient::OnWindowDestroying(aura::Window* window) { - if (current_active_ == window) { - current_active_ = NULL; - FOR_EACH_OBSERVER(aura::client::ActivationChangeObserver, - observers_, - OnWindowActivated(NULL, window)); - - // ash::ActivationController will also activate the next window here; we - // don't do this because that's the desktop environment's job. - } - observer_manager_.Remove(window); -} - -void DesktopActivationClient::OnWindowFocused(aura::Window* gained_focus, - aura::Window* lost_focus) { - if (gained_focus) - ActivateWindow(GetActivatableWindow(gained_focus)); -} - -bool DesktopActivationClient::CanActivateWindow(aura::Window* window) const { - return window && - window->IsVisible() && - (!aura::client::GetActivationDelegate(window) || - aura::client::GetActivationDelegate(window)->ShouldActivate()); -} - -void DesktopActivationClient::OnKeyEvent(ui::KeyEvent* event) { -} - -void DesktopActivationClient::OnMouseEvent(ui::MouseEvent* event) { - if (event->type() == ui::ET_MOUSE_PRESSED) - FocusWindowWithEvent(event); -} - -void DesktopActivationClient::OnScrollEvent(ui::ScrollEvent* event) { -} - -void DesktopActivationClient::OnTouchEvent(ui::TouchEvent* event) { -} - -void DesktopActivationClient::OnGestureEvent(ui::GestureEvent* event) { - if (event->type() == ui::ET_GESTURE_BEGIN && - event->details().touch_points() == 1) { - FocusWindowWithEvent(event); - } -} - -void DesktopActivationClient::FocusWindowWithEvent(const ui::Event* event) { - aura::Window* window = static_cast<aura::Window*>(event->target()); - if (GetActiveWindow() != window) { - aura::client::GetFocusClient(window)->FocusWindow( - FindFocusableWindowFor(window)); - } -} - -} // namespace views diff --git a/ui/views/widget/desktop_aura/desktop_activation_client.h b/ui/views/widget/desktop_aura/desktop_activation_client.h deleted file mode 100644 index b341817..0000000 --- a/ui/views/widget/desktop_aura/desktop_activation_client.h +++ /dev/null @@ -1,90 +0,0 @@ -// 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_AURA_DESTKOP_ACTIVATION_CLIENT_H_ -#define UI_VIEWS_WIDGET_DESKTOP_AURA_DESTKOP_ACTIVATION_CLIENT_H_ - -#include "base/basictypes.h" -#include "base/observer_list.h" -#include "base/scoped_observer.h" -#include "ui/aura/client/activation_client.h" -#include "ui/aura/client/focus_change_observer.h" -#include "ui/aura/env_observer.h" -#include "ui/aura/root_window_observer.h" -#include "ui/aura/window_observer.h" -#include "ui/views/views_export.h" - -namespace aura { -class FocusManager; -class RootWindow; - -namespace client { -class ActivationChangeObserver; -} -} - -namespace views { - -// An activation client that handles activation events in a single -// RootWindow. Used only on the Desktop where there can be multiple RootWindow -// objects. -class VIEWS_EXPORT DesktopActivationClient - : public aura::client::ActivationClient, - public aura::WindowObserver, - public ui::EventHandler, - public aura::client::FocusChangeObserver { - public: - explicit DesktopActivationClient(aura::RootWindow* root_window); - virtual ~DesktopActivationClient(); - - // ActivationClient: - virtual void AddObserver( - aura::client::ActivationChangeObserver* observer) OVERRIDE; - virtual void RemoveObserver( - aura::client::ActivationChangeObserver* observer) OVERRIDE; - virtual void ActivateWindow(aura::Window* window) OVERRIDE; - virtual void DeactivateWindow(aura::Window* window) OVERRIDE; - virtual aura::Window* GetActiveWindow() OVERRIDE; - virtual aura::Window* GetActivatableWindow(aura::Window* window) OVERRIDE; - virtual aura::Window* GetToplevelWindow(aura::Window* window) OVERRIDE; - virtual bool OnWillFocusWindow(aura::Window* window, - const ui::Event* event) OVERRIDE; - virtual bool CanActivateWindow(aura::Window* window) const OVERRIDE; - - // Overridden from aura::WindowObserver: - virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; - - // Overridden from aura::client::FocusChangeObserver: - virtual void OnWindowFocused(aura::Window* gained_focus, - aura::Window* lost_focus) OVERRIDE; - - // Overridden from ui::EventHandler: - virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; - virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; - virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; - virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; - virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; - - private: - void FocusWindowWithEvent(const ui::Event* event); - - aura::RootWindow* root_window_; - - // The current active window. - aura::Window* current_active_; - - // True inside ActivateWindow(). Used to prevent recursion of focus - // change notifications causing activation. - bool updating_activation_; - - ObserverList<aura::client::ActivationChangeObserver> observers_; - - ScopedObserver<aura::Window, aura::WindowObserver> observer_manager_; - - DISALLOW_COPY_AND_ASSIGN(DesktopActivationClient); -}; - -} // namespace views - -#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESTKOP_ACTIVATION_CLIENT_H_ diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc index 0bb643e..b1604e2 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc @@ -867,28 +867,10 @@ void DesktopNativeWidgetAura::OnWindowActivated(aura::Window* gained_active, restore_focus_on_activate_ = false; GetWidget()->GetFocusManager()->RestoreFocusedView(); } else if (lost_active == window_ && GetWidget()->HasFocusManager()) { - bool store_focused_view = corewm::UseFocusControllerOnDesktop(); - if (!store_focused_view) { - // 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); - store_focused_view = focused_widget && focused_widget != GetWidget() && - focused_widget->is_top_level(); - } - } - if (store_focused_view) { - DCHECK(!restore_focus_on_activate_); - restore_focus_on_activate_ = true; - // Pass in false so that ClearNativeFocus() isn't invoked. - GetWidget()->GetFocusManager()->StoreFocusedView(false); - } + DCHECK(!restore_focus_on_activate_); + restore_focus_on_activate_ = true; + // Pass in false so that ClearNativeFocus() isn't invoked. + GetWidget()->GetFocusManager()->StoreFocusedView(false); } } diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc index 6d24adc..d81aeb8 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc @@ -29,7 +29,6 @@ #include "ui/views/corewm/input_method_event_filter.h" #include "ui/views/corewm/window_animations.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_loader_updater.h" #include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h" #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h" @@ -67,10 +66,8 @@ DesktopRootWindowHostWin::DesktopRootWindowHostWin( } DesktopRootWindowHostWin::~DesktopRootWindowHostWin() { - if (corewm::UseFocusControllerOnDesktop()) { - aura::client::SetFocusClient(root_window_, NULL); - aura::client::SetActivationClient(root_window_, NULL); - } + aura::client::SetFocusClient(root_window_, NULL); + aura::client::SetActivationClient(root_window_, NULL); } // static @@ -128,18 +125,12 @@ aura::RootWindow* DesktopRootWindowHostWin::Init( desktop_native_widget_aura_->CreateCaptureClient(root_window_); - if (corewm::UseFocusControllerOnDesktop()) { - 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); - root_window_->AddPreTargetHandler(focus_controller); - } else { - focus_client_.reset(new aura::FocusManager); - aura::client::SetFocusClient(root_window_, focus_client_.get()); - activation_client_.reset(new DesktopActivationClient(root_window_)); - } + 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); + root_window_->AddPreTargetHandler(focus_controller); dispatcher_client_.reset(new DesktopDispatcherClient); aura::client::SetDispatcherClient(root_window_, diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_win.h b/ui/views/widget/desktop_aura/desktop_root_window_host_win.h index 028e608..483b634 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_win.h +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_win.h @@ -19,7 +19,6 @@ class ScreenPositionClient; } namespace views { -class DesktopActivationClient; class DesktopCursorClient; class DesktopDispatcherClient; class DesktopDragDropClientWin; @@ -215,8 +214,6 @@ class VIEWS_EXPORT DesktopRootWindowHostWin scoped_ptr<HWNDMessageHandler> message_handler_; scoped_ptr<DesktopDispatcherClient> dispatcher_client_; scoped_ptr<aura::client::FocusClient> focus_client_; - // Depends on focus_manager_. - scoped_ptr<DesktopActivationClient> activation_client_; // TODO(beng): Consider providing an interface to DesktopNativeWidgetAura // instead of providing this route back to Widget. diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc index 4853741..e398383 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc @@ -32,7 +32,6 @@ #include "ui/views/corewm/cursor_manager.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_loader_updater_aurax11.h" #include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h" #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h" @@ -128,10 +127,8 @@ DesktopRootWindowHostX11::DesktopRootWindowHostX11( DesktopRootWindowHostX11::~DesktopRootWindowHostX11() { root_window_->ClearProperty(kHostForRootWindow); - if (corewm::UseFocusControllerOnDesktop()) { - aura::client::SetFocusClient(root_window_, NULL); - aura::client::SetActivationClient(root_window_, NULL); - } + aura::client::SetFocusClient(root_window_, NULL); + aura::client::SetActivationClient(root_window_, NULL); } // static @@ -896,18 +893,12 @@ aura::RootWindow* DesktopRootWindowHostX11::InitRootWindow( // messages to us. X11DesktopHandler::get(); - if (corewm::UseFocusControllerOnDesktop()) { - 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); - root_window_->AddPreTargetHandler(focus_controller); - } else { - focus_client_.reset(new aura::FocusManager); - aura::client::SetFocusClient(root_window_, focus_client_.get()); - activation_client_.reset(new DesktopActivationClient(root_window_)); - } + 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); + root_window_->AddPreTargetHandler(focus_controller); dispatcher_client_.reset(new DesktopDispatcherClient); aura::client::SetDispatcherClient(root_window_, @@ -936,8 +927,7 @@ aura::RootWindow* DesktopRootWindowHostX11::InitRootWindow( aura::client::SetDragDropClient(root_window_, drag_drop_client_.get()); // TODO(erg): Unify this code once the other consumer goes away. - x11_window_event_filter_.reset( - new X11WindowEventFilter(root_window_, activation_client_.get())); + x11_window_event_filter_.reset(new X11WindowEventFilter(root_window_)); x11_window_event_filter_->SetUseHostWindowBorders(false); desktop_native_widget_aura_->root_window_event_filter()->AddHandler( x11_window_event_filter_.get()); diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h index 65a135a..526bee4 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h @@ -29,7 +29,6 @@ class ScreenPositionClient; } namespace views { -class DesktopActivationClient; class DesktopDragDropClientAuraX11; class DesktopDispatcherClient; class DesktopRootWindowHostObserverX11; @@ -224,7 +223,6 @@ private: // aura:: objects that we own. scoped_ptr<aura::client::FocusClient> focus_client_; - scoped_ptr<DesktopActivationClient> activation_client_; scoped_ptr<views::corewm::CursorManager> cursor_client_; scoped_ptr<DesktopDispatcherClient> dispatcher_client_; scoped_ptr<aura::client::ScreenPositionClient> position_client_; diff --git a/ui/views/widget/desktop_aura/x11_desktop_handler.cc b/ui/views/widget/desktop_aura/x11_desktop_handler.cc index 4690699..4c38fa7 100644 --- a/ui/views/widget/desktop_aura/x11_desktop_handler.cc +++ b/ui/views/widget/desktop_aura/x11_desktop_handler.cc @@ -9,7 +9,6 @@ #include "ui/aura/focus_manager.h" #include "ui/aura/root_window.h" #include "ui/base/x/x11_util.h" -#include "ui/views/widget/desktop_aura/desktop_activation_client.h" #if !defined(OS_CHROMEOS) #include "ui/views/ime/input_method.h" diff --git a/ui/views/widget/desktop_aura/x11_window_event_filter.cc b/ui/views/widget/desktop_aura/x11_window_event_filter.cc index 3495b04..5d040c9 100644 --- a/ui/views/widget/desktop_aura/x11_window_event_filter.cc +++ b/ui/views/widget/desktop_aura/x11_window_event_filter.cc @@ -15,7 +15,6 @@ #include "ui/base/events/event.h" #include "ui/base/events/event_utils.h" #include "ui/base/hit_test.h" -#include "ui/views/widget/desktop_aura/desktop_activation_client.h" #include "ui/views/widget/native_widget_aura.h" namespace { @@ -59,10 +58,8 @@ const char* kAtomsToCache[] = { namespace views { X11WindowEventFilter::X11WindowEventFilter( - aura::RootWindow* root_window, - DesktopActivationClient* activation_client) - : activation_client_(activation_client), - xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), + aura::RootWindow* root_window) + : xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), xwindow_(root_window->GetAcceleratedWidget()), x_root_window_(DefaultRootWindow(xdisplay_)), atom_cache_(xdisplay_, kAtomsToCache), diff --git a/ui/views/widget/desktop_aura/x11_window_event_filter.h b/ui/views/widget/desktop_aura/x11_window_event_filter.h index a6bdce8..1cf3f9c 100644 --- a/ui/views/widget/desktop_aura/x11_window_event_filter.h +++ b/ui/views/widget/desktop_aura/x11_window_event_filter.h @@ -25,14 +25,12 @@ class Point; } namespace views { -class DesktopActivationClient; class NativeWidgetAura; // An EventFilter that sets properties on X11 windows. class VIEWS_EXPORT X11WindowEventFilter : public ui::EventHandler { public: - explicit X11WindowEventFilter(aura::RootWindow* root_window, - DesktopActivationClient* activation_client); + explicit X11WindowEventFilter(aura::RootWindow* root_window); virtual ~X11WindowEventFilter(); // Changes whether borders are shown on this |root_window|. @@ -47,8 +45,6 @@ class VIEWS_EXPORT X11WindowEventFilter : public ui::EventHandler { bool DispatchHostWindowDragMovement(int hittest, const gfx::Point& screen_location); - DesktopActivationClient* activation_client_; - // The display and the native X window hosting the root window. Display* xdisplay_; ::Window xwindow_; |