| 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_window_state.h" | 5 #include "ash/wm/lock_window_state.h" |
| 6 | 6 |
| 7 #include <memory> |
| 7 #include <utility> | 8 #include <utility> |
| 8 | 9 |
| 9 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
| 10 #include "ash/wm/lock_layout_manager.h" | 11 #include "ash/wm/lock_layout_manager.h" |
| 11 #include "ash/wm/window_animation_types.h" | 12 #include "ash/wm/window_animation_types.h" |
| 12 #include "ash/wm/window_state.h" | 13 #include "ash/wm/window_state.h" |
| 13 #include "ash/wm/window_state_delegate.h" | 14 #include "ash/wm/window_state_delegate.h" |
| 14 #include "ash/wm/window_state_util.h" | 15 #include "ash/wm/window_state_util.h" |
| 15 #include "ash/wm/wm_event.h" | 16 #include "ash/wm/wm_event.h" |
| 16 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 17 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| 18 #include "ui/gfx/geometry/rect.h" | 19 #include "ui/gfx/geometry/rect.h" |
| 19 #include "ui/keyboard/keyboard_controller.h" | 20 #include "ui/keyboard/keyboard_controller.h" |
| 20 #include "ui/keyboard/keyboard_util.h" | 21 #include "ui/keyboard/keyboard_util.h" |
| 22 #include "ui/wm/core/coordinate_conversion.h" |
| 21 | 23 |
| 22 namespace ash { | 24 namespace ash { |
| 23 | 25 |
| 24 LockWindowState::LockWindowState(aura::Window* window) | 26 LockWindowState::LockWindowState(aura::Window* window, bool shelf_visible) |
| 25 : current_state_type_(wm::GetWindowState(window)->GetStateType()) {} | 27 : current_state_type_(wm::GetWindowState(window)->GetStateType()), |
| 28 shelf_visible_(shelf_visible) {} |
| 26 | 29 |
| 27 LockWindowState::~LockWindowState() {} | 30 LockWindowState::~LockWindowState() {} |
| 28 | 31 |
| 29 void LockWindowState::OnWMEvent(wm::WindowState* window_state, | 32 void LockWindowState::OnWMEvent(wm::WindowState* window_state, |
| 30 const wm::WMEvent* event) { | 33 const wm::WMEvent* event) { |
| 31 switch (event->type()) { | 34 switch (event->type()) { |
| 32 case wm::WM_EVENT_TOGGLE_FULLSCREEN: | 35 case wm::WM_EVENT_TOGGLE_FULLSCREEN: |
| 33 ToggleFullScreen(window_state, window_state->delegate()); | 36 ToggleFullScreen(window_state, window_state->delegate()); |
| 34 break; | 37 break; |
| 35 case wm::WM_EVENT_FULLSCREEN: | 38 case wm::WM_EVENT_FULLSCREEN: |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 current_state_type_ != wm::WINDOW_STATE_TYPE_FULLSCREEN) { | 101 current_state_type_ != wm::WINDOW_STATE_TYPE_FULLSCREEN) { |
| 99 UpdateWindow(window_state, GetMaximizedOrCenteredWindowType(window_state)); | 102 UpdateWindow(window_state, GetMaximizedOrCenteredWindowType(window_state)); |
| 100 } | 103 } |
| 101 } | 104 } |
| 102 | 105 |
| 103 void LockWindowState::DetachState(wm::WindowState* window_state) {} | 106 void LockWindowState::DetachState(wm::WindowState* window_state) {} |
| 104 | 107 |
| 105 // static | 108 // static |
| 106 wm::WindowState* LockWindowState::SetLockWindowState(aura::Window* window) { | 109 wm::WindowState* LockWindowState::SetLockWindowState(aura::Window* window) { |
| 107 std::unique_ptr<wm::WindowState::State> lock_state = | 110 std::unique_ptr<wm::WindowState::State> lock_state = |
| 108 base::MakeUnique<LockWindowState>(window); | 111 base::MakeUnique<LockWindowState>(window, false); |
| 109 wm::WindowState* window_state = wm::GetWindowState(window); | 112 wm::WindowState* window_state = wm::GetWindowState(window); |
| 110 std::unique_ptr<wm::WindowState::State> old_state( | 113 std::unique_ptr<wm::WindowState::State> old_state( |
| 111 window_state->SetStateObject(std::move(lock_state))); | 114 window_state->SetStateObject(std::move(lock_state))); |
| 115 return window_state; |
| 116 } |
| 117 |
| 118 // static |
| 119 wm::WindowState* LockWindowState::SetLockWindowStateWithVisibleShelf( |
| 120 aura::Window* window) { |
| 121 std::unique_ptr<wm::WindowState::State> lock_state = |
| 122 base::MakeUnique<LockWindowState>(window, true); |
| 123 wm::WindowState* window_state = wm::GetWindowState(window); |
| 124 std::unique_ptr<wm::WindowState::State> old_state( |
| 125 window_state->SetStateObject(std::move(lock_state))); |
| 112 return window_state; | 126 return window_state; |
| 113 } | 127 } |
| 114 | 128 |
| 115 void LockWindowState::UpdateWindow(wm::WindowState* window_state, | 129 void LockWindowState::UpdateWindow(wm::WindowState* window_state, |
| 116 wm::WindowStateType target_state) { | 130 wm::WindowStateType target_state) { |
| 117 DCHECK(target_state == wm::WINDOW_STATE_TYPE_MINIMIZED || | 131 DCHECK(target_state == wm::WINDOW_STATE_TYPE_MINIMIZED || |
| 118 target_state == wm::WINDOW_STATE_TYPE_MAXIMIZED || | 132 target_state == wm::WINDOW_STATE_TYPE_MAXIMIZED || |
| 119 (target_state == wm::WINDOW_STATE_TYPE_NORMAL && | 133 (target_state == wm::WINDOW_STATE_TYPE_NORMAL && |
| 120 !window_state->CanMaximize()) || | 134 !window_state->CanMaximize()) || |
| 121 target_state == wm::WINDOW_STATE_TYPE_FULLSCREEN); | 135 target_state == wm::WINDOW_STATE_TYPE_FULLSCREEN); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 window_state->window()->Show(); | 168 window_state->window()->Show(); |
| 155 } | 169 } |
| 156 } | 170 } |
| 157 | 171 |
| 158 wm::WindowStateType LockWindowState::GetMaximizedOrCenteredWindowType( | 172 wm::WindowStateType LockWindowState::GetMaximizedOrCenteredWindowType( |
| 159 wm::WindowState* window_state) { | 173 wm::WindowState* window_state) { |
| 160 return window_state->CanMaximize() ? wm::WINDOW_STATE_TYPE_MAXIMIZED | 174 return window_state->CanMaximize() ? wm::WINDOW_STATE_TYPE_MAXIMIZED |
| 161 : wm::WINDOW_STATE_TYPE_NORMAL; | 175 : wm::WINDOW_STATE_TYPE_NORMAL; |
| 162 } | 176 } |
| 163 | 177 |
| 164 void LockWindowState::UpdateBounds(wm::WindowState* window_state) { | 178 gfx::Rect LockWindowState::GetWindowBounds(aura::Window* window) { |
| 165 if (!window_state->IsMaximized() && !window_state->IsFullscreen()) | 179 if (shelf_visible_) |
| 166 return; | 180 return ScreenUtil::GetDisplayWorkAreaBoundsInParentForLockScreen(window); |
| 167 | 181 |
| 168 keyboard::KeyboardController* keyboard_controller = | 182 keyboard::KeyboardController* keyboard_controller = |
| 169 keyboard::KeyboardController::GetInstance(); | 183 keyboard::KeyboardController::GetInstance(); |
| 170 gfx::Rect keyboard_bounds; | 184 gfx::Rect keyboard_bounds; |
| 171 | 185 |
| 172 if (keyboard_controller && !keyboard::IsKeyboardOverscrollEnabled() && | 186 if (keyboard_controller && !keyboard::IsKeyboardOverscrollEnabled() && |
| 173 keyboard_controller->keyboard_visible()) { | 187 keyboard_controller->keyboard_visible()) { |
| 174 keyboard_bounds = keyboard_controller->current_keyboard_bounds(); | 188 keyboard_bounds = keyboard_controller->current_keyboard_bounds(); |
| 175 } | 189 } |
| 176 gfx::Rect bounds = | |
| 177 ScreenUtil::GetDisplayBoundsWithShelf(window_state->window()); | |
| 178 bounds.set_height(bounds.height() - keyboard_bounds.height()); | |
| 179 | 190 |
| 191 gfx::Rect bounds = ScreenUtil::GetDisplayBoundsWithShelf(window); |
| 192 bounds.Inset(0, 0, 0, keyboard_bounds.height()); |
| 193 return bounds; |
| 194 } |
| 195 |
| 196 void LockWindowState::UpdateBounds(wm::WindowState* window_state) { |
| 197 if (!window_state->IsMaximized() && !window_state->IsFullscreen()) |
| 198 return; |
| 199 |
| 200 gfx::Rect bounds = GetWindowBounds(window_state->window()); |
| 180 VLOG(1) << "Updating window bounds to: " << bounds.ToString(); | 201 VLOG(1) << "Updating window bounds to: " << bounds.ToString(); |
| 181 window_state->SetBoundsDirect(bounds); | 202 window_state->SetBoundsDirect(bounds); |
| 182 } | 203 } |
| 183 | 204 |
| 184 } // namespace ash | 205 } // namespace ash |
| OLD | NEW |