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

Side by Side Diff: components/exo/shell_surface.h

Issue 2645663004: exo: Initial support for multiple displays in ARC (Closed)
Patch Set: Fix race and refactor Created 3 years, 10 months 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
OLDNEW
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
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 };
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
99 // parent. 117 // parent.
100 void SetParent(ShellSurface* parent); 118 void SetParent(ShellSurface* parent);
101 119
102 // Activates the shell surface. 120 // Activates the shell surface.
103 void Activate(); 121 void Activate();
104 122
105 // Maximizes the shell surface. 123 // Maximizes the shell surface.
106 void Maximize(); 124 void Maximize();
107 125
108 // Minimize the shell surface. 126 // Minimize the shell surface.
109 void Minimize(); 127 void Minimize();
110 128
111 // Restore the shell surface. 129 // Restore the shell surface.
112 void Restore(); 130 void Restore();
113 131
132 // Start and stop a client-driven move of the shell surface.
133 void SetMoving();
reveman 2017/02/06 19:49:34 Please remove all functionality related to this fr
Dominik Laskowski 2017/02/08 18:07:40 Done.
134 void UnsetMoving(bool revert);
135
114 // Set fullscreen state for shell surface. 136 // Set fullscreen state for shell surface.
115 void SetFullscreen(bool fullscreen); 137 void SetFullscreen(bool fullscreen);
116 138
117 // Pins the shell surface. |trusted| flag is ignored when |pinned| is false. 139 // Pins the shell surface. |trusted| flag is ignored when |pinned| is false.
118 void SetPinned(bool pinned, bool trusted); 140 void SetPinned(bool pinned, bool trusted);
119 141
120 // Set title for surface. 142 // Set title for surface.
121 void SetTitle(const base::string16& title); 143 void SetTitle(const base::string16& title);
122 144
123 // Sets the system modality. 145 // Sets the system modality.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // Asks the client to configure its surface. 281 // Asks the client to configure its surface.
260 void Configure(); 282 void Configure();
261 283
262 // Attempt to start a drag operation. The type of drag operation to start is 284 // Attempt to start a drag operation. The type of drag operation to start is
263 // determined by |component|. 285 // determined by |component|.
264 void AttemptToStartDrag(int component); 286 void AttemptToStartDrag(int component);
265 287
266 // End current drag operation. 288 // End current drag operation.
267 void EndDrag(bool revert); 289 void EndDrag(bool revert);
268 290
291 // End current drag or client-driven move.
292 void EndDragOrMove(bool revert);
293
269 // Returns true if surface is currently being resized. 294 // Returns true if surface is currently being resized.
270 bool IsResizing() const; 295 bool IsResizing() const;
271 296
272 // Returns the "visible bounds" for the surface from the user's perspective. 297 // Returns the "visible bounds" for the surface from the user's perspective.
273 gfx::Rect GetVisibleBounds() const; 298 gfx::Rect GetVisibleBounds() const;
274 299
275 // Returns the origin for the surface taking visible bounds and current 300 // Returns the origin for the surface taking visible bounds and current
276 // resize direction into account. 301 // resize direction into account.
277 gfx::Point GetSurfaceOrigin() const; 302 gfx::Point GetSurfaceOrigin() const;
278 303
279 // Updates the bounds of widget to match the current surface bounds. 304 // Updates the bounds of widget to match the current surface bounds.
280 void UpdateWidgetBounds(); 305 void UpdateWidgetBounds();
281 306
307 // Updates the bounds of surface to match the current widget bounds.
308 void UpdateSurfaceBounds();
309
282 // Creates, deletes and update the shadow bounds based on 310 // Creates, deletes and update the shadow bounds based on
283 // |pending_shadow_content_bounds_|. 311 // |pending_shadow_content_bounds_|.
284 void UpdateShadow(); 312 void UpdateShadow();
285 313
314 // In the coordinate system of the parent root window.
315 gfx::Point GetMouseLocation() const;
316
286 views::Widget* widget_ = nullptr; 317 views::Widget* widget_ = nullptr;
287 Surface* surface_; 318 Surface* surface_;
288 aura::Window* parent_; 319 aura::Window* parent_;
289 gfx::Rect initial_bounds_; 320 const BoundsMode bounds_mode_;
321 gfx::Point origin_;
290 bool activatable_ = true; 322 bool activatable_ = true;
291 const bool can_minimize_; 323 const bool can_minimize_;
292 // Container Window Id (see ash/public/cpp/shell_window_ids.h) 324 // Container Window Id (see ash/public/cpp/shell_window_ids.h)
293 int container_; 325 int container_;
294 bool frame_enabled_ = false; 326 bool frame_enabled_ = false;
295 bool shadow_enabled_ = false; 327 bool shadow_enabled_ = false;
296 bool pending_show_widget_ = false; 328 bool pending_show_widget_ = false;
297 base::string16 title_; 329 base::string16 title_;
298 std::string application_id_; 330 std::string application_id_;
299 gfx::Rect geometry_; 331 gfx::Rect geometry_;
300 gfx::Rect pending_geometry_; 332 gfx::Rect pending_geometry_;
301 double scale_ = 1.0; 333 double scale_ = 1.0;
302 double pending_scale_ = 1.0; 334 double pending_scale_ = 1.0;
303 base::Closure close_callback_; 335 base::Closure close_callback_;
336 base::Closure destroyed_callback_;
reveman 2017/02/06 19:49:34 why is this needed? please remove if related to in
Dominik Laskowski 2017/02/08 18:07:40 WaylandRemoteShell updates the origin for each she
304 base::Closure surface_destroyed_callback_; 337 base::Closure surface_destroyed_callback_;
305 StateChangedCallback state_changed_callback_; 338 StateChangedCallback state_changed_callback_;
306 ConfigureCallback configure_callback_; 339 ConfigureCallback configure_callback_;
307 ScopedConfigure* scoped_configure_ = nullptr; 340 ScopedConfigure* scoped_configure_ = nullptr;
308 bool ignore_window_bounds_changes_ = false; 341 bool ignore_window_bounds_changes_ = false;
309 gfx::Point origin_; 342 gfx::Vector2d origin_offset_;
310 gfx::Vector2d pending_origin_offset_; 343 gfx::Vector2d pending_origin_offset_;
311 gfx::Vector2d pending_origin_config_offset_; 344 gfx::Vector2d pending_origin_offset_accumulator_;
reveman 2017/02/06 19:49:34 I guess this is just a cleanup? Can you keep it as
Dominik Laskowski 2017/02/08 18:07:40 The diff for this rename is small, and the change
312 int resize_component_ = HTCAPTION; // HT constant (see ui/base/hit_test.h) 345 int resize_component_ = HTCAPTION; // HT constant (see ui/base/hit_test.h)
313 int pending_resize_component_ = HTCAPTION; 346 int pending_resize_component_ = HTCAPTION;
314 aura::Window* shadow_overlay_ = nullptr; 347 aura::Window* shadow_overlay_ = nullptr;
315 aura::Window* shadow_underlay_ = nullptr; 348 aura::Window* shadow_underlay_ = nullptr;
316 std::unique_ptr<ui::EventHandler> shadow_underlay_event_handler_; 349 std::unique_ptr<ui::EventHandler> shadow_underlay_event_handler_;
317 gfx::Rect shadow_content_bounds_; 350 gfx::Rect shadow_content_bounds_;
318 float shadow_background_opacity_ = 1.0; 351 float shadow_background_opacity_ = 1.0;
319 std::deque<Config> pending_configs_; 352 std::deque<Config> pending_configs_;
320 std::unique_ptr<ash::WindowResizer> resizer_; 353 std::unique_ptr<ash::WindowResizer> resizer_;
354 std::unique_ptr<ash::WindowResizer> move_resizer_;
reveman 2017/02/06 19:49:34 please remove from this patch
Dominik Laskowski 2017/02/08 18:07:40 Done.
321 std::unique_ptr<ScopedAnimationsDisabled> scoped_animations_disabled_; 355 std::unique_ptr<ScopedAnimationsDisabled> scoped_animations_disabled_;
322 int top_inset_height_ = 0; 356 int top_inset_height_ = 0;
323 int pending_top_inset_height_ = 0; 357 int pending_top_inset_height_ = 0;
324 358
325 DISALLOW_COPY_AND_ASSIGN(ShellSurface); 359 DISALLOW_COPY_AND_ASSIGN(ShellSurface);
326 }; 360 };
327 361
328 } // namespace exo 362 } // namespace exo
329 363
330 #endif // COMPONENTS_EXO_SHELL_SURFACE_H_ 364 #endif // COMPONENTS_EXO_SHELL_SURFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698