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

Side by Side Diff: ui/aura/env.h

Issue 2714763002: Change FocusSynchronizer to maintain active focus client and window. (Closed)
Patch Set: fix crash in aura_test_helper tear down Created 3 years, 9 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
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_AURA_ENV_H_ 5 #ifndef UI_AURA_ENV_H_
6 #define UI_AURA_ENV_H_ 6 #define UI_AURA_ENV_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "base/supports_user_data.h" 12 #include "base/supports_user_data.h"
13 #include "ui/aura/aura_export.h" 13 #include "ui/aura/aura_export.h"
14 #include "ui/events/event_handler.h" 14 #include "ui/events/event_handler.h"
15 #include "ui/events/event_target.h" 15 #include "ui/events/event_target.h"
16 #include "ui/gfx/geometry/point.h" 16 #include "ui/gfx/geometry/point.h"
17 17
18 namespace ui { 18 namespace ui {
19 class ContextFactory; 19 class ContextFactory;
20 class ContextFactoryPrivate; 20 class ContextFactoryPrivate;
21 class PlatformEventSource; 21 class PlatformEventSource;
22 } 22 }
23 namespace aura { 23 namespace aura {
24
25 namespace client {
26 class FocusClient;
27 }
28
29 namespace test { 24 namespace test {
30 class EnvTestHelper; 25 class EnvTestHelper;
31 } 26 }
32 27
33 class EnvObserver; 28 class EnvObserver;
34 class InputStateLookup; 29 class InputStateLookup;
35 class MusMouseLocationUpdater; 30 class MusMouseLocationUpdater;
36 class Window; 31 class Window;
37 class WindowPort; 32 class WindowPort;
38 class WindowTreeClient; 33 class WindowTreeClient;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 context_factory_private_ = context_factory_private; 89 context_factory_private_ = context_factory_private;
95 } 90 }
96 ui::ContextFactoryPrivate* context_factory_private() { 91 ui::ContextFactoryPrivate* context_factory_private() {
97 return context_factory_private_; 92 return context_factory_private_;
98 } 93 }
99 94
100 // See CreateInstance() for description. 95 // See CreateInstance() for description.
101 void SetWindowTreeClient(WindowTreeClient* window_tree_client); 96 void SetWindowTreeClient(WindowTreeClient* window_tree_client);
102 bool HasWindowTreeClient() const { return window_tree_client_ != nullptr; } 97 bool HasWindowTreeClient() const { return window_tree_client_ != nullptr; }
103 98
104 // Sets the active FocusClient and the window the FocusClient is associated
105 // with. |window| is not necessarily the window that actually has focus.
106 // |window| may be null, which indicates all windows share a FocusClient.
107 void SetActiveFocusClient(client::FocusClient* focus_client,
108 Window* focus_client_root);
109 client::FocusClient* active_focus_client() { return active_focus_client_; }
110 Window* active_focus_client_root() { return active_focus_client_root_; }
111
112 private: 99 private:
113 class ActiveFocusClientWindowObserver;
114
115 friend class test::EnvTestHelper; 100 friend class test::EnvTestHelper;
116 friend class MusMouseLocationUpdater; 101 friend class MusMouseLocationUpdater;
117 friend class Window; 102 friend class Window;
118 friend class WindowTreeHost; 103 friend class WindowTreeHost;
119 104
120 explicit Env(Mode mode); 105 explicit Env(Mode mode);
121 106
122 void Init(); 107 void Init();
123 108
124 // Called by the Window when it is initialized. Notifies observers. 109 // Called by the Window when it is initialized. Notifies observers.
125 void NotifyWindowInitialized(Window* window); 110 void NotifyWindowInitialized(Window* window);
126 111
127 // Called by the WindowTreeHost when it is initialized. Notifies observers. 112 // Called by the WindowTreeHost when it is initialized. Notifies observers.
128 void NotifyHostInitialized(WindowTreeHost* host); 113 void NotifyHostInitialized(WindowTreeHost* host);
129 114
130 // Invoked by WindowTreeHost when it is activated. Notifies observers. 115 // Invoked by WindowTreeHost when it is activated. Notifies observers.
131 void NotifyHostActivated(WindowTreeHost* host); 116 void NotifyHostActivated(WindowTreeHost* host);
132 117
133 void OnActiveFocusClientWindowDestroying();
134
135 // Overridden from ui::EventTarget: 118 // Overridden from ui::EventTarget:
136 bool CanAcceptEvent(const ui::Event& event) override; 119 bool CanAcceptEvent(const ui::Event& event) override;
137 ui::EventTarget* GetParentTarget() override; 120 ui::EventTarget* GetParentTarget() override;
138 std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override; 121 std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override;
139 ui::EventTargeter* GetEventTargeter() override; 122 ui::EventTargeter* GetEventTargeter() override;
140 123
141 // This is not const for tests, which may share Env across tests and so needs 124 // This is not const for tests, which may share Env across tests and so needs
142 // to reset the value. 125 // to reset the value.
143 Mode mode_; 126 Mode mode_;
144 WindowTreeClient* window_tree_client_ = nullptr; 127 WindowTreeClient* window_tree_client_ = nullptr;
145 128
146 base::ObserverList<EnvObserver> observers_; 129 base::ObserverList<EnvObserver> observers_;
147 130
148 int mouse_button_flags_; 131 int mouse_button_flags_;
149 // Location of last mouse event, in screen coordinates. 132 // Location of last mouse event, in screen coordinates.
150 mutable gfx::Point last_mouse_location_; 133 mutable gfx::Point last_mouse_location_;
151 bool is_touch_down_; 134 bool is_touch_down_;
152 bool get_last_mouse_location_from_mus_; 135 bool get_last_mouse_location_from_mus_;
153 // This may be set to true in tests to force using |last_mouse_location_| 136 // This may be set to true in tests to force using |last_mouse_location_|
154 // rather than querying WindowTreeClient. 137 // rather than querying WindowTreeClient.
155 bool always_use_last_mouse_location_ = false; 138 bool always_use_last_mouse_location_ = false;
156 139
157 std::unique_ptr<InputStateLookup> input_state_lookup_; 140 std::unique_ptr<InputStateLookup> input_state_lookup_;
158 std::unique_ptr<ui::PlatformEventSource> event_source_; 141 std::unique_ptr<ui::PlatformEventSource> event_source_;
159 142
160 ui::ContextFactory* context_factory_; 143 ui::ContextFactory* context_factory_;
161 ui::ContextFactoryPrivate* context_factory_private_; 144 ui::ContextFactoryPrivate* context_factory_private_;
162 145
163 Window* active_focus_client_root_ = nullptr;
164 client::FocusClient* active_focus_client_ = nullptr;
165 std::unique_ptr<ActiveFocusClientWindowObserver>
166 active_focus_client_window_observer_;
167
168 DISALLOW_COPY_AND_ASSIGN(Env); 146 DISALLOW_COPY_AND_ASSIGN(Env);
169 }; 147 };
170 148
171 } // namespace aura 149 } // namespace aura
172 150
173 #endif // UI_AURA_ENV_H_ 151 #endif // UI_AURA_ENV_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698