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

Side by Side Diff: ash/mus/bridge/wm_window_mus.h

Issue 2029883002: Moves mash/wm into ash/mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_static_assert
Patch Set: move comment Created 4 years, 6 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 | « ash/mus/bridge/wm_shelf_mus.cc ('k') | ash/mus/bridge/wm_window_mus.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 MASH_WM_BRIDGE_WM_WINDOW_MUS_H_ 5 #ifndef ASH_MUS_BRIDGE_WM_WINDOW_MUS_H_
6 #define MASH_WM_BRIDGE_WM_WINDOW_MUS_H_ 6 #define ASH_MUS_BRIDGE_WM_WINDOW_MUS_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/common/wm/wm_window.h" 10 #include "ash/common/wm/wm_window.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "components/mus/public/cpp/window_observer.h" 13 #include "components/mus/public/cpp/window_observer.h"
14 14
15 namespace ash {
16 namespace wm {
17 class WmLayoutManager;
18 }
19 }
20
21 namespace views { 15 namespace views {
22 class Widget; 16 class Widget;
23 } 17 }
24 18
25 namespace mash { 19 namespace ash {
20
26 namespace wm { 21 namespace wm {
22 class WmLayoutManager;
23 }
24
25 namespace mus {
27 26
28 class MusLayoutManagerAdapter; 27 class MusLayoutManagerAdapter;
29 class WmRootWindowControllerMus; 28 class WmRootWindowControllerMus;
30 29
31 // WmWindow implementation for mus. 30 // WmWindow implementation for mus.
32 // 31 //
33 // WmWindowMus is tied to the life of the underlying mus::Window (it is stored 32 // WmWindowMus is tied to the life of the underlying ::mus::Window (it is stored
34 // as an owned property). 33 // as an owned property).
35 class WmWindowMus : public ash::wm::WmWindow, public mus::WindowObserver { 34 class WmWindowMus : public wm::WmWindow, public ::mus::WindowObserver {
36 public: 35 public:
37 // Indicates the source of the widget creation. 36 // Indicates the source of the widget creation.
38 enum class WidgetCreationType { 37 enum class WidgetCreationType {
39 // The widget was created internally, and not at the request of a client. 38 // The widget was created internally, and not at the request of a client.
40 // For example, overview mode creates a number of widgets. These widgets are 39 // For example, overview mode creates a number of widgets. These widgets are
41 // created with a type of INTERNAL. 40 // created with a type of INTERNAL.
42 INTERNAL, 41 INTERNAL,
43 42
44 // The widget was created for a client. In other words there is a client 43 // The widget was created for a client. In other words there is a client
45 // embedded in the mus::Window. For example, when Chrome creates a new 44 // embedded in the mus::Window. For example, when Chrome creates a new
46 // browser window the window manager is asked to create the mus::Window. 45 // browser window the window manager is asked to create the mus::Window.
47 // The window manager creates a mus::Window and a views::Widget to show the 46 // The window manager creates a mus::Window and a views::Widget to show the
48 // non-client frame decorations. In this case the creation type is 47 // non-client frame decorations. In this case the creation type is
49 // FOR_CLIENT. 48 // FOR_CLIENT.
50 49
51 FOR_CLIENT, 50 FOR_CLIENT,
52 }; 51 };
53 52
54 explicit WmWindowMus(mus::Window* window); 53 explicit WmWindowMus(::mus::Window* window);
55 // NOTE: this class is owned by the corresponding window. You shouldn't delete 54 // NOTE: this class is owned by the corresponding window. You shouldn't delete
56 // TODO(sky): friend deleter and make private. 55 // TODO(sky): friend deleter and make private.
57 ~WmWindowMus() override; 56 ~WmWindowMus() override;
58 57
59 // Returns a WmWindow for an mus::Window, creating if necessary. 58 // Returns a WmWindow for an mus::Window, creating if necessary.
60 static WmWindowMus* Get(mus::Window* window); 59 static WmWindowMus* Get(::mus::Window* window);
61 60
62 static WmWindowMus* Get(views::Widget* widget); 61 static WmWindowMus* Get(views::Widget* widget);
63 62
64 static mus::Window* GetMusWindow(ash::wm::WmWindow* wm_window) { 63 static ::mus::Window* GetMusWindow(wm::WmWindow* wm_window) {
65 return const_cast<mus::Window*>( 64 return const_cast<::mus::Window*>(
66 GetMusWindow(const_cast<const ash::wm::WmWindow*>(wm_window))); 65 GetMusWindow(const_cast<const wm::WmWindow*>(wm_window)));
67 } 66 }
68 static const mus::Window* GetMusWindow(const ash::wm::WmWindow* wm_window); 67 static const ::mus::Window* GetMusWindow(const wm::WmWindow* wm_window);
69 68
70 static std::vector<WmWindow*> FromMusWindows( 69 static std::vector<WmWindow*> FromMusWindows(
71 const std::vector<mus::Window*>& mus_windows); 70 const std::vector<::mus::Window*>& mus_windows);
72 71
73 // Sets the widget associated with the window. The widget is used to query 72 // Sets the widget associated with the window. The widget is used to query
74 // state, such as min/max size. The widget is not owned by the WmWindowMus. 73 // state, such as min/max size. The widget is not owned by the WmWindowMus.
75 void set_widget(views::Widget* widget, WidgetCreationType type) { 74 void set_widget(views::Widget* widget, WidgetCreationType type) {
76 widget_ = widget; 75 widget_ = widget;
77 widget_creation_type_ = type; 76 widget_creation_type_ = type;
78 } 77 }
79 78
80 mus::Window* mus_window() { return window_; } 79 ::mus::Window* mus_window() { return window_; }
81 const mus::Window* mus_window() const { return window_; } 80 const ::mus::Window* mus_window() const { return window_; }
82 81
83 WmRootWindowControllerMus* GetRootWindowControllerMus() { 82 WmRootWindowControllerMus* GetRootWindowControllerMus() {
84 return const_cast<WmRootWindowControllerMus*>( 83 return const_cast<WmRootWindowControllerMus*>(
85 const_cast<const WmWindowMus*>(this)->GetRootWindowControllerMus()); 84 const_cast<const WmWindowMus*>(this)->GetRootWindowControllerMus());
86 } 85 }
87 const WmRootWindowControllerMus* GetRootWindowControllerMus() const; 86 const WmRootWindowControllerMus* GetRootWindowControllerMus() const;
88 87
89 static WmWindowMus* AsWmWindowMus(ash::wm::WmWindow* window) { 88 static WmWindowMus* AsWmWindowMus(wm::WmWindow* window) {
90 return static_cast<WmWindowMus*>(window); 89 return static_cast<WmWindowMus*>(window);
91 } 90 }
92 static const WmWindowMus* AsWmWindowMus(const ash::wm::WmWindow* window) { 91 static const WmWindowMus* AsWmWindowMus(const wm::WmWindow* window) {
93 return static_cast<const WmWindowMus*>(window); 92 return static_cast<const WmWindowMus*>(window);
94 } 93 }
95 94
96 ash::wm::WindowState* GetWindowState() { 95 wm::WindowState* GetWindowState() { return wm::WmWindow::GetWindowState(); }
97 return ash::wm::WmWindow::GetWindowState();
98 }
99 96
100 // See description of |children_use_extended_hit_region_|. 97 // See description of |children_use_extended_hit_region_|.
101 bool ShouldUseExtendedHitRegion() const; 98 bool ShouldUseExtendedHitRegion() const;
102 99
103 // WmWindow: 100 // WmWindow:
104 const ash::wm::WmWindow* GetRootWindow() const override; 101 const wm::WmWindow* GetRootWindow() const override;
105 ash::wm::WmRootWindowController* GetRootWindowController() override; 102 wm::WmRootWindowController* GetRootWindowController() override;
106 ash::wm::WmGlobals* GetGlobals() const override; 103 wm::WmGlobals* GetGlobals() const override;
107 void SetName(const char* name) override; 104 void SetName(const char* name) override;
108 base::string16 GetTitle() const override; 105 base::string16 GetTitle() const override;
109 void SetShellWindowId(int id) override; 106 void SetShellWindowId(int id) override;
110 int GetShellWindowId() const override; 107 int GetShellWindowId() const override;
111 ash::wm::WmWindow* GetChildByShellWindowId(int id) override; 108 wm::WmWindow* GetChildByShellWindowId(int id) override;
112 ui::wm::WindowType GetType() const override; 109 ui::wm::WindowType GetType() const override;
113 ui::Layer* GetLayer() override; 110 ui::Layer* GetLayer() override;
114 display::Display GetDisplayNearestWindow() override; 111 display::Display GetDisplayNearestWindow() override;
115 bool HasNonClientArea() override; 112 bool HasNonClientArea() override;
116 int GetNonClientComponent(const gfx::Point& location) override; 113 int GetNonClientComponent(const gfx::Point& location) override;
117 gfx::Point ConvertPointToTarget(const ash::wm::WmWindow* target, 114 gfx::Point ConvertPointToTarget(const wm::WmWindow* target,
118 const gfx::Point& point) const override; 115 const gfx::Point& point) const override;
119 gfx::Point ConvertPointToScreen(const gfx::Point& point) const override; 116 gfx::Point ConvertPointToScreen(const gfx::Point& point) const override;
120 gfx::Point ConvertPointFromScreen(const gfx::Point& point) const override; 117 gfx::Point ConvertPointFromScreen(const gfx::Point& point) const override;
121 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const override; 118 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const override;
122 gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const override; 119 gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const override;
123 gfx::Size GetMinimumSize() const override; 120 gfx::Size GetMinimumSize() const override;
124 gfx::Size GetMaximumSize() const override; 121 gfx::Size GetMaximumSize() const override;
125 bool GetTargetVisibility() const override; 122 bool GetTargetVisibility() const override;
126 bool IsVisible() const override; 123 bool IsVisible() const override;
127 void SetOpacity(float opacity) override; 124 void SetOpacity(float opacity) override;
128 float GetTargetOpacity() const override; 125 float GetTargetOpacity() const override;
129 void SetTransform(const gfx::Transform& transform) override; 126 void SetTransform(const gfx::Transform& transform) override;
130 gfx::Transform GetTargetTransform() const override; 127 gfx::Transform GetTargetTransform() const override;
131 bool IsSystemModal() const override; 128 bool IsSystemModal() const override;
132 bool GetBoolProperty(ash::wm::WmWindowProperty key) override; 129 bool GetBoolProperty(wm::WmWindowProperty key) override;
133 int GetIntProperty(ash::wm::WmWindowProperty key) override; 130 int GetIntProperty(wm::WmWindowProperty key) override;
134 const ash::wm::WindowState* GetWindowState() const override; 131 const wm::WindowState* GetWindowState() const override;
135 ash::wm::WmWindow* GetToplevelWindow() override; 132 wm::WmWindow* GetToplevelWindow() override;
136 void SetParentUsingContext(ash::wm::WmWindow* context, 133 void SetParentUsingContext(wm::WmWindow* context,
137 const gfx::Rect& screen_bounds) override; 134 const gfx::Rect& screen_bounds) override;
138 void AddChild(ash::wm::WmWindow* window) override; 135 void AddChild(wm::WmWindow* window) override;
139 ash::wm::WmWindow* GetParent() override; 136 wm::WmWindow* GetParent() override;
140 const ash::wm::WmWindow* GetTransientParent() const override; 137 const wm::WmWindow* GetTransientParent() const override;
141 std::vector<ash::wm::WmWindow*> GetTransientChildren() override; 138 std::vector<wm::WmWindow*> GetTransientChildren() override;
142 void SetLayoutManager( 139 void SetLayoutManager(
143 std::unique_ptr<ash::wm::WmLayoutManager> layout_manager) override; 140 std::unique_ptr<wm::WmLayoutManager> layout_manager) override;
144 ash::wm::WmLayoutManager* GetLayoutManager() override; 141 wm::WmLayoutManager* GetLayoutManager() override;
145 void SetVisibilityAnimationType(int type) override; 142 void SetVisibilityAnimationType(int type) override;
146 void SetVisibilityAnimationDuration(base::TimeDelta delta) override; 143 void SetVisibilityAnimationDuration(base::TimeDelta delta) override;
147 void SetVisibilityAnimationTransition( 144 void SetVisibilityAnimationTransition(
148 ::wm::WindowVisibilityAnimationTransition transition) override; 145 ::wm::WindowVisibilityAnimationTransition transition) override;
149 void Animate(::wm::WindowAnimationType type) override; 146 void Animate(::wm::WindowAnimationType type) override;
150 void StopAnimatingProperty( 147 void StopAnimatingProperty(
151 ui::LayerAnimationElement::AnimatableProperty property) override; 148 ui::LayerAnimationElement::AnimatableProperty property) override;
152 void SetChildWindowVisibilityChangesAnimated() override; 149 void SetChildWindowVisibilityChangesAnimated() override;
153 void SetMasksToBounds(bool value) override; 150 void SetMasksToBounds(bool value) override;
154 void SetBounds(const gfx::Rect& bounds) override; 151 void SetBounds(const gfx::Rect& bounds) override;
155 void SetBoundsWithTransitionDelay(const gfx::Rect& bounds, 152 void SetBoundsWithTransitionDelay(const gfx::Rect& bounds,
156 base::TimeDelta delta) override; 153 base::TimeDelta delta) override;
157 void SetBoundsDirect(const gfx::Rect& bounds) override; 154 void SetBoundsDirect(const gfx::Rect& bounds) override;
158 void SetBoundsDirectAnimated(const gfx::Rect& bounds) override; 155 void SetBoundsDirectAnimated(const gfx::Rect& bounds) override;
159 void SetBoundsDirectCrossFade(const gfx::Rect& bounds) override; 156 void SetBoundsDirectCrossFade(const gfx::Rect& bounds) override;
160 void SetBoundsInScreen(const gfx::Rect& bounds_in_screen, 157 void SetBoundsInScreen(const gfx::Rect& bounds_in_screen,
161 const display::Display& dst_display) override; 158 const display::Display& dst_display) override;
162 gfx::Rect GetBoundsInScreen() const override; 159 gfx::Rect GetBoundsInScreen() const override;
163 const gfx::Rect& GetBounds() const override; 160 const gfx::Rect& GetBounds() const override;
164 gfx::Rect GetTargetBounds() override; 161 gfx::Rect GetTargetBounds() override;
165 void ClearRestoreBounds() override; 162 void ClearRestoreBounds() override;
166 void SetRestoreBoundsInScreen(const gfx::Rect& bounds) override; 163 void SetRestoreBoundsInScreen(const gfx::Rect& bounds) override;
167 gfx::Rect GetRestoreBoundsInScreen() const override; 164 gfx::Rect GetRestoreBoundsInScreen() const override;
168 bool Contains(const ash::wm::WmWindow* other) const override; 165 bool Contains(const wm::WmWindow* other) const override;
169 void SetShowState(ui::WindowShowState show_state) override; 166 void SetShowState(ui::WindowShowState show_state) override;
170 ui::WindowShowState GetShowState() const override; 167 ui::WindowShowState GetShowState() const override;
171 void SetRestoreShowState(ui::WindowShowState show_state) override; 168 void SetRestoreShowState(ui::WindowShowState show_state) override;
172 void SetLockedToRoot(bool value) override; 169 void SetLockedToRoot(bool value) override;
173 void SetCapture() override; 170 void SetCapture() override;
174 bool HasCapture() override; 171 bool HasCapture() override;
175 void ReleaseCapture() override; 172 void ReleaseCapture() override;
176 bool HasRestoreBounds() const override; 173 bool HasRestoreBounds() const override;
177 void SetAlwaysOnTop(bool value) override; 174 void SetAlwaysOnTop(bool value) override;
178 bool IsAlwaysOnTop() const override; 175 bool IsAlwaysOnTop() const override;
179 void Hide() override; 176 void Hide() override;
180 void Show() override; 177 void Show() override;
181 void CloseWidget() override; 178 void CloseWidget() override;
182 bool IsFocused() const override; 179 bool IsFocused() const override;
183 bool IsActive() const override; 180 bool IsActive() const override;
184 void Activate() override; 181 void Activate() override;
185 void Deactivate() override; 182 void Deactivate() override;
186 void SetFullscreen() override; 183 void SetFullscreen() override;
187 void Maximize() override; 184 void Maximize() override;
188 void Minimize() override; 185 void Minimize() override;
189 void Unminimize() override; 186 void Unminimize() override;
190 bool CanMaximize() const override; 187 bool CanMaximize() const override;
191 bool CanMinimize() const override; 188 bool CanMinimize() const override;
192 bool CanResize() const override; 189 bool CanResize() const override;
193 bool CanActivate() const override; 190 bool CanActivate() const override;
194 void StackChildAtTop(ash::wm::WmWindow* child) override; 191 void StackChildAtTop(wm::WmWindow* child) override;
195 void StackChildAtBottom(ash::wm::WmWindow* child) override; 192 void StackChildAtBottom(wm::WmWindow* child) override;
196 void StackChildAbove(ash::wm::WmWindow* child, 193 void StackChildAbove(wm::WmWindow* child, wm::WmWindow* target) override;
197 ash::wm::WmWindow* target) override; 194 void StackChildBelow(wm::WmWindow* child, wm::WmWindow* target) override;
198 void StackChildBelow(ash::wm::WmWindow* child, 195 std::vector<wm::WmWindow*> GetChildren() override;
199 ash::wm::WmWindow* target) override;
200 std::vector<ash::wm::WmWindow*> GetChildren() override;
201 void ShowResizeShadow(int component) override; 196 void ShowResizeShadow(int component) override;
202 void HideResizeShadow() override; 197 void HideResizeShadow() override;
203 void SetBoundsInScreenBehaviorForChildren( 198 void SetBoundsInScreenBehaviorForChildren(
204 BoundsInScreenBehavior behavior) override; 199 BoundsInScreenBehavior behavior) override;
205 void SetSnapsChildrenToPhysicalPixelBoundary() override; 200 void SetSnapsChildrenToPhysicalPixelBoundary() override;
206 void SnapToPixelBoundaryIfNecessary() override; 201 void SnapToPixelBoundaryIfNecessary() override;
207 void SetChildrenUseExtendedHitRegion() override; 202 void SetChildrenUseExtendedHitRegion() override;
208 void SetDescendantsStayInSameRootWindow(bool value) override; 203 void SetDescendantsStayInSameRootWindow(bool value) override;
209 void AddObserver(ash::wm::WmWindowObserver* observer) override; 204 void AddObserver(wm::WmWindowObserver* observer) override;
210 void RemoveObserver(ash::wm::WmWindowObserver* observer) override; 205 void RemoveObserver(wm::WmWindowObserver* observer) override;
211 206
212 private: 207 private:
213 // mus::WindowObserver: 208 // mus::WindowObserver:
214 void OnTreeChanged(const TreeChangeParams& params) override; 209 void OnTreeChanged(const TreeChangeParams& params) override;
215 void OnWindowReordered(mus::Window* window, 210 void OnWindowReordered(::mus::Window* window,
216 mus::Window* relative_window, 211 ::mus::Window* relative_window,
217 mus::mojom::OrderDirection direction) override; 212 ::mus::mojom::OrderDirection direction) override;
218 void OnWindowSharedPropertyChanged( 213 void OnWindowSharedPropertyChanged(
219 mus::Window* window, 214 ::mus::Window* window,
220 const std::string& name, 215 const std::string& name,
221 const std::vector<uint8_t>* old_data, 216 const std::vector<uint8_t>* old_data,
222 const std::vector<uint8_t>* new_data) override; 217 const std::vector<uint8_t>* new_data) override;
223 void OnWindowBoundsChanged(mus::Window* window, 218 void OnWindowBoundsChanged(::mus::Window* window,
224 const gfx::Rect& old_bounds, 219 const gfx::Rect& old_bounds,
225 const gfx::Rect& new_bounds) override; 220 const gfx::Rect& new_bounds) override;
226 void OnWindowDestroying(mus::Window* window) override; 221 void OnWindowDestroying(::mus::Window* window) override;
227 222
228 mus::Window* window_; 223 ::mus::Window* window_;
229 224
230 // The shell window id of this window. Shell window ids are defined in 225 // The shell window id of this window. Shell window ids are defined in
231 // ash/common/shell_window_ids.h. 226 // ash/common/shell_window_ids.h.
232 int shell_window_id_ = -1; 227 int shell_window_id_ = -1;
233 228
234 std::unique_ptr<ash::wm::WindowState> window_state_; 229 std::unique_ptr<wm::WindowState> window_state_;
235 230
236 views::Widget* widget_ = nullptr; 231 views::Widget* widget_ = nullptr;
237 232
238 WidgetCreationType widget_creation_type_ = WidgetCreationType::INTERNAL; 233 WidgetCreationType widget_creation_type_ = WidgetCreationType::INTERNAL;
239 234
240 base::ObserverList<ash::wm::WmWindowObserver> observers_; 235 base::ObserverList<wm::WmWindowObserver> observers_;
241 236
242 std::unique_ptr<MusLayoutManagerAdapter> layout_manager_adapter_; 237 std::unique_ptr<MusLayoutManagerAdapter> layout_manager_adapter_;
243 238
244 std::unique_ptr<gfx::Rect> restore_bounds_in_screen_; 239 std::unique_ptr<gfx::Rect> restore_bounds_in_screen_;
245 240
246 ui::WindowShowState restore_show_state_ = ui::SHOW_STATE_DEFAULT; 241 ui::WindowShowState restore_show_state_ = ui::SHOW_STATE_DEFAULT;
247 242
248 bool snap_children_to_pixel_boundary_ = false; 243 bool snap_children_to_pixel_boundary_ = false;
249 244
250 // If true child windows should get a slightly larger hit region to make 245 // If true child windows should get a slightly larger hit region to make
251 // resizing easier. 246 // resizing easier.
252 bool children_use_extended_hit_region_ = false; 247 bool children_use_extended_hit_region_ = false;
253 248
254 DISALLOW_COPY_AND_ASSIGN(WmWindowMus); 249 DISALLOW_COPY_AND_ASSIGN(WmWindowMus);
255 }; 250 };
256 251
257 } // namespace wm 252 } // namespace mus
258 } // namespace mash 253 } // namespace ash
259 254
260 #endif // MASH_WM_BRIDGE_WM_WINDOW_MUS_H_ 255 #endif // ASH_MUS_BRIDGE_WM_WINDOW_MUS_H_
OLDNEW
« no previous file with comments | « ash/mus/bridge/wm_shelf_mus.cc ('k') | ash/mus/bridge/wm_window_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698