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

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

Issue 2354533004: Ports LockLayoutManager/LockWindowState to ash/common (Closed)
Patch Set: Created 4 years, 3 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/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/window_state.h" 8 #include "ash/common/wm/window_state.h"
8 #include "ash/common/wm/wm_event.h" 9 #include "ash/common/wm/wm_event.h"
9 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
10 #include "ash/wm/lock_window_state.h" 11 #include "ash/common/wm_window.h"
11 #include "ash/wm/window_state_aura.h"
12 #include "ui/aura/window.h"
13 #include "ui/aura/window_observer.h"
14 #include "ui/events/event.h" 12 #include "ui/events/event.h"
15 #include "ui/keyboard/keyboard_controller.h" 13 #include "ui/keyboard/keyboard_controller.h"
16 #include "ui/keyboard/keyboard_util.h" 14 #include "ui/keyboard/keyboard_util.h"
17 15
18 namespace ash { 16 namespace ash {
19 17
20 LockLayoutManager::LockLayoutManager(aura::Window* window) 18 LockLayoutManager::LockLayoutManager(WmWindow* window)
21 : SnapToPixelLayoutManager(window), 19 : wm::WmSnapToPixelLayoutManager(),
22 window_(window), 20 window_(window),
23 root_window_(window->GetRootWindow()), 21 root_window_(window->GetRootWindow()),
24 is_observing_keyboard_(false) { 22 is_observing_keyboard_(false) {
25 WmShell::Get()->AddShellObserver(this); 23 WmShell::Get()->AddShellObserver(this);
26 root_window_->AddObserver(this); 24 root_window_->AddObserver(this);
27 if (keyboard::KeyboardController::GetInstance()) { 25 if (keyboard::KeyboardController::GetInstance()) {
28 keyboard::KeyboardController::GetInstance()->AddObserver(this); 26 keyboard::KeyboardController::GetInstance()->AddObserver(this);
29 is_observing_keyboard_ = true; 27 is_observing_keyboard_ = true;
30 } 28 }
31 } 29 }
32 30
33 LockLayoutManager::~LockLayoutManager() { 31 LockLayoutManager::~LockLayoutManager() {
34 if (root_window_) 32 if (root_window_)
35 root_window_->RemoveObserver(this); 33 root_window_->RemoveObserver(this);
36 34
37 for (aura::Window::Windows::const_iterator it = window_->children().begin(); 35 for (WmWindow* child : window_->GetChildren())
38 it != window_->children().end(); ++it) { 36 child->RemoveObserver(this);
39 (*it)->RemoveObserver(this);
40 }
41 37
42 WmShell::Get()->RemoveShellObserver(this); 38 WmShell::Get()->RemoveShellObserver(this);
43 39
44 if (keyboard::KeyboardController::GetInstance() && is_observing_keyboard_) { 40 if (keyboard::KeyboardController::GetInstance() && is_observing_keyboard_) {
45 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); 41 keyboard::KeyboardController::GetInstance()->RemoveObserver(this);
46 is_observing_keyboard_ = false; 42 is_observing_keyboard_ = false;
47 } 43 }
48 } 44 }
49 45
50 void LockLayoutManager::OnWindowResized() { 46 void LockLayoutManager::OnWindowResized() {
51 const wm::WMEvent event(wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED); 47 const wm::WMEvent event(wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED);
52 AdjustWindowsForWorkAreaChange(&event); 48 AdjustWindowsForWorkAreaChange(&event);
53 } 49 }
54 50
55 void LockLayoutManager::OnWindowAddedToLayout(aura::Window* child) { 51 void LockLayoutManager::OnWindowAddedToLayout(WmWindow* child) {
56 child->AddObserver(this); 52 child->AddObserver(this);
57 53
58 // LockWindowState replaces default WindowState of a child. 54 // LockWindowState replaces default WindowState of a child.
59 wm::WindowState* window_state = LockWindowState::SetLockWindowState(child); 55 wm::WindowState* window_state = LockWindowState::SetLockWindowState(child);
60 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE); 56 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE);
61 window_state->OnWMEvent(&event); 57 window_state->OnWMEvent(&event);
62 } 58 }
63 59
64 void LockLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) { 60 void LockLayoutManager::OnWillRemoveWindowFromLayout(WmWindow* child) {
65 child->RemoveObserver(this); 61 child->RemoveObserver(this);
66 } 62 }
67 63
68 void LockLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {} 64 void LockLayoutManager::OnWindowRemovedFromLayout(WmWindow* child) {}
69 65
70 void LockLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child, 66 void LockLayoutManager::OnChildWindowVisibilityChanged(WmWindow* child,
71 bool visible) {} 67 bool visible) {}
72 68
73 void LockLayoutManager::SetChildBounds(aura::Window* child, 69 void LockLayoutManager::SetChildBounds(WmWindow* child,
74 const gfx::Rect& requested_bounds) { 70 const gfx::Rect& requested_bounds) {
75 wm::WindowState* window_state = wm::GetWindowState(child); 71 wm::WindowState* window_state = child->GetWindowState();
76 wm::SetBoundsEvent event(wm::WM_EVENT_SET_BOUNDS, requested_bounds); 72 wm::SetBoundsEvent event(wm::WM_EVENT_SET_BOUNDS, requested_bounds);
77 window_state->OnWMEvent(&event); 73 window_state->OnWMEvent(&event);
78 } 74 }
79 75
80 void LockLayoutManager::OnWindowHierarchyChanged( 76 void LockLayoutManager::OnWindowDestroying(WmWindow* window) {
81 const WindowObserver::HierarchyChangeParams& params) {}
82
83 void LockLayoutManager::OnWindowPropertyChanged(aura::Window* window,
84 const void* key,
85 intptr_t old) {}
86
87 void LockLayoutManager::OnWindowStackingChanged(aura::Window* window) {}
88
89 void LockLayoutManager::OnWindowDestroying(aura::Window* window) {
90 window->RemoveObserver(this); 77 window->RemoveObserver(this);
91 if (root_window_ == window) 78 if (root_window_ == window)
92 root_window_ = NULL; 79 root_window_ = nullptr;
93 } 80 }
94 81
95 void LockLayoutManager::OnWindowBoundsChanged(aura::Window* window, 82 void LockLayoutManager::OnWindowBoundsChanged(WmWindow* window,
96 const gfx::Rect& old_bounds, 83 const gfx::Rect& old_bounds,
97 const gfx::Rect& new_bounds) { 84 const gfx::Rect& new_bounds) {
98 if (root_window_ == window) { 85 if (root_window_ == window) {
99 const wm::WMEvent wm_event(wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED); 86 const wm::WMEvent wm_event(wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED);
100 AdjustWindowsForWorkAreaChange(&wm_event); 87 AdjustWindowsForWorkAreaChange(&wm_event);
101 } 88 }
102 } 89 }
103 90
104 void LockLayoutManager::OnVirtualKeyboardStateChanged(bool activated) { 91 void LockLayoutManager::OnVirtualKeyboardStateChanged(bool activated) {
105 if (keyboard::KeyboardController::GetInstance()) { 92 if (keyboard::KeyboardController::GetInstance()) {
(...skipping 14 matching lines...) Expand all
120 OnWindowResized(); 107 OnWindowResized();
121 } 108 }
122 109
123 void LockLayoutManager::OnKeyboardClosed() {} 110 void LockLayoutManager::OnKeyboardClosed() {}
124 111
125 void LockLayoutManager::AdjustWindowsForWorkAreaChange( 112 void LockLayoutManager::AdjustWindowsForWorkAreaChange(
126 const wm::WMEvent* event) { 113 const wm::WMEvent* event) {
127 DCHECK(event->type() == wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED || 114 DCHECK(event->type() == wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED ||
128 event->type() == wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED); 115 event->type() == wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED);
129 116
130 for (aura::Window::Windows::const_iterator it = window_->children().begin(); 117 for (WmWindow* child : window_->GetChildren())
131 it != window_->children().end(); ++it) { 118 child->GetWindowState()->OnWMEvent(event);
132 wm::GetWindowState(*it)->OnWMEvent(event);
133 }
134 } 119 }
135 120
136 } // namespace ash 121 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698