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