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_WINDOW_TREE_HOST_H_ | 5 #ifndef UI_AURA_WINDOW_TREE_HOST_H_ |
6 #define UI_AURA_WINDOW_TREE_HOST_H_ | 6 #define UI_AURA_WINDOW_TREE_HOST_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/event_types.h" | 10 #include "base/event_types.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "ui/aura/aura_export.h" | 12 #include "ui/aura/aura_export.h" |
13 #include "ui/base/cursor/cursor.h" | 13 #include "ui/base/cursor/cursor.h" |
| 14 #include "ui/base/ime/input_method_delegate.h" |
14 #include "ui/events/event_source.h" | 15 #include "ui/events/event_source.h" |
15 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
16 | 17 |
17 namespace gfx { | 18 namespace gfx { |
18 class Insets; | 19 class Insets; |
19 class Point; | 20 class Point; |
20 class Rect; | 21 class Rect; |
21 class Size; | 22 class Size; |
22 class Transform; | 23 class Transform; |
23 } | 24 } |
24 | 25 |
25 namespace ui { | 26 namespace ui { |
26 class Compositor; | 27 class Compositor; |
27 class EventProcessor; | 28 class EventProcessor; |
| 29 class InputMethod; |
28 class ViewProp; | 30 class ViewProp; |
29 } | 31 } |
30 | 32 |
31 namespace aura { | 33 namespace aura { |
32 namespace test { | 34 namespace test { |
33 class WindowTreeHostTestApi; | 35 class WindowTreeHostTestApi; |
34 } | 36 } |
35 | 37 |
36 class WindowEventDispatcher; | 38 class WindowEventDispatcher; |
37 class WindowTreeHostObserver; | 39 class WindowTreeHostObserver; |
38 | 40 |
39 // WindowTreeHost bridges between a native window and the embedded RootWindow. | 41 // WindowTreeHost bridges between a native window and the embedded RootWindow. |
40 // It provides the accelerated widget and maps events from the native os to | 42 // It provides the accelerated widget and maps events from the native os to |
41 // aura. | 43 // aura. |
42 class AURA_EXPORT WindowTreeHost { | 44 class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate, |
| 45 public ui::EventSource { |
43 public: | 46 public: |
44 virtual ~WindowTreeHost(); | 47 ~WindowTreeHost() override; |
45 | 48 |
46 // Creates a new WindowTreeHost. The caller owns the returned value. | 49 // Creates a new WindowTreeHost. The caller owns the returned value. |
47 static WindowTreeHost* Create(const gfx::Rect& bounds); | 50 static WindowTreeHost* Create(const gfx::Rect& bounds); |
48 | 51 |
49 // Returns the WindowTreeHost for the specified accelerated widget, or NULL | 52 // Returns the WindowTreeHost for the specified accelerated widget, or NULL |
50 // if there is none associated. | 53 // if there is none associated. |
51 static WindowTreeHost* GetForAcceleratedWidget(gfx::AcceleratedWidget widget); | 54 static WindowTreeHost* GetForAcceleratedWidget(gfx::AcceleratedWidget widget); |
52 | 55 |
53 void InitHost(); | 56 void InitHost(); |
54 | 57 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 void OnCursorVisibilityChanged(bool visible); | 112 void OnCursorVisibilityChanged(bool visible); |
110 | 113 |
111 // Moves the cursor to the specified location relative to the root window. | 114 // Moves the cursor to the specified location relative to the root window. |
112 void MoveCursorTo(const gfx::Point& location); | 115 void MoveCursorTo(const gfx::Point& location); |
113 | 116 |
114 // Moves the cursor to the |host_location| given in host coordinates. | 117 // Moves the cursor to the |host_location| given in host coordinates. |
115 void MoveCursorToHostLocation(const gfx::Point& host_location); | 118 void MoveCursorToHostLocation(const gfx::Point& host_location); |
116 | 119 |
117 gfx::NativeCursor last_cursor() const { return last_cursor_; } | 120 gfx::NativeCursor last_cursor() const { return last_cursor_; } |
118 | 121 |
| 122 // Gets the InputMethod instance, if NULL, creates & owns it. |
| 123 ui::InputMethod* GetInputMethod(); |
| 124 |
| 125 // Sets the InputMethod instance, and it is not owned by this WindowTreeHost. |
| 126 // This is to let some environment can have the singleton InputMethod |
| 127 // instance cross multiple WindowTreeHost's (e.g. Ash). |
| 128 void SetInputMethod(ui::InputMethod* input_method); |
| 129 |
| 130 // Overridden from ui::internal::InputMethodDelegate: |
| 131 bool DispatchKeyEventPostIME(const ui::KeyEvent& event) override; |
| 132 |
119 // Returns the EventSource responsible for dispatching events to the window | 133 // Returns the EventSource responsible for dispatching events to the window |
120 // tree. | 134 // tree. |
121 virtual ui::EventSource* GetEventSource() = 0; | 135 virtual ui::EventSource* GetEventSource() = 0; |
122 | 136 |
123 // Returns the accelerated widget. | 137 // Returns the accelerated widget. |
124 virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0; | 138 virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0; |
125 | 139 |
126 // Shows the WindowTreeHost. | 140 // Shows the WindowTreeHost. |
127 virtual void Show() = 0; | 141 virtual void Show() = 0; |
128 | 142 |
(...skipping 30 matching lines...) Expand all Loading... |
159 | 173 |
160 // Sets the currently displayed cursor. | 174 // Sets the currently displayed cursor. |
161 virtual void SetCursorNative(gfx::NativeCursor cursor) = 0; | 175 virtual void SetCursorNative(gfx::NativeCursor cursor) = 0; |
162 | 176 |
163 // Moves the cursor to the specified location relative to the root window. | 177 // Moves the cursor to the specified location relative to the root window. |
164 virtual void MoveCursorToNative(const gfx::Point& location) = 0; | 178 virtual void MoveCursorToNative(const gfx::Point& location) = 0; |
165 | 179 |
166 // kCalled when the cursor visibility has changed. | 180 // kCalled when the cursor visibility has changed. |
167 virtual void OnCursorVisibilityChangedNative(bool show) = 0; | 181 virtual void OnCursorVisibilityChangedNative(bool show) = 0; |
168 | 182 |
| 183 // Overridden from ui::EventSource: |
| 184 ui::EventProcessor* GetEventProcessor() override; |
| 185 ui::EventDispatchDetails DeliverEventToProcessor(ui::Event* event) override; |
| 186 |
169 private: | 187 private: |
170 friend class test::WindowTreeHostTestApi; | 188 friend class test::WindowTreeHostTestApi; |
171 | 189 |
172 // Moves the cursor to the specified location. This method is internally used | 190 // Moves the cursor to the specified location. This method is internally used |
173 // by MoveCursorTo() and MoveCursorToHostLocation(). | 191 // by MoveCursorTo() and MoveCursorToHostLocation(). |
174 void MoveCursorToInternal(const gfx::Point& root_location, | 192 void MoveCursorToInternal(const gfx::Point& root_location, |
175 const gfx::Point& host_location); | 193 const gfx::Point& host_location); |
176 | 194 |
177 // We don't use a scoped_ptr for |window_| since we need this ptr to be valid | 195 // We don't use a scoped_ptr for |window_| since we need this ptr to be valid |
178 // during its deletion. (Window's dtor notifies observers that may attempt to | 196 // during its deletion. (Window's dtor notifies observers that may attempt to |
179 // reach back up to access this object which will be valid until the end of | 197 // reach back up to access this object which will be valid until the end of |
180 // the dtor). | 198 // the dtor). |
181 Window* window_; // Owning. | 199 Window* window_; // Owning. |
182 | 200 |
183 ObserverList<WindowTreeHostObserver> observers_; | 201 ObserverList<WindowTreeHostObserver> observers_; |
184 | 202 |
185 scoped_ptr<WindowEventDispatcher> dispatcher_; | 203 scoped_ptr<WindowEventDispatcher> dispatcher_; |
186 | 204 |
187 scoped_ptr<ui::Compositor> compositor_; | 205 scoped_ptr<ui::Compositor> compositor_; |
188 | 206 |
189 // Last cursor set. Used for testing. | 207 // Last cursor set. Used for testing. |
190 gfx::NativeCursor last_cursor_; | 208 gfx::NativeCursor last_cursor_; |
191 gfx::Point last_cursor_request_position_in_host_; | 209 gfx::Point last_cursor_request_position_in_host_; |
192 | 210 |
193 scoped_ptr<ui::ViewProp> prop_; | 211 scoped_ptr<ui::ViewProp> prop_; |
194 | 212 |
| 213 // The InputMethod instance used to process key events. |
| 214 // If owned it, it is created in GetInputMethod() method; |
| 215 // If not owned it, it is passed in through SetInputMethod() method. |
| 216 ui::InputMethod* input_method_; |
| 217 |
| 218 // Whether the InputMethod instance is owned by this WindowTreeHost. |
| 219 // So that the destructor can determine whether to release the InputMethod |
| 220 // instance. |
| 221 bool owned_input_method_; |
| 222 |
195 DISALLOW_COPY_AND_ASSIGN(WindowTreeHost); | 223 DISALLOW_COPY_AND_ASSIGN(WindowTreeHost); |
196 }; | 224 }; |
197 | 225 |
198 } // namespace aura | 226 } // namespace aura |
199 | 227 |
200 #endif // UI_AURA_WINDOW_TREE_HOST_H_ | 228 #endif // UI_AURA_WINDOW_TREE_HOST_H_ |
OLD | NEW |