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

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

Powered by Google App Engine
This is Rietveld 408576698