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