| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
| 10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/wm/common/wm_event.h" | 12 #include "ash/wm/common/wm_event.h" |
| 13 #include "ash/wm/lock_layout_manager.h" | 13 #include "ash/wm/lock_layout_manager.h" |
| 14 #include "ash/wm/window_animations.h" | 14 #include "ash/wm/window_animations.h" |
| 15 #include "ash/wm/window_state.h" | 15 #include "ash/wm/window_state.h" |
| 16 #include "ash/wm/window_state_aura.h" |
| 16 #include "ash/wm/window_state_delegate.h" | 17 #include "ash/wm/window_state_delegate.h" |
| 17 #include "ash/wm/window_state_util.h" | 18 #include "ash/wm/window_state_util.h" |
| 18 #include "ash/wm/window_util.h" | 19 #include "ash/wm/window_util.h" |
| 19 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
| 20 #include "ui/aura/window_delegate.h" | 21 #include "ui/aura/window_delegate.h" |
| 21 #include "ui/gfx/geometry/rect.h" | 22 #include "ui/gfx/geometry/rect.h" |
| 22 #include "ui/keyboard/keyboard_controller.h" | 23 #include "ui/keyboard/keyboard_controller.h" |
| 23 #include "ui/keyboard/keyboard_util.h" | 24 #include "ui/keyboard/keyboard_util.h" |
| 24 #include "ui/wm/core/window_animations.h" | 25 #include "ui/wm/core/window_animations.h" |
| 25 | 26 |
| 26 namespace ash { | 27 namespace ash { |
| 27 | 28 |
| 28 LockWindowState::LockWindowState(aura::Window* window) | 29 LockWindowState::LockWindowState(aura::Window* window) |
| 29 : current_state_type_(wm::GetWindowState(window)->GetStateType()) { | 30 : current_state_type_(wm::GetWindowState(window)->GetStateType()) { |
| 30 } | 31 } |
| 31 | 32 |
| 32 LockWindowState::~LockWindowState() { | 33 LockWindowState::~LockWindowState() { |
| 33 } | 34 } |
| 34 | 35 |
| 35 void LockWindowState::OnWMEvent(wm::WindowState* window_state, | 36 void LockWindowState::OnWMEvent(wm::WindowState* window_state, |
| 36 const wm::WMEvent* event) { | 37 const wm::WMEvent* event) { |
| 37 aura::Window* window = window_state->window(); | 38 aura::Window* window = window_state->aura_window(); |
| 38 gfx::Rect bounds = window->bounds(); | 39 gfx::Rect bounds = window->bounds(); |
| 39 | 40 |
| 40 switch (event->type()) { | 41 switch (event->type()) { |
| 41 case wm::WM_EVENT_TOGGLE_FULLSCREEN: | 42 case wm::WM_EVENT_TOGGLE_FULLSCREEN: |
| 42 ToggleFullScreen(window_state, window_state->delegate()); | 43 ToggleFullScreen(window_state, window_state->delegate()); |
| 43 break; | 44 break; |
| 44 case wm::WM_EVENT_FULLSCREEN: | 45 case wm::WM_EVENT_FULLSCREEN: |
| 45 UpdateWindow(window_state, wm::WINDOW_STATE_TYPE_FULLSCREEN); | 46 UpdateWindow(window_state, wm::WINDOW_STATE_TYPE_FULLSCREEN); |
| 46 break; | 47 break; |
| 47 case wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: | 48 case wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 (target_state == wm::WINDOW_STATE_TYPE_NORMAL && | 127 (target_state == wm::WINDOW_STATE_TYPE_NORMAL && |
| 127 !window_state->CanMaximize()) || | 128 !window_state->CanMaximize()) || |
| 128 target_state == wm::WINDOW_STATE_TYPE_FULLSCREEN); | 129 target_state == wm::WINDOW_STATE_TYPE_FULLSCREEN); |
| 129 | 130 |
| 130 if (target_state == wm::WINDOW_STATE_TYPE_MINIMIZED) { | 131 if (target_state == wm::WINDOW_STATE_TYPE_MINIMIZED) { |
| 131 if (current_state_type_ == wm::WINDOW_STATE_TYPE_MINIMIZED) | 132 if (current_state_type_ == wm::WINDOW_STATE_TYPE_MINIMIZED) |
| 132 return; | 133 return; |
| 133 | 134 |
| 134 current_state_type_ = target_state; | 135 current_state_type_ = target_state; |
| 135 ::wm::SetWindowVisibilityAnimationType( | 136 ::wm::SetWindowVisibilityAnimationType( |
| 136 window_state->window(), WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); | 137 window_state->aura_window(), WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); |
| 137 window_state->window()->Hide(); | 138 window_state->window()->Hide(); |
| 138 if (window_state->IsActive()) | 139 if (window_state->IsActive()) |
| 139 window_state->Deactivate(); | 140 window_state->Deactivate(); |
| 140 return; | 141 return; |
| 141 } | 142 } |
| 142 | 143 |
| 143 if (current_state_type_ == target_state) { | 144 if (current_state_type_ == target_state) { |
| 144 // If the state type did not change, update it accordingly. | 145 // If the state type did not change, update it accordingly. |
| 145 UpdateBounds(window_state); | 146 UpdateBounds(window_state); |
| 146 return; | 147 return; |
| 147 } | 148 } |
| 148 | 149 |
| 149 const wm::WindowStateType old_state_type = current_state_type_; | 150 const wm::WindowStateType old_state_type = current_state_type_; |
| 150 current_state_type_ = target_state; | 151 current_state_type_ = target_state; |
| 151 window_state->UpdateWindowShowStateFromStateType(); | 152 window_state->UpdateWindowShowStateFromStateType(); |
| 152 window_state->NotifyPreStateTypeChange(old_state_type); | 153 window_state->NotifyPreStateTypeChange(old_state_type); |
| 153 UpdateBounds(window_state); | 154 UpdateBounds(window_state); |
| 154 window_state->NotifyPostStateTypeChange(old_state_type); | 155 window_state->NotifyPostStateTypeChange(old_state_type); |
| 155 | 156 |
| 156 if ((window_state->window()->TargetVisibility() || | 157 if ((window_state->aura_window()->TargetVisibility() || |
| 157 old_state_type == wm::WINDOW_STATE_TYPE_MINIMIZED) && | 158 old_state_type == wm::WINDOW_STATE_TYPE_MINIMIZED) && |
| 158 !window_state->window()->layer()->visible()) { | 159 !window_state->aura_window()->layer()->visible()) { |
| 159 // The layer may be hidden if the window was previously minimized. Make | 160 // The layer may be hidden if the window was previously minimized. Make |
| 160 // sure it's visible. | 161 // sure it's visible. |
| 161 window_state->window()->Show(); | 162 window_state->window()->Show(); |
| 162 } | 163 } |
| 163 } | 164 } |
| 164 | 165 |
| 165 wm::WindowStateType LockWindowState::GetMaximizedOrCenteredWindowType( | 166 wm::WindowStateType LockWindowState::GetMaximizedOrCenteredWindowType( |
| 166 wm::WindowState* window_state) { | 167 wm::WindowState* window_state) { |
| 167 return window_state->CanMaximize() ? wm::WINDOW_STATE_TYPE_MAXIMIZED : | 168 return window_state->CanMaximize() ? wm::WINDOW_STATE_TYPE_MAXIMIZED : |
| 168 wm::WINDOW_STATE_TYPE_NORMAL; | 169 wm::WINDOW_STATE_TYPE_NORMAL; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 186 keyboard::KeyboardController* keyboard_controller = | 187 keyboard::KeyboardController* keyboard_controller = |
| 187 keyboard::KeyboardController::GetInstance(); | 188 keyboard::KeyboardController::GetInstance(); |
| 188 gfx::Rect keyboard_bounds; | 189 gfx::Rect keyboard_bounds; |
| 189 | 190 |
| 190 if (keyboard_controller && | 191 if (keyboard_controller && |
| 191 !keyboard::IsKeyboardOverscrollEnabled() && | 192 !keyboard::IsKeyboardOverscrollEnabled() && |
| 192 keyboard_controller->keyboard_visible()) { | 193 keyboard_controller->keyboard_visible()) { |
| 193 keyboard_bounds = keyboard_controller->current_keyboard_bounds(); | 194 keyboard_bounds = keyboard_controller->current_keyboard_bounds(); |
| 194 } | 195 } |
| 195 gfx::Rect bounds = | 196 gfx::Rect bounds = |
| 196 ScreenUtil::GetShelfDisplayBoundsInRoot(window_state->window()); | 197 ScreenUtil::GetShelfDisplayBoundsInRoot(window_state->aura_window()); |
| 197 | 198 |
| 198 bounds.set_height(bounds.height() - keyboard_bounds.height()); | 199 bounds.set_height(bounds.height() - keyboard_bounds.height()); |
| 199 | 200 |
| 200 VLOG(1) << "Updating window bounds to: " << bounds.ToString(); | 201 VLOG(1) << "Updating window bounds to: " << bounds.ToString(); |
| 201 window_state->SetBoundsDirect(bounds); | 202 window_state->SetBoundsDirect(bounds); |
| 202 } | 203 } |
| 203 | 204 |
| 204 } // namespace ash | 205 } // namespace ash |
| OLD | NEW |