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

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

Issue 2629643002: chromeos: Renames WmWindowAura to WmWindow (Closed)
Patch Set: feedback Created 3 years, 11 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/test/wm_test_base.cc ('k') | ash/root_window_controller.cc » ('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
11 #include "ash/aura/wm_window_aura.h"
12 #include "ash/common/session/session_controller.h" 11 #include "ash/common/session/session_controller.h"
13 #include "ash/common/wm/container_finder.h" 12 #include "ash/common/wm/container_finder.h"
14 #include "ash/common/wm/window_state.h" 13 #include "ash/common/wm/window_state.h"
14 #include "ash/common/wm_window.h"
15 #include "ash/display/screen_position_controller.h" 15 #include "ash/display/screen_position_controller.h"
16 #include "ash/mus/accelerators/accelerator_handler.h" 16 #include "ash/mus/accelerators/accelerator_handler.h"
17 #include "ash/mus/accelerators/accelerator_ids.h" 17 #include "ash/mus/accelerators/accelerator_ids.h"
18 #include "ash/mus/bridge/wm_lookup_mus.h" 18 #include "ash/mus/bridge/wm_lookup_mus.h"
19 #include "ash/mus/bridge/wm_shell_mus.h" 19 #include "ash/mus/bridge/wm_shell_mus.h"
20 #include "ash/mus/move_event_handler.h" 20 #include "ash/mus/move_event_handler.h"
21 #include "ash/mus/non_client_frame_controller.h" 21 #include "ash/mus/non_client_frame_controller.h"
22 #include "ash/mus/property_util.h" 22 #include "ash/mus/property_util.h"
23 #include "ash/mus/root_window_controller.h" 23 #include "ash/mus/root_window_controller.h"
24 #include "ash/mus/screen_mus.h" 24 #include "ash/mus/screen_mus.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 aura::Window* WindowManager::NewTopLevelWindow( 147 aura::Window* WindowManager::NewTopLevelWindow(
148 ui::mojom::WindowType window_type, 148 ui::mojom::WindowType window_type,
149 std::map<std::string, std::vector<uint8_t>>* properties) { 149 std::map<std::string, std::vector<uint8_t>>* properties) {
150 RootWindowController* root_window_controller = 150 RootWindowController* root_window_controller =
151 GetRootWindowControllerForNewTopLevelWindow(properties); 151 GetRootWindowControllerForNewTopLevelWindow(properties);
152 aura::Window* window = 152 aura::Window* window =
153 root_window_controller->NewTopLevelWindow(window_type, properties); 153 root_window_controller->NewTopLevelWindow(window_type, properties);
154 if (properties->count( 154 if (properties->count(
155 ui::mojom::WindowManager::kWindowIgnoredByShelf_Property)) { 155 ui::mojom::WindowManager::kWindowIgnoredByShelf_Property)) {
156 wm::WindowState* window_state = 156 wm::WindowState* window_state = WmWindow::Get(window)->GetWindowState();
157 static_cast<WmWindow*>(WmWindowAura::Get(window))->GetWindowState();
158 window_state->set_ignored_by_shelf(mojo::ConvertTo<bool>( 157 window_state->set_ignored_by_shelf(mojo::ConvertTo<bool>(
159 (*properties) 158 (*properties)
160 [ui::mojom::WindowManager::kWindowIgnoredByShelf_Property])); 159 [ui::mojom::WindowManager::kWindowIgnoredByShelf_Property]));
161 // No need to persist this value. 160 // No need to persist this value.
162 properties->erase(ui::mojom::WindowManager::kWindowIgnoredByShelf_Property); 161 properties->erase(ui::mojom::WindowManager::kWindowIgnoredByShelf_Property);
163 } 162 }
164 return window; 163 return window;
165 } 164 }
166 165
167 std::set<RootWindowController*> WindowManager::GetRootWindowControllers() { 166 std::set<RootWindowController*> WindowManager::GetRootWindowControllers() {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 pointer_watcher_event_router_.reset(); 298 pointer_watcher_event_router_.reset();
300 299
301 window_tree_client_.reset(); 300 window_tree_client_.reset();
302 window_manager_client_ = nullptr; 301 window_manager_client_ = nullptr;
303 302
304 DCHECK_EQ(screen_.get(), display::Screen::GetScreen()); 303 DCHECK_EQ(screen_.get(), display::Screen::GetScreen());
305 display::Screen::SetScreenInstance(nullptr); 304 display::Screen::SetScreenInstance(nullptr);
306 } 305 }
307 306
308 RootWindowController* WindowManager::GetPrimaryRootWindowController() { 307 RootWindowController* WindowManager::GetPrimaryRootWindowController() {
309 return RootWindowController::ForWindow( 308 return RootWindowController::ForWindow(WmShell::Get()
310 static_cast<WmWindowAura*>( 309 ->GetPrimaryRootWindowController()
311 WmShell::Get()->GetPrimaryRootWindowController()->GetWindow()) 310 ->GetWindow()
312 ->aura_window()); 311 ->aura_window());
313 } 312 }
314 313
315 RootWindowController* 314 RootWindowController*
316 WindowManager::GetRootWindowControllerForNewTopLevelWindow( 315 WindowManager::GetRootWindowControllerForNewTopLevelWindow(
317 std::map<std::string, std::vector<uint8_t>>* properties) { 316 std::map<std::string, std::vector<uint8_t>>* properties) {
318 // If a specific display was requested, use it. 317 // If a specific display was requested, use it.
319 const int64_t display_id = GetInitialDisplayId(*properties); 318 const int64_t display_id = GetInitialDisplayId(*properties);
320 for (auto& root_window_controller_ptr : root_window_controllers_) { 319 for (auto& root_window_controller_ptr : root_window_controllers_) {
321 if (root_window_controller_ptr->display().id() == display_id) 320 if (root_window_controller_ptr->display().id() == display_id)
322 return root_window_controller_ptr.get(); 321 return root_window_controller_ptr.get();
323 } 322 }
324 323
325 return RootWindowController::ForWindow( 324 return RootWindowController::ForWindow(
326 static_cast<WmWindowAura*>( 325 WmShellMus::Get()->GetRootWindowForNewWindows()->aura_window());
327 WmShellMus::Get()->GetRootWindowForNewWindows())
328 ->aura_window());
329 } 326 }
330 327
331 void WindowManager::OnEmbed( 328 void WindowManager::OnEmbed(
332 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { 329 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) {
333 // WindowManager should never see this, instead OnWmNewDisplay() is called. 330 // WindowManager should never see this, instead OnWmNewDisplay() is called.
334 NOTREACHED(); 331 NOTREACHED();
335 } 332 }
336 333
337 void WindowManager::OnEmbedRootDestroyed( 334 void WindowManager::OnEmbedRootDestroyed(
338 aura::WindowTreeHostMus* window_tree_host) { 335 aura::WindowTreeHostMus* window_tree_host) {
(...skipping 22 matching lines...) Expand all
361 } 358 }
362 359
363 void WindowManager::SetWindowManagerClient(aura::WindowManagerClient* client) { 360 void WindowManager::SetWindowManagerClient(aura::WindowManagerClient* client) {
364 window_manager_client_ = client; 361 window_manager_client_ = client;
365 ash::Shell::set_window_manager_client(client); 362 ash::Shell::set_window_manager_client(client);
366 } 363 }
367 364
368 bool WindowManager::OnWmSetBounds(aura::Window* window, gfx::Rect* bounds) { 365 bool WindowManager::OnWmSetBounds(aura::Window* window, gfx::Rect* bounds) {
369 // TODO(sky): this indirectly sets bounds, which is against what 366 // TODO(sky): this indirectly sets bounds, which is against what
370 // OnWmSetBounds() recommends doing. Remove that restriction, or fix this. 367 // OnWmSetBounds() recommends doing. Remove that restriction, or fix this.
371 WmWindowAura::Get(window)->SetBounds(*bounds); 368 WmWindow::Get(window)->SetBounds(*bounds);
372 *bounds = window->bounds(); 369 *bounds = window->bounds();
373 return true; 370 return true;
374 } 371 }
375 372
376 bool WindowManager::OnWmSetProperty( 373 bool WindowManager::OnWmSetProperty(
377 aura::Window* window, 374 aura::Window* window,
378 const std::string& name, 375 const std::string& name,
379 std::unique_ptr<std::vector<uint8_t>>* new_data) { 376 std::unique_ptr<std::vector<uint8_t>>* new_data) {
380 // TODO(sky): constrain this to set of keys we know about, and allowed values. 377 // TODO(sky): constrain this to set of keys we know about, and allowed values.
381 if (name == ui::mojom::WindowManager::kWindowIgnoredByShelf_Property) { 378 if (name == ui::mojom::WindowManager::kWindowIgnoredByShelf_Property) {
382 wm::WindowState* window_state = WmWindowAura::Get(window)->GetWindowState(); 379 wm::WindowState* window_state = WmWindow::Get(window)->GetWindowState();
383 window_state->set_ignored_by_shelf( 380 window_state->set_ignored_by_shelf(
384 new_data ? mojo::ConvertTo<bool>(**new_data) : false); 381 new_data ? mojo::ConvertTo<bool>(**new_data) : false);
385 return false; // Won't attempt to map through property converter. 382 return false; // Won't attempt to map through property converter.
386 } 383 }
387 return name == ui::mojom::WindowManager::kAppIcon_Property || 384 return name == ui::mojom::WindowManager::kAppIcon_Property ||
388 name == ui::mojom::WindowManager::kShowState_Property || 385 name == ui::mojom::WindowManager::kShowState_Property ||
389 name == ui::mojom::WindowManager::kPreferredSize_Property || 386 name == ui::mojom::WindowManager::kPreferredSize_Property ||
390 name == ui::mojom::WindowManager::kResizeBehavior_Property || 387 name == ui::mojom::WindowManager::kResizeBehavior_Property ||
391 name == ui::mojom::WindowManager::kShelfItemType_Property || 388 name == ui::mojom::WindowManager::kShelfItemType_Property ||
392 name == ui::mojom::WindowManager::kWindowIcon_Property || 389 name == ui::mojom::WindowManager::kWindowIcon_Property ||
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 } 455 }
459 456
460 NOTREACHED(); 457 NOTREACHED();
461 } 458 }
462 459
463 void WindowManager::OnWmPerformMoveLoop( 460 void WindowManager::OnWmPerformMoveLoop(
464 aura::Window* window, 461 aura::Window* window,
465 ui::mojom::MoveLoopSource source, 462 ui::mojom::MoveLoopSource source,
466 const gfx::Point& cursor_location, 463 const gfx::Point& cursor_location,
467 const base::Callback<void(bool)>& on_done) { 464 const base::Callback<void(bool)>& on_done) {
468 WmWindowAura* child_window = WmWindowAura::Get(window); 465 WmWindow* child_window = WmWindow::Get(window);
469 MoveEventHandler* handler = MoveEventHandler::GetForWindow(child_window); 466 MoveEventHandler* handler = MoveEventHandler::GetForWindow(child_window);
470 if (!handler) { 467 if (!handler) {
471 on_done.Run(false); 468 on_done.Run(false);
472 return; 469 return;
473 } 470 }
474 471
475 DCHECK(!handler->IsDragInProgress()); 472 DCHECK(!handler->IsDragInProgress());
476 aura::client::WindowMoveSource aura_source = 473 aura::client::WindowMoveSource aura_source =
477 source == ui::mojom::MoveLoopSource::MOUSE 474 source == ui::mojom::MoveLoopSource::MOUSE
478 ? aura::client::WINDOW_MOVE_SOURCE_MOUSE 475 ? aura::client::WINDOW_MOVE_SOURCE_MOUSE
479 : aura::client::WINDOW_MOVE_SOURCE_TOUCH; 476 : aura::client::WINDOW_MOVE_SOURCE_TOUCH;
480 handler->AttemptToStartDrag(cursor_location, HTCAPTION, aura_source, on_done); 477 handler->AttemptToStartDrag(cursor_location, HTCAPTION, aura_source, on_done);
481 } 478 }
482 479
483 void WindowManager::OnWmCancelMoveLoop(aura::Window* window) { 480 void WindowManager::OnWmCancelMoveLoop(aura::Window* window) {
484 WmWindowAura* child_window = WmWindowAura::Get(window); 481 WmWindow* child_window = WmWindow::Get(window);
485 MoveEventHandler* handler = MoveEventHandler::GetForWindow(child_window); 482 MoveEventHandler* handler = MoveEventHandler::GetForWindow(child_window);
486 if (handler) 483 if (handler)
487 handler->RevertDrag(); 484 handler->RevertDrag();
488 } 485 }
489 486
490 ui::mojom::EventResult WindowManager::OnAccelerator(uint32_t id, 487 ui::mojom::EventResult WindowManager::OnAccelerator(uint32_t id,
491 const ui::Event& event) { 488 const ui::Event& event) {
492 auto iter = accelerator_handlers_.find(GetAcceleratorNamespaceId(id)); 489 auto iter = accelerator_handlers_.find(GetAcceleratorNamespaceId(id));
493 if (iter == accelerator_handlers_.end()) 490 if (iter == accelerator_handlers_.end())
494 return ui::mojom::EventResult::HANDLED; 491 return ui::mojom::EventResult::HANDLED;
495 492
496 return iter->second->OnAccelerator(id, event); 493 return iter->second->OnAccelerator(id, event);
497 } 494 }
498 495
499 void WindowManager::OnWmSetClientArea( 496 void WindowManager::OnWmSetClientArea(
500 aura::Window* window, 497 aura::Window* window,
501 const gfx::Insets& insets, 498 const gfx::Insets& insets,
502 const std::vector<gfx::Rect>& additional_client_areas) { 499 const std::vector<gfx::Rect>& additional_client_areas) {
503 NonClientFrameController* non_client_frame_controller = 500 NonClientFrameController* non_client_frame_controller =
504 NonClientFrameController::Get(window); 501 NonClientFrameController::Get(window);
505 if (!non_client_frame_controller) 502 if (!non_client_frame_controller)
506 return; 503 return;
507 non_client_frame_controller->SetClientArea(insets, additional_client_areas); 504 non_client_frame_controller->SetClientArea(insets, additional_client_areas);
508 } 505 }
509 506
510 } // namespace mus 507 } // namespace mus
511 } // namespace ash 508 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/test/wm_test_base.cc ('k') | ash/root_window_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698