Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_EXO_SHELL_SURFACE_H_ | 5 #ifndef COMPONENTS_EXO_SHELL_SURFACE_H_ |
| 6 #define COMPONENTS_EXO_SHELL_SURFACE_H_ | 6 #define COMPONENTS_EXO_SHELL_SURFACE_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 // metadata like title and class, etc. | 40 // metadata like title and class, etc. |
| 41 class ShellSurface : public SurfaceDelegate, | 41 class ShellSurface : public SurfaceDelegate, |
| 42 public SurfaceObserver, | 42 public SurfaceObserver, |
| 43 public views::WidgetDelegate, | 43 public views::WidgetDelegate, |
| 44 public views::View, | 44 public views::View, |
| 45 public ash::wm::WindowStateObserver, | 45 public ash::wm::WindowStateObserver, |
| 46 public aura::WindowObserver, | 46 public aura::WindowObserver, |
| 47 public WMHelper::ActivationObserver, | 47 public WMHelper::ActivationObserver, |
| 48 public WMHelper::AccessibilityObserver { | 48 public WMHelper::AccessibilityObserver { |
| 49 public: | 49 public: |
| 50 enum class BoundsMode { SHELL, CLIENT, FIXED }; | |
|
reveman
2017/02/08 22:04:43
Can you start by pulling out the origin and Bounds
Dominik Laskowski
2017/02/09 03:01:35
Done.
| |
| 51 | |
| 52 // The |origin| is in screen coordinates. When bounds are controlled by the | |
| 53 // shell or fixed, it determines the initial position of the shell surface. | |
| 54 // In that case, the position specified as part of the geometry is relative | |
| 55 // to the shell surface. | |
| 56 // | |
| 57 // When bounds are controlled by the client, it represents the origin of a | |
| 58 // coordinate system to which the position of the shell surface, specified | |
| 59 // as part of the geometry, is relative. The client must acknowledge changes | |
| 60 // to the origin, and offset the geometry accordingly. | |
| 50 ShellSurface(Surface* surface, | 61 ShellSurface(Surface* surface, |
| 51 ShellSurface* parent, | 62 ShellSurface* parent, |
| 52 const gfx::Rect& initial_bounds, | 63 BoundsMode bounds_mode, |
| 64 const gfx::Point& origin, | |
| 53 bool activatable, | 65 bool activatable, |
| 54 bool can_minimize, | 66 bool can_minimize, |
| 55 int container); | 67 int container); |
| 56 explicit ShellSurface(Surface* surface); | 68 explicit ShellSurface(Surface* surface); |
| 57 ~ShellSurface() override; | 69 ~ShellSurface() override; |
| 58 | 70 |
| 59 // Set the callback to run when the user wants the shell surface to be closed. | 71 // Set the callback to run when the user wants the shell surface to be closed. |
| 60 // The receiver can chose to not close the window on this signal. | 72 // The receiver can chose to not close the window on this signal. |
| 61 void set_close_callback(const base::Closure& close_callback) { | 73 void set_close_callback(const base::Closure& close_callback) { |
| 62 close_callback_ = close_callback; | 74 close_callback_ = close_callback; |
| 63 } | 75 } |
| 64 | 76 |
| 77 // Set the callback to run when the shell surface is destroyed. | |
| 78 void set_destroyed_callback(const base::Closure& destroyed_callback) { | |
| 79 destroyed_callback_ = destroyed_callback; | |
| 80 } | |
| 81 | |
| 65 // Set the callback to run when the surface is destroyed. | 82 // Set the callback to run when the surface is destroyed. |
| 66 void set_surface_destroyed_callback( | 83 void set_surface_destroyed_callback( |
| 67 const base::Closure& surface_destroyed_callback) { | 84 const base::Closure& surface_destroyed_callback) { |
| 68 surface_destroyed_callback_ = surface_destroyed_callback; | 85 surface_destroyed_callback_ = surface_destroyed_callback; |
| 69 } | 86 } |
| 70 | 87 |
| 71 // Set the callback to run when the surface state changed. | 88 // Set the callback to run when the surface state changed. |
| 72 using StateChangedCallback = | 89 using StateChangedCallback = |
| 73 base::Callback<void(ash::wm::WindowStateType old_state_type, | 90 base::Callback<void(ash::wm::WindowStateType old_state_type, |
| 74 ash::wm::WindowStateType new_state_type)>; | 91 ash::wm::WindowStateType new_state_type)>; |
| 75 void set_state_changed_callback( | 92 void set_state_changed_callback( |
| 76 const StateChangedCallback& state_changed_callback) { | 93 const StateChangedCallback& state_changed_callback) { |
| 77 state_changed_callback_ = state_changed_callback; | 94 state_changed_callback_ = state_changed_callback; |
| 78 } | 95 } |
| 79 | 96 |
| 80 // Set the callback to run when the client is asked to configure the surface. | 97 // Set the callback to run when the client is asked to configure the surface. |
| 81 // The size is a hint, in the sense that the client is free to ignore it if | 98 // The size is a hint, in the sense that the client is free to ignore it if |
| 82 // it doesn't resize, pick a smaller size (to satisfy aspect ratio or resize | 99 // it doesn't resize, pick a smaller size (to satisfy aspect ratio or resize |
| 83 // in steps of NxM pixels). | 100 // in steps of NxM pixels). |
| 84 using ConfigureCallback = | 101 using ConfigureCallback = |
| 85 base::Callback<uint32_t(const gfx::Size& size, | 102 base::Callback<uint32_t(const gfx::Size& size, |
| 86 ash::wm::WindowStateType state_type, | 103 ash::wm::WindowStateType state_type, |
| 87 bool resizing, | 104 bool resizing, |
| 88 bool activated)>; | 105 bool activated, |
| 106 const gfx::Point& origin)>; | |
| 89 void set_configure_callback(const ConfigureCallback& configure_callback) { | 107 void set_configure_callback(const ConfigureCallback& configure_callback) { |
| 90 configure_callback_ = configure_callback; | 108 configure_callback_ = configure_callback; |
| 91 } | 109 } |
| 92 | 110 |
| 93 // When the client is asked to configure the surface, it should acknowledge | 111 // When the client is asked to configure the surface, it should acknowledge |
| 94 // the configure request sometime before the commit. |serial| is the serial | 112 // the configure request sometime before the commit. |serial| is the serial |
| 95 // from the configure callback. | 113 // from the configure callback. |
| 96 void AcknowledgeConfigure(uint32_t serial); | 114 void AcknowledgeConfigure(uint32_t serial); |
| 97 | 115 |
| 98 // Set the "parent" of this surface. This window should be stacked above a | 116 // Set the "parent" of this surface. This window should be stacked above a |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 // of the widget (e.g. maximized). | 282 // of the widget (e.g. maximized). |
| 265 void CreateShellSurfaceWidget(ui::WindowShowState show_state); | 283 void CreateShellSurfaceWidget(ui::WindowShowState show_state); |
| 266 | 284 |
| 267 // Asks the client to configure its surface. | 285 // Asks the client to configure its surface. |
| 268 void Configure(); | 286 void Configure(); |
| 269 | 287 |
| 270 // Attempt to start a drag operation. The type of drag operation to start is | 288 // Attempt to start a drag operation. The type of drag operation to start is |
| 271 // determined by |component|. | 289 // determined by |component|. |
| 272 void AttemptToStartDrag(int component); | 290 void AttemptToStartDrag(int component); |
| 273 | 291 |
| 292 // Attempt to start a client-driven drag operation. | |
| 293 void AttemptToStartClientDrag(); | |
| 294 | |
| 274 // End current drag operation. | 295 // End current drag operation. |
| 275 void EndDrag(bool revert); | 296 void EndDrag(bool revert); |
| 297 void EndDrag(aura::Window* window, bool revert); | |
| 276 | 298 |
| 277 // Returns true if surface is currently being resized. | 299 // Returns true if surface is currently being resized. |
| 278 bool IsResizing() const; | 300 bool IsResizing() const; |
| 279 | 301 |
| 280 // Returns the "visible bounds" for the surface from the user's perspective. | 302 // Returns the "visible bounds" for the surface from the user's perspective. |
| 281 gfx::Rect GetVisibleBounds() const; | 303 gfx::Rect GetVisibleBounds() const; |
| 282 | 304 |
| 283 // Returns the origin for the surface taking visible bounds and current | 305 // Returns the origin for the surface taking visible bounds and current |
| 284 // resize direction into account. | 306 // resize direction into account. |
| 285 gfx::Point GetSurfaceOrigin() const; | 307 gfx::Point GetSurfaceOrigin() const; |
| 286 | 308 |
| 287 // Updates the bounds of widget to match the current surface bounds. | 309 // Updates the bounds of widget to match the current surface bounds. |
| 288 void UpdateWidgetBounds(); | 310 void UpdateWidgetBounds(); |
| 289 | 311 |
| 312 // Updates the bounds of surface to match the current widget bounds. | |
| 313 void UpdateSurfaceBounds(); | |
| 314 | |
| 290 // Creates, deletes and update the shadow bounds based on | 315 // Creates, deletes and update the shadow bounds based on |
| 291 // |pending_shadow_content_bounds_|. | 316 // |pending_shadow_content_bounds_|. |
| 292 void UpdateShadow(); | 317 void UpdateShadow(); |
| 293 | 318 |
| 319 // In the coordinate system of the parent root window. | |
| 320 gfx::Point GetMouseLocation() const; | |
| 321 | |
| 294 views::Widget* widget_ = nullptr; | 322 views::Widget* widget_ = nullptr; |
| 295 Surface* surface_; | 323 Surface* surface_; |
| 296 aura::Window* parent_; | 324 aura::Window* parent_; |
| 297 gfx::Rect initial_bounds_; | 325 const BoundsMode bounds_mode_; |
| 326 gfx::Point origin_; | |
| 298 bool activatable_ = true; | 327 bool activatable_ = true; |
| 299 const bool can_minimize_; | 328 const bool can_minimize_; |
| 300 // Container Window Id (see ash/public/cpp/shell_window_ids.h) | 329 // Container Window Id (see ash/public/cpp/shell_window_ids.h) |
| 301 int container_; | 330 int container_; |
| 302 bool frame_enabled_ = false; | 331 bool frame_enabled_ = false; |
| 303 bool shadow_enabled_ = false; | 332 bool shadow_enabled_ = false; |
| 304 bool pending_show_widget_ = false; | 333 bool pending_show_widget_ = false; |
| 305 base::string16 title_; | 334 base::string16 title_; |
| 306 std::string application_id_; | 335 std::string application_id_; |
| 307 gfx::Rect geometry_; | 336 gfx::Rect geometry_; |
| 308 gfx::Rect pending_geometry_; | 337 gfx::Rect pending_geometry_; |
| 309 double scale_ = 1.0; | 338 double scale_ = 1.0; |
| 310 double pending_scale_ = 1.0; | 339 double pending_scale_ = 1.0; |
| 311 base::Closure close_callback_; | 340 base::Closure close_callback_; |
| 341 base::Closure destroyed_callback_; | |
| 312 base::Closure surface_destroyed_callback_; | 342 base::Closure surface_destroyed_callback_; |
| 313 StateChangedCallback state_changed_callback_; | 343 StateChangedCallback state_changed_callback_; |
| 314 ConfigureCallback configure_callback_; | 344 ConfigureCallback configure_callback_; |
| 315 ScopedConfigure* scoped_configure_ = nullptr; | 345 ScopedConfigure* scoped_configure_ = nullptr; |
| 316 bool ignore_window_bounds_changes_ = false; | 346 bool ignore_window_bounds_changes_ = false; |
| 317 gfx::Point origin_; | 347 gfx::Vector2d origin_offset_; |
| 318 gfx::Vector2d pending_origin_offset_; | 348 gfx::Vector2d pending_origin_offset_; |
| 319 gfx::Vector2d pending_origin_config_offset_; | 349 gfx::Vector2d pending_origin_offset_accumulator_; |
|
reveman
2017/02/08 22:04:43
I'd like to see these member variable name changes
Dominik Laskowski
2017/02/09 03:01:35
Done.
| |
| 320 int resize_component_ = HTCAPTION; // HT constant (see ui/base/hit_test.h) | 350 int resize_component_ = HTCAPTION; // HT constant (see ui/base/hit_test.h) |
| 321 int pending_resize_component_ = HTCAPTION; | 351 int pending_resize_component_ = HTCAPTION; |
| 322 aura::Window* shadow_overlay_ = nullptr; | 352 aura::Window* shadow_overlay_ = nullptr; |
| 323 aura::Window* shadow_underlay_ = nullptr; | 353 aura::Window* shadow_underlay_ = nullptr; |
| 324 std::unique_ptr<ui::EventHandler> shadow_underlay_event_handler_; | 354 std::unique_ptr<ui::EventHandler> shadow_underlay_event_handler_; |
| 325 gfx::Rect shadow_content_bounds_; | 355 gfx::Rect shadow_content_bounds_; |
| 326 float shadow_background_opacity_ = 1.0; | 356 float shadow_background_opacity_ = 1.0; |
| 327 std::deque<Config> pending_configs_; | 357 std::deque<Config> pending_configs_; |
| 328 std::unique_ptr<ash::WindowResizer> resizer_; | 358 std::unique_ptr<ash::WindowResizer> resizer_; |
| 329 std::unique_ptr<ScopedAnimationsDisabled> scoped_animations_disabled_; | 359 std::unique_ptr<ScopedAnimationsDisabled> scoped_animations_disabled_; |
| 330 int top_inset_height_ = 0; | 360 int top_inset_height_ = 0; |
| 331 int pending_top_inset_height_ = 0; | 361 int pending_top_inset_height_ = 0; |
| 332 bool shadow_underlay_in_surface_ = true; | 362 bool shadow_underlay_in_surface_ = true; |
| 333 | 363 |
| 334 DISALLOW_COPY_AND_ASSIGN(ShellSurface); | 364 DISALLOW_COPY_AND_ASSIGN(ShellSurface); |
| 335 }; | 365 }; |
| 336 | 366 |
| 337 } // namespace exo | 367 } // namespace exo |
| 338 | 368 |
| 339 #endif // COMPONENTS_EXO_SHELL_SURFACE_H_ | 369 #endif // COMPONENTS_EXO_SHELL_SURFACE_H_ |
| OLD | NEW |