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 "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/wm/lock_layout_manager.h" | 9 #include "ash/wm/lock_layout_manager.h" |
10 #include "ash/wm/window_animations.h" | 10 #include "ash/wm/window_animations.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 case wm::WM_EVENT_MAXIMIZE: | 52 case wm::WM_EVENT_MAXIMIZE: |
53 UpdateWindow(window_state, | 53 UpdateWindow(window_state, |
54 GetMaximizedOrCenteredWindowType(window_state)); | 54 GetMaximizedOrCenteredWindowType(window_state)); |
55 return; | 55 return; |
56 case wm::WM_EVENT_MINIMIZE: | 56 case wm::WM_EVENT_MINIMIZE: |
57 UpdateWindow(window_state, wm::WINDOW_STATE_TYPE_MINIMIZED); | 57 UpdateWindow(window_state, wm::WINDOW_STATE_TYPE_MINIMIZED); |
58 return; | 58 return; |
59 case wm::WM_EVENT_SHOW_INACTIVE: | 59 case wm::WM_EVENT_SHOW_INACTIVE: |
60 return; | 60 return; |
61 case wm::WM_EVENT_SET_BOUNDS: | 61 case wm::WM_EVENT_SET_BOUNDS: |
62 UpdateBounds(window_state); | 62 if (window_state->IsMaximized() || window_state->IsFullscreen()) { |
| 63 UpdateBounds(window_state); |
| 64 } else { |
| 65 const ash::wm::SetBoundsEvent* bounds_event = |
| 66 static_cast<const ash::wm::SetBoundsEvent*>(event); |
| 67 window_state->SetBoundsConstrained(bounds_event->requested_bounds()); |
| 68 } |
63 break; | 69 break; |
64 case wm::WM_EVENT_ADDED_TO_WORKSPACE: | 70 case wm::WM_EVENT_ADDED_TO_WORKSPACE: |
65 if (current_state_type_ != wm::WINDOW_STATE_TYPE_MAXIMIZED && | 71 if (current_state_type_ != wm::WINDOW_STATE_TYPE_MAXIMIZED && |
66 current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED && | 72 current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED && |
67 current_state_type_ != wm::WINDOW_STATE_TYPE_FULLSCREEN) { | 73 current_state_type_ != wm::WINDOW_STATE_TYPE_FULLSCREEN) { |
68 UpdateWindow(window_state, | 74 UpdateWindow(window_state, |
69 GetMaximizedOrCenteredWindowType(window_state)); | 75 GetMaximizedOrCenteredWindowType(window_state)); |
70 } | 76 } |
71 break; | 77 break; |
72 case wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED: | 78 case wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED: |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 153 } |
148 } | 154 } |
149 | 155 |
150 wm::WindowStateType LockWindowState::GetMaximizedOrCenteredWindowType( | 156 wm::WindowStateType LockWindowState::GetMaximizedOrCenteredWindowType( |
151 wm::WindowState* window_state) { | 157 wm::WindowState* window_state) { |
152 return window_state->CanMaximize() ? wm::WINDOW_STATE_TYPE_MAXIMIZED : | 158 return window_state->CanMaximize() ? wm::WINDOW_STATE_TYPE_MAXIMIZED : |
153 wm::WINDOW_STATE_TYPE_NORMAL; | 159 wm::WINDOW_STATE_TYPE_NORMAL; |
154 } | 160 } |
155 | 161 |
156 void LockWindowState::UpdateBounds(wm::WindowState* window_state) { | 162 void LockWindowState::UpdateBounds(wm::WindowState* window_state) { |
| 163 if (!window_state->IsMaximized() && !window_state->IsFullscreen()) |
| 164 return; |
| 165 |
157 keyboard::KeyboardController* keyboard_controller = | 166 keyboard::KeyboardController* keyboard_controller = |
158 keyboard::KeyboardController::GetInstance(); | 167 keyboard::KeyboardController::GetInstance(); |
159 gfx::Rect keyboard_bounds; | 168 gfx::Rect keyboard_bounds; |
160 | 169 |
161 if (keyboard_controller && !keyboard::IsKeyboardOverscrollEnabled()) | 170 if (keyboard_controller && !keyboard::IsKeyboardOverscrollEnabled()) |
162 keyboard_bounds = keyboard_controller->current_keyboard_bounds(); | 171 keyboard_bounds = keyboard_controller->current_keyboard_bounds(); |
163 | 172 |
164 gfx::Rect bounds = | 173 gfx::Rect bounds = |
165 ScreenUtil::GetDisplayBoundsInParent(window_state->window()); | 174 ScreenUtil::GetDisplayBoundsInParent(window_state->window()); |
166 bounds.set_height(bounds.height() - keyboard_bounds.height()); | 175 bounds.set_height(bounds.height() - keyboard_bounds.height()); |
167 window_state->SetBoundsDirect(bounds); | 176 window_state->SetBoundsDirect(bounds); |
168 } | 177 } |
169 | 178 |
170 } // namespace ash | 179 } // namespace ash |
OLD | NEW |