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" |
(...skipping 11 matching lines...) Expand all Loading... |
22 class Transform; | 22 class Transform; |
23 } | 23 } |
24 | 24 |
25 namespace ui { | 25 namespace ui { |
26 class Compositor; | 26 class Compositor; |
27 class EventProcessor; | 27 class EventProcessor; |
28 class ViewProp; | 28 class ViewProp; |
29 } | 29 } |
30 | 30 |
31 namespace aura { | 31 namespace aura { |
| 32 namespace test { |
| 33 class WindowTreeHostTestApi; |
| 34 } |
| 35 |
32 class WindowEventDispatcher; | 36 class WindowEventDispatcher; |
33 class WindowTreeHostObserver; | 37 class WindowTreeHostObserver; |
34 | 38 |
35 // WindowTreeHost bridges between a native window and the embedded RootWindow. | 39 // WindowTreeHost bridges between a native window and the embedded RootWindow. |
36 // It provides the accelerated widget and maps events from the native os to | 40 // It provides the accelerated widget and maps events from the native os to |
37 // aura. | 41 // aura. |
38 class AURA_EXPORT WindowTreeHost { | 42 class AURA_EXPORT WindowTreeHost { |
39 public: | 43 public: |
40 virtual ~WindowTreeHost(); | 44 virtual ~WindowTreeHost(); |
41 | 45 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // Gets/Sets the size of the WindowTreeHost. | 132 // Gets/Sets the size of the WindowTreeHost. |
129 virtual gfx::Rect GetBounds() const = 0; | 133 virtual gfx::Rect GetBounds() const = 0; |
130 virtual void SetBounds(const gfx::Rect& bounds) = 0; | 134 virtual void SetBounds(const gfx::Rect& bounds) = 0; |
131 | 135 |
132 // Sets the OS capture to the root window. | 136 // Sets the OS capture to the root window. |
133 virtual void SetCapture() = 0; | 137 virtual void SetCapture() = 0; |
134 | 138 |
135 // Releases OS capture of the root window. | 139 // Releases OS capture of the root window. |
136 virtual void ReleaseCapture() = 0; | 140 virtual void ReleaseCapture() = 0; |
137 | 141 |
138 // Queries the mouse's current position relative to the host window and sets | |
139 // it in |location_return|. Returns true if the cursor is within the host | |
140 // window. The position set to |location_return| is constrained within the | |
141 // host window. If the cursor is disabled, returns false and (0, 0) is set to | |
142 // |location_return|. | |
143 // This method is expensive, instead use gfx::Screen::GetCursorScreenPoint(). | |
144 virtual bool QueryMouseLocation(gfx::Point* location_return) = 0; | |
145 | |
146 // Posts |native_event| to the platform's event queue. | 142 // Posts |native_event| to the platform's event queue. |
147 virtual void PostNativeEvent(const base::NativeEvent& native_event) = 0; | 143 virtual void PostNativeEvent(const base::NativeEvent& native_event) = 0; |
148 | 144 |
149 // Called when the device scale factor of the root window has chagned. | 145 // Called when the device scale factor of the root window has chagned. |
150 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) = 0; | 146 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) = 0; |
151 | 147 |
152 protected: | 148 protected: |
153 friend class TestScreen; // TODO(beng): see if we can remove/consolidate. | 149 friend class TestScreen; // TODO(beng): see if we can remove/consolidate. |
154 | 150 |
155 WindowTreeHost(); | 151 WindowTreeHost(); |
(...skipping 14 matching lines...) Expand all Loading... |
170 // Sets the currently displayed cursor. | 166 // Sets the currently displayed cursor. |
171 virtual void SetCursorNative(gfx::NativeCursor cursor) = 0; | 167 virtual void SetCursorNative(gfx::NativeCursor cursor) = 0; |
172 | 168 |
173 // Moves the cursor to the specified location relative to the root window. | 169 // Moves the cursor to the specified location relative to the root window. |
174 virtual void MoveCursorToNative(const gfx::Point& location) = 0; | 170 virtual void MoveCursorToNative(const gfx::Point& location) = 0; |
175 | 171 |
176 // kCalled when the cursor visibility has changed. | 172 // kCalled when the cursor visibility has changed. |
177 virtual void OnCursorVisibilityChangedNative(bool show) = 0; | 173 virtual void OnCursorVisibilityChangedNative(bool show) = 0; |
178 | 174 |
179 private: | 175 private: |
| 176 friend class test::WindowTreeHostTestApi; |
| 177 |
180 // Moves the cursor to the specified location. This method is internally used | 178 // Moves the cursor to the specified location. This method is internally used |
181 // by MoveCursorTo() and MoveCursorToHostLocation(). | 179 // by MoveCursorTo() and MoveCursorToHostLocation(). |
182 void MoveCursorToInternal(const gfx::Point& root_location, | 180 void MoveCursorToInternal(const gfx::Point& root_location, |
183 const gfx::Point& host_location); | 181 const gfx::Point& host_location); |
184 | 182 |
185 // We don't use a scoped_ptr for |window_| since we need this ptr to be valid | 183 // We don't use a scoped_ptr for |window_| since we need this ptr to be valid |
186 // during its deletion. (Window's dtor notifies observers that may attempt to | 184 // during its deletion. (Window's dtor notifies observers that may attempt to |
187 // reach back up to access this object which will be valid until the end of | 185 // reach back up to access this object which will be valid until the end of |
188 // the dtor). | 186 // the dtor). |
189 Window* window_; // Owning. | 187 Window* window_; // Owning. |
190 | 188 |
191 ObserverList<WindowTreeHostObserver> observers_; | 189 ObserverList<WindowTreeHostObserver> observers_; |
192 | 190 |
193 scoped_ptr<WindowEventDispatcher> dispatcher_; | 191 scoped_ptr<WindowEventDispatcher> dispatcher_; |
194 | 192 |
195 scoped_ptr<ui::Compositor> compositor_; | 193 scoped_ptr<ui::Compositor> compositor_; |
196 | 194 |
197 // Last cursor set. Used for testing. | 195 // Last cursor set. Used for testing. |
198 gfx::NativeCursor last_cursor_; | 196 gfx::NativeCursor last_cursor_; |
| 197 gfx::Point last_cursor_request_position_in_host_; |
199 | 198 |
200 scoped_ptr<ui::ViewProp> prop_; | 199 scoped_ptr<ui::ViewProp> prop_; |
201 | 200 |
202 DISALLOW_COPY_AND_ASSIGN(WindowTreeHost); | 201 DISALLOW_COPY_AND_ASSIGN(WindowTreeHost); |
203 }; | 202 }; |
204 | 203 |
205 } // namespace aura | 204 } // namespace aura |
206 | 205 |
207 #endif // UI_AURA_WINDOW_TREE_HOST_H_ | 206 #endif // UI_AURA_WINDOW_TREE_HOST_H_ |
OLD | NEW |