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 16 matching lines...) Expand all Loading... | |
| 27 class WindowResizer; | 27 class WindowResizer; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace base { | 30 namespace base { |
| 31 namespace trace_event { | 31 namespace trace_event { |
| 32 class TracedValue; | 32 class TracedValue; |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 namespace exo { | 36 namespace exo { |
| 37 class Display; | |
| 37 class Surface; | 38 class Surface; |
| 38 | 39 |
| 39 // This class provides functions for treating a surfaces like toplevel, | 40 // This class provides functions for treating a surfaces like toplevel, |
| 40 // fullscreen or popup widgets, move, resize or maximize them, associate | 41 // fullscreen or popup widgets, move, resize or maximize them, associate |
| 41 // metadata like title and class, etc. | 42 // metadata like title and class, etc. |
| 42 class ShellSurface : public SurfaceDelegate, | 43 class ShellSurface : public SurfaceDelegate, |
| 43 public SurfaceObserver, | 44 public SurfaceObserver, |
| 44 public views::WidgetDelegate, | 45 public views::WidgetDelegate, |
| 45 public views::View, | 46 public views::View, |
| 46 public ash::AccessibilityObserver, | 47 public ash::AccessibilityObserver, |
| 47 public ash::wm::WindowStateObserver, | 48 public ash::wm::WindowStateObserver, |
| 48 public aura::WindowObserver, | 49 public aura::WindowObserver, |
| 49 public WMHelper::ActivationObserver { | 50 public WMHelper::ActivationObserver, |
| 51 public WMHelper::ShellObserver { | |
| 50 public: | 52 public: |
| 51 ShellSurface(Surface* surface, | 53 ShellSurface(const Display& display, |
| 54 Surface* surface, | |
| 52 ShellSurface* parent, | 55 ShellSurface* parent, |
| 53 const gfx::Rect& initial_bounds, | 56 const gfx::Rect& initial_bounds, |
| 54 bool activatable, | 57 bool activatable, |
| 55 int container); | 58 int container); |
| 56 explicit ShellSurface(Surface* surface); | 59 ShellSurface(const Display& display, Surface* surface); |
| 57 ~ShellSurface() override; | 60 ~ShellSurface() override; |
| 58 | 61 |
| 59 // Set the callback to run when the user wants the shell surface to be closed. | 62 // 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. | 63 // The receiver can chose to not close the window on this signal. |
| 61 void set_close_callback(const base::Closure& close_callback) { | 64 void set_close_callback(const base::Closure& close_callback) { |
| 62 close_callback_ = close_callback; | 65 close_callback_ = close_callback; |
| 63 } | 66 } |
| 64 | 67 |
| 65 // Set the callback to run when the surface is destroyed. | 68 // Set the callback to run when the surface is destroyed. |
| 66 void set_surface_destroyed_callback( | 69 void set_surface_destroyed_callback( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 | 107 |
| 105 // Maximizes the shell surface. | 108 // Maximizes the shell surface. |
| 106 void Maximize(); | 109 void Maximize(); |
| 107 | 110 |
| 108 // Minimize the shell surface. | 111 // Minimize the shell surface. |
| 109 void Minimize(); | 112 void Minimize(); |
| 110 | 113 |
| 111 // Restore the shell surface. | 114 // Restore the shell surface. |
| 112 void Restore(); | 115 void Restore(); |
| 113 | 116 |
| 117 // Start and stop a client-driven move of the shell surface. | |
| 118 void SetMoving(); | |
| 119 void UnsetMoving(bool revert); | |
| 120 | |
| 114 // Set fullscreen state for shell surface. | 121 // Set fullscreen state for shell surface. |
| 115 void SetFullscreen(bool fullscreen); | 122 void SetFullscreen(bool fullscreen); |
| 116 | 123 |
| 117 // Pins the shell surface. |trusted| flag is ignored when |pinned| is false. | 124 // Pins the shell surface. |trusted| flag is ignored when |pinned| is false. |
| 118 void SetPinned(bool pinned, bool trusted); | 125 void SetPinned(bool pinned, bool trusted); |
| 119 | 126 |
| 120 // Set title for surface. | 127 // Set title for surface. |
| 121 void SetTitle(const base::string16& title); | 128 void SetTitle(const base::string16& title); |
| 122 | 129 |
| 123 // Sets the system modality. | 130 // Sets the system modality. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 void OnWindowBoundsChanged(aura::Window* window, | 217 void OnWindowBoundsChanged(aura::Window* window, |
| 211 const gfx::Rect& old_bounds, | 218 const gfx::Rect& old_bounds, |
| 212 const gfx::Rect& new_bounds) override; | 219 const gfx::Rect& new_bounds) override; |
| 213 void OnWindowDestroying(aura::Window* window) override; | 220 void OnWindowDestroying(aura::Window* window) override; |
| 214 | 221 |
| 215 // Overridden from WMHelper::ActivationObserver: | 222 // Overridden from WMHelper::ActivationObserver: |
| 216 void OnWindowActivated( | 223 void OnWindowActivated( |
| 217 aura::Window* gained_active, | 224 aura::Window* gained_active, |
| 218 aura::Window* lost_active) override; | 225 aura::Window* lost_active) override; |
| 219 | 226 |
| 227 // Overridden from WMHelper::ShellObserver: | |
| 228 void OnOverviewModeStarted() override; | |
| 229 void OnOverviewModeEnded() override; | |
| 230 | |
| 220 // Overridden from ui::EventHandler: | 231 // Overridden from ui::EventHandler: |
| 221 void OnKeyEvent(ui::KeyEvent* event) override; | 232 void OnKeyEvent(ui::KeyEvent* event) override; |
| 222 void OnMouseEvent(ui::MouseEvent* event) override; | 233 void OnMouseEvent(ui::MouseEvent* event) override; |
| 223 | 234 |
| 224 // Overridden from ui::AcceleratorTarget: | 235 // Overridden from ui::AcceleratorTarget: |
| 225 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 236 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 226 | 237 |
| 227 aura::Window* shadow_underlay() { return shadow_underlay_; } | 238 aura::Window* shadow_underlay() { return shadow_underlay_; } |
| 228 | 239 |
| 229 private: | 240 private: |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 244 // Asks the client to configure its surface. | 255 // Asks the client to configure its surface. |
| 245 void Configure(); | 256 void Configure(); |
| 246 | 257 |
| 247 // Attempt to start a drag operation. The type of drag operation to start is | 258 // Attempt to start a drag operation. The type of drag operation to start is |
| 248 // determined by |component|. | 259 // determined by |component|. |
| 249 void AttemptToStartDrag(int component); | 260 void AttemptToStartDrag(int component); |
| 250 | 261 |
| 251 // End current drag operation. | 262 // End current drag operation. |
| 252 void EndDrag(bool revert); | 263 void EndDrag(bool revert); |
| 253 | 264 |
| 265 // End current drag or client-driven move. | |
| 266 void EndDragOrMove(bool revert); | |
| 267 | |
| 254 // Returns true if surface is currently being resized. | 268 // Returns true if surface is currently being resized. |
| 255 bool IsResizing() const; | 269 bool IsResizing() const; |
| 256 | 270 |
| 257 // Returns the "visible bounds" for the surface from the user's perspective. | 271 // Returns the "visible bounds" for the surface from the user's perspective. |
| 258 gfx::Rect GetVisibleBounds() const; | 272 gfx::Rect GetVisibleBounds() const; |
| 259 | 273 |
| 260 // Returns the origin for the surface taking visible bounds and current | 274 // Returns the origin for the surface taking visible bounds and current |
| 261 // resize direction into account. | 275 // resize direction into account. |
| 262 gfx::Point GetSurfaceOrigin() const; | 276 gfx::Point GetSurfaceOrigin() const; |
| 263 | 277 |
| 264 // Updates the bounds of widget to match the current surface bounds. | 278 // Updates the bounds of widget to match the current surface bounds. |
| 265 void UpdateWidgetBounds(); | 279 void UpdateWidgetBounds(); |
| 266 | 280 |
| 281 // Updates the bounds of surface to match the current widget bounds. | |
| 282 void UpdateSurfaceBounds(); | |
| 283 | |
| 267 // Creates, deletes and update the shadow bounds based on | 284 // Creates, deletes and update the shadow bounds based on |
| 268 // |pending_shadow_content_bounds_|. | 285 // |pending_shadow_content_bounds_|. |
| 269 void UpdateShadow(); | 286 void UpdateShadow(); |
| 270 | 287 |
| 288 // In the coordinate system of the parent root window. | |
| 289 gfx::Point GetMouseLocation() const; | |
| 290 | |
| 291 const Display& display_; | |
|
oshima
2016/10/12 01:56:54
can you use const Display* ?
Dominik Laskowski
2016/10/13 03:21:17
It should never be null, and the reference makes t
oshima
2016/10/17 17:22:58
It doesn't prevent from passing null reference. as
Dominik Laskowski
2016/10/18 21:22:56
The caller would have to dereference a null pointe
| |
| 271 views::Widget* widget_ = nullptr; | 292 views::Widget* widget_ = nullptr; |
| 272 Surface* surface_; | 293 Surface* surface_; |
| 273 aura::Window* parent_; | 294 aura::Window* parent_; |
| 274 const gfx::Rect initial_bounds_; | 295 const gfx::Rect initial_bounds_; |
| 275 const bool activatable_; | 296 const bool activatable_; |
| 276 // Container Window Id (see ash/common/shell_window_ids.h) | 297 // Container Window Id (see ash/common/shell_window_ids.h) |
| 277 const int container_; | 298 const int container_; |
| 278 bool pending_show_widget_ = false; | 299 bool pending_show_widget_ = false; |
| 279 base::string16 title_; | 300 base::string16 title_; |
| 280 std::string application_id_; | 301 std::string application_id_; |
| 281 gfx::Rect geometry_; | 302 gfx::Rect geometry_; |
| 282 gfx::Rect pending_geometry_; | 303 gfx::Rect pending_geometry_; |
| 283 double scale_ = 1.0; | 304 double scale_ = 1.0; |
| 284 double pending_scale_ = 1.0; | 305 double pending_scale_ = 1.0; |
| 285 base::Closure close_callback_; | 306 base::Closure close_callback_; |
| 286 base::Closure surface_destroyed_callback_; | 307 base::Closure surface_destroyed_callback_; |
| 287 StateChangedCallback state_changed_callback_; | 308 StateChangedCallback state_changed_callback_; |
| 288 ConfigureCallback configure_callback_; | 309 ConfigureCallback configure_callback_; |
| 289 ScopedConfigure* scoped_configure_ = nullptr; | 310 ScopedConfigure* scoped_configure_ = nullptr; |
| 311 bool ignore_widget_bounds_changes_ = false; | |
| 290 bool ignore_window_bounds_changes_ = false; | 312 bool ignore_window_bounds_changes_ = false; |
| 291 gfx::Point origin_; | 313 gfx::Point origin_; |
| 292 gfx::Vector2d pending_origin_offset_; | 314 gfx::Vector2d pending_origin_offset_; |
| 293 gfx::Vector2d pending_origin_config_offset_; | 315 gfx::Vector2d pending_origin_config_offset_; |
| 294 int resize_component_ = HTCAPTION; // HT constant (see ui/base/hit_test.h) | 316 int resize_component_ = HTCAPTION; // HT constant (see ui/base/hit_test.h) |
| 295 int pending_resize_component_ = HTCAPTION; | 317 int pending_resize_component_ = HTCAPTION; |
| 296 aura::Window* shadow_overlay_ = nullptr; | 318 aura::Window* shadow_overlay_ = nullptr; |
| 297 aura::Window* shadow_underlay_ = nullptr; | 319 aura::Window* shadow_underlay_ = nullptr; |
| 298 std::unique_ptr<ui::EventHandler> shadow_underlay_event_handler_; | 320 std::unique_ptr<ui::EventHandler> shadow_underlay_event_handler_; |
| 299 gfx::Rect shadow_content_bounds_; | 321 gfx::Rect shadow_content_bounds_; |
| 300 std::deque<Config> pending_configs_; | 322 std::deque<Config> pending_configs_; |
| 301 std::unique_ptr<ash::WindowResizer> resizer_; | 323 std::unique_ptr<ash::WindowResizer> resizer_; |
| 324 std::unique_ptr<ash::WindowResizer> move_resizer_; | |
|
oshima
2016/10/12 01:56:54
the original resizer_ is also used to drag. How ab
Dominik Laskowski
2016/10/13 03:21:17
The pointer is also used to check whether a client
oshima
2016/10/17 17:22:58
Hmm, then I may be reading this wrong. Can you exp
Dominik Laskowski
2016/10/18 21:22:56
There are three states we want to detect:
Dominik Laskowski
2016/10/21 03:05:19
After an offline chat with oshima, the suggestion
| |
| 302 std::unique_ptr<ScopedAnimationsDisabled> scoped_animations_disabled_; | 325 std::unique_ptr<ScopedAnimationsDisabled> scoped_animations_disabled_; |
| 303 int top_inset_height_ = 0; | 326 int top_inset_height_ = 0; |
| 304 int pending_top_inset_height_ = 0; | 327 int pending_top_inset_height_ = 0; |
| 305 float rectangular_shadow_background_opacity_ = 1.0; | 328 float rectangular_shadow_background_opacity_ = 1.0; |
| 306 | 329 |
| 307 DISALLOW_COPY_AND_ASSIGN(ShellSurface); | 330 DISALLOW_COPY_AND_ASSIGN(ShellSurface); |
| 308 }; | 331 }; |
| 309 | 332 |
| 310 } // namespace exo | 333 } // namespace exo |
| 311 | 334 |
| 312 #endif // COMPONENTS_EXO_SHELL_SURFACE_H_ | 335 #endif // COMPONENTS_EXO_SHELL_SURFACE_H_ |
| OLD | NEW |