Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: ui/wm/core/focus_controller.h

Issue 1151133003: Added an ActivationReason parameter to ActivationChangeObserver::OnWindowActivated(...). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Uploaded diff based on dependant CL. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/wm/core/default_activation_client.cc ('k') | ui/wm/core/focus_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_WM_CORE_FOCUS_CONTROLLER_H_ 5 #ifndef UI_WM_CORE_FOCUS_CONTROLLER_H_
6 #define UI_WM_CORE_FOCUS_CONTROLLER_H_ 6 #define UI_WM_CORE_FOCUS_CONTROLLER_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
11 #include "base/scoped_observer.h" 11 #include "base/scoped_observer.h"
12 #include "ui/aura/client/focus_client.h" 12 #include "ui/aura/client/focus_client.h"
13 #include "ui/aura/window_observer.h" 13 #include "ui/aura/window_observer.h"
14 #include "ui/events/event_handler.h" 14 #include "ui/events/event_handler.h"
15 #include "ui/wm/public/activation_change_observer.h"
15 #include "ui/wm/public/activation_client.h" 16 #include "ui/wm/public/activation_client.h"
16 #include "ui/wm/wm_export.h" 17 #include "ui/wm/wm_export.h"
17 18
18 namespace wm { 19 namespace wm {
19 20
20 class FocusRules; 21 class FocusRules;
21 22
22 // FocusController handles focus and activation changes for an environment 23 // FocusController handles focus and activation changes for an environment
23 // encompassing one or more RootWindows. Within an environment there can be 24 // encompassing one or more RootWindows. Within an environment there can be
24 // only one focused and one active window at a time. When focus or activation 25 // only one focused and one active window at a time. When focus or activation
25 // changes notifications are sent using the 26 // changes notifications are sent using the
26 // aura::client::Focus/ActivationChangeObserver interfaces. 27 // aura::client::Focus/ActivationChangeObserver interfaces.
27 // Changes to focus and activation can be from three sources: 28 // Changes to focus and activation can be from three sources. The source can be
28 // . the Aura Client API (implemented here in aura::client::ActivationClient). 29 // determined by the ActivationReason parameter in
29 // (The FocusController must be set as the ActivationClient implementation 30 // ActivationChangeObserver::OnWindowActivated(...).
30 // for all RootWindows). 31 // . ActivationReason::ACTIVATION_CLIENT: The Aura Client API (implemented here
31 // . input events (implemented here in ui::EventHandler). 32 // in aura::client::ActivationClient). (The FocusController must be set as the
32 // (The FocusController must be registered as a pre-target handler for 33 // ActivationClient implementation for all RootWindows).
33 // the applicable environment owner, either a RootWindow or another type). 34 // . ActivationReason::INPUT_EVENT: Input events (implemented here in
34 // . Window disposition changes (implemented here in aura::WindowObserver). 35 // ui::EventHandler). (The FocusController must be registered as a pre-target
35 // (The FocusController registers itself as an observer of the active and 36 // handler for the applicable environment owner, either a RootWindow or
36 // focused windows). 37 // another type).
38 // . ActivationReason::WINDOW_DISPOSITION_CHANGED: Window disposition changes
39 // (implemented here in aura::WindowObserver). (The FocusController registers
40 // itself as an observer of the active and focused windows).
37 class WM_EXPORT FocusController : public aura::client::ActivationClient, 41 class WM_EXPORT FocusController : public aura::client::ActivationClient,
38 public aura::client::FocusClient, 42 public aura::client::FocusClient,
39 public ui::EventHandler, 43 public ui::EventHandler,
40 public aura::WindowObserver { 44 public aura::WindowObserver {
41 public: 45 public:
42 // |rules| cannot be NULL. 46 // |rules| cannot be NULL.
43 explicit FocusController(FocusRules* rules); 47 explicit FocusController(FocusRules* rules);
44 ~FocusController() override; 48 ~FocusController() override;
45 49
46 private: 50 private:
(...skipping 21 matching lines...) Expand all
68 void OnScrollEvent(ui::ScrollEvent* event) override; 72 void OnScrollEvent(ui::ScrollEvent* event) override;
69 void OnTouchEvent(ui::TouchEvent* event) override; 73 void OnTouchEvent(ui::TouchEvent* event) override;
70 void OnGestureEvent(ui::GestureEvent* event) override; 74 void OnGestureEvent(ui::GestureEvent* event) override;
71 75
72 // Overridden from aura::WindowObserver: 76 // Overridden from aura::WindowObserver:
73 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; 77 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override;
74 void OnWindowDestroying(aura::Window* window) override; 78 void OnWindowDestroying(aura::Window* window) override;
75 void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override; 79 void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override;
76 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override; 80 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override;
77 81
82 // Internal implementation that coordinates window focus and activation
83 // changes.
84 void FocusAndActivateWindow(
85 aura::client::ActivationChangeObserver::ActivationReason reason,
86 aura::Window* window);
87
78 // Internal implementation that sets the focused window, fires events etc. 88 // Internal implementation that sets the focused window, fires events etc.
79 // This function must be called with a valid focusable window. 89 // This function must be called with a valid focusable window.
80 void SetFocusedWindow(aura::Window* window); 90 void SetFocusedWindow(aura::Window* window);
81 91
82 // Internal implementation that sets the active window, fires events etc. 92 // Internal implementation that sets the active window, fires events etc.
83 // This function must be called with a valid |activatable_window|. 93 // This function must be called with a valid |activatable_window|.
84 // |requested window| refers to the window that was passed in to an external 94 // |requested_window| refers to the window that was passed in to an external
85 // request (e.g. FocusWindow or ActivateWindow). It may be NULL, e.g. if 95 // request (e.g. FocusWindow or ActivateWindow). It may be NULL, e.g. if
86 // SetActiveWindow was not called by an external request. |activatable_window| 96 // SetActiveWindow was not called by an external request. |activatable_window|
87 // refers to the actual window to be activated, which may be different. 97 // refers to the actual window to be activated, which may be different.
88 void SetActiveWindow(aura::Window* requested_window, 98 void SetActiveWindow(
89 aura::Window* activatable_window); 99 aura::client::ActivationChangeObserver::ActivationReason reason,
100 aura::Window* requested_window,
101 aura::Window* activatable_window);
90 102
91 // Called when a window's disposition changed such that it and its hierarchy 103 // Called when a window's disposition changed such that it and its hierarchy
92 // are no longer focusable/activatable. |next| is a valid window that is used 104 // are no longer focusable/activatable. |next| is a valid window that is used
93 // as a starting point for finding a window to focus next based on rules. 105 // as a starting point for finding a window to focus next based on rules.
94 void WindowLostFocusFromDispositionChange(aura::Window* window, 106 void WindowLostFocusFromDispositionChange(aura::Window* window,
95 aura::Window* next); 107 aura::Window* next);
96 108
97 // Called when an attempt is made to focus or activate a window via an input 109 // Called when an attempt is made to focus or activate a window via an input
98 // event targeted at that window. Rules determine the best focusable window 110 // event targeted at that window. Rules determine the best focusable window
99 // for the input window. 111 // for the input window.
(...skipping 11 matching lines...) Expand all
111 ObserverList<aura::client::FocusChangeObserver> focus_observers_; 123 ObserverList<aura::client::FocusChangeObserver> focus_observers_;
112 124
113 ScopedObserver<aura::Window, aura::WindowObserver> observer_manager_; 125 ScopedObserver<aura::Window, aura::WindowObserver> observer_manager_;
114 126
115 DISALLOW_COPY_AND_ASSIGN(FocusController); 127 DISALLOW_COPY_AND_ASSIGN(FocusController);
116 }; 128 };
117 129
118 } // namespace wm 130 } // namespace wm
119 131
120 #endif // UI_WM_CORE_FOCUS_CONTROLLER_H_ 132 #endif // UI_WM_CORE_FOCUS_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ui/wm/core/default_activation_client.cc ('k') | ui/wm/core/focus_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698