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_root_window_controller_mus.h" | 5 #include "ash/mus/bridge/wm_root_window_controller_mus.h" |
6 | 6 |
7 #include "ash/common/wm/wm_root_window_controller_observer.h" | 7 #include "ash/common/wm/wm_root_window_controller_observer.h" |
| 8 #include "ash/mus/bridge/wm_globals_mus.h" |
| 9 #include "ash/mus/bridge/wm_shelf_mus.h" |
| 10 #include "ash/mus/bridge/wm_window_mus.h" |
| 11 #include "ash/mus/container_ids.h" |
| 12 #include "ash/mus/root_window_controller.h" |
8 #include "components/mus/public/cpp/window.h" | 13 #include "components/mus/public/cpp/window.h" |
9 #include "components/mus/public/cpp/window_property.h" | 14 #include "components/mus/public/cpp/window_property.h" |
10 #include "components/mus/public/cpp/window_tree_client.h" | 15 #include "components/mus/public/cpp/window_tree_client.h" |
11 #include "mash/wm/bridge/wm_globals_mus.h" | |
12 #include "mash/wm/bridge/wm_shelf_mus.h" | |
13 #include "mash/wm/bridge/wm_window_mus.h" | |
14 #include "mash/wm/container_ids.h" | |
15 #include "mash/wm/root_window_controller.h" | |
16 #include "ui/display/display.h" | 16 #include "ui/display/display.h" |
17 #include "ui/views/mus/native_widget_mus.h" | 17 #include "ui/views/mus/native_widget_mus.h" |
18 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
19 | 19 |
20 MUS_DECLARE_WINDOW_PROPERTY_TYPE(mash::wm::WmRootWindowControllerMus*); | 20 MUS_DECLARE_WINDOW_PROPERTY_TYPE(ash::mus::WmRootWindowControllerMus*); |
21 | 21 |
22 namespace mash { | 22 namespace { |
23 namespace wm { | |
24 | 23 |
25 MUS_DEFINE_LOCAL_WINDOW_PROPERTY_KEY(mash::wm::WmRootWindowControllerMus*, | 24 MUS_DEFINE_LOCAL_WINDOW_PROPERTY_KEY(ash::mus::WmRootWindowControllerMus*, |
26 kWmRootWindowControllerKey, | 25 kWmRootWindowControllerKey, |
27 nullptr); | 26 nullptr); |
28 | 27 |
| 28 } // namespace |
| 29 |
| 30 namespace ash { |
| 31 namespace mus { |
| 32 |
29 WmRootWindowControllerMus::WmRootWindowControllerMus( | 33 WmRootWindowControllerMus::WmRootWindowControllerMus( |
30 WmGlobalsMus* globals, | 34 WmGlobalsMus* globals, |
31 RootWindowController* root_window_controller) | 35 RootWindowController* root_window_controller) |
32 : globals_(globals), root_window_controller_(root_window_controller) { | 36 : globals_(globals), root_window_controller_(root_window_controller) { |
33 globals_->AddRootWindowController(this); | 37 globals_->AddRootWindowController(this); |
34 root_window_controller_->root()->SetLocalProperty(kWmRootWindowControllerKey, | 38 root_window_controller_->root()->SetLocalProperty(kWmRootWindowControllerKey, |
35 this); | 39 this); |
36 } | 40 } |
37 | 41 |
38 WmRootWindowControllerMus::~WmRootWindowControllerMus() { | 42 WmRootWindowControllerMus::~WmRootWindowControllerMus() { |
39 globals_->RemoveRootWindowController(this); | 43 globals_->RemoveRootWindowController(this); |
40 } | 44 } |
41 | 45 |
42 // static | 46 // static |
43 const WmRootWindowControllerMus* WmRootWindowControllerMus::Get( | 47 const WmRootWindowControllerMus* WmRootWindowControllerMus::Get( |
44 const mus::Window* window) { | 48 const ::mus::Window* window) { |
45 if (!window) | 49 if (!window) |
46 return nullptr; | 50 return nullptr; |
47 | 51 |
48 return window->GetRoot()->GetLocalProperty(kWmRootWindowControllerKey); | 52 return window->GetRoot()->GetLocalProperty(kWmRootWindowControllerKey); |
49 } | 53 } |
50 | 54 |
51 void WmRootWindowControllerMus::NotifyFullscreenStateChange( | 55 void WmRootWindowControllerMus::NotifyFullscreenStateChange( |
52 bool is_fullscreen) { | 56 bool is_fullscreen) { |
53 FOR_EACH_OBSERVER(ash::wm::WmRootWindowControllerObserver, observers_, | 57 FOR_EACH_OBSERVER(wm::WmRootWindowControllerObserver, observers_, |
54 OnFullscreenStateChanged(is_fullscreen)); | 58 OnFullscreenStateChanged(is_fullscreen)); |
55 } | 59 } |
56 | 60 |
57 gfx::Point WmRootWindowControllerMus::ConvertPointToScreen( | 61 gfx::Point WmRootWindowControllerMus::ConvertPointToScreen( |
58 const WmWindowMus* source, | 62 const WmWindowMus* source, |
59 const gfx::Point& point) const { | 63 const gfx::Point& point) const { |
60 gfx::Point point_in_root = | 64 gfx::Point point_in_root = |
61 source->ConvertPointToTarget(source->GetRootWindow(), point); | 65 source->ConvertPointToTarget(source->GetRootWindow(), point); |
62 point_in_root += GetDisplay().bounds().OffsetFromOrigin(); | 66 point_in_root += GetDisplay().bounds().OffsetFromOrigin(); |
63 return point_in_root; | 67 return point_in_root; |
64 } | 68 } |
65 | 69 |
66 gfx::Point WmRootWindowControllerMus::ConvertPointFromScreen( | 70 gfx::Point WmRootWindowControllerMus::ConvertPointFromScreen( |
67 const WmWindowMus* target, | 71 const WmWindowMus* target, |
68 const gfx::Point& point) const { | 72 const gfx::Point& point) const { |
69 gfx::Point result = point; | 73 gfx::Point result = point; |
70 result -= GetDisplay().bounds().OffsetFromOrigin(); | 74 result -= GetDisplay().bounds().OffsetFromOrigin(); |
71 return target->GetRootWindow()->ConvertPointToTarget(target, result); | 75 return target->GetRootWindow()->ConvertPointToTarget(target, result); |
72 } | 76 } |
73 | 77 |
74 const display::Display& WmRootWindowControllerMus::GetDisplay() const { | 78 const display::Display& WmRootWindowControllerMus::GetDisplay() const { |
75 return root_window_controller_->display(); | 79 return root_window_controller_->display(); |
76 } | 80 } |
77 | 81 |
78 bool WmRootWindowControllerMus::HasShelf() { | 82 bool WmRootWindowControllerMus::HasShelf() { |
79 return GetShelf() != nullptr; | 83 return GetShelf() != nullptr; |
80 } | 84 } |
81 | 85 |
82 ash::wm::WmGlobals* WmRootWindowControllerMus::GetGlobals() { | 86 wm::WmGlobals* WmRootWindowControllerMus::GetGlobals() { |
83 return globals_; | 87 return globals_; |
84 } | 88 } |
85 | 89 |
86 ash::wm::WorkspaceWindowState | 90 wm::WorkspaceWindowState WmRootWindowControllerMus::GetWorkspaceWindowState() { |
87 WmRootWindowControllerMus::GetWorkspaceWindowState() { | |
88 NOTIMPLEMENTED(); | 91 NOTIMPLEMENTED(); |
89 return ash::wm::WORKSPACE_WINDOW_STATE_DEFAULT; | 92 return wm::WORKSPACE_WINDOW_STATE_DEFAULT; |
90 } | 93 } |
91 | 94 |
92 ash::AlwaysOnTopController* | 95 AlwaysOnTopController* WmRootWindowControllerMus::GetAlwaysOnTopController() { |
93 WmRootWindowControllerMus::GetAlwaysOnTopController() { | |
94 return root_window_controller_->always_on_top_controller(); | 96 return root_window_controller_->always_on_top_controller(); |
95 } | 97 } |
96 | 98 |
97 ash::wm::WmShelf* WmRootWindowControllerMus::GetShelf() { | 99 wm::WmShelf* WmRootWindowControllerMus::GetShelf() { |
98 return root_window_controller_->wm_shelf(); | 100 return root_window_controller_->wm_shelf(); |
99 } | 101 } |
100 | 102 |
101 ash::wm::WmWindow* WmRootWindowControllerMus::GetWindow() { | 103 wm::WmWindow* WmRootWindowControllerMus::GetWindow() { |
102 return WmWindowMus::Get(root_window_controller_->root()); | 104 return WmWindowMus::Get(root_window_controller_->root()); |
103 } | 105 } |
104 | 106 |
105 void WmRootWindowControllerMus::ConfigureWidgetInitParamsForContainer( | 107 void WmRootWindowControllerMus::ConfigureWidgetInitParamsForContainer( |
106 views::Widget* widget, | 108 views::Widget* widget, |
107 int shell_container_id, | 109 int shell_container_id, |
108 views::Widget::InitParams* init_params) { | 110 views::Widget::InitParams* init_params) { |
109 init_params->parent_mus = WmWindowMus::GetMusWindow( | 111 init_params->parent_mus = WmWindowMus::GetMusWindow( |
110 WmWindowMus::Get(root_window_controller_->root()) | 112 WmWindowMus::Get(root_window_controller_->root()) |
111 ->GetChildByShellWindowId(shell_container_id)); | 113 ->GetChildByShellWindowId(shell_container_id)); |
112 DCHECK(init_params->parent_mus); | 114 DCHECK(init_params->parent_mus); |
113 mus::Window* new_window = | 115 ::mus::Window* new_window = |
114 root_window_controller_->root()->window_tree()->NewWindow(); | 116 root_window_controller_->root()->window_tree()->NewWindow(); |
115 WmWindowMus::Get(new_window) | 117 WmWindowMus::Get(new_window) |
116 ->set_widget(widget, WmWindowMus::WidgetCreationType::INTERNAL); | 118 ->set_widget(widget, WmWindowMus::WidgetCreationType::INTERNAL); |
117 init_params->native_widget = new views::NativeWidgetMus( | 119 init_params->native_widget = new views::NativeWidgetMus( |
118 widget, root_window_controller_->GetConnector(), new_window, | 120 widget, root_window_controller_->GetConnector(), new_window, |
119 mus::mojom::SurfaceType::DEFAULT); | 121 ::mus::mojom::SurfaceType::DEFAULT); |
120 } | 122 } |
121 | 123 |
122 ash::wm::WmWindow* WmRootWindowControllerMus::FindEventTarget( | 124 wm::WmWindow* WmRootWindowControllerMus::FindEventTarget( |
123 const gfx::Point& location_in_screen) { | 125 const gfx::Point& location_in_screen) { |
124 NOTIMPLEMENTED(); | 126 NOTIMPLEMENTED(); |
125 return nullptr; | 127 return nullptr; |
126 } | 128 } |
127 | 129 |
128 void WmRootWindowControllerMus::AddObserver( | 130 void WmRootWindowControllerMus::AddObserver( |
129 ash::wm::WmRootWindowControllerObserver* observer) { | 131 wm::WmRootWindowControllerObserver* observer) { |
130 observers_.AddObserver(observer); | 132 observers_.AddObserver(observer); |
131 } | 133 } |
132 | 134 |
133 void WmRootWindowControllerMus::RemoveObserver( | 135 void WmRootWindowControllerMus::RemoveObserver( |
134 ash::wm::WmRootWindowControllerObserver* observer) { | 136 wm::WmRootWindowControllerObserver* observer) { |
135 observers_.RemoveObserver(observer); | 137 observers_.RemoveObserver(observer); |
136 } | 138 } |
137 | 139 |
138 } // namespace wm | 140 } // namespace mus |
139 } // namespace mash | 141 } // namespace ash |
OLD | NEW |