OLD | NEW |
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/wm/lock_layout_manager.h" |
6 | 6 |
7 #include "ash/keyboard/keyboard_observer_register.h" | 7 #include "ash/keyboard/keyboard_observer_register.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/wm/lock_window_state.h" | 9 #include "ash/wm/lock_window_state.h" |
10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
| 11 #include "ash/wm/window_state_aura.h" |
11 #include "ash/wm/wm_event.h" | 12 #include "ash/wm/wm_event.h" |
12 #include "ash/wm_window.h" | 13 #include "ash/wm_window.h" |
13 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
14 #include "ui/keyboard/keyboard_controller.h" | 15 #include "ui/keyboard/keyboard_controller.h" |
15 #include "ui/keyboard/keyboard_util.h" | 16 #include "ui/keyboard/keyboard_util.h" |
16 | 17 |
17 namespace ash { | 18 namespace ash { |
18 | 19 |
19 LockLayoutManager::LockLayoutManager(WmWindow* window) | 20 LockLayoutManager::LockLayoutManager(aura::Window* window) |
20 : wm::WmSnapToPixelLayoutManager(), | 21 : wm::WmSnapToPixelLayoutManager(), |
21 window_(window), | 22 window_(window), |
22 root_window_(window->GetRootWindow()), | 23 root_window_(window->GetRootWindow()), |
23 keyboard_observer_(this) { | 24 keyboard_observer_(this) { |
24 Shell::Get()->AddShellObserver(this); | 25 Shell::Get()->AddShellObserver(this); |
25 root_window_->aura_window()->AddObserver(this); | 26 root_window_->AddObserver(this); |
26 if (keyboard::KeyboardController::GetInstance()) | 27 if (keyboard::KeyboardController::GetInstance()) |
27 keyboard_observer_.Add(keyboard::KeyboardController::GetInstance()); | 28 keyboard_observer_.Add(keyboard::KeyboardController::GetInstance()); |
28 } | 29 } |
29 | 30 |
30 LockLayoutManager::~LockLayoutManager() { | 31 LockLayoutManager::~LockLayoutManager() { |
31 if (root_window_) | 32 if (root_window_) |
32 root_window_->aura_window()->RemoveObserver(this); | 33 root_window_->RemoveObserver(this); |
33 | 34 |
34 for (WmWindow* child : window_->GetChildren()) | 35 for (aura::Window* child : window_->children()) |
35 child->aura_window()->RemoveObserver(this); | 36 child->RemoveObserver(this); |
36 | 37 |
37 Shell::Get()->RemoveShellObserver(this); | 38 Shell::Get()->RemoveShellObserver(this); |
38 } | 39 } |
39 | 40 |
40 void LockLayoutManager::OnWindowResized() { | 41 void LockLayoutManager::OnWindowResized() { |
41 const wm::WMEvent event(wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED); | 42 const wm::WMEvent event(wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED); |
42 AdjustWindowsForWorkAreaChange(&event); | 43 AdjustWindowsForWorkAreaChange(&event); |
43 } | 44 } |
44 | 45 |
45 void LockLayoutManager::OnWindowAddedToLayout(WmWindow* child) { | 46 void LockLayoutManager::OnWindowAddedToLayout(aura::Window* child) { |
46 child->aura_window()->AddObserver(this); | 47 child->AddObserver(this); |
47 | 48 |
48 // LockWindowState replaces default WindowState of a child. | 49 // LockWindowState replaces default WindowState of a child. |
49 wm::WindowState* window_state = LockWindowState::SetLockWindowState(child); | 50 wm::WindowState* window_state = |
| 51 LockWindowState::SetLockWindowState(WmWindow::Get(child)); |
50 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE); | 52 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE); |
51 window_state->OnWMEvent(&event); | 53 window_state->OnWMEvent(&event); |
52 } | 54 } |
53 | 55 |
54 void LockLayoutManager::OnWillRemoveWindowFromLayout(WmWindow* child) { | 56 void LockLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) { |
55 child->aura_window()->RemoveObserver(this); | 57 child->RemoveObserver(this); |
56 } | 58 } |
57 | 59 |
58 void LockLayoutManager::OnWindowRemovedFromLayout(WmWindow* child) {} | 60 void LockLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {} |
59 | 61 |
60 void LockLayoutManager::OnChildWindowVisibilityChanged(WmWindow* child, | 62 void LockLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child, |
61 bool visible) {} | 63 bool visible) {} |
62 | 64 |
63 void LockLayoutManager::SetChildBounds(WmWindow* child, | 65 void LockLayoutManager::SetChildBounds(aura::Window* child, |
64 const gfx::Rect& requested_bounds) { | 66 const gfx::Rect& requested_bounds) { |
65 wm::WindowState* window_state = child->GetWindowState(); | 67 wm::WindowState* window_state = wm::GetWindowState(child); |
66 wm::SetBoundsEvent event(wm::WM_EVENT_SET_BOUNDS, requested_bounds); | 68 wm::SetBoundsEvent event(wm::WM_EVENT_SET_BOUNDS, requested_bounds); |
67 window_state->OnWMEvent(&event); | 69 window_state->OnWMEvent(&event); |
68 } | 70 } |
69 | 71 |
70 void LockLayoutManager::OnWindowDestroying(aura::Window* window) { | 72 void LockLayoutManager::OnWindowDestroying(aura::Window* window) { |
71 window->RemoveObserver(this); | 73 window->RemoveObserver(this); |
72 if (root_window_ == WmWindow::Get(window)) | 74 if (root_window_ == window) |
73 root_window_ = nullptr; | 75 root_window_ = nullptr; |
74 } | 76 } |
75 | 77 |
76 void LockLayoutManager::OnWindowBoundsChanged(aura::Window* window, | 78 void LockLayoutManager::OnWindowBoundsChanged(aura::Window* window, |
77 const gfx::Rect& old_bounds, | 79 const gfx::Rect& old_bounds, |
78 const gfx::Rect& new_bounds) { | 80 const gfx::Rect& new_bounds) { |
79 if (root_window_ == WmWindow::Get(window)) { | 81 if (root_window_ == window) { |
80 const wm::WMEvent wm_event(wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED); | 82 const wm::WMEvent wm_event(wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED); |
81 AdjustWindowsForWorkAreaChange(&wm_event); | 83 AdjustWindowsForWorkAreaChange(&wm_event); |
82 } | 84 } |
83 } | 85 } |
84 | 86 |
85 void LockLayoutManager::OnVirtualKeyboardStateChanged(bool activated, | 87 void LockLayoutManager::OnVirtualKeyboardStateChanged( |
86 WmWindow* root_window) { | 88 bool activated, |
| 89 aura::Window* root_window) { |
87 UpdateKeyboardObserverFromStateChanged(activated, root_window, root_window_, | 90 UpdateKeyboardObserverFromStateChanged(activated, root_window, root_window_, |
88 &keyboard_observer_); | 91 &keyboard_observer_); |
89 } | 92 } |
90 | 93 |
91 void LockLayoutManager::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) { | 94 void LockLayoutManager::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) { |
92 keyboard_bounds_ = new_bounds; | 95 keyboard_bounds_ = new_bounds; |
93 OnWindowResized(); | 96 OnWindowResized(); |
94 } | 97 } |
95 | 98 |
96 void LockLayoutManager::OnKeyboardClosed() { | 99 void LockLayoutManager::OnKeyboardClosed() { |
97 keyboard_observer_.RemoveAll(); | 100 keyboard_observer_.RemoveAll(); |
98 } | 101 } |
99 | 102 |
100 void LockLayoutManager::AdjustWindowsForWorkAreaChange( | 103 void LockLayoutManager::AdjustWindowsForWorkAreaChange( |
101 const wm::WMEvent* event) { | 104 const wm::WMEvent* event) { |
102 DCHECK(event->type() == wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED || | 105 DCHECK(event->type() == wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED || |
103 event->type() == wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED); | 106 event->type() == wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED); |
104 | 107 |
105 for (WmWindow* child : window_->GetChildren()) | 108 for (aura::Window* child : window_->children()) |
106 child->GetWindowState()->OnWMEvent(event); | 109 wm::GetWindowState(child)->OnWMEvent(event); |
107 } | 110 } |
108 | 111 |
109 } // namespace ash | 112 } // namespace ash |
OLD | NEW |