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 | |
29 namespace test { | 25 namespace test { |
30 class EnvTestHelper; | 26 class EnvTestHelper; |
31 } | 27 } |
32 | 28 |
33 class EnvObserver; | 29 class EnvObserver; |
34 class InputStateLookup; | 30 class InputStateLookup; |
35 class Window; | 31 class Window; |
36 class WindowPort; | 32 class WindowPort; |
37 class WindowTreeHost; | 33 class WindowTreeHost; |
38 | 34 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 67 |
72 // Whether any touch device is currently down. | 68 // Whether any touch device is currently down. |
73 bool is_touch_down() const { return is_touch_down_; } | 69 bool is_touch_down() const { return is_touch_down_; } |
74 void set_touch_down(bool value) { is_touch_down_ = value; } | 70 void set_touch_down(bool value) { is_touch_down_ = value; } |
75 | 71 |
76 void set_context_factory(ui::ContextFactory* context_factory) { | 72 void set_context_factory(ui::ContextFactory* context_factory) { |
77 context_factory_ = context_factory; | 73 context_factory_ = context_factory; |
78 } | 74 } |
79 ui::ContextFactory* context_factory() { return context_factory_; } | 75 ui::ContextFactory* context_factory() { return context_factory_; } |
80 | 76 |
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 | |
89 private: | 77 private: |
90 class ActiveFocusClientWindowObserver; | |
91 | |
92 friend class test::EnvTestHelper; | 78 friend class test::EnvTestHelper; |
93 friend class Window; | 79 friend class Window; |
94 friend class WindowTreeHost; | 80 friend class WindowTreeHost; |
95 | 81 |
96 explicit Env(const WindowPortFactory& window_port_factory); | 82 explicit Env(const WindowPortFactory& window_port_factory); |
97 | 83 |
98 void Init(); | 84 void Init(); |
99 | 85 |
100 // Called by the Window when it is initialized. Notifies observers. | 86 // Called by the Window when it is initialized. Notifies observers. |
101 void NotifyWindowInitialized(Window* window); | 87 void NotifyWindowInitialized(Window* window); |
102 | 88 |
103 // Called by the WindowTreeHost when it is initialized. Notifies observers. | 89 // Called by the WindowTreeHost when it is initialized. Notifies observers. |
104 void NotifyHostInitialized(WindowTreeHost* host); | 90 void NotifyHostInitialized(WindowTreeHost* host); |
105 | 91 |
106 // Invoked by WindowTreeHost when it is activated. Notifies observers. | 92 // Invoked by WindowTreeHost when it is activated. Notifies observers. |
107 void NotifyHostActivated(WindowTreeHost* host); | 93 void NotifyHostActivated(WindowTreeHost* host); |
108 | 94 |
109 void OnActiveFocusClientWindowDestroying(); | |
110 | |
111 // Overridden from ui::EventTarget: | 95 // Overridden from ui::EventTarget: |
112 bool CanAcceptEvent(const ui::Event& event) override; | 96 bool CanAcceptEvent(const ui::Event& event) override; |
113 ui::EventTarget* GetParentTarget() override; | 97 ui::EventTarget* GetParentTarget() override; |
114 std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override; | 98 std::unique_ptr<ui::EventTargetIterator> GetChildIterator() const override; |
115 ui::EventTargeter* GetEventTargeter() override; | 99 ui::EventTargeter* GetEventTargeter() override; |
116 | 100 |
117 WindowPortFactory window_port_factory_; | 101 WindowPortFactory window_port_factory_; |
118 | 102 |
119 base::ObserverList<EnvObserver> observers_; | 103 base::ObserverList<EnvObserver> observers_; |
120 | 104 |
121 int mouse_button_flags_; | 105 int mouse_button_flags_; |
122 // Location of last mouse event, in screen coordinates. | 106 // Location of last mouse event, in screen coordinates. |
123 gfx::Point last_mouse_location_; | 107 gfx::Point last_mouse_location_; |
124 bool is_touch_down_; | 108 bool is_touch_down_; |
125 | 109 |
126 std::unique_ptr<InputStateLookup> input_state_lookup_; | 110 std::unique_ptr<InputStateLookup> input_state_lookup_; |
127 std::unique_ptr<ui::PlatformEventSource> event_source_; | 111 std::unique_ptr<ui::PlatformEventSource> event_source_; |
128 | 112 |
129 ui::ContextFactory* context_factory_; | 113 ui::ContextFactory* context_factory_; |
130 | 114 |
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 | |
136 DISALLOW_COPY_AND_ASSIGN(Env); | 115 DISALLOW_COPY_AND_ASSIGN(Env); |
137 }; | 116 }; |
138 | 117 |
139 } // namespace aura | 118 } // namespace aura |
140 | 119 |
141 #endif // UI_AURA_ENV_H_ | 120 #endif // UI_AURA_ENV_H_ |
OLD | NEW |