OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ | 5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ |
6 #define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ | 6 #define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 173 |
174 // Returns the current location of the mouse on screen. Note: this method may | 174 // Returns the current location of the mouse on screen. Note: this method may |
175 // race the asynchronous initialization; but in that case we return (0, 0). | 175 // race the asynchronous initialization; but in that case we return (0, 0). |
176 gfx::Point GetCursorScreenPoint(); | 176 gfx::Point GetCursorScreenPoint(); |
177 | 177 |
178 // See description in window_tree.mojom. When an existing event observer is | 178 // See description in window_tree.mojom. When an existing event observer is |
179 // updated or cleared then any future events from the server for that observer | 179 // updated or cleared then any future events from the server for that observer |
180 // will be ignored. | 180 // will be ignored. |
181 void SetEventObserver(mojom::EventMatcherPtr matcher); | 181 void SetEventObserver(mojom::EventMatcherPtr matcher); |
182 | 182 |
| 183 // Performs a window move. This call blocks but spins up a nested message |
| 184 // loop to handle incoming move messages. |
| 185 bool PerformWindowMove(Window* window, const gfx::Point& cursor_location); |
| 186 |
| 187 // Cancels a in progress window move. (If no window is currently being moved, |
| 188 // does nothing.) |
| 189 void CancelWindowMove(Window* window); |
| 190 |
183 // Creates and returns a new Window (which is owned by the window server). | 191 // Creates and returns a new Window (which is owned by the window server). |
184 // Windows are initially hidden, use SetVisible(true) to show. | 192 // Windows are initially hidden, use SetVisible(true) to show. |
185 Window* NewWindow() { return NewWindow(nullptr); } | 193 Window* NewWindow() { return NewWindow(nullptr); } |
186 Window* NewWindow( | 194 Window* NewWindow( |
187 const std::map<std::string, std::vector<uint8_t>>* properties); | 195 const std::map<std::string, std::vector<uint8_t>>* properties); |
188 Window* NewTopLevelWindow( | 196 Window* NewTopLevelWindow( |
189 const std::map<std::string, std::vector<uint8_t>>* properties); | 197 const std::map<std::string, std::vector<uint8_t>>* properties); |
190 | 198 |
191 void AddObserver(WindowTreeClientObserver* observer); | 199 void AddObserver(WindowTreeClientObserver* observer); |
192 void RemoveObserver(WindowTreeClientObserver* observer); | 200 void RemoveObserver(WindowTreeClientObserver* observer); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 void OnWindowInputEvent(uint32_t event_id, | 300 void OnWindowInputEvent(uint32_t event_id, |
293 Id window_id, | 301 Id window_id, |
294 std::unique_ptr<ui::Event> event, | 302 std::unique_ptr<ui::Event> event, |
295 uint32_t event_observer_id) override; | 303 uint32_t event_observer_id) override; |
296 void OnEventObserved(std::unique_ptr<ui::Event> event, | 304 void OnEventObserved(std::unique_ptr<ui::Event> event, |
297 uint32_t event_observer_id) override; | 305 uint32_t event_observer_id) override; |
298 void OnWindowFocused(Id focused_window_id) override; | 306 void OnWindowFocused(Id focused_window_id) override; |
299 void OnWindowPredefinedCursorChanged(Id window_id, | 307 void OnWindowPredefinedCursorChanged(Id window_id, |
300 mojom::Cursor cursor) override; | 308 mojom::Cursor cursor) override; |
301 void OnChangeCompleted(uint32_t change_id, bool success) override; | 309 void OnChangeCompleted(uint32_t change_id, bool success) override; |
| 310 void OnMoveLoopCompleted(uint32_t change_id, bool success) override; |
302 void RequestClose(uint32_t window_id) override; | 311 void RequestClose(uint32_t window_id) override; |
303 void GetWindowManager( | 312 void GetWindowManager( |
304 mojo::AssociatedInterfaceRequest<WindowManager> internal) override; | 313 mojo::AssociatedInterfaceRequest<WindowManager> internal) override; |
305 | 314 |
306 // Overridden from WindowManager: | 315 // Overridden from WindowManager: |
307 void OnConnect(ClientSpecificId client_id) override; | 316 void OnConnect(ClientSpecificId client_id) override; |
308 void WmNewDisplayAdded(mojom::DisplayPtr display, | 317 void WmNewDisplayAdded(mojom::DisplayPtr display, |
309 mojom::WindowDataPtr root_data, | 318 mojom::WindowDataPtr root_data, |
310 bool parent_drawn) override; | 319 bool parent_drawn) override; |
311 void WmSetBounds(uint32_t change_id, | 320 void WmSetBounds(uint32_t change_id, |
312 Id window_id, | 321 Id window_id, |
313 const gfx::Rect& transit_bounds) override; | 322 const gfx::Rect& transit_bounds) override; |
314 void WmSetProperty(uint32_t change_id, | 323 void WmSetProperty(uint32_t change_id, |
315 Id window_id, | 324 Id window_id, |
316 const mojo::String& name, | 325 const mojo::String& name, |
317 mojo::Array<uint8_t> transit_data) override; | 326 mojo::Array<uint8_t> transit_data) override; |
318 void WmCreateTopLevelWindow(uint32_t change_id, | 327 void WmCreateTopLevelWindow(uint32_t change_id, |
319 ClientSpecificId requesting_client_id, | 328 ClientSpecificId requesting_client_id, |
320 mojo::Map<mojo::String, mojo::Array<uint8_t>> | 329 mojo::Map<mojo::String, mojo::Array<uint8_t>> |
321 transport_properties) override; | 330 transport_properties) override; |
322 void WmClientJankinessChanged(ClientSpecificId client_id, | 331 void WmClientJankinessChanged(ClientSpecificId client_id, |
323 bool janky) override; | 332 bool janky) override; |
| 333 void WmPerformMoveLoop(uint32_t change_id, |
| 334 Id window_id, |
| 335 const gfx::Point& cursor_location) override; |
| 336 void WmCancelMoveLoop(uint32_t window_id) override; |
324 void OnAccelerator(uint32_t id, std::unique_ptr<ui::Event> event) override; | 337 void OnAccelerator(uint32_t id, std::unique_ptr<ui::Event> event) override; |
325 | 338 |
326 // Overridden from WindowManagerClient: | 339 // Overridden from WindowManagerClient: |
327 void SetFrameDecorationValues( | 340 void SetFrameDecorationValues( |
328 mojom::FrameDecorationValuesPtr values) override; | 341 mojom::FrameDecorationValuesPtr values) override; |
329 void SetNonClientCursor(Window* window, | 342 void SetNonClientCursor(Window* window, |
330 mus::mojom::Cursor cursor_id) override; | 343 mus::mojom::Cursor cursor_id) override; |
331 void AddAccelerator(uint32_t id, | 344 void AddAccelerator(uint32_t id, |
332 mojom::EventMatcherPtr event_matcher, | 345 mojom::EventMatcherPtr event_matcher, |
333 const base::Callback<void(bool)>& callback) override; | 346 const base::Callback<void(bool)>& callback) override; |
334 void RemoveAccelerator(uint32_t id) override; | 347 void RemoveAccelerator(uint32_t id) override; |
335 void AddActivationParent(Window* window) override; | 348 void AddActivationParent(Window* window) override; |
336 void RemoveActivationParent(Window* window) override; | 349 void RemoveActivationParent(Window* window) override; |
337 void ActivateNextWindow() override; | 350 void ActivateNextWindow() override; |
338 void SetUnderlaySurfaceOffsetAndExtendedHitArea( | 351 void SetUnderlaySurfaceOffsetAndExtendedHitArea( |
339 Window* window, | 352 Window* window, |
340 const gfx::Vector2d& offset, | 353 const gfx::Vector2d& offset, |
341 const gfx::Insets& hit_area) override; | 354 const gfx::Insets& hit_area) override; |
| 355 void OnWmMoveLoopCompleted(uint32_t change_id, |
| 356 uint32_t window_id, |
| 357 bool completed) override; |
342 | 358 |
343 // The one int in |cursor_location_mapping_|. When we read from this | 359 // The one int in |cursor_location_mapping_|. When we read from this |
344 // location, we must always read from it atomically. | 360 // location, we must always read from it atomically. |
345 base::subtle::Atomic32* cursor_location_memory() { | 361 base::subtle::Atomic32* cursor_location_memory() { |
346 return reinterpret_cast<base::subtle::Atomic32*>( | 362 return reinterpret_cast<base::subtle::Atomic32*>( |
347 cursor_location_mapping_.get()); | 363 cursor_location_mapping_.get()); |
348 } | 364 } |
349 | 365 |
350 // This is set once and only once when we get OnEmbed(). It gives the unique | 366 // This is set once and only once when we get OnEmbed(). It gives the unique |
351 // id for this client. | 367 // id for this client. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 | 405 |
390 std::unique_ptr<mojo::AssociatedBinding<mojom::WindowManager>> | 406 std::unique_ptr<mojo::AssociatedBinding<mojom::WindowManager>> |
391 window_manager_internal_; | 407 window_manager_internal_; |
392 mojom::WindowManagerClientAssociatedPtr window_manager_internal_client_; | 408 mojom::WindowManagerClientAssociatedPtr window_manager_internal_client_; |
393 | 409 |
394 bool has_event_observer_ = false; | 410 bool has_event_observer_ = false; |
395 | 411 |
396 // Monotonically increasing ID for event observers. | 412 // Monotonically increasing ID for event observers. |
397 uint32_t event_observer_id_ = 0u; | 413 uint32_t event_observer_id_ = 0u; |
398 | 414 |
| 415 // We spin up a nested message loop to handle interactive window moves; this |
| 416 // is the return value and the Closure to call to complete the loop. |
| 417 bool current_move_succeeded_ = false; |
| 418 base::Closure on_current_move_finished_; |
| 419 |
399 base::WeakPtrFactory<WindowTreeClient> weak_factory_; | 420 base::WeakPtrFactory<WindowTreeClient> weak_factory_; |
400 | 421 |
401 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient); | 422 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient); |
402 }; | 423 }; |
403 | 424 |
404 } // namespace mus | 425 } // namespace mus |
405 | 426 |
406 #endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ | 427 #endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ |
OLD | NEW |