Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: ash/mus/window_manager.cc

Issue 2182633011: Replaces ::ui:: with ui:: in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/mus/window_manager.h ('k') | ash/mus/window_manager_application.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/window_manager.h" 5 #include "ash/mus/window_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 }; 66 };
67 67
68 WindowManager::WindowManager(shell::Connector* connector) 68 WindowManager::WindowManager(shell::Connector* connector)
69 : connector_(connector) {} 69 : connector_(connector) {}
70 70
71 WindowManager::~WindowManager() { 71 WindowManager::~WindowManager() {
72 // NOTE: |window_tree_client_| may already be null. 72 // NOTE: |window_tree_client_| may already be null.
73 delete window_tree_client_; 73 delete window_tree_client_;
74 } 74 }
75 75
76 void WindowManager::Init(::ui::WindowTreeClient* window_tree_client) { 76 void WindowManager::Init(ui::WindowTreeClient* window_tree_client) {
77 DCHECK(!window_tree_client_); 77 DCHECK(!window_tree_client_);
78 window_tree_client_ = window_tree_client; 78 window_tree_client_ = window_tree_client;
79 79
80 shadow_controller_.reset(new ShadowController(window_tree_client)); 80 shadow_controller_.reset(new ShadowController(window_tree_client));
81 81
82 // The insets are roughly what is needed by CustomFrameView. The expectation 82 // The insets are roughly what is needed by CustomFrameView. The expectation
83 // is at some point we'll write our own NonClientFrameView and get the insets 83 // is at some point we'll write our own NonClientFrameView and get the insets
84 // from it. 84 // from it.
85 ::ui::mojom::FrameDecorationValuesPtr frame_decoration_values = 85 ui::mojom::FrameDecorationValuesPtr frame_decoration_values =
86 ::ui::mojom::FrameDecorationValues::New(); 86 ui::mojom::FrameDecorationValues::New();
87 const gfx::Insets client_area_insets = 87 const gfx::Insets client_area_insets =
88 NonClientFrameController::GetPreferredClientAreaInsets(); 88 NonClientFrameController::GetPreferredClientAreaInsets();
89 frame_decoration_values->normal_client_area_insets = client_area_insets; 89 frame_decoration_values->normal_client_area_insets = client_area_insets;
90 frame_decoration_values->maximized_client_area_insets = client_area_insets; 90 frame_decoration_values->maximized_client_area_insets = client_area_insets;
91 frame_decoration_values->max_title_bar_button_width = 91 frame_decoration_values->max_title_bar_button_width =
92 NonClientFrameController::GetMaxTitleBarButtonWidth(); 92 NonClientFrameController::GetMaxTitleBarButtonWidth();
93 window_manager_client_->SetFrameDecorationValues( 93 window_manager_client_->SetFrameDecorationValues(
94 std::move(frame_decoration_values)); 94 std::move(frame_decoration_values));
95 95
96 std::unique_ptr<ShellDelegate> shell_delegate(new ShellDelegateMus( 96 std::unique_ptr<ShellDelegate> shell_delegate(new ShellDelegateMus(
97 base::MakeUnique<AppListPresenterStub>(), connector_)); 97 base::MakeUnique<AppListPresenterStub>(), connector_));
98 shell_.reset(new WmShellMus(std::move(shell_delegate), this)); 98 shell_.reset(new WmShellMus(std::move(shell_delegate), this));
99 shell_->Initialize(); 99 shell_->Initialize();
100 lookup_.reset(new WmLookupMus); 100 lookup_.reset(new WmLookupMus);
101 } 101 }
102 102
103 void WindowManager::SetScreenLocked(bool is_locked) { 103 void WindowManager::SetScreenLocked(bool is_locked) {
104 // TODO: screen locked state needs to be persisted for newly added displays. 104 // TODO: screen locked state needs to be persisted for newly added displays.
105 for (auto& root_window_controller : root_window_controllers_) { 105 for (auto& root_window_controller : root_window_controllers_) {
106 WmWindowMus* non_lock_screen_containers_container = 106 WmWindowMus* non_lock_screen_containers_container =
107 root_window_controller->GetWindowByShellWindowId( 107 root_window_controller->GetWindowByShellWindowId(
108 kShellWindowId_NonLockScreenContainersContainer); 108 kShellWindowId_NonLockScreenContainersContainer);
109 non_lock_screen_containers_container->mus_window()->SetVisible(!is_locked); 109 non_lock_screen_containers_container->mus_window()->SetVisible(!is_locked);
110 } 110 }
111 } 111 }
112 112
113 ::ui::Window* WindowManager::NewTopLevelWindow( 113 ui::Window* WindowManager::NewTopLevelWindow(
114 std::map<std::string, std::vector<uint8_t>>* properties) { 114 std::map<std::string, std::vector<uint8_t>>* properties) {
115 // TODO(sky): need to maintain active as well as allowing specifying display. 115 // TODO(sky): need to maintain active as well as allowing specifying display.
116 RootWindowController* root_window_controller = 116 RootWindowController* root_window_controller =
117 root_window_controllers_.begin()->get(); 117 root_window_controllers_.begin()->get();
118 return root_window_controller->NewTopLevelWindow(properties); 118 return root_window_controller->NewTopLevelWindow(properties);
119 } 119 }
120 120
121 std::set<RootWindowController*> WindowManager::GetRootWindowControllers() { 121 std::set<RootWindowController*> WindowManager::GetRootWindowControllers() {
122 std::set<RootWindowController*> result; 122 std::set<RootWindowController*> result;
123 for (auto& root_window_controller : root_window_controllers_) 123 for (auto& root_window_controller : root_window_controllers_)
(...skipping 23 matching lines...) Expand all
147 147
148 void WindowManager::AddObserver(WindowManagerObserver* observer) { 148 void WindowManager::AddObserver(WindowManagerObserver* observer) {
149 observers_.AddObserver(observer); 149 observers_.AddObserver(observer);
150 } 150 }
151 151
152 void WindowManager::RemoveObserver(WindowManagerObserver* observer) { 152 void WindowManager::RemoveObserver(WindowManagerObserver* observer) {
153 observers_.RemoveObserver(observer); 153 observers_.RemoveObserver(observer);
154 } 154 }
155 155
156 RootWindowController* WindowManager::CreateRootWindowController( 156 RootWindowController* WindowManager::CreateRootWindowController(
157 ::ui::Window* window, 157 ui::Window* window,
158 const display::Display& display) { 158 const display::Display& display) {
159 // TODO(sky): there is timing issues with using ScreenMus. 159 // TODO(sky): there is timing issues with using ScreenMus.
160 if (!screen_) { 160 if (!screen_) {
161 std::unique_ptr<views::ScreenMus> screen(new views::ScreenMus(nullptr)); 161 std::unique_ptr<views::ScreenMus> screen(new views::ScreenMus(nullptr));
162 screen->Init(connector_); 162 screen->Init(connector_);
163 screen_ = std::move(screen); 163 screen_ = std::move(screen);
164 } 164 }
165 165
166 std::unique_ptr<RootWindowController> root_window_controller_ptr( 166 std::unique_ptr<RootWindowController> root_window_controller_ptr(
167 new RootWindowController(this, window, display)); 167 new RootWindowController(this, window, display));
168 RootWindowController* root_window_controller = 168 RootWindowController* root_window_controller =
169 root_window_controller_ptr.get(); 169 root_window_controller_ptr.get();
170 root_window_controllers_.insert(std::move(root_window_controller_ptr)); 170 root_window_controllers_.insert(std::move(root_window_controller_ptr));
171 window->AddObserver(this); 171 window->AddObserver(this);
172 172
173 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 173 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
174 OnRootWindowControllerAdded(root_window_controller)); 174 OnRootWindowControllerAdded(root_window_controller));
175 return root_window_controller; 175 return root_window_controller;
176 } 176 }
177 177
178 void WindowManager::OnWindowDestroying(::ui::Window* window) { 178 void WindowManager::OnWindowDestroying(ui::Window* window) {
179 for (auto it = root_window_controllers_.begin(); 179 for (auto it = root_window_controllers_.begin();
180 it != root_window_controllers_.end(); ++it) { 180 it != root_window_controllers_.end(); ++it) {
181 if ((*it)->root() == window) { 181 if ((*it)->root() == window) {
182 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 182 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
183 OnWillDestroyRootWindowController((*it).get())); 183 OnWillDestroyRootWindowController((*it).get()));
184 return; 184 return;
185 } 185 }
186 } 186 }
187 NOTREACHED(); 187 NOTREACHED();
188 } 188 }
189 189
190 void WindowManager::OnWindowDestroyed(::ui::Window* window) { 190 void WindowManager::OnWindowDestroyed(ui::Window* window) {
191 window->RemoveObserver(this); 191 window->RemoveObserver(this);
192 for (auto it = root_window_controllers_.begin(); 192 for (auto it = root_window_controllers_.begin();
193 it != root_window_controllers_.end(); ++it) { 193 it != root_window_controllers_.end(); ++it) {
194 if ((*it)->root() == window) { 194 if ((*it)->root() == window) {
195 root_window_controllers_.erase(it); 195 root_window_controllers_.erase(it);
196 return; 196 return;
197 } 197 }
198 } 198 }
199 NOTREACHED(); 199 NOTREACHED();
200 } 200 }
201 201
202 void WindowManager::OnEmbed(::ui::Window* root) { 202 void WindowManager::OnEmbed(ui::Window* root) {
203 // WindowManager should never see this, instead OnWmNewDisplay() is called. 203 // WindowManager should never see this, instead OnWmNewDisplay() is called.
204 NOTREACHED(); 204 NOTREACHED();
205 } 205 }
206 206
207 void WindowManager::OnDidDestroyClient(::ui::WindowTreeClient* client) { 207 void WindowManager::OnDidDestroyClient(ui::WindowTreeClient* client) {
208 // Destroying the roots should result in removal from 208 // Destroying the roots should result in removal from
209 // |root_window_controllers_|. 209 // |root_window_controllers_|.
210 DCHECK(root_window_controllers_.empty()); 210 DCHECK(root_window_controllers_.empty());
211 211
212 lookup_.reset(); 212 lookup_.reset();
213 shell_.reset(); 213 shell_.reset();
214 shadow_controller_.reset(); 214 shadow_controller_.reset();
215 215
216 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 216 FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
217 OnWindowTreeClientDestroyed()); 217 OnWindowTreeClientDestroyed());
218 218
219 window_tree_client_ = nullptr; 219 window_tree_client_ = nullptr;
220 window_manager_client_ = nullptr; 220 window_manager_client_ = nullptr;
221 } 221 }
222 222
223 void WindowManager::OnEventObserved(const ui::Event& event, 223 void WindowManager::OnEventObserved(const ui::Event& event,
224 ::ui::Window* target) { 224 ui::Window* target) {
225 // Does not use EventObservers. 225 // Does not use EventObservers.
226 } 226 }
227 227
228 void WindowManager::SetWindowManagerClient(::ui::WindowManagerClient* client) { 228 void WindowManager::SetWindowManagerClient(ui::WindowManagerClient* client) {
229 window_manager_client_ = client; 229 window_manager_client_ = client;
230 } 230 }
231 231
232 bool WindowManager::OnWmSetBounds(::ui::Window* window, gfx::Rect* bounds) { 232 bool WindowManager::OnWmSetBounds(ui::Window* window, gfx::Rect* bounds) {
233 // TODO(sky): this indirectly sets bounds, which is against what 233 // TODO(sky): this indirectly sets bounds, which is against what
234 // OnWmSetBounds() recommends doing. Remove that restriction, or fix this. 234 // OnWmSetBounds() recommends doing. Remove that restriction, or fix this.
235 WmWindowMus::Get(window)->SetBounds(*bounds); 235 WmWindowMus::Get(window)->SetBounds(*bounds);
236 *bounds = window->bounds(); 236 *bounds = window->bounds();
237 return true; 237 return true;
238 } 238 }
239 239
240 bool WindowManager::OnWmSetProperty( 240 bool WindowManager::OnWmSetProperty(
241 ::ui::Window* window, 241 ui::Window* window,
242 const std::string& name, 242 const std::string& name,
243 std::unique_ptr<std::vector<uint8_t>>* new_data) { 243 std::unique_ptr<std::vector<uint8_t>>* new_data) {
244 // TODO(sky): constrain this to set of keys we know about, and allowed 244 // TODO(sky): constrain this to set of keys we know about, and allowed
245 // values. 245 // values.
246 return name == ::ui::mojom::WindowManager::kShowState_Property || 246 return name == ui::mojom::WindowManager::kShowState_Property ||
247 name == ::ui::mojom::WindowManager::kPreferredSize_Property || 247 name == ui::mojom::WindowManager::kPreferredSize_Property ||
248 name == ::ui::mojom::WindowManager::kResizeBehavior_Property || 248 name == ui::mojom::WindowManager::kResizeBehavior_Property ||
249 name == ::ui::mojom::WindowManager::kWindowAppIcon_Property || 249 name == ui::mojom::WindowManager::kWindowAppIcon_Property ||
250 name == ::ui::mojom::WindowManager::kWindowTitle_Property; 250 name == ui::mojom::WindowManager::kWindowTitle_Property;
251 } 251 }
252 252
253 ::ui::Window* WindowManager::OnWmCreateTopLevelWindow( 253 ui::Window* WindowManager::OnWmCreateTopLevelWindow(
254 std::map<std::string, std::vector<uint8_t>>* properties) { 254 std::map<std::string, std::vector<uint8_t>>* properties) {
255 return NewTopLevelWindow(properties); 255 return NewTopLevelWindow(properties);
256 } 256 }
257 257
258 void WindowManager::OnWmClientJankinessChanged( 258 void WindowManager::OnWmClientJankinessChanged(
259 const std::set<::ui::Window*>& client_windows, 259 const std::set<ui::Window*>& client_windows,
260 bool janky) { 260 bool janky) {
261 for (auto* window : client_windows) 261 for (auto* window : client_windows)
262 SetWindowIsJanky(window, janky); 262 SetWindowIsJanky(window, janky);
263 } 263 }
264 264
265 void WindowManager::OnWmNewDisplay(::ui::Window* window, 265 void WindowManager::OnWmNewDisplay(ui::Window* window,
266 const display::Display& display) { 266 const display::Display& display) {
267 CreateRootWindowController(window, display); 267 CreateRootWindowController(window, display);
268 } 268 }
269 269
270 void WindowManager::OnWmPerformMoveLoop( 270 void WindowManager::OnWmPerformMoveLoop(
271 ::ui::Window* window, 271 ui::Window* window,
272 ::ui::mojom::MoveLoopSource source, 272 ui::mojom::MoveLoopSource source,
273 const gfx::Point& cursor_location, 273 const gfx::Point& cursor_location,
274 const base::Callback<void(bool)>& on_done) { 274 const base::Callback<void(bool)>& on_done) {
275 WmWindowMus* child_window = WmWindowMus::Get(window); 275 WmWindowMus* child_window = WmWindowMus::Get(window);
276 MoveEventHandler* handler = MoveEventHandler::GetForWindow(child_window); 276 MoveEventHandler* handler = MoveEventHandler::GetForWindow(child_window);
277 if (!handler) { 277 if (!handler) {
278 on_done.Run(false); 278 on_done.Run(false);
279 return; 279 return;
280 } 280 }
281 281
282 DCHECK(!handler->IsDragInProgress()); 282 DCHECK(!handler->IsDragInProgress());
283 aura::client::WindowMoveSource aura_source = 283 aura::client::WindowMoveSource aura_source =
284 source == ::ui::mojom::MoveLoopSource::MOUSE 284 source == ui::mojom::MoveLoopSource::MOUSE
285 ? aura::client::WINDOW_MOVE_SOURCE_MOUSE 285 ? aura::client::WINDOW_MOVE_SOURCE_MOUSE
286 : aura::client::WINDOW_MOVE_SOURCE_TOUCH; 286 : aura::client::WINDOW_MOVE_SOURCE_TOUCH;
287 handler->AttemptToStartDrag(cursor_location, HTCAPTION, aura_source, on_done); 287 handler->AttemptToStartDrag(cursor_location, HTCAPTION, aura_source, on_done);
288 } 288 }
289 289
290 void WindowManager::OnWmCancelMoveLoop(::ui::Window* window) { 290 void WindowManager::OnWmCancelMoveLoop(ui::Window* window) {
291 WmWindowMus* child_window = WmWindowMus::Get(window); 291 WmWindowMus* child_window = WmWindowMus::Get(window);
292 MoveEventHandler* handler = MoveEventHandler::GetForWindow(child_window); 292 MoveEventHandler* handler = MoveEventHandler::GetForWindow(child_window);
293 if (handler) 293 if (handler)
294 handler->RevertDrag(); 294 handler->RevertDrag();
295 } 295 }
296 296
297 ui::mojom::EventResult WindowManager::OnAccelerator(uint32_t id, 297 ui::mojom::EventResult WindowManager::OnAccelerator(uint32_t id,
298 const ui::Event& event) { 298 const ui::Event& event) {
299 auto iter = accelerator_handlers_.find(GetAcceleratorNamespaceId(id)); 299 auto iter = accelerator_handlers_.find(GetAcceleratorNamespaceId(id));
300 if (iter == accelerator_handlers_.end()) 300 if (iter == accelerator_handlers_.end())
301 return ui::mojom::EventResult::HANDLED; 301 return ui::mojom::EventResult::HANDLED;
302 302
303 return iter->second->OnAccelerator(id, event); 303 return iter->second->OnAccelerator(id, event);
304 } 304 }
305 305
306 } // namespace mus 306 } // namespace mus
307 } // namespace ash 307 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/window_manager.h ('k') | ash/mus/window_manager_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698