OLD | NEW |
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 #include "mash/wm/bridge/wm_window_mus.h" | 5 #include "ash/mus/bridge/wm_window_mus.h" |
6 | 6 |
7 #include "ash/common/wm/container_finder.h" | 7 #include "ash/common/wm/container_finder.h" |
8 #include "ash/common/wm/window_state.h" | 8 #include "ash/common/wm/window_state.h" |
9 #include "ash/common/wm/wm_layout_manager.h" | 9 #include "ash/common/wm/wm_layout_manager.h" |
10 #include "ash/common/wm/wm_window_observer.h" | 10 #include "ash/common/wm/wm_window_observer.h" |
11 #include "ash/common/wm/wm_window_property.h" | 11 #include "ash/common/wm/wm_window_property.h" |
| 12 #include "ash/mus/bridge/mus_layout_manager_adapter.h" |
| 13 #include "ash/mus/bridge/wm_globals_mus.h" |
| 14 #include "ash/mus/bridge/wm_root_window_controller_mus.h" |
| 15 #include "ash/mus/property_util.h" |
12 #include "components/mus/public/cpp/property_type_converters.h" | 16 #include "components/mus/public/cpp/property_type_converters.h" |
13 #include "components/mus/public/cpp/window.h" | 17 #include "components/mus/public/cpp/window.h" |
14 #include "components/mus/public/cpp/window_property.h" | 18 #include "components/mus/public/cpp/window_property.h" |
15 #include "components/mus/public/cpp/window_tree_client.h" | 19 #include "components/mus/public/cpp/window_tree_client.h" |
16 #include "components/mus/public/interfaces/window_manager.mojom.h" | 20 #include "components/mus/public/interfaces/window_manager.mojom.h" |
17 #include "mash/wm/bridge/mus_layout_manager_adapter.h" | |
18 #include "mash/wm/bridge/wm_globals_mus.h" | |
19 #include "mash/wm/bridge/wm_root_window_controller_mus.h" | |
20 #include "mash/wm/property_util.h" | |
21 #include "ui/aura/mus/mus_util.h" | 21 #include "ui/aura/mus/mus_util.h" |
22 #include "ui/base/hit_test.h" | 22 #include "ui/base/hit_test.h" |
23 #include "ui/display/display.h" | 23 #include "ui/display/display.h" |
24 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
25 #include "ui/views/widget/widget_delegate.h" | 25 #include "ui/views/widget/widget_delegate.h" |
26 | 26 |
27 MUS_DECLARE_WINDOW_PROPERTY_TYPE(mash::wm::WmWindowMus*); | 27 MUS_DECLARE_WINDOW_PROPERTY_TYPE(ash::mus::WmWindowMus*); |
28 | 28 |
29 // TODO(sky): fully implement this. Making DVLOG as too spammy to be useful. | 29 // TODO(sky): fully implement this. Making DVLOG as too spammy to be useful. |
30 #undef NOTIMPLEMENTED | 30 #undef NOTIMPLEMENTED |
31 #define NOTIMPLEMENTED() DVLOG(1) << "notimplemented" | 31 #define NOTIMPLEMENTED() DVLOG(1) << "notimplemented" |
32 | 32 |
33 namespace mash { | 33 namespace { |
34 namespace wm { | |
35 | 34 |
36 MUS_DEFINE_OWNED_WINDOW_PROPERTY_KEY(mash::wm::WmWindowMus, | 35 MUS_DEFINE_OWNED_WINDOW_PROPERTY_KEY(ash::mus::WmWindowMus, |
37 kWmWindowKey, | 36 kWmWindowKey, |
38 nullptr); | 37 nullptr); |
| 38 |
| 39 } // namespace |
| 40 |
| 41 namespace ash { |
| 42 namespace mus { |
| 43 |
39 namespace { | 44 namespace { |
40 | 45 |
41 // This classes is used so that the WindowState constructor can be made | 46 // This classes is used so that the WindowState constructor can be made |
42 // protected. GetWindowState() is the only place that should be creating | 47 // protected. GetWindowState() is the only place that should be creating |
43 // WindowState. | 48 // WindowState. |
44 class WindowStateMus : public ash::wm::WindowState { | 49 class WindowStateMus : public wm::WindowState { |
45 public: | 50 public: |
46 explicit WindowStateMus(ash::wm::WmWindow* window) | 51 explicit WindowStateMus(wm::WmWindow* window) : wm::WindowState(window) {} |
47 : ash::wm::WindowState(window) {} | |
48 ~WindowStateMus() override {} | 52 ~WindowStateMus() override {} |
49 | 53 |
50 private: | 54 private: |
51 DISALLOW_COPY_AND_ASSIGN(WindowStateMus); | 55 DISALLOW_COPY_AND_ASSIGN(WindowStateMus); |
52 }; | 56 }; |
53 | 57 |
54 ui::WindowShowState UIWindowShowStateFromMojom(mus::mojom::ShowState state) { | 58 ui::WindowShowState UIWindowShowStateFromMojom(::mus::mojom::ShowState state) { |
55 switch (state) { | 59 switch (state) { |
56 case mus::mojom::ShowState::DEFAULT: | 60 case ::mus::mojom::ShowState::DEFAULT: |
57 return ui::SHOW_STATE_DEFAULT; | 61 return ui::SHOW_STATE_DEFAULT; |
58 case mus::mojom::ShowState::NORMAL: | 62 case ::mus::mojom::ShowState::NORMAL: |
59 return ui::SHOW_STATE_NORMAL; | 63 return ui::SHOW_STATE_NORMAL; |
60 case mus::mojom::ShowState::MINIMIZED: | 64 case ::mus::mojom::ShowState::MINIMIZED: |
61 return ui::SHOW_STATE_MINIMIZED; | 65 return ui::SHOW_STATE_MINIMIZED; |
62 case mus::mojom::ShowState::MAXIMIZED: | 66 case ::mus::mojom::ShowState::MAXIMIZED: |
63 return ui::SHOW_STATE_MAXIMIZED; | 67 return ui::SHOW_STATE_MAXIMIZED; |
64 case mus::mojom::ShowState::INACTIVE: | 68 case ::mus::mojom::ShowState::INACTIVE: |
65 return ui::SHOW_STATE_INACTIVE; | 69 return ui::SHOW_STATE_INACTIVE; |
66 case mus::mojom::ShowState::FULLSCREEN: | 70 case ::mus::mojom::ShowState::FULLSCREEN: |
67 return ui::SHOW_STATE_FULLSCREEN; | 71 return ui::SHOW_STATE_FULLSCREEN; |
68 case mus::mojom::ShowState::DOCKED: | 72 case ::mus::mojom::ShowState::DOCKED: |
69 return ui::SHOW_STATE_DOCKED; | 73 return ui::SHOW_STATE_DOCKED; |
70 default: | 74 default: |
71 break; | 75 break; |
72 } | 76 } |
73 return ui::SHOW_STATE_DEFAULT; | 77 return ui::SHOW_STATE_DEFAULT; |
74 } | 78 } |
75 | 79 |
76 mus::mojom::ShowState MojomWindowShowStateFromUI(ui::WindowShowState state) { | 80 ::mus::mojom::ShowState MojomWindowShowStateFromUI(ui::WindowShowState state) { |
77 switch (state) { | 81 switch (state) { |
78 case ui::SHOW_STATE_DEFAULT: | 82 case ui::SHOW_STATE_DEFAULT: |
79 return mus::mojom::ShowState::DEFAULT; | 83 return ::mus::mojom::ShowState::DEFAULT; |
80 case ui::SHOW_STATE_NORMAL: | 84 case ui::SHOW_STATE_NORMAL: |
81 return mus::mojom::ShowState::NORMAL; | 85 return ::mus::mojom::ShowState::NORMAL; |
82 case ui::SHOW_STATE_MINIMIZED: | 86 case ui::SHOW_STATE_MINIMIZED: |
83 return mus::mojom::ShowState::MINIMIZED; | 87 return ::mus::mojom::ShowState::MINIMIZED; |
84 case ui::SHOW_STATE_MAXIMIZED: | 88 case ui::SHOW_STATE_MAXIMIZED: |
85 return mus::mojom::ShowState::MAXIMIZED; | 89 return ::mus::mojom::ShowState::MAXIMIZED; |
86 case ui::SHOW_STATE_INACTIVE: | 90 case ui::SHOW_STATE_INACTIVE: |
87 return mus::mojom::ShowState::INACTIVE; | 91 return ::mus::mojom::ShowState::INACTIVE; |
88 case ui::SHOW_STATE_FULLSCREEN: | 92 case ui::SHOW_STATE_FULLSCREEN: |
89 return mus::mojom::ShowState::FULLSCREEN; | 93 return ::mus::mojom::ShowState::FULLSCREEN; |
90 case ui::SHOW_STATE_DOCKED: | 94 case ui::SHOW_STATE_DOCKED: |
91 return mus::mojom::ShowState::DOCKED; | 95 return ::mus::mojom::ShowState::DOCKED; |
92 default: | 96 default: |
93 break; | 97 break; |
94 } | 98 } |
95 return mus::mojom::ShowState::DEFAULT; | 99 return ::mus::mojom::ShowState::DEFAULT; |
96 } | 100 } |
97 | 101 |
98 } // namespace | 102 } // namespace |
99 | 103 |
100 WmWindowMus::WmWindowMus(mus::Window* window) | 104 WmWindowMus::WmWindowMus(::mus::Window* window) |
101 : window_(window), | 105 : window_(window), |
102 // Matches aura, see aura::Window for details. | 106 // Matches aura, see aura::Window for details. |
103 observers_( | 107 observers_( |
104 base::ObserverList<ash::wm::WmWindowObserver>::NOTIFY_EXISTING_ONLY) { | 108 base::ObserverList<wm::WmWindowObserver>::NOTIFY_EXISTING_ONLY) { |
105 window_->AddObserver(this); | 109 window_->AddObserver(this); |
106 window_->SetLocalProperty(kWmWindowKey, this); | 110 window_->SetLocalProperty(kWmWindowKey, this); |
107 window_state_.reset(new WindowStateMus(this)); | 111 window_state_.reset(new WindowStateMus(this)); |
108 } | 112 } |
109 | 113 |
110 WmWindowMus::~WmWindowMus() { | 114 WmWindowMus::~WmWindowMus() { |
111 window_->RemoveObserver(this); | 115 window_->RemoveObserver(this); |
112 } | 116 } |
113 | 117 |
114 // static | 118 // static |
115 WmWindowMus* WmWindowMus::Get(mus::Window* window) { | 119 WmWindowMus* WmWindowMus::Get(::mus::Window* window) { |
116 if (!window) | 120 if (!window) |
117 return nullptr; | 121 return nullptr; |
118 | 122 |
119 wm::WmWindowMus* wm_window = window->GetLocalProperty(kWmWindowKey); | 123 WmWindowMus* wm_window = window->GetLocalProperty(kWmWindowKey); |
120 if (wm_window) | 124 if (wm_window) |
121 return wm_window; | 125 return wm_window; |
122 // WmWindowMus is owned by the mus::Window. | 126 // WmWindowMus is owned by the mus::Window. |
123 return new WmWindowMus(window); | 127 return new WmWindowMus(window); |
124 } | 128 } |
125 | 129 |
126 // static | 130 // static |
127 WmWindowMus* WmWindowMus::Get(views::Widget* widget) { | 131 WmWindowMus* WmWindowMus::Get(views::Widget* widget) { |
128 return WmWindowMus::Get(aura::GetMusWindow(widget->GetNativeView())); | 132 return WmWindowMus::Get(aura::GetMusWindow(widget->GetNativeView())); |
129 } | 133 } |
130 | 134 |
131 // static | 135 // static |
132 const mus::Window* WmWindowMus::GetMusWindow( | 136 const ::mus::Window* WmWindowMus::GetMusWindow(const wm::WmWindow* wm_window) { |
133 const ash::wm::WmWindow* wm_window) { | |
134 return static_cast<const WmWindowMus*>(wm_window)->mus_window(); | 137 return static_cast<const WmWindowMus*>(wm_window)->mus_window(); |
135 } | 138 } |
136 | 139 |
137 // static | 140 // static |
138 std::vector<ash::wm::WmWindow*> WmWindowMus::FromMusWindows( | 141 std::vector<wm::WmWindow*> WmWindowMus::FromMusWindows( |
139 const std::vector<mus::Window*>& mus_windows) { | 142 const std::vector<::mus::Window*>& mus_windows) { |
140 std::vector<ash::wm::WmWindow*> result(mus_windows.size()); | 143 std::vector<wm::WmWindow*> result(mus_windows.size()); |
141 for (size_t i = 0; i < mus_windows.size(); ++i) | 144 for (size_t i = 0; i < mus_windows.size(); ++i) |
142 result[i] = Get(mus_windows[i]); | 145 result[i] = Get(mus_windows[i]); |
143 return result; | 146 return result; |
144 } | 147 } |
145 | 148 |
146 const WmRootWindowControllerMus* WmWindowMus::GetRootWindowControllerMus() | 149 const WmRootWindowControllerMus* WmWindowMus::GetRootWindowControllerMus() |
147 const { | 150 const { |
148 return WmRootWindowControllerMus::Get(window_->GetRoot()); | 151 return WmRootWindowControllerMus::Get(window_->GetRoot()); |
149 } | 152 } |
150 | 153 |
151 bool WmWindowMus::ShouldUseExtendedHitRegion() const { | 154 bool WmWindowMus::ShouldUseExtendedHitRegion() const { |
152 const WmWindowMus* parent = Get(window_->parent()); | 155 const WmWindowMus* parent = Get(window_->parent()); |
153 return parent && parent->children_use_extended_hit_region_; | 156 return parent && parent->children_use_extended_hit_region_; |
154 } | 157 } |
155 | 158 |
156 const ash::wm::WmWindow* WmWindowMus::GetRootWindow() const { | 159 const wm::WmWindow* WmWindowMus::GetRootWindow() const { |
157 return Get(window_->GetRoot()); | 160 return Get(window_->GetRoot()); |
158 } | 161 } |
159 | 162 |
160 ash::wm::WmRootWindowController* WmWindowMus::GetRootWindowController() { | 163 wm::WmRootWindowController* WmWindowMus::GetRootWindowController() { |
161 return GetRootWindowControllerMus(); | 164 return GetRootWindowControllerMus(); |
162 } | 165 } |
163 | 166 |
164 ash::wm::WmGlobals* WmWindowMus::GetGlobals() const { | 167 wm::WmGlobals* WmWindowMus::GetGlobals() const { |
165 return WmGlobalsMus::Get(); | 168 return WmGlobalsMus::Get(); |
166 } | 169 } |
167 | 170 |
168 void WmWindowMus::SetName(const char* name) { | 171 void WmWindowMus::SetName(const char* name) { |
169 if (name) { | 172 if (name) { |
170 window_->SetSharedProperty<std::string>( | 173 window_->SetSharedProperty<std::string>( |
171 mus::mojom::WindowManager::kName_Property, std::string(name)); | 174 ::mus::mojom::WindowManager::kName_Property, std::string(name)); |
172 } else { | 175 } else { |
173 window_->ClearSharedProperty(mus::mojom::WindowManager::kName_Property); | 176 window_->ClearSharedProperty(::mus::mojom::WindowManager::kName_Property); |
174 } | 177 } |
175 } | 178 } |
176 | 179 |
177 base::string16 WmWindowMus::GetTitle() const { | 180 base::string16 WmWindowMus::GetTitle() const { |
178 return GetWindowTitle(window_); | 181 return GetWindowTitle(window_); |
179 } | 182 } |
180 | 183 |
181 void WmWindowMus::SetShellWindowId(int id) { | 184 void WmWindowMus::SetShellWindowId(int id) { |
182 shell_window_id_ = id; | 185 shell_window_id_ = id; |
183 } | 186 } |
(...skipping 20 matching lines...) Expand all Loading... |
204 bool WmWindowMus::HasNonClientArea() { | 207 bool WmWindowMus::HasNonClientArea() { |
205 return widget_ ? true : false; | 208 return widget_ ? true : false; |
206 } | 209 } |
207 | 210 |
208 int WmWindowMus::GetNonClientComponent(const gfx::Point& location) { | 211 int WmWindowMus::GetNonClientComponent(const gfx::Point& location) { |
209 return widget_ ? widget_->GetNonClientComponent(location) : HTNOWHERE; | 212 return widget_ ? widget_->GetNonClientComponent(location) : HTNOWHERE; |
210 } | 213 } |
211 | 214 |
212 gfx::Point WmWindowMus::ConvertPointToTarget(const WmWindow* target, | 215 gfx::Point WmWindowMus::ConvertPointToTarget(const WmWindow* target, |
213 const gfx::Point& point) const { | 216 const gfx::Point& point) const { |
214 const mus::Window* target_window = GetMusWindow(target); | 217 const ::mus::Window* target_window = GetMusWindow(target); |
215 if (target_window->Contains(window_)) { | 218 if (target_window->Contains(window_)) { |
216 gfx::Point result(point); | 219 gfx::Point result(point); |
217 const mus::Window* window = window_; | 220 const ::mus::Window* window = window_; |
218 while (window != target_window) { | 221 while (window != target_window) { |
219 result += window->bounds().origin().OffsetFromOrigin(); | 222 result += window->bounds().origin().OffsetFromOrigin(); |
220 window = window->parent(); | 223 window = window->parent(); |
221 } | 224 } |
222 return result; | 225 return result; |
223 } | 226 } |
224 if (window_->Contains(target_window)) { | 227 if (window_->Contains(target_window)) { |
225 gfx::Point result(point); | 228 gfx::Point result(point); |
226 result -= | 229 result -= |
227 target->ConvertPointToTarget(this, gfx::Point()).OffsetFromOrigin(); | 230 target->ConvertPointToTarget(this, gfx::Point()).OffsetFromOrigin(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 gfx::Transform WmWindowMus::GetTargetTransform() const { | 289 gfx::Transform WmWindowMus::GetTargetTransform() const { |
287 // TODO: need animation support: http://crbug.com/615087. | 290 // TODO: need animation support: http://crbug.com/615087. |
288 return gfx::Transform(); | 291 return gfx::Transform(); |
289 } | 292 } |
290 | 293 |
291 bool WmWindowMus::IsSystemModal() const { | 294 bool WmWindowMus::IsSystemModal() const { |
292 NOTIMPLEMENTED(); | 295 NOTIMPLEMENTED(); |
293 return false; | 296 return false; |
294 } | 297 } |
295 | 298 |
296 bool WmWindowMus::GetBoolProperty(ash::wm::WmWindowProperty key) { | 299 bool WmWindowMus::GetBoolProperty(wm::WmWindowProperty key) { |
297 switch (key) { | 300 switch (key) { |
298 case ash::wm::WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY: | 301 case wm::WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY: |
299 return snap_children_to_pixel_boundary_; | 302 return snap_children_to_pixel_boundary_; |
300 | 303 |
301 case ash::wm::WmWindowProperty::ALWAYS_ON_TOP: | 304 case wm::WmWindowProperty::ALWAYS_ON_TOP: |
302 return IsAlwaysOnTop(); | 305 return IsAlwaysOnTop(); |
303 | 306 |
304 default: | 307 default: |
305 NOTREACHED(); | 308 NOTREACHED(); |
306 break; | 309 break; |
307 } | 310 } |
308 | 311 |
309 NOTREACHED(); | 312 NOTREACHED(); |
310 return false; | 313 return false; |
311 } | 314 } |
312 | 315 |
313 int WmWindowMus::GetIntProperty(ash::wm::WmWindowProperty key) { | 316 int WmWindowMus::GetIntProperty(wm::WmWindowProperty key) { |
314 if (key == ash::wm::WmWindowProperty::SHELF_ID) { | 317 if (key == wm::WmWindowProperty::SHELF_ID) { |
315 NOTIMPLEMENTED(); | 318 NOTIMPLEMENTED(); |
316 return 0; | 319 return 0; |
317 } | 320 } |
318 | 321 |
319 if (key == ash::wm::WmWindowProperty::TOP_VIEW_INSET) { | 322 if (key == wm::WmWindowProperty::TOP_VIEW_INSET) { |
320 // TODO: need support for TOP_VIEW_INSET: http://crbug.com/615100. | 323 // TODO: need support for TOP_VIEW_INSET: http://crbug.com/615100. |
321 NOTIMPLEMENTED(); | 324 NOTIMPLEMENTED(); |
322 return 0; | 325 return 0; |
323 } | 326 } |
324 | 327 |
325 NOTREACHED(); | 328 NOTREACHED(); |
326 return 0; | 329 return 0; |
327 } | 330 } |
328 | 331 |
329 const ash::wm::WindowState* WmWindowMus::GetWindowState() const { | 332 const wm::WindowState* WmWindowMus::GetWindowState() const { |
330 return window_state_.get(); | 333 return window_state_.get(); |
331 } | 334 } |
332 | 335 |
333 ash::wm::WmWindow* WmWindowMus::GetToplevelWindow() { | 336 wm::WmWindow* WmWindowMus::GetToplevelWindow() { |
334 return WmGlobalsMus::GetToplevelAncestor(window_); | 337 return WmGlobalsMus::GetToplevelAncestor(window_); |
335 } | 338 } |
336 | 339 |
337 void WmWindowMus::SetParentUsingContext(WmWindow* context, | 340 void WmWindowMus::SetParentUsingContext(WmWindow* context, |
338 const gfx::Rect& screen_bounds) { | 341 const gfx::Rect& screen_bounds) { |
339 GetDefaultParent(context, this, screen_bounds)->AddChild(this); | 342 GetDefaultParent(context, this, screen_bounds)->AddChild(this); |
340 } | 343 } |
341 | 344 |
342 void WmWindowMus::AddChild(WmWindow* window) { | 345 void WmWindowMus::AddChild(WmWindow* window) { |
343 window_->AddChild(GetMusWindow(window)); | 346 window_->AddChild(GetMusWindow(window)); |
344 } | 347 } |
345 | 348 |
346 ash::wm::WmWindow* WmWindowMus::GetParent() { | 349 wm::WmWindow* WmWindowMus::GetParent() { |
347 return Get(window_->parent()); | 350 return Get(window_->parent()); |
348 } | 351 } |
349 | 352 |
350 const ash::wm::WmWindow* WmWindowMus::GetTransientParent() const { | 353 const wm::WmWindow* WmWindowMus::GetTransientParent() const { |
351 return Get(window_->transient_parent()); | 354 return Get(window_->transient_parent()); |
352 } | 355 } |
353 | 356 |
354 std::vector<ash::wm::WmWindow*> WmWindowMus::GetTransientChildren() { | 357 std::vector<wm::WmWindow*> WmWindowMus::GetTransientChildren() { |
355 return FromMusWindows(window_->transient_children()); | 358 return FromMusWindows(window_->transient_children()); |
356 } | 359 } |
357 | 360 |
358 void WmWindowMus::SetLayoutManager( | 361 void WmWindowMus::SetLayoutManager( |
359 std::unique_ptr<ash::wm::WmLayoutManager> layout_manager) { | 362 std::unique_ptr<wm::WmLayoutManager> layout_manager) { |
360 if (layout_manager) { | 363 if (layout_manager) { |
361 layout_manager_adapter_.reset( | 364 layout_manager_adapter_.reset( |
362 new MusLayoutManagerAdapter(window_, std::move(layout_manager))); | 365 new MusLayoutManagerAdapter(window_, std::move(layout_manager))); |
363 } else { | 366 } else { |
364 layout_manager_adapter_.reset(); | 367 layout_manager_adapter_.reset(); |
365 } | 368 } |
366 } | 369 } |
367 | 370 |
368 ash::wm::WmLayoutManager* WmWindowMus::GetLayoutManager() { | 371 wm::WmLayoutManager* WmWindowMus::GetLayoutManager() { |
369 return layout_manager_adapter_ ? layout_manager_adapter_->layout_manager() | 372 return layout_manager_adapter_ ? layout_manager_adapter_->layout_manager() |
370 : nullptr; | 373 : nullptr; |
371 } | 374 } |
372 | 375 |
373 void WmWindowMus::SetVisibilityAnimationType(int type) { | 376 void WmWindowMus::SetVisibilityAnimationType(int type) { |
374 // TODO: need animation support: http://crbug.com/615087. | 377 // TODO: need animation support: http://crbug.com/615087. |
375 NOTIMPLEMENTED(); | 378 NOTIMPLEMENTED(); |
376 } | 379 } |
377 | 380 |
378 void WmWindowMus::SetVisibilityAnimationDuration(base::TimeDelta delta) { | 381 void WmWindowMus::SetVisibilityAnimationDuration(base::TimeDelta delta) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 } | 473 } |
471 | 474 |
472 void WmWindowMus::SetRestoreBoundsInScreen(const gfx::Rect& bounds) { | 475 void WmWindowMus::SetRestoreBoundsInScreen(const gfx::Rect& bounds) { |
473 restore_bounds_in_screen_.reset(new gfx::Rect(bounds)); | 476 restore_bounds_in_screen_.reset(new gfx::Rect(bounds)); |
474 } | 477 } |
475 | 478 |
476 gfx::Rect WmWindowMus::GetRestoreBoundsInScreen() const { | 479 gfx::Rect WmWindowMus::GetRestoreBoundsInScreen() const { |
477 return *restore_bounds_in_screen_; | 480 return *restore_bounds_in_screen_; |
478 } | 481 } |
479 | 482 |
480 bool WmWindowMus::Contains(const ash::wm::WmWindow* other) const { | 483 bool WmWindowMus::Contains(const wm::WmWindow* other) const { |
481 return other | 484 return other |
482 ? window_->Contains( | 485 ? window_->Contains( |
483 static_cast<const WmWindowMus*>(other)->window_) | 486 static_cast<const WmWindowMus*>(other)->window_) |
484 : false; | 487 : false; |
485 } | 488 } |
486 | 489 |
487 void WmWindowMus::SetShowState(ui::WindowShowState show_state) { | 490 void WmWindowMus::SetShowState(ui::WindowShowState show_state) { |
488 SetWindowShowState(window_, MojomWindowShowStateFromUI(show_state)); | 491 SetWindowShowState(window_, MojomWindowShowStateFromUI(show_state)); |
489 } | 492 } |
490 | 493 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 bool WmWindowMus::CanResize() const { | 531 bool WmWindowMus::CanResize() const { |
529 return widget_ ? widget_->widget_delegate()->CanResize() : false; | 532 return widget_ ? widget_->widget_delegate()->CanResize() : false; |
530 } | 533 } |
531 | 534 |
532 bool WmWindowMus::CanActivate() const { | 535 bool WmWindowMus::CanActivate() const { |
533 // TODO(sky): this isn't quite right. Should key off CanFocus(), which is not | 536 // TODO(sky): this isn't quite right. Should key off CanFocus(), which is not |
534 // replicated. | 537 // replicated. |
535 return widget_ != nullptr; | 538 return widget_ != nullptr; |
536 } | 539 } |
537 | 540 |
538 void WmWindowMus::StackChildAtTop(ash::wm::WmWindow* child) { | 541 void WmWindowMus::StackChildAtTop(wm::WmWindow* child) { |
539 GetMusWindow(child)->MoveToFront(); | 542 GetMusWindow(child)->MoveToFront(); |
540 } | 543 } |
541 | 544 |
542 void WmWindowMus::StackChildAtBottom(ash::wm::WmWindow* child) { | 545 void WmWindowMus::StackChildAtBottom(wm::WmWindow* child) { |
543 GetMusWindow(child)->MoveToBack(); | 546 GetMusWindow(child)->MoveToBack(); |
544 } | 547 } |
545 | 548 |
546 void WmWindowMus::StackChildAbove(ash::wm::WmWindow* child, | 549 void WmWindowMus::StackChildAbove(wm::WmWindow* child, wm::WmWindow* target) { |
547 ash::wm::WmWindow* target) { | |
548 GetMusWindow(child)->Reorder(GetMusWindow(target), | 550 GetMusWindow(child)->Reorder(GetMusWindow(target), |
549 mus::mojom::OrderDirection::ABOVE); | 551 ::mus::mojom::OrderDirection::ABOVE); |
550 } | 552 } |
551 | 553 |
552 void WmWindowMus::StackChildBelow(WmWindow* child, WmWindow* target) { | 554 void WmWindowMus::StackChildBelow(WmWindow* child, WmWindow* target) { |
553 GetMusWindow(child)->Reorder(GetMusWindow(target), | 555 GetMusWindow(child)->Reorder(GetMusWindow(target), |
554 mus::mojom::OrderDirection::BELOW); | 556 ::mus::mojom::OrderDirection::BELOW); |
555 } | 557 } |
556 | 558 |
557 void WmWindowMus::SetAlwaysOnTop(bool value) { | 559 void WmWindowMus::SetAlwaysOnTop(bool value) { |
558 mash::wm::SetAlwaysOnTop(window_, value); | 560 mus::SetAlwaysOnTop(window_, value); |
559 } | 561 } |
560 | 562 |
561 bool WmWindowMus::IsAlwaysOnTop() const { | 563 bool WmWindowMus::IsAlwaysOnTop() const { |
562 return mash::wm::IsAlwaysOnTop(window_); | 564 return mus::IsAlwaysOnTop(window_); |
563 } | 565 } |
564 | 566 |
565 void WmWindowMus::Hide() { | 567 void WmWindowMus::Hide() { |
566 window_->SetVisible(false); | 568 window_->SetVisible(false); |
567 } | 569 } |
568 | 570 |
569 void WmWindowMus::Show() { | 571 void WmWindowMus::Show() { |
570 window_->SetVisible(true); | 572 window_->SetVisible(true); |
571 } | 573 } |
572 | 574 |
573 void WmWindowMus::CloseWidget() { | 575 void WmWindowMus::CloseWidget() { |
574 DCHECK(widget_); | 576 DCHECK(widget_); |
575 // Allow the client to service the close request for remote widgets. | 577 // Allow the client to service the close request for remote widgets. |
576 if (widget_creation_type_ == WidgetCreationType::FOR_CLIENT) | 578 if (widget_creation_type_ == WidgetCreationType::FOR_CLIENT) |
577 window_->RequestClose(); | 579 window_->RequestClose(); |
578 else | 580 else |
579 widget_->Close(); | 581 widget_->Close(); |
580 } | 582 } |
581 | 583 |
582 bool WmWindowMus::IsFocused() const { | 584 bool WmWindowMus::IsFocused() const { |
583 return window_->HasFocus(); | 585 return window_->HasFocus(); |
584 } | 586 } |
585 | 587 |
586 bool WmWindowMus::IsActive() const { | 588 bool WmWindowMus::IsActive() const { |
587 mus::Window* focused = window_->window_tree()->GetFocusedWindow(); | 589 ::mus::Window* focused = window_->window_tree()->GetFocusedWindow(); |
588 return focused && window_->Contains(focused); | 590 return focused && window_->Contains(focused); |
589 } | 591 } |
590 | 592 |
591 void WmWindowMus::Activate() { | 593 void WmWindowMus::Activate() { |
592 window_->SetFocus(); | 594 window_->SetFocus(); |
593 ash::wm::WmWindow* top_level = GetToplevelWindow(); | 595 wm::WmWindow* top_level = GetToplevelWindow(); |
594 if (!top_level) | 596 if (!top_level) |
595 return; | 597 return; |
596 | 598 |
597 // TODO(sky): mus should do this too. | 599 // TODO(sky): mus should do this too. |
598 GetMusWindow(top_level)->MoveToFront(); | 600 GetMusWindow(top_level)->MoveToFront(); |
599 } | 601 } |
600 | 602 |
601 void WmWindowMus::Deactivate() { | 603 void WmWindowMus::Deactivate() { |
602 if (IsActive()) | 604 if (IsActive()) |
603 window_->window_tree()->ClearFocus(); | 605 window_->window_tree()->ClearFocus(); |
604 } | 606 } |
605 | 607 |
606 void WmWindowMus::SetFullscreen() { | 608 void WmWindowMus::SetFullscreen() { |
607 SetWindowShowState(window_, mus::mojom::ShowState::FULLSCREEN); | 609 SetWindowShowState(window_, ::mus::mojom::ShowState::FULLSCREEN); |
608 } | 610 } |
609 | 611 |
610 void WmWindowMus::Maximize() { | 612 void WmWindowMus::Maximize() { |
611 SetWindowShowState(window_, mus::mojom::ShowState::MAXIMIZED); | 613 SetWindowShowState(window_, ::mus::mojom::ShowState::MAXIMIZED); |
612 } | 614 } |
613 | 615 |
614 void WmWindowMus::Minimize() { | 616 void WmWindowMus::Minimize() { |
615 SetWindowShowState(window_, mus::mojom::ShowState::MINIMIZED); | 617 SetWindowShowState(window_, ::mus::mojom::ShowState::MINIMIZED); |
616 } | 618 } |
617 | 619 |
618 void WmWindowMus::Unminimize() { | 620 void WmWindowMus::Unminimize() { |
619 SetWindowShowState(window_, MojomWindowShowStateFromUI(restore_show_state_)); | 621 SetWindowShowState(window_, MojomWindowShowStateFromUI(restore_show_state_)); |
620 restore_show_state_ = ui::SHOW_STATE_DEFAULT; | 622 restore_show_state_ = ui::SHOW_STATE_DEFAULT; |
621 } | 623 } |
622 | 624 |
623 std::vector<ash::wm::WmWindow*> WmWindowMus::GetChildren() { | 625 std::vector<wm::WmWindow*> WmWindowMus::GetChildren() { |
624 return FromMusWindows(window_->children()); | 626 return FromMusWindows(window_->children()); |
625 } | 627 } |
626 | 628 |
627 ash::wm::WmWindow* WmWindowMus::GetChildByShellWindowId(int id) { | 629 wm::WmWindow* WmWindowMus::GetChildByShellWindowId(int id) { |
628 if (id == shell_window_id_) | 630 if (id == shell_window_id_) |
629 return this; | 631 return this; |
630 for (mus::Window* child : window_->children()) { | 632 for (::mus::Window* child : window_->children()) { |
631 ash::wm::WmWindow* result = Get(child)->GetChildByShellWindowId(id); | 633 wm::WmWindow* result = Get(child)->GetChildByShellWindowId(id); |
632 if (result) | 634 if (result) |
633 return result; | 635 return result; |
634 } | 636 } |
635 return nullptr; | 637 return nullptr; |
636 } | 638 } |
637 | 639 |
638 void WmWindowMus::ShowResizeShadow(int component) { | 640 void WmWindowMus::ShowResizeShadow(int component) { |
639 NOTIMPLEMENTED(); | 641 NOTIMPLEMENTED(); |
640 } | 642 } |
641 | 643 |
642 void WmWindowMus::HideResizeShadow() { | 644 void WmWindowMus::HideResizeShadow() { |
643 NOTIMPLEMENTED(); | 645 NOTIMPLEMENTED(); |
644 } | 646 } |
645 | 647 |
646 void WmWindowMus::SetBoundsInScreenBehaviorForChildren( | 648 void WmWindowMus::SetBoundsInScreenBehaviorForChildren( |
647 ash::wm::WmWindow::BoundsInScreenBehavior behavior) { | 649 wm::WmWindow::BoundsInScreenBehavior behavior) { |
648 // TODO: SetBoundsInScreen isn't fully implemented yet, | 650 // TODO: SetBoundsInScreen isn't fully implemented yet, |
649 // http://crbug.com/615552. | 651 // http://crbug.com/615552. |
650 NOTIMPLEMENTED(); | 652 NOTIMPLEMENTED(); |
651 } | 653 } |
652 | 654 |
653 void WmWindowMus::SetSnapsChildrenToPhysicalPixelBoundary() { | 655 void WmWindowMus::SetSnapsChildrenToPhysicalPixelBoundary() { |
654 if (snap_children_to_pixel_boundary_) | 656 if (snap_children_to_pixel_boundary_) |
655 return; | 657 return; |
656 | 658 |
657 snap_children_to_pixel_boundary_ = true; | 659 snap_children_to_pixel_boundary_ = true; |
658 FOR_EACH_OBSERVER( | 660 FOR_EACH_OBSERVER( |
659 ash::wm::WmWindowObserver, observers_, | 661 wm::WmWindowObserver, observers_, |
660 OnWindowPropertyChanged( | 662 OnWindowPropertyChanged( |
661 this, ash::wm::WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY)); | 663 this, wm::WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY)); |
662 } | 664 } |
663 | 665 |
664 void WmWindowMus::SnapToPixelBoundaryIfNecessary() { | 666 void WmWindowMus::SnapToPixelBoundaryIfNecessary() { |
665 WmWindowMus* parent = Get(window_->parent()); | 667 WmWindowMus* parent = Get(window_->parent()); |
666 if (parent && parent->snap_children_to_pixel_boundary_) { | 668 if (parent && parent->snap_children_to_pixel_boundary_) { |
667 // TODO: implement snap to pixel: http://crbug.com/615554. | 669 // TODO: implement snap to pixel: http://crbug.com/615554. |
668 NOTIMPLEMENTED(); | 670 NOTIMPLEMENTED(); |
669 } | 671 } |
670 } | 672 } |
671 | 673 |
672 void WmWindowMus::SetChildrenUseExtendedHitRegion() { | 674 void WmWindowMus::SetChildrenUseExtendedHitRegion() { |
673 children_use_extended_hit_region_ = true; | 675 children_use_extended_hit_region_ = true; |
674 } | 676 } |
675 | 677 |
676 void WmWindowMus::SetDescendantsStayInSameRootWindow(bool value) { | 678 void WmWindowMus::SetDescendantsStayInSameRootWindow(bool value) { |
677 // TODO: this logic feeds into SetBoundsInScreen(), which is not implemented: | 679 // TODO: this logic feeds into SetBoundsInScreen(), which is not implemented: |
678 // http://crbug.com/615552. | 680 // http://crbug.com/615552. |
679 NOTIMPLEMENTED(); | 681 NOTIMPLEMENTED(); |
680 } | 682 } |
681 | 683 |
682 void WmWindowMus::AddObserver(ash::wm::WmWindowObserver* observer) { | 684 void WmWindowMus::AddObserver(wm::WmWindowObserver* observer) { |
683 observers_.AddObserver(observer); | 685 observers_.AddObserver(observer); |
684 } | 686 } |
685 | 687 |
686 void WmWindowMus::RemoveObserver(ash::wm::WmWindowObserver* observer) { | 688 void WmWindowMus::RemoveObserver(wm::WmWindowObserver* observer) { |
687 observers_.RemoveObserver(observer); | 689 observers_.RemoveObserver(observer); |
688 } | 690 } |
689 | 691 |
690 void WmWindowMus::OnTreeChanged(const TreeChangeParams& params) { | 692 void WmWindowMus::OnTreeChanged(const TreeChangeParams& params) { |
691 ash::wm::WmWindowObserver::TreeChangeParams wm_params; | 693 wm::WmWindowObserver::TreeChangeParams wm_params; |
692 wm_params.target = Get(params.target); | 694 wm_params.target = Get(params.target); |
693 wm_params.new_parent = Get(params.new_parent); | 695 wm_params.new_parent = Get(params.new_parent); |
694 wm_params.old_parent = Get(params.old_parent); | 696 wm_params.old_parent = Get(params.old_parent); |
695 FOR_EACH_OBSERVER(ash::wm::WmWindowObserver, observers_, | 697 FOR_EACH_OBSERVER(wm::WmWindowObserver, observers_, |
696 OnWindowTreeChanged(this, wm_params)); | 698 OnWindowTreeChanged(this, wm_params)); |
697 } | 699 } |
698 | 700 |
699 void WmWindowMus::OnWindowReordered(mus::Window* window, | 701 void WmWindowMus::OnWindowReordered(::mus::Window* window, |
700 mus::Window* relative_window, | 702 ::mus::Window* relative_window, |
701 mus::mojom::OrderDirection direction) { | 703 ::mus::mojom::OrderDirection direction) { |
702 FOR_EACH_OBSERVER(ash::wm::WmWindowObserver, observers_, | 704 FOR_EACH_OBSERVER(wm::WmWindowObserver, observers_, |
703 OnWindowStackingChanged(this)); | 705 OnWindowStackingChanged(this)); |
704 } | 706 } |
705 | 707 |
706 void WmWindowMus::OnWindowSharedPropertyChanged( | 708 void WmWindowMus::OnWindowSharedPropertyChanged( |
707 mus::Window* window, | 709 ::mus::Window* window, |
708 const std::string& name, | 710 const std::string& name, |
709 const std::vector<uint8_t>* old_data, | 711 const std::vector<uint8_t>* old_data, |
710 const std::vector<uint8_t>* new_data) { | 712 const std::vector<uint8_t>* new_data) { |
711 if (name == mus::mojom::WindowManager::kShowState_Property) { | 713 if (name == ::mus::mojom::WindowManager::kShowState_Property) { |
712 GetWindowState()->OnWindowShowStateChanged(); | 714 GetWindowState()->OnWindowShowStateChanged(); |
713 return; | 715 return; |
714 } | 716 } |
715 if (name == mus::mojom::WindowManager::kAlwaysOnTop_Property) { | 717 if (name == ::mus::mojom::WindowManager::kAlwaysOnTop_Property) { |
716 FOR_EACH_OBSERVER(ash::wm::WmWindowObserver, observers_, | 718 FOR_EACH_OBSERVER( |
717 OnWindowPropertyChanged( | 719 wm::WmWindowObserver, observers_, |
718 this, ash::wm::WmWindowProperty::ALWAYS_ON_TOP)); | 720 OnWindowPropertyChanged(this, wm::WmWindowProperty::ALWAYS_ON_TOP)); |
719 return; | 721 return; |
720 } | 722 } |
721 | 723 |
722 // Deal with snap to pixel. | 724 // Deal with snap to pixel. |
723 NOTIMPLEMENTED(); | 725 NOTIMPLEMENTED(); |
724 } | 726 } |
725 | 727 |
726 void WmWindowMus::OnWindowBoundsChanged(mus::Window* window, | 728 void WmWindowMus::OnWindowBoundsChanged(::mus::Window* window, |
727 const gfx::Rect& old_bounds, | 729 const gfx::Rect& old_bounds, |
728 const gfx::Rect& new_bounds) { | 730 const gfx::Rect& new_bounds) { |
729 FOR_EACH_OBSERVER(ash::wm::WmWindowObserver, observers_, | 731 FOR_EACH_OBSERVER(wm::WmWindowObserver, observers_, |
730 OnWindowBoundsChanged(this, old_bounds, new_bounds)); | 732 OnWindowBoundsChanged(this, old_bounds, new_bounds)); |
731 } | 733 } |
732 | 734 |
733 void WmWindowMus::OnWindowDestroying(mus::Window* window) { | 735 void WmWindowMus::OnWindowDestroying(::mus::Window* window) { |
734 FOR_EACH_OBSERVER(ash::wm::WmWindowObserver, observers_, | 736 FOR_EACH_OBSERVER(wm::WmWindowObserver, observers_, OnWindowDestroying(this)); |
735 OnWindowDestroying(this)); | |
736 } | 737 } |
737 | 738 |
738 } // namespace wm | 739 } // namespace mus |
739 } // namespace mash | 740 } // namespace ash |
OLD | NEW |