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

Side by Side Diff: mash/wm/bridge/wm_window_mus.h

Issue 1954933002: Initial cut of ash/wm/common classes for mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge to trunk Created 4 years, 7 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_root_window_controller_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/wm/common/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 explicit WmWindowMus(mus::Window* window);
38 // NOTE: this class is owned by the corresponding window. You shouldn't delete
39 // TODO(sky): friend deleter and make private.
40 ~WmWindowMus() override;
41
42 // Returns a WmWindow for an mus::Window, creating if necessary.
43 static WmWindowMus* Get(mus::Window* window);
44
45 static WmWindowMus* Get(views::Widget* widget);
46
47 static mus::Window* GetMusWindow(ash::wm::WmWindow* wm_window) {
48 return const_cast<mus::Window*>(
49 GetMusWindow(const_cast<const ash::wm::WmWindow*>(wm_window)));
50 }
51 static const mus::Window* GetMusWindow(const ash::wm::WmWindow* wm_window);
52
53 static std::vector<WmWindow*> FromMusWindows(
54 const std::vector<mus::Window*>& mus_windows);
55
56 // Sets the widget associated with the window. The widget is used to query
57 // state, such as min/max size. The widget is not owned by the WmWindowMus.
58 void set_widget(views::Widget* widget) { widget_ = widget; }
59
60 mus::Window* mus_window() { return window_; }
61 const mus::Window* mus_window() const { return window_; }
62
63 WmRootWindowControllerMus* GetRootWindowControllerMus() {
64 return const_cast<WmRootWindowControllerMus*>(
65 const_cast<const WmWindowMus*>(this)->GetRootWindowControllerMus());
66 }
67 const WmRootWindowControllerMus* GetRootWindowControllerMus() const;
68
69 static WmWindowMus* AsWmWindowMus(ash::wm::WmWindow* window) {
70 return static_cast<WmWindowMus*>(window);
71 }
72 static const WmWindowMus* AsWmWindowMus(const ash::wm::WmWindow* window) {
73 return static_cast<const WmWindowMus*>(window);
74 }
75
76 // WmWindow:
77 const ash::wm::WmWindow* GetRootWindow() const override;
78 ash::wm::WmRootWindowController* GetRootWindowController() override;
79 ash::wm::WmGlobals* GetGlobals() const override;
80 void SetShellWindowId(int id) override;
81 int GetShellWindowId() const override;
82 ash::wm::WmWindow* GetChildByShellWindowId(int id) override;
83 ui::wm::WindowType GetType() const override;
84 ui::Layer* GetLayer() override;
85 display::Display GetDisplayNearestWindow() override;
86 bool HasNonClientArea() override;
87 int GetNonClientComponent(const gfx::Point& location) override;
88 gfx::Point ConvertPointToTarget(const ash::wm::WmWindow* target,
89 const gfx::Point& point) const override;
90 gfx::Point ConvertPointToScreen(const gfx::Point& point) const override;
91 gfx::Point ConvertPointFromScreen(const gfx::Point& point) const override;
92 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const override;
93 gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const override;
94 gfx::Size GetMinimumSize() const override;
95 gfx::Size GetMaximumSize() const override;
96 bool GetTargetVisibility() const override;
97 bool IsVisible() const override;
98 bool IsSystemModal() const override;
99 bool GetBoolProperty(ash::wm::WmWindowProperty key) override;
100 int GetIntProperty(ash::wm::WmWindowProperty key) override;
101 const ash::wm::WindowState* GetWindowState() const override;
102 ash::wm::WmWindow* GetToplevelWindow() override;
103 void SetParentUsingContext(ash::wm::WmWindow* context,
104 const gfx::Rect& screen_bounds) override;
105 void AddChild(ash::wm::WmWindow* window) override;
106 ash::wm::WmWindow* GetParent() override;
107 const ash::wm::WmWindow* GetTransientParent() const override;
108 std::vector<ash::wm::WmWindow*> GetTransientChildren() override;
109 void SetLayoutManager(
110 std::unique_ptr<ash::wm::WmLayoutManager> layout_manager) override;
111 ash::wm::WmLayoutManager* GetLayoutManager() override;
112 void SetVisibilityAnimationType(int type) override;
113 void SetVisibilityAnimationDuration(base::TimeDelta delta) override;
114 void Animate(::wm::WindowAnimationType type) override;
115 void SetBounds(const gfx::Rect& bounds) override;
116 void SetBoundsWithTransitionDelay(const gfx::Rect& bounds,
117 base::TimeDelta delta) override;
118 void SetBoundsDirect(const gfx::Rect& bounds) override;
119 void SetBoundsDirectAnimated(const gfx::Rect& bounds) override;
120 void SetBoundsDirectCrossFade(const gfx::Rect& bounds) override;
121 void SetBoundsInScreen(const gfx::Rect& bounds_in_screen,
122 const display::Display& dst_display) override;
123 gfx::Rect GetBoundsInScreen() const override;
124 const gfx::Rect& GetBounds() const override;
125 gfx::Rect GetTargetBounds() override;
126 void ClearRestoreBounds() override;
127 void SetRestoreBoundsInScreen(const gfx::Rect& bounds) override;
128 gfx::Rect GetRestoreBoundsInScreen() const override;
129 bool Contains(const ash::wm::WmWindow* other) const override;
130 void SetShowState(ui::WindowShowState show_state) override;
131 ui::WindowShowState GetShowState() const override;
132 void SetRestoreShowState(ui::WindowShowState show_state) override;
133 void SetLockedToRoot(bool value) override;
134 void SetCapture() override;
135 bool HasCapture() override;
136 void ReleaseCapture() override;
137 bool HasRestoreBounds() const override;
138 void SetAlwaysOnTop(bool value) override;
139 bool IsAlwaysOnTop() const override;
140 void Hide() override;
141 void Show() override;
142 bool IsFocused() const override;
143 bool IsActive() const override;
144 void Activate() override;
145 void Deactivate() override;
146 void SetFullscreen() override;
147 void Maximize() override;
148 void Minimize() override;
149 void Unminimize() override;
150 bool CanMaximize() const override;
151 bool CanMinimize() const override;
152 bool CanResize() const override;
153 bool CanActivate() const override;
154 void StackChildAtTop(ash::wm::WmWindow* child) override;
155 void StackChildAtBottom(ash::wm::WmWindow* child) override;
156 void StackChildAbove(ash::wm::WmWindow* child,
157 ash::wm::WmWindow* target) override;
158 void StackChildBelow(ash::wm::WmWindow* child,
159 ash::wm::WmWindow* target) override;
160 std::vector<ash::wm::WmWindow*> GetChildren() override;
161 void SnapToPixelBoundaryIfNecessary() override;
162 void AddObserver(ash::wm::WmWindowObserver* observer) override;
163 void RemoveObserver(ash::wm::WmWindowObserver* observer) override;
164
165 private:
166 void NotifyStackingChanged();
167
168 // mus::WindowObserver:
169 void OnTreeChanged(const TreeChangeParams& params) override;
170 void OnWindowReordered(mus::Window* window,
171 mus::Window* relative_window,
172 mus::mojom::OrderDirection direction) override;
173 void OnWindowSharedPropertyChanged(
174 mus::Window* window,
175 const std::string& name,
176 const std::vector<uint8_t>* old_data,
177 const std::vector<uint8_t>* new_data) override;
178 void OnWindowBoundsChanged(mus::Window* window,
179 const gfx::Rect& old_bounds,
180 const gfx::Rect& new_bounds) override;
181 void OnWindowDestroying(mus::Window* window) override;
182
183 mus::Window* window_;
184 std::unique_ptr<ash::wm::WindowState> window_state_;
185
186 views::Widget* widget_ = nullptr;
187
188 base::ObserverList<ash::wm::WmWindowObserver> observers_;
189
190 std::unique_ptr<MusLayoutManagerAdapter> layout_manager_adapter_;
191
192 std::unique_ptr<gfx::Rect> restore_bounds_in_screen_;
193
194 ui::WindowShowState restore_show_state_ = ui::SHOW_STATE_DEFAULT;
195
196 DISALLOW_COPY_AND_ASSIGN(WmWindowMus);
197 };
198
199 } // namespace wm
200 } // namespace mash
201
202 #endif // MASH_WM_BRIDGE_WM_WINDOW_MUS_H_
OLDNEW
« no previous file with comments | « mash/wm/bridge/wm_root_window_controller_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