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