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

Side by Side Diff: ash/common/wm/lock_layout_manager.cc

Issue 2699033002: Replace WmWindowObserver with aura::WindowObserver. (Closed)
Patch Set: Check for null images in ShelfWindowWatcher. Created 3 years, 10 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/common/wm/lock_layout_manager.h" 5 #include "ash/common/wm/lock_layout_manager.h"
6 6
7 #include "ash/common/wm/lock_window_state.h" 7 #include "ash/common/wm/lock_window_state.h"
8 #include "ash/common/wm/window_state.h" 8 #include "ash/common/wm/window_state.h"
9 #include "ash/common/wm/wm_event.h" 9 #include "ash/common/wm/wm_event.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
11 #include "ash/common/wm_window.h" 11 #include "ash/common/wm_window.h"
12 #include "ui/events/event.h" 12 #include "ui/events/event.h"
13 #include "ui/keyboard/keyboard_controller.h" 13 #include "ui/keyboard/keyboard_controller.h"
14 #include "ui/keyboard/keyboard_util.h" 14 #include "ui/keyboard/keyboard_util.h"
15 15
16 namespace ash { 16 namespace ash {
17 17
18 LockLayoutManager::LockLayoutManager(WmWindow* window) 18 LockLayoutManager::LockLayoutManager(WmWindow* window)
19 : wm::WmSnapToPixelLayoutManager(), 19 : wm::WmSnapToPixelLayoutManager(),
20 window_(window), 20 window_(window),
21 root_window_(window->GetRootWindow()), 21 root_window_(window->GetRootWindow()),
22 is_observing_keyboard_(false) { 22 is_observing_keyboard_(false) {
23 WmShell::Get()->AddShellObserver(this); 23 WmShell::Get()->AddShellObserver(this);
24 root_window_->AddObserver(this); 24 root_window_->aura_window()->AddObserver(this);
25 if (keyboard::KeyboardController::GetInstance()) { 25 if (keyboard::KeyboardController::GetInstance()) {
26 keyboard::KeyboardController::GetInstance()->AddObserver(this); 26 keyboard::KeyboardController::GetInstance()->AddObserver(this);
27 is_observing_keyboard_ = true; 27 is_observing_keyboard_ = true;
28 } 28 }
29 } 29 }
30 30
31 LockLayoutManager::~LockLayoutManager() { 31 LockLayoutManager::~LockLayoutManager() {
32 if (root_window_) 32 if (root_window_)
33 root_window_->RemoveObserver(this); 33 root_window_->aura_window()->RemoveObserver(this);
34 34
35 for (WmWindow* child : window_->GetChildren()) 35 for (WmWindow* child : window_->GetChildren())
36 child->RemoveObserver(this); 36 child->aura_window()->RemoveObserver(this);
37 37
38 WmShell::Get()->RemoveShellObserver(this); 38 WmShell::Get()->RemoveShellObserver(this);
39 39
40 if (keyboard::KeyboardController::GetInstance() && is_observing_keyboard_) { 40 if (keyboard::KeyboardController::GetInstance() && is_observing_keyboard_) {
41 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); 41 keyboard::KeyboardController::GetInstance()->RemoveObserver(this);
42 is_observing_keyboard_ = false; 42 is_observing_keyboard_ = false;
43 } 43 }
44 } 44 }
45 45
46 void LockLayoutManager::OnWindowResized() { 46 void LockLayoutManager::OnWindowResized() {
47 const wm::WMEvent event(wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED); 47 const wm::WMEvent event(wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED);
48 AdjustWindowsForWorkAreaChange(&event); 48 AdjustWindowsForWorkAreaChange(&event);
49 } 49 }
50 50
51 void LockLayoutManager::OnWindowAddedToLayout(WmWindow* child) { 51 void LockLayoutManager::OnWindowAddedToLayout(WmWindow* child) {
52 child->AddObserver(this); 52 child->aura_window()->AddObserver(this);
53 53
54 // LockWindowState replaces default WindowState of a child. 54 // LockWindowState replaces default WindowState of a child.
55 wm::WindowState* window_state = LockWindowState::SetLockWindowState(child); 55 wm::WindowState* window_state = LockWindowState::SetLockWindowState(child);
56 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE); 56 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE);
57 window_state->OnWMEvent(&event); 57 window_state->OnWMEvent(&event);
58 } 58 }
59 59
60 void LockLayoutManager::OnWillRemoveWindowFromLayout(WmWindow* child) { 60 void LockLayoutManager::OnWillRemoveWindowFromLayout(WmWindow* child) {
61 child->RemoveObserver(this); 61 child->aura_window()->RemoveObserver(this);
62 } 62 }
63 63
64 void LockLayoutManager::OnWindowRemovedFromLayout(WmWindow* child) {} 64 void LockLayoutManager::OnWindowRemovedFromLayout(WmWindow* child) {}
65 65
66 void LockLayoutManager::OnChildWindowVisibilityChanged(WmWindow* child, 66 void LockLayoutManager::OnChildWindowVisibilityChanged(WmWindow* child,
67 bool visible) {} 67 bool visible) {}
68 68
69 void LockLayoutManager::SetChildBounds(WmWindow* child, 69 void LockLayoutManager::SetChildBounds(WmWindow* child,
70 const gfx::Rect& requested_bounds) { 70 const gfx::Rect& requested_bounds) {
71 wm::WindowState* window_state = child->GetWindowState(); 71 wm::WindowState* window_state = child->GetWindowState();
72 wm::SetBoundsEvent event(wm::WM_EVENT_SET_BOUNDS, requested_bounds); 72 wm::SetBoundsEvent event(wm::WM_EVENT_SET_BOUNDS, requested_bounds);
73 window_state->OnWMEvent(&event); 73 window_state->OnWMEvent(&event);
74 } 74 }
75 75
76 void LockLayoutManager::OnWindowDestroying(WmWindow* window) { 76 void LockLayoutManager::OnWindowDestroying(aura::Window* window) {
77 window->RemoveObserver(this); 77 window->RemoveObserver(this);
78 if (root_window_ == window) 78 if (root_window_ == WmWindow::Get(window))
79 root_window_ = nullptr; 79 root_window_ = nullptr;
80 } 80 }
81 81
82 void LockLayoutManager::OnWindowBoundsChanged(WmWindow* window, 82 void LockLayoutManager::OnWindowBoundsChanged(aura::Window* window,
83 const gfx::Rect& old_bounds, 83 const gfx::Rect& old_bounds,
84 const gfx::Rect& new_bounds) { 84 const gfx::Rect& new_bounds) {
85 if (root_window_ == window) { 85 if (root_window_ == WmWindow::Get(window)) {
86 const wm::WMEvent wm_event(wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED); 86 const wm::WMEvent wm_event(wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED);
87 AdjustWindowsForWorkAreaChange(&wm_event); 87 AdjustWindowsForWorkAreaChange(&wm_event);
88 } 88 }
89 } 89 }
90 90
91 void LockLayoutManager::OnVirtualKeyboardStateChanged(bool activated) { 91 void LockLayoutManager::OnVirtualKeyboardStateChanged(bool activated) {
92 if (keyboard::KeyboardController::GetInstance()) { 92 if (keyboard::KeyboardController::GetInstance()) {
93 if (activated) { 93 if (activated) {
94 if (!is_observing_keyboard_) { 94 if (!is_observing_keyboard_) {
95 keyboard::KeyboardController::GetInstance()->AddObserver(this); 95 keyboard::KeyboardController::GetInstance()->AddObserver(this);
(...skipping 16 matching lines...) Expand all
112 void LockLayoutManager::AdjustWindowsForWorkAreaChange( 112 void LockLayoutManager::AdjustWindowsForWorkAreaChange(
113 const wm::WMEvent* event) { 113 const wm::WMEvent* event) {
114 DCHECK(event->type() == wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED || 114 DCHECK(event->type() == wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED ||
115 event->type() == wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED); 115 event->type() == wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED);
116 116
117 for (WmWindow* child : window_->GetChildren()) 117 for (WmWindow* child : window_->GetChildren())
118 child->GetWindowState()->OnWMEvent(event); 118 child->GetWindowState()->OnWMEvent(event);
119 } 119 }
120 120
121 } // namespace ash 121 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/lock_layout_manager.h ('k') | ash/common/wm/maximize_mode/maximize_mode_window_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698