OLD | NEW |
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/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 #include "base/supports_user_data.h" | 13 #include "base/supports_user_data.h" |
14 #include "ui/aura/aura_export.h" | 14 #include "ui/aura/aura_export.h" |
15 #include "ui/events/event_handler.h" | 15 #include "ui/events/event_handler.h" |
16 #include "ui/events/event_target.h" | 16 #include "ui/events/event_target.h" |
17 #include "ui/gfx/geometry/point.h" | 17 #include "ui/gfx/geometry/point.h" |
18 | 18 |
19 namespace ui { | 19 namespace ui { |
20 class ContextFactory; | 20 class ContextFactory; |
21 class PlatformEventSource; | 21 class PlatformEventSource; |
22 } | 22 } |
23 namespace aura { | 23 namespace aura { |
24 | 24 |
| 25 namespace client { |
| 26 class FocusClient; |
| 27 } |
| 28 |
25 namespace test { | 29 namespace test { |
26 class EnvTestHelper; | 30 class EnvTestHelper; |
27 } | 31 } |
28 | 32 |
29 class EnvObserver; | 33 class EnvObserver; |
30 class InputStateLookup; | 34 class InputStateLookup; |
31 class Window; | 35 class Window; |
32 class WindowPort; | 36 class WindowPort; |
33 class WindowTreeHost; | 37 class WindowTreeHost; |
34 | 38 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 71 |
68 // Whether any touch device is currently down. | 72 // Whether any touch device is currently down. |
69 bool is_touch_down() const { return is_touch_down_; } | 73 bool is_touch_down() const { return is_touch_down_; } |
70 void set_touch_down(bool value) { is_touch_down_ = value; } | 74 void set_touch_down(bool value) { is_touch_down_ = value; } |
71 | 75 |
72 void set_context_factory(ui::ContextFactory* context_factory) { | 76 void set_context_factory(ui::ContextFactory* context_factory) { |
73 context_factory_ = context_factory; | 77 context_factory_ = context_factory; |
74 } | 78 } |
75 ui::ContextFactory* context_factory() { return context_factory_; } | 79 ui::ContextFactory* context_factory() { return context_factory_; } |
76 | 80 |
| 81 // Sets the active FocusClient and the window the FocusClient is associated |
| 82 // with. |window| is not necessarily the window that actually has focus. |
| 83 // |window| may be null, which indicates all windows share a FocusClient. |
| 84 void SetActiveFocusClient(client::FocusClient* focus_client, |
| 85 Window* focus_client_root); |
| 86 client::FocusClient* active_focus_client() { return active_focus_client_; } |
| 87 Window* active_focus_client_root() { return active_focus_client_root_; } |
| 88 |
77 private: | 89 private: |
| 90 class ActiveFocusClientWindowObserver; |
| 91 |
78 friend class test::EnvTestHelper; | 92 friend class test::EnvTestHelper; |
79 friend class Window; | 93 friend class Window; |
80 friend class WindowTreeHost; | 94 friend class WindowTreeHost; |
81 | 95 |
82 explicit Env(const WindowPortFactory& window_port_factory); | 96 explicit Env(const WindowPortFactory& window_port_factory); |
83 | 97 |
84 void Init(); | 98 void Init(); |
85 | 99 |
86 // Called by the Window when it is initialized. Notifies observers. | 100 // Called by the Window when it is initialized. Notifies observers. |
87 void NotifyWindowInitialized(Window* window); | 101 void NotifyWindowInitialized(Window* window); |
88 | 102 |
89 // Called by the WindowTreeHost when it is initialized. Notifies observers. | 103 // Called by the WindowTreeHost when it is initialized. Notifies observers. |
90 void NotifyHostInitialized(WindowTreeHost* host); | 104 void NotifyHostInitialized(WindowTreeHost* host); |
91 | 105 |
92 // Invoked by WindowTreeHost when it is activated. Notifies observers. | 106 // Invoked by WindowTreeHost when it is activated. Notifies observers. |
93 void NotifyHostActivated(WindowTreeHost* host); | 107 void NotifyHostActivated(WindowTreeHost* host); |
94 | 108 |
| 109 void OnActiveFocusClientWindowDestroying(); |
| 110 |
95 // Overridden from ui::EventTarget: | 111 // Overridden from ui::EventTarget: |
96 bool CanAcceptEvent(const ui::Event& event) override; | 112 bool CanAcceptEvent(const ui::Event& event) override; |
97 ui::EventTarget* GetParentTarget() override; | 113 ui::EventTarget* GetParentTarget() override; |
98 std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override; | 114 std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override; |
99 ui::EventTargeter* GetEventTargeter() override; | 115 ui::EventTargeter* GetEventTargeter() override; |
100 | 116 |
101 WindowPortFactory window_port_factory_; | 117 WindowPortFactory window_port_factory_; |
102 | 118 |
103 base::ObserverList<EnvObserver> observers_; | 119 base::ObserverList<EnvObserver> observers_; |
104 | 120 |
105 int mouse_button_flags_; | 121 int mouse_button_flags_; |
106 // Location of last mouse event, in screen coordinates. | 122 // Location of last mouse event, in screen coordinates. |
107 gfx::Point last_mouse_location_; | 123 gfx::Point last_mouse_location_; |
108 bool is_touch_down_; | 124 bool is_touch_down_; |
109 | 125 |
110 std::unique_ptr<InputStateLookup> input_state_lookup_; | 126 std::unique_ptr<InputStateLookup> input_state_lookup_; |
111 std::unique_ptr<ui::PlatformEventSource> event_source_; | 127 std::unique_ptr<ui::PlatformEventSource> event_source_; |
112 | 128 |
113 ui::ContextFactory* context_factory_; | 129 ui::ContextFactory* context_factory_; |
114 | 130 |
| 131 Window* active_focus_client_root_ = nullptr; |
| 132 client::FocusClient* active_focus_client_ = nullptr; |
| 133 std::unique_ptr<ActiveFocusClientWindowObserver> |
| 134 active_focus_client_window_observer_; |
| 135 |
115 DISALLOW_COPY_AND_ASSIGN(Env); | 136 DISALLOW_COPY_AND_ASSIGN(Env); |
116 }; | 137 }; |
117 | 138 |
118 } // namespace aura | 139 } // namespace aura |
119 | 140 |
120 #endif // UI_AURA_ENV_H_ | 141 #endif // UI_AURA_ENV_H_ |
OLD | NEW |