Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: ui/aura/window_tree_host.h

Issue 2525113002: Rename WindowTreeHost functions to indicate pixels/dips. (Closed)
Patch Set: DIP + rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/aura/window_event_dispatcher.cc ('k') | ui/aura/window_tree_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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_pixels|, that is, |window|'s origin is set to
89 // padding.top(). 89 // padding_in_pixels.left(), padding_in_pixels.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 // OnHostResizedInPixels()), but the location of window() is set to that of
94 // |padding|. 94 // |padding_in_pixels|.
95 void SetOutputSurfacePadding(const gfx::Insets& padding); 95 void SetOutputSurfacePaddingInPixels(const gfx::Insets& padding_in_pixels);
96 96
97 // Updates the root window's size using |host_size|, current 97 // Updates the root window's size using |host_size_in_pixels|, current
98 // transform and outsets. 98 // transform and outsets.
99 virtual void UpdateRootWindowSize(const gfx::Size& host_size); 99 virtual void UpdateRootWindowSizeInPixels(
100 const gfx::Size& host_size_in_pixels);
100 101
101 // Converts |point| from the root window's coordinate system to native 102 // Converts |point| from the root window's coordinate system to native
102 // screen's. 103 // screen's.
103 void ConvertPointToNativeScreen(gfx::Point* point) const; 104 void ConvertPointFromDIPToNativeScreen(gfx::Point* point) const;
sky 2016/11/26 17:09:54 I find the use of screen and host in these functio
104 105
105 // Converts |point| from native screen coordinate system to the root window's. 106 // Converts |point| from native screen coordinate system to the root window's.
106 void ConvertPointFromNativeScreen(gfx::Point* point) const; 107 void ConvertPointFromNativeScreenToDIP(gfx::Point* point) const;
107 108
108 // Converts |point| from the root window's coordinate system to the 109 // Converts |point| from the root window's coordinate system to the
109 // host window's. 110 // host window's.
110 void ConvertPointToHost(gfx::Point* point) const; 111 void ConvertPointFromDIPToHost(gfx::Point* point) const;
111 112
112 // Converts |point| from the host window's coordinate system to the 113 // Converts |point| from the host window's coordinate system to the
113 // root window's. 114 // root window's.
114 void ConvertPointFromHost(gfx::Point* point) const; 115 void ConvertPointFromHostToDIP(gfx::Point* point) const;
115 116
116 // Cursor. 117 // Cursor.
117 // Sets the currently-displayed cursor. If the cursor was previously hidden 118 // Sets the currently-displayed cursor. If the cursor was previously hidden
118 // via ShowCursor(false), it will remain hidden until ShowCursor(true) is 119 // 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 120 // called, at which point the cursor that was last set via SetCursor() will be
120 // used. 121 // used.
121 void SetCursor(gfx::NativeCursor cursor); 122 void SetCursor(gfx::NativeCursor cursor);
122 123
123 // Invoked when the cursor's visibility has changed. 124 // Invoked when the cursor's visibility has changed.
124 void OnCursorVisibilityChanged(bool visible); 125 void OnCursorVisibilityChanged(bool visible);
125 126
126 // Moves the cursor to the specified location relative to the root window. 127 // Moves the cursor to the specified location relative to the root window.
127 void MoveCursorTo(const gfx::Point& location); 128 void MoveCursorToLocationInDIP(const gfx::Point& location_in_dip);
128 129
129 // Moves the cursor to the |host_location| given in host coordinates. 130 // Moves the cursor to the |host_location| given in host coordinates.
130 void MoveCursorToHostLocation(const gfx::Point& host_location); 131 void MoveCursorToHostLocationInPixels(
sky 2016/11/26 17:09:54 Similarly here remove host, just MoveCursorToLocat
132 const gfx::Point& host_location_in_pixels);
131 133
132 gfx::NativeCursor last_cursor() const { return last_cursor_; } 134 gfx::NativeCursor last_cursor() const { return last_cursor_; }
133 135
134 // Gets the InputMethod instance, if NULL, creates & owns it. 136 // Gets the InputMethod instance, if NULL, creates & owns it.
135 ui::InputMethod* GetInputMethod(); 137 ui::InputMethod* GetInputMethod();
136 138
137 // Sets a shared unowned InputMethod. This is used when there is a singleton 139 // Sets a shared unowned InputMethod. This is used when there is a singleton
138 // InputMethod shared between multiple WindowTreeHost instances. 140 // InputMethod shared between multiple WindowTreeHost instances.
139 // 141 //
140 // This is used for Ash only. There are 2 reasons: 142 // This is used for Ash only. There are 2 reasons:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 WindowTreeHost(); 190 WindowTreeHost();
189 explicit WindowTreeHost(std::unique_ptr<WindowPort> window_port); 191 explicit WindowTreeHost(std::unique_ptr<WindowPort> window_port);
190 192
191 void DestroyCompositor(); 193 void DestroyCompositor();
192 void DestroyDispatcher(); 194 void DestroyDispatcher();
193 195
194 void CreateCompositor(); 196 void CreateCompositor();
195 void OnAcceleratedWidgetAvailable(); 197 void OnAcceleratedWidgetAvailable();
196 198
197 // Returns the location of the RootWindow on native screen. 199 // Returns the location of the RootWindow on native screen.
198 virtual gfx::Point GetLocationOnNativeScreen() const = 0; 200 virtual gfx::Point GetLocationOnNativeScreenInPixels() const = 0;
199 201
200 void OnHostMoved(const gfx::Point& new_location); 202 void OnHostMovedInPixels(const gfx::Point& new_location_in_pixels);
201 void OnHostResized(const gfx::Size& new_size); 203 void OnHostResizedInPixels(const gfx::Size& new_size_in_pixels);
202 void OnHostWorkspaceChanged(); 204 void OnHostWorkspaceChanged();
203 void OnHostCloseRequested(); 205 void OnHostCloseRequested();
204 void OnHostActivated(); 206 void OnHostActivated();
205 void OnHostLostWindowCapture(); 207 void OnHostLostWindowCapture();
206 208
207 // Sets the currently displayed cursor. 209 // Sets the currently displayed cursor.
208 virtual void SetCursorNative(gfx::NativeCursor cursor) = 0; 210 virtual void SetCursorNative(gfx::NativeCursor cursor) = 0;
209 211
210 // Moves the cursor to the specified location relative to the root window. 212 // Moves the cursor to the specified location relative to the root window.
211 virtual void MoveCursorToNative(const gfx::Point& location) = 0; 213 virtual void MoveCursorToNativeInPixels(
sky 2016/11/26 17:09:54 MoveCursorToScreenLocationInPixels?
214 const gfx::Point& location_in_pixels) = 0;
212 215
213 // kCalled when the cursor visibility has changed. 216 // kCalled when the cursor visibility has changed.
214 virtual void OnCursorVisibilityChangedNative(bool show) = 0; 217 virtual void OnCursorVisibilityChangedNative(bool show) = 0;
215 218
216 // Shows the WindowTreeHost. 219 // Shows the WindowTreeHost.
217 virtual void ShowImpl() = 0; 220 virtual void ShowImpl() = 0;
218 221
219 // Hides the WindowTreeHost. 222 // Hides the WindowTreeHost.
220 virtual void HideImpl() = 0; 223 virtual void HideImpl() = 0;
221 224
222 virtual gfx::ICCProfile GetICCProfileForCurrentDisplay(); 225 virtual gfx::ICCProfile GetICCProfileForCurrentDisplay();
223 226
224 // Overridden from ui::EventSource: 227 // Overridden from ui::EventSource:
225 ui::EventProcessor* GetEventProcessor() override; 228 ui::EventProcessor* GetEventProcessor() override;
226 229
227 private: 230 private:
228 friend class test::WindowTreeHostTestApi; 231 friend class test::WindowTreeHostTestApi;
229 232
230 // Moves the cursor to the specified location. This method is internally used 233 // Moves the cursor to the specified location. This method is internally used
231 // by MoveCursorTo() and MoveCursorToHostLocation(). 234 // by MoveCursorToLocationInDIP() and MoveCursorToHostLocationInPixels().
232 void MoveCursorToInternal(const gfx::Point& root_location, 235 void MoveCursorToInternal(const gfx::Point& root_location,
233 const gfx::Point& host_location); 236 const gfx::Point& host_location);
234 237
235 // We don't use a std::unique_ptr for |window_| since we need this ptr to be 238 // 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 239 // 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 240 // attempt to reach back up to access this object which will be valid until
238 // the end of the dtor). 241 // the end of the dtor).
239 Window* window_; // Owning. 242 Window* window_; // Owning.
240 243
241 base::ObserverList<WindowTreeHostObserver> observers_; 244 base::ObserverList<WindowTreeHostObserver> observers_;
242 245
243 std::unique_ptr<WindowEventDispatcher> dispatcher_; 246 std::unique_ptr<WindowEventDispatcher> dispatcher_;
244 247
245 std::unique_ptr<ui::Compositor> compositor_; 248 std::unique_ptr<ui::Compositor> compositor_;
246 249
247 // Last cursor set. Used for testing. 250 // Last cursor set. Used for testing.
248 gfx::NativeCursor last_cursor_; 251 gfx::NativeCursor last_cursor_;
249 gfx::Point last_cursor_request_position_in_host_; 252 gfx::Point last_cursor_request_position_in_host_;
250 253
251 std::unique_ptr<ui::ViewProp> prop_; 254 std::unique_ptr<ui::ViewProp> prop_;
252 255
253 // The InputMethod instance used to process key events. 256 // The InputMethod instance used to process key events.
254 // If owned it, it is created in GetInputMethod() method; 257 // If owned it, it is created in GetInputMethod() method;
255 // If not owned it, it is passed in through SetSharedInputMethod() method. 258 // If not owned it, it is passed in through SetSharedInputMethod() method.
256 ui::InputMethod* input_method_; 259 ui::InputMethod* input_method_;
257 260
258 // Whether the InputMethod instance is owned by this WindowTreeHost. 261 // Whether the InputMethod instance is owned by this WindowTreeHost.
259 bool owned_input_method_; 262 bool owned_input_method_;
260 263
261 gfx::Insets output_surface_padding_; 264 gfx::Insets output_surface_padding_in_pixels_;
262 265
263 DISALLOW_COPY_AND_ASSIGN(WindowTreeHost); 266 DISALLOW_COPY_AND_ASSIGN(WindowTreeHost);
264 }; 267 };
265 268
266 } // namespace aura 269 } // namespace aura
267 270
268 #endif // UI_AURA_WINDOW_TREE_HOST_H_ 271 #endif // UI_AURA_WINDOW_TREE_HOST_H_
OLDNEW
« no previous file with comments | « ui/aura/window_event_dispatcher.cc ('k') | ui/aura/window_tree_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698