Chromium Code Reviews| 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 <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 | 45 |
| 46 // WindowTreeHost bridges between a native window and the embedded RootWindow. | 46 // WindowTreeHost bridges between a native window and the embedded RootWindow. |
| 47 // It provides the accelerated widget and maps events from the native os to | 47 // It provides the accelerated widget and maps events from the native os to |
| 48 // aura. | 48 // aura. |
| 49 class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate, | 49 class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate, |
| 50 public ui::EventSource { | 50 public ui::EventSource { |
| 51 public: | 51 public: |
| 52 ~WindowTreeHost() override; | 52 ~WindowTreeHost() override; |
| 53 | 53 |
| 54 // Creates a new WindowTreeHost. The caller owns the returned value. | 54 // Creates a new WindowTreeHost. The caller owns the returned value. |
| 55 static WindowTreeHost* Create(const gfx::Rect& bounds); | 55 static WindowTreeHost* Create(const gfx::Rect& bounds_in_pixels); |
| 56 | 56 |
| 57 // Returns the WindowTreeHost for the specified accelerated widget, or NULL | 57 // Returns the WindowTreeHost for the specified accelerated widget, or NULL |
| 58 // if there is none associated. | 58 // if there is none associated. |
| 59 static WindowTreeHost* GetForAcceleratedWidget(gfx::AcceleratedWidget widget); | 59 static WindowTreeHost* GetForAcceleratedWidget(gfx::AcceleratedWidget widget); |
| 60 | 60 |
| 61 void InitHost(); | 61 void InitHost(); |
| 62 | 62 |
| 63 void InitCompositor(); | 63 void InitCompositor(); |
| 64 | 64 |
| 65 void AddObserver(WindowTreeHostObserver* observer); | 65 void AddObserver(WindowTreeHostObserver* observer); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 78 | 78 |
| 79 ui::Compositor* compositor() { return compositor_.get(); } | 79 ui::Compositor* compositor() { return compositor_.get(); } |
| 80 | 80 |
| 81 // Gets/Sets the root window's transform. | 81 // Gets/Sets the root window's transform. |
| 82 virtual gfx::Transform GetRootTransform() const; | 82 virtual gfx::Transform GetRootTransform() const; |
| 83 virtual void SetRootTransform(const gfx::Transform& transform); | 83 virtual void SetRootTransform(const gfx::Transform& transform); |
| 84 virtual gfx::Transform GetInverseRootTransform() const; | 84 virtual gfx::Transform GetInverseRootTransform() const; |
| 85 | 85 |
| 86 // Sets padding applied to the output surface. The output surface is sized to | 86 // Sets padding applied to the output surface. The output surface is sized to |
| 87 // to the size of the host plus output surface padding. |window()| is offset | 87 // to the size of the host plus output surface padding. |window()| is offset |
| 88 // by |padding|, that is, |window|'s origin is set to padding.left(), | 88 // by |padding_in_pixel|, that is, |window|'s origin is set to |
| 89 // padding.top(). | 89 // padding_in_pixel.left(), padding_in_pixel.top(). |
| 90 // This does not impact the bounds as returned from GetBounds(), only the | 90 // This does not impact the bounds as returned from GetBounds(), only the |
| 91 // output surface size and location of window(). Additionally window() is | 91 // output surface size and location of window(). Additionally window() is |
| 92 // sized to the size set by bounds (more specifically the size passed to | 92 // sized to the size set by bounds (more specifically the size passed to |
| 93 // OnHostResized()), but the location of window() is set to that of | 93 // OnHostResizedInPixel()), but the location of window() is set to that of |
| 94 // |padding|. | 94 // |padding_in_pixel|. |
| 95 void SetOutputSurfacePadding(const gfx::Insets& padding); | 95 void SetOutputSurfacePaddingInPixel(const gfx::Insets& padding_in_pixel); |
| 96 | 96 |
| 97 // Updates the root window's size using |host_size|, current | 97 // Updates the root window's size using |host_size_in_pixel|, current |
| 98 // transform and outsets. | 98 // transform and outsets. |
| 99 virtual void UpdateRootWindowSize(const gfx::Size& host_size); | 99 virtual void UpdateRootWindowSizeInPixel(const gfx::Size& host_size_in_pixel); |
| 100 | 100 |
| 101 // Converts |point| from the root window's coordinate system to native | 101 // Converts |point| from the root window's coordinate system to native |
| 102 // screen's. | 102 // screen's. |
| 103 void ConvertPointToNativeScreen(gfx::Point* point) const; | 103 void ConvertPointFromDIPToNativeScreen(gfx::Point* point) const; |
| 104 | 104 |
| 105 // Converts |point| from native screen coordinate system to the root window's. | 105 // Converts |point| from native screen coordinate system to the root window's. |
| 106 void ConvertPointFromNativeScreen(gfx::Point* point) const; | 106 void ConvertPointFromNativeScreenToDIP(gfx::Point* point) const; |
| 107 | 107 |
| 108 // Converts |point| from the root window's coordinate system to the | 108 // Converts |point| from the root window's coordinate system to the |
| 109 // host window's. | 109 // host window's. |
| 110 void ConvertPointToHost(gfx::Point* point) const; | 110 void ConvertPointFromDIPToHost(gfx::Point* point) const; |
| 111 | 111 |
| 112 // Converts |point| from the host window's coordinate system to the | 112 // Converts |point| from the host window's coordinate system to the |
| 113 // root window's. | 113 // root window's. |
| 114 void ConvertPointFromHost(gfx::Point* point) const; | 114 void ConvertPointFromHostToDIP(gfx::Point* point) const; |
| 115 | 115 |
| 116 // Cursor. | 116 // Cursor. |
| 117 // Sets the currently-displayed cursor. If the cursor was previously hidden | 117 // Sets the currently-displayed cursor. If the cursor was previously hidden |
| 118 // via ShowCursor(false), it will remain hidden until ShowCursor(true) is | 118 // via ShowCursor(false), it will remain hidden until ShowCursor(true) is |
| 119 // called, at which point the cursor that was last set via SetCursor() will be | 119 // called, at which point the cursor that was last set via SetCursor() will be |
| 120 // used. | 120 // used. |
| 121 void SetCursor(gfx::NativeCursor cursor); | 121 void SetCursor(gfx::NativeCursor cursor); |
| 122 | 122 |
| 123 // Invoked when the cursor's visibility has changed. | 123 // Invoked when the cursor's visibility has changed. |
| 124 void OnCursorVisibilityChanged(bool visible); | 124 void OnCursorVisibilityChanged(bool visible); |
| 125 | 125 |
| 126 // Moves the cursor to the specified location relative to the root window. | 126 // Moves the cursor to the specified location relative to the root window. |
| 127 void MoveCursorTo(const gfx::Point& location); | 127 void MoveCursorToLocationInDIP(const gfx::Point& location_in_dip); |
| 128 | 128 |
| 129 // Moves the cursor to the |host_location| given in host coordinates. | 129 // Moves the cursor to the |host_location| given in host coordinates. |
| 130 void MoveCursorToHostLocation(const gfx::Point& host_location); | 130 void MoveCursorToHostLocationInPixel( |
|
sky
2016/11/23 23:04:48
You are patch uses Pixels. Please be consistent. P
riajiang
2016/11/23 23:16:44
I was using pixel/pixels based on if the noun is s
| |
| 131 const gfx::Point& host_location_in_pixel); | |
| 131 | 132 |
| 132 gfx::NativeCursor last_cursor() const { return last_cursor_; } | 133 gfx::NativeCursor last_cursor() const { return last_cursor_; } |
| 133 | 134 |
| 134 // Gets the InputMethod instance, if NULL, creates & owns it. | 135 // Gets the InputMethod instance, if NULL, creates & owns it. |
| 135 ui::InputMethod* GetInputMethod(); | 136 ui::InputMethod* GetInputMethod(); |
| 136 | 137 |
| 137 // Sets a shared unowned InputMethod. This is used when there is a singleton | 138 // Sets a shared unowned InputMethod. This is used when there is a singleton |
| 138 // InputMethod shared between multiple WindowTreeHost instances. | 139 // InputMethod shared between multiple WindowTreeHost instances. |
| 139 // | 140 // |
| 140 // This is used for Ash only. There are 2 reasons: | 141 // This is used for Ash only. There are 2 reasons: |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 WindowTreeHost(); | 189 WindowTreeHost(); |
| 189 explicit WindowTreeHost(std::unique_ptr<WindowPort> window_port); | 190 explicit WindowTreeHost(std::unique_ptr<WindowPort> window_port); |
| 190 | 191 |
| 191 void DestroyCompositor(); | 192 void DestroyCompositor(); |
| 192 void DestroyDispatcher(); | 193 void DestroyDispatcher(); |
| 193 | 194 |
| 194 void CreateCompositor(); | 195 void CreateCompositor(); |
| 195 void OnAcceleratedWidgetAvailable(); | 196 void OnAcceleratedWidgetAvailable(); |
| 196 | 197 |
| 197 // Returns the location of the RootWindow on native screen. | 198 // Returns the location of the RootWindow on native screen. |
| 198 virtual gfx::Point GetLocationOnNativeScreen() const = 0; | 199 virtual gfx::Point GetLocationOnNativeScreenInPixel() const = 0; |
| 199 | 200 |
| 200 void OnHostMoved(const gfx::Point& new_location); | 201 void OnHostMovedInPixel(const gfx::Point& new_location_in_pixel); |
| 201 void OnHostResized(const gfx::Size& new_size); | 202 void OnHostResizedInPixel(const gfx::Size& new_size_in_pixel); |
| 202 void OnHostWorkspaceChanged(); | 203 void OnHostWorkspaceChanged(); |
| 203 void OnHostCloseRequested(); | 204 void OnHostCloseRequested(); |
| 204 void OnHostActivated(); | 205 void OnHostActivated(); |
| 205 void OnHostLostWindowCapture(); | 206 void OnHostLostWindowCapture(); |
| 206 | 207 |
| 207 // Sets the currently displayed cursor. | 208 // Sets the currently displayed cursor. |
| 208 virtual void SetCursorNative(gfx::NativeCursor cursor) = 0; | 209 virtual void SetCursorNative(gfx::NativeCursor cursor) = 0; |
| 209 | 210 |
| 210 // Moves the cursor to the specified location relative to the root window. | 211 // Moves the cursor to the specified location relative to the root window. |
| 211 virtual void MoveCursorToNative(const gfx::Point& location) = 0; | 212 virtual void MoveCursorToNativeInPixel( |
| 213 const gfx::Point& location_in_pixel) = 0; | |
| 212 | 214 |
| 213 // kCalled when the cursor visibility has changed. | 215 // kCalled when the cursor visibility has changed. |
| 214 virtual void OnCursorVisibilityChangedNative(bool show) = 0; | 216 virtual void OnCursorVisibilityChangedNative(bool show) = 0; |
| 215 | 217 |
| 216 // Shows the WindowTreeHost. | 218 // Shows the WindowTreeHost. |
| 217 virtual void ShowImpl() = 0; | 219 virtual void ShowImpl() = 0; |
| 218 | 220 |
| 219 // Hides the WindowTreeHost. | 221 // Hides the WindowTreeHost. |
| 220 virtual void HideImpl() = 0; | 222 virtual void HideImpl() = 0; |
| 221 | 223 |
| 222 virtual gfx::ICCProfile GetICCProfileForCurrentDisplay(); | 224 virtual gfx::ICCProfile GetICCProfileForCurrentDisplay(); |
| 223 | 225 |
| 224 // Overridden from ui::EventSource: | 226 // Overridden from ui::EventSource: |
| 225 ui::EventProcessor* GetEventProcessor() override; | 227 ui::EventProcessor* GetEventProcessor() override; |
| 226 | 228 |
| 227 private: | 229 private: |
| 228 friend class test::WindowTreeHostTestApi; | 230 friend class test::WindowTreeHostTestApi; |
| 229 | 231 |
| 230 // Moves the cursor to the specified location. This method is internally used | 232 // Moves the cursor to the specified location. This method is internally used |
| 231 // by MoveCursorTo() and MoveCursorToHostLocation(). | 233 // by MoveCursorToLocationInDIP() and MoveCursorToHostLocationInPixel(). |
| 232 void MoveCursorToInternal(const gfx::Point& root_location, | 234 void MoveCursorToInternal(const gfx::Point& root_location, |
| 233 const gfx::Point& host_location); | 235 const gfx::Point& host_location); |
| 234 | 236 |
| 235 // We don't use a std::unique_ptr for |window_| since we need this ptr to be | 237 // We don't use a std::unique_ptr for |window_| since we need this ptr to be |
| 236 // valid during its deletion. (Window's dtor notifies observers that may | 238 // valid during its deletion. (Window's dtor notifies observers that may |
| 237 // attempt to reach back up to access this object which will be valid until | 239 // attempt to reach back up to access this object which will be valid until |
| 238 // the end of the dtor). | 240 // the end of the dtor). |
| 239 Window* window_; // Owning. | 241 Window* window_; // Owning. |
| 240 | 242 |
| 241 base::ObserverList<WindowTreeHostObserver> observers_; | 243 base::ObserverList<WindowTreeHostObserver> observers_; |
| 242 | 244 |
| 243 std::unique_ptr<WindowEventDispatcher> dispatcher_; | 245 std::unique_ptr<WindowEventDispatcher> dispatcher_; |
| 244 | 246 |
| 245 std::unique_ptr<ui::Compositor> compositor_; | 247 std::unique_ptr<ui::Compositor> compositor_; |
| 246 | 248 |
| 247 // Last cursor set. Used for testing. | 249 // Last cursor set. Used for testing. |
| 248 gfx::NativeCursor last_cursor_; | 250 gfx::NativeCursor last_cursor_; |
| 249 gfx::Point last_cursor_request_position_in_host_; | 251 gfx::Point last_cursor_request_position_in_host_; |
| 250 | 252 |
| 251 std::unique_ptr<ui::ViewProp> prop_; | 253 std::unique_ptr<ui::ViewProp> prop_; |
| 252 | 254 |
| 253 // The InputMethod instance used to process key events. | 255 // The InputMethod instance used to process key events. |
| 254 // If owned it, it is created in GetInputMethod() method; | 256 // If owned it, it is created in GetInputMethod() method; |
| 255 // If not owned it, it is passed in through SetSharedInputMethod() method. | 257 // If not owned it, it is passed in through SetSharedInputMethod() method. |
| 256 ui::InputMethod* input_method_; | 258 ui::InputMethod* input_method_; |
| 257 | 259 |
| 258 // Whether the InputMethod instance is owned by this WindowTreeHost. | 260 // Whether the InputMethod instance is owned by this WindowTreeHost. |
| 259 bool owned_input_method_; | 261 bool owned_input_method_; |
| 260 | 262 |
| 261 gfx::Insets output_surface_padding_; | 263 gfx::Insets output_surface_padding_in_pixel_; |
| 262 | 264 |
| 263 DISALLOW_COPY_AND_ASSIGN(WindowTreeHost); | 265 DISALLOW_COPY_AND_ASSIGN(WindowTreeHost); |
| 264 }; | 266 }; |
| 265 | 267 |
| 266 } // namespace aura | 268 } // namespace aura |
| 267 | 269 |
| 268 #endif // UI_AURA_WINDOW_TREE_HOST_H_ | 270 #endif // UI_AURA_WINDOW_TREE_HOST_H_ |
| OLD | NEW |