| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_ | |
| 6 #define ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <set> | |
| 10 | |
| 11 #include "ash/ash_export.h" | |
| 12 #include "ash/wm/common/window_state_observer.h" | |
| 13 #include "ash/wm/common/wm_activation_observer.h" | |
| 14 #include "ash/wm/common/wm_layout_manager.h" | |
| 15 #include "ash/wm/common/wm_root_window_controller_observer.h" | |
| 16 #include "ash/wm/common/wm_types.h" | |
| 17 #include "ash/wm/common/wm_window_observer.h" | |
| 18 #include "base/macros.h" | |
| 19 #include "ui/gfx/geometry/rect.h" | |
| 20 #include "ui/keyboard/keyboard_controller_observer.h" | |
| 21 | |
| 22 namespace ash { | |
| 23 class WorkspaceLayoutManagerBackdropDelegate; | |
| 24 | |
| 25 namespace wm { | |
| 26 class WmGlobals; | |
| 27 class WmRootWindowController; | |
| 28 class WorkspaceLayoutManagerDelegate; | |
| 29 class WMEvent; | |
| 30 } | |
| 31 | |
| 32 // LayoutManager used on the window created for a workspace. | |
| 33 class ASH_EXPORT WorkspaceLayoutManager | |
| 34 : public wm::WmLayoutManager, | |
| 35 public wm::WmWindowObserver, | |
| 36 public wm::WmActivationObserver, | |
| 37 public keyboard::KeyboardControllerObserver, | |
| 38 public wm::WmRootWindowControllerObserver, | |
| 39 public wm::WindowStateObserver { | |
| 40 public: | |
| 41 WorkspaceLayoutManager( | |
| 42 wm::WmWindow* window, | |
| 43 std::unique_ptr<wm::WorkspaceLayoutManagerDelegate> delegate); | |
| 44 | |
| 45 ~WorkspaceLayoutManager() override; | |
| 46 | |
| 47 void DeleteDelegate(); | |
| 48 | |
| 49 // A delegate which can be set to add a backdrop behind the top most visible | |
| 50 // window. With the call the ownership of the delegate will be transferred to | |
| 51 // the WorkspaceLayoutManager. | |
| 52 void SetMaximizeBackdropDelegate( | |
| 53 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> delegate); | |
| 54 | |
| 55 // Overridden from wm::WmLayoutManager: | |
| 56 void OnWindowResized() override; | |
| 57 void OnWindowAddedToLayout(wm::WmWindow* child) override; | |
| 58 void OnWillRemoveWindowFromLayout(wm::WmWindow* child) override; | |
| 59 void OnWindowRemovedFromLayout(wm::WmWindow* child) override; | |
| 60 void OnChildWindowVisibilityChanged(wm::WmWindow* child, | |
| 61 bool visibile) override; | |
| 62 void SetChildBounds(wm::WmWindow* child, | |
| 63 const gfx::Rect& requested_bounds) override; | |
| 64 | |
| 65 // wm::WmRootWindowControllerObserver overrides: | |
| 66 void OnWorkAreaChanged() override; | |
| 67 void OnFullscreenStateChanged(bool is_fullscreen) override; | |
| 68 | |
| 69 // Overriden from wm::WmWindowObserver: | |
| 70 void OnWindowTreeChanged( | |
| 71 wm::WmWindow* window, | |
| 72 const wm::WmWindowObserver::TreeChangeParams& params) override; | |
| 73 void OnWindowPropertyChanged(wm::WmWindow* window, | |
| 74 wm::WmWindowProperty property, | |
| 75 intptr_t old) override; | |
| 76 void OnWindowStackingChanged(wm::WmWindow* window) override; | |
| 77 void OnWindowDestroying(wm::WmWindow* window) override; | |
| 78 void OnWindowBoundsChanged(wm::WmWindow* window, | |
| 79 const gfx::Rect& old_bounds, | |
| 80 const gfx::Rect& new_bounds) override; | |
| 81 | |
| 82 // wm::WmActivationObserver overrides: | |
| 83 void OnWindowActivated(wm::WmWindow* gained_active, | |
| 84 wm::WmWindow* lost_active) override; | |
| 85 | |
| 86 // keyboard::KeyboardControllerObserver overrides: | |
| 87 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override; | |
| 88 | |
| 89 // WindowStateObserver overrides: | |
| 90 void OnPostWindowStateTypeChange(wm::WindowState* window_state, | |
| 91 wm::WindowStateType old_type) override; | |
| 92 | |
| 93 private: | |
| 94 typedef std::set<wm::WmWindow*> WindowSet; | |
| 95 | |
| 96 // Adjusts the bounds of all managed windows when the display area changes. | |
| 97 // This happens when the display size, work area insets has changed. | |
| 98 // If this is called for a display size change (i.e. |event| | |
| 99 // is DISPLAY_RESIZED), the non-maximized/non-fullscreen | |
| 100 // windows are readjusted to make sure the window is completely within the | |
| 101 // display region. Otherwise, it makes sure at least some parts of the window | |
| 102 // is on display. | |
| 103 void AdjustAllWindowsBoundsForWorkAreaChange(const wm::WMEvent* event); | |
| 104 | |
| 105 // Updates the visibility state of the shelf. | |
| 106 void UpdateShelfVisibility(); | |
| 107 | |
| 108 // Updates the fullscreen state of the workspace and notifies Shell if it | |
| 109 // has changed. | |
| 110 void UpdateFullscreenState(); | |
| 111 | |
| 112 // Updates the bounds of the window for a stte type change from | |
| 113 // |old_show_type|. | |
| 114 void UpdateBoundsFromStateType(wm::WindowState* window_state, | |
| 115 wm::WindowStateType old_state_type); | |
| 116 | |
| 117 // If |window_state| is maximized or fullscreen the bounds of the | |
| 118 // window are set and true is returned. Does nothing otherwise. | |
| 119 bool SetMaximizedOrFullscreenBounds(wm::WindowState* window_state); | |
| 120 | |
| 121 // Animates the window bounds to |bounds|. | |
| 122 void SetChildBoundsAnimated(wm::WmWindow* child, const gfx::Rect& bounds); | |
| 123 | |
| 124 wm::WmWindow* window_; | |
| 125 wm::WmWindow* root_window_; | |
| 126 wm::WmRootWindowController* root_window_controller_; | |
| 127 wm::WmGlobals* globals_; | |
| 128 | |
| 129 std::unique_ptr<wm::WorkspaceLayoutManagerDelegate> delegate_; | |
| 130 | |
| 131 // Set of windows we're listening to. | |
| 132 WindowSet windows_; | |
| 133 | |
| 134 // The work area in the coordinates of |window_|. | |
| 135 gfx::Rect work_area_in_parent_; | |
| 136 | |
| 137 // True if this workspace is currently in fullscreen mode. | |
| 138 bool is_fullscreen_; | |
| 139 | |
| 140 // A window which covers the full container and which gets inserted behind the | |
| 141 // topmost visible window. | |
| 142 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> backdrop_delegate_; | |
| 143 | |
| 144 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManager); | |
| 145 }; | |
| 146 | |
| 147 } // namespace ash | |
| 148 | |
| 149 #endif // ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_ | |
| OLD | NEW |