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

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

Issue 2645663004: exo: Initial support for multiple displays in ARC (Closed)
Patch Set: Refactor Created 3 years, 9 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
« no previous file with comments | « no previous file | components/exo/shell_surface.cc » ('j') | components/exo/shell_surface.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 27 matching lines...) Expand all
38 // This class provides functions for treating a surfaces like toplevel, 38 // This class provides functions for treating a surfaces like toplevel,
39 // fullscreen or popup widgets, move, resize or maximize them, associate 39 // fullscreen or popup widgets, move, resize or maximize them, associate
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 WMHelper::DisplayConfigurationObserver {
49 public: 50 public:
50 enum class BoundsMode { SHELL, CLIENT, FIXED }; 51 enum class BoundsMode { SHELL, CLIENT, FIXED };
51 52
52 // The |origin| is in screen coordinates. When bounds are controlled by the 53 // 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 // 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 // In that case, the position specified as part of the geometry is relative
55 // to the shell surface. 56 // to the shell surface.
56 // 57 //
57 // When bounds are controlled by the client, it represents the origin of a 58 // 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 // coordinate system to which the position of the shell surface, specified
(...skipping 14 matching lines...) Expand all
73 void set_close_callback(const base::Closure& close_callback) { 74 void set_close_callback(const base::Closure& close_callback) {
74 close_callback_ = close_callback; 75 close_callback_ = close_callback;
75 } 76 }
76 77
77 // Set the callback to run when the surface is destroyed. 78 // Set the callback to run when the surface is destroyed.
78 void set_surface_destroyed_callback( 79 void set_surface_destroyed_callback(
79 const base::Closure& surface_destroyed_callback) { 80 const base::Closure& surface_destroyed_callback) {
80 surface_destroyed_callback_ = surface_destroyed_callback; 81 surface_destroyed_callback_ = surface_destroyed_callback;
81 } 82 }
82 83
84 // Set the callback to run when the display configuration changed.
85 void set_display_config_changed_callback(
86 const base::Closure& display_config_changed_callback) {
87 display_config_changed_callback_ = display_config_changed_callback;
88 }
89
83 // Set the callback to run when the surface state changed. 90 // Set the callback to run when the surface state changed.
84 using StateChangedCallback = 91 using StateChangedCallback =
85 base::Callback<void(ash::wm::WindowStateType old_state_type, 92 base::Callback<void(ash::wm::WindowStateType old_state_type,
86 ash::wm::WindowStateType new_state_type)>; 93 ash::wm::WindowStateType new_state_type)>;
87 void set_state_changed_callback( 94 void set_state_changed_callback(
88 const StateChangedCallback& state_changed_callback) { 95 const StateChangedCallback& state_changed_callback) {
89 state_changed_callback_ = state_changed_callback; 96 state_changed_callback_ = state_changed_callback;
90 } 97 }
91 98
92 // Set the callback to run when the client is asked to configure the surface. 99 // Set the callback to run when the client is asked to configure the surface.
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 void OnWindowDestroying(aura::Window* window) override; 250 void OnWindowDestroying(aura::Window* window) override;
244 251
245 // Overridden from WMHelper::ActivationObserver: 252 // Overridden from WMHelper::ActivationObserver:
246 void OnWindowActivated( 253 void OnWindowActivated(
247 aura::Window* gained_active, 254 aura::Window* gained_active,
248 aura::Window* lost_active) override; 255 aura::Window* lost_active) override;
249 256
250 // Overridden from WMHelper::AccessibilityObserver: 257 // Overridden from WMHelper::AccessibilityObserver:
251 void OnAccessibilityModeChanged() override; 258 void OnAccessibilityModeChanged() override;
252 259
260 // Overridden from WMHelper::DisplayConfigurationObserver:
261 void OnDisplayConfigurationChanged() override;
262
253 // Overridden from ui::EventHandler: 263 // Overridden from ui::EventHandler:
254 void OnKeyEvent(ui::KeyEvent* event) override; 264 void OnKeyEvent(ui::KeyEvent* event) override;
255 void OnMouseEvent(ui::MouseEvent* event) override; 265 void OnMouseEvent(ui::MouseEvent* event) override;
256 266
257 // Overridden from ui::AcceleratorTarget: 267 // Overridden from ui::AcceleratorTarget:
258 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; 268 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
259 269
260 aura::Window* shadow_overlay() { return shadow_overlay_; } 270 aura::Window* shadow_overlay() { return shadow_overlay_; }
261 aura::Window* shadow_underlay() { return shadow_underlay_; } 271 aura::Window* shadow_underlay() { return shadow_underlay_; }
262 272
(...skipping 10 matching lines...) Expand all
273 int resize_component; 283 int resize_component;
274 }; 284 };
275 285
276 // Creates the |widget_| for |surface_|. |show_state| is the initial state 286 // Creates the |widget_| for |surface_|. |show_state| is the initial state
277 // of the widget (e.g. maximized). 287 // of the widget (e.g. maximized).
278 void CreateShellSurfaceWidget(ui::WindowShowState show_state); 288 void CreateShellSurfaceWidget(ui::WindowShowState show_state);
279 289
280 // Asks the client to configure its surface. 290 // Asks the client to configure its surface.
281 void Configure(); 291 void Configure();
282 292
293 aura::Window* GetDragWindow() const;
reveman 2017/03/06 19:02:13 Can this be private? nit: please add a comment exp
Dominik Laskowski 2017/03/08 23:13:23 Already private. Done.
294
283 // Attempt to start a drag operation. The type of drag operation to start is 295 // Attempt to start a drag operation. The type of drag operation to start is
284 // determined by |component|. 296 // determined by |component|.
285 void AttemptToStartDrag(int component); 297 void AttemptToStartDrag(int component);
286 298
287 // End current drag operation. 299 // End current drag operation.
288 void EndDrag(bool revert); 300 void EndDrag(bool revert);
289 301
290 // Returns true if surface is currently being resized. 302 // Returns true if surface is currently being resized.
291 bool IsResizing() const; 303 bool IsResizing() const;
292 304
293 // Returns the "visible bounds" for the surface from the user's perspective. 305 // Returns the "visible bounds" for the surface from the user's perspective.
294 gfx::Rect GetVisibleBounds() const; 306 gfx::Rect GetVisibleBounds() const;
295 307
296 // Returns the origin for the surface taking visible bounds and current 308 // Returns the origin for the surface taking visible bounds and current
297 // resize direction into account. 309 // resize direction into account.
298 gfx::Point GetSurfaceOrigin() const; 310 gfx::Point GetSurfaceOrigin() const;
299 311
300 // Updates the bounds of widget to match the current surface bounds. 312 // Updates the bounds of widget to match the current surface bounds.
301 void UpdateWidgetBounds(); 313 void UpdateWidgetBounds();
302 314
303 // Updates the bounds of surface to match the current widget bounds. 315 // Updates the bounds of surface to match the current widget bounds.
304 void UpdateSurfaceBounds(); 316 void UpdateSurfaceBounds();
305 317
306 // Creates, deletes and update the shadow bounds based on 318 // Creates, deletes and update the shadow bounds based on
307 // |pending_shadow_content_bounds_|. 319 // |pending_shadow_content_bounds_|.
308 void UpdateShadow(); 320 void UpdateShadow();
309 321
322 // In the coordinate system of the parent root window.
323 gfx::Point GetMouseLocation() const;
324
310 views::Widget* widget_ = nullptr; 325 views::Widget* widget_ = nullptr;
311 Surface* surface_; 326 Surface* surface_;
312 aura::Window* parent_; 327 aura::Window* parent_;
313 const BoundsMode bounds_mode_; 328 const BoundsMode bounds_mode_;
314 gfx::Point origin_; 329 gfx::Point origin_;
315 bool activatable_ = true; 330 bool activatable_ = true;
316 const bool can_minimize_; 331 const bool can_minimize_;
317 // Container Window Id (see ash/public/cpp/shell_window_ids.h) 332 // Container Window Id (see ash/public/cpp/shell_window_ids.h)
318 int container_; 333 int container_;
319 bool frame_enabled_ = false; 334 bool frame_enabled_ = false;
320 bool shadow_enabled_ = false; 335 bool shadow_enabled_ = false;
321 bool pending_show_widget_ = false; 336 bool pending_show_widget_ = false;
322 base::string16 title_; 337 base::string16 title_;
323 std::string application_id_; 338 std::string application_id_;
324 gfx::Rect geometry_; 339 gfx::Rect geometry_;
325 gfx::Rect pending_geometry_; 340 gfx::Rect pending_geometry_;
326 double scale_ = 1.0; 341 double scale_ = 1.0;
327 double pending_scale_ = 1.0; 342 double pending_scale_ = 1.0;
328 base::Closure close_callback_; 343 base::Closure close_callback_;
329 base::Closure surface_destroyed_callback_; 344 base::Closure surface_destroyed_callback_;
345 base::Closure display_config_changed_callback_;
330 StateChangedCallback state_changed_callback_; 346 StateChangedCallback state_changed_callback_;
331 ConfigureCallback configure_callback_; 347 ConfigureCallback configure_callback_;
332 ScopedConfigure* scoped_configure_ = nullptr; 348 ScopedConfigure* scoped_configure_ = nullptr;
333 bool ignore_window_bounds_changes_ = false; 349 bool ignore_window_bounds_changes_ = false;
334 gfx::Vector2d origin_offset_; 350 gfx::Vector2d origin_offset_;
335 gfx::Vector2d pending_origin_offset_; 351 gfx::Vector2d pending_origin_offset_;
336 gfx::Vector2d pending_origin_offset_accumulator_; 352 gfx::Vector2d pending_origin_offset_accumulator_;
337 int resize_component_ = HTCAPTION; // HT constant (see ui/base/hit_test.h) 353 int resize_component_ = HTCAPTION; // HT constant (see ui/base/hit_test.h)
338 int pending_resize_component_ = HTCAPTION; 354 int pending_resize_component_ = HTCAPTION;
339 aura::Window* shadow_overlay_ = nullptr; 355 aura::Window* shadow_overlay_ = nullptr;
340 aura::Window* shadow_underlay_ = nullptr; 356 aura::Window* shadow_underlay_ = nullptr;
341 std::unique_ptr<ui::EventHandler> shadow_underlay_event_handler_; 357 std::unique_ptr<ui::EventHandler> shadow_underlay_event_handler_;
342 gfx::Rect shadow_content_bounds_; 358 gfx::Rect shadow_content_bounds_;
343 float shadow_background_opacity_ = 1.0; 359 float shadow_background_opacity_ = 1.0;
344 std::deque<Config> pending_configs_; 360 std::deque<Config> pending_configs_;
345 std::unique_ptr<ash::WindowResizer> resizer_; 361 std::unique_ptr<ash::WindowResizer> resizer_;
346 std::unique_ptr<ScopedAnimationsDisabled> scoped_animations_disabled_; 362 std::unique_ptr<ScopedAnimationsDisabled> scoped_animations_disabled_;
347 int top_inset_height_ = 0; 363 int top_inset_height_ = 0;
348 int pending_top_inset_height_ = 0; 364 int pending_top_inset_height_ = 0;
349 bool shadow_underlay_in_surface_ = true; 365 bool shadow_underlay_in_surface_ = true;
350 366
351 DISALLOW_COPY_AND_ASSIGN(ShellSurface); 367 DISALLOW_COPY_AND_ASSIGN(ShellSurface);
352 }; 368 };
353 369
354 } // namespace exo 370 } // namespace exo
355 371
356 #endif // COMPONENTS_EXO_SHELL_SURFACE_H_ 372 #endif // COMPONENTS_EXO_SHELL_SURFACE_H_
OLDNEW
« no previous file with comments | « no previous file | components/exo/shell_surface.cc » ('j') | components/exo/shell_surface.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698