OLD | NEW |
| (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 #include "ash/mus/bridge/wm_window_mus.h" | |
6 | |
7 #include "ash/common/shelf/shelf_item_types.h" | |
8 #include "ash/common/wm/container_finder.h" | |
9 #include "ash/common/wm/window_positioning_utils.h" | |
10 #include "ash/common/wm/window_state.h" | |
11 #include "ash/common/wm_layout_manager.h" | |
12 #include "ash/common/wm_lookup.h" | |
13 #include "ash/common/wm_transient_window_observer.h" | |
14 #include "ash/common/wm_window_observer.h" | |
15 #include "ash/common/wm_window_property.h" | |
16 #include "ash/mus/bridge/wm_shell_mus.h" | |
17 #include "ash/mus/property_util.h" | |
18 #include "ash/mus/root_window_controller.h" | |
19 #include "ash/mus/window_manager.h" | |
20 #include "ash/public/cpp/shell_window_ids.h" | |
21 #include "ash/wm/window_properties.h" | |
22 #include "services/ui/public/interfaces/window_manager.mojom.h" | |
23 #include "ui/aura/client/aura_constants.h" | |
24 #include "ui/aura/mus/window_manager_delegate.h" | |
25 #include "ui/aura/mus/window_mus.h" | |
26 #include "ui/aura/mus/window_tree_client.h" | |
27 #include "ui/aura/window.h" | |
28 #include "ui/base/hit_test.h" | |
29 #include "ui/display/display.h" | |
30 #include "ui/resources/grit/ui_resources.h" | |
31 #include "ui/views/view.h" | |
32 #include "ui/views/widget/widget.h" | |
33 #include "ui/views/widget/widget_delegate.h" | |
34 | |
35 namespace ash { | |
36 namespace mus { | |
37 | |
38 WmWindowMus::WmWindowMus(aura::Window* window) : WmWindowAura(window) {} | |
39 | |
40 WmWindowMus::~WmWindowMus() {} | |
41 | |
42 // static | |
43 const WmWindowMus* WmWindowMus::Get(const aura::Window* window) { | |
44 if (!window) | |
45 return nullptr; | |
46 | |
47 if (HasInstance(window)) | |
48 return static_cast<const WmWindowMus*>(WmWindowAura::Get(window)); | |
49 | |
50 // WmWindowMus is owned by the aura::Window. | |
51 // Unfortunately there isn't a good way to avoid the cast here. | |
52 return new WmWindowMus(const_cast<aura::Window*>(window)); | |
53 } | |
54 | |
55 // static | |
56 WmWindowMus* WmWindowMus::Get(views::Widget* widget) { | |
57 return WmWindowMus::Get(widget->GetNativeView()); | |
58 } | |
59 | |
60 bool WmWindowMus::IsContainer() const { | |
61 return GetShellWindowId() != kShellWindowId_Invalid; | |
62 } | |
63 | |
64 WmShell* WmWindowMus::GetShell() const { | |
65 return WmShellMus::Get(); | |
66 } | |
67 | |
68 void WmWindowMus::CloseWidget() { | |
69 // NOTE: in the FOR_CLIENT case there is not necessarily a widget associated | |
70 // with the window. Mash only creates widgets for top level windows if mash | |
71 // renders the non-client frame. | |
72 if (aura_window()->GetProperty(kWidgetCreationTypeKey) == | |
73 WidgetCreationType::FOR_CLIENT) { | |
74 WmShellMus::Get()->window_manager()->window_manager_client()->RequestClose( | |
75 aura_window()); | |
76 } else { | |
77 WmWindowAura::CloseWidget(); | |
78 } | |
79 } | |
80 | |
81 void WmWindowMus::AddLimitedPreTargetHandler(ui::EventHandler* handler) { | |
82 DCHECK(WmShellMus::Get()->window_tree_client()->WasCreatedByThisClient( | |
83 aura::WindowMus::Get(aura_window()))); | |
84 WmWindowAura::AddLimitedPreTargetHandler(handler); | |
85 } | |
86 | |
87 } // namespace mus | |
88 } // namespace ash | |
OLD | NEW |