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

Side by Side Diff: ash/wm/lock_window_state.cc

Issue 2876993002: Introduce window container to be used by lock screen app windows (Closed)
Patch Set: . Created 3 years, 7 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_window_state.h" 5 #include "ash/wm/lock_window_state.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/screen_util.h" 9 #include "ash/screen_util.h"
10 #include "ash/shelf/wm_shelf.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 "ash/wm_window.h" 17 #include "ash/wm_window.h"
17 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.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(WmWindow* window) 26 LockWindowState::LockWindowState(WmWindow* window, bool shelf_visible)
25 : current_state_type_(window->GetWindowState()->GetStateType()) {} 27 : current_state_type_(window->GetWindowState()->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
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(WmWindow* window) { 109 wm::WindowState* LockWindowState::SetLockWindowState(WmWindow* 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 std::unique_ptr<wm::WindowState::State> old_state( 112 std::unique_ptr<wm::WindowState::State> old_state(
110 window->GetWindowState()->SetStateObject(std::move(lock_state))); 113 window->GetWindowState()->SetStateObject(std::move(lock_state)));
111 return window->GetWindowState(); 114 return window->GetWindowState();
115 }
116
117 // static
118 wm::WindowState* LockWindowState::SetLockWindowStateWithVisibleShelf(
119 WmWindow* window) {
120 std::unique_ptr<wm::WindowState::State> lock_state =
121 base::MakeUnique<LockWindowState>(window, true);
122 std::unique_ptr<wm::WindowState::State> old_state(
123 window->GetWindowState()->SetStateObject(std::move(lock_state)));
124 return window->GetWindowState();
112 } 125 }
113 126
114 void LockWindowState::UpdateWindow(wm::WindowState* window_state, 127 void LockWindowState::UpdateWindow(wm::WindowState* window_state,
115 wm::WindowStateType target_state) { 128 wm::WindowStateType target_state) {
116 DCHECK(target_state == wm::WINDOW_STATE_TYPE_MINIMIZED || 129 DCHECK(target_state == wm::WINDOW_STATE_TYPE_MINIMIZED ||
117 target_state == wm::WINDOW_STATE_TYPE_MAXIMIZED || 130 target_state == wm::WINDOW_STATE_TYPE_MAXIMIZED ||
118 (target_state == wm::WINDOW_STATE_TYPE_NORMAL && 131 (target_state == wm::WINDOW_STATE_TYPE_NORMAL &&
119 !window_state->CanMaximize()) || 132 !window_state->CanMaximize()) ||
120 target_state == wm::WINDOW_STATE_TYPE_FULLSCREEN); 133 target_state == wm::WINDOW_STATE_TYPE_FULLSCREEN);
121 134
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 window_state->window()->Show(); 166 window_state->window()->Show();
154 } 167 }
155 } 168 }
156 169
157 wm::WindowStateType LockWindowState::GetMaximizedOrCenteredWindowType( 170 wm::WindowStateType LockWindowState::GetMaximizedOrCenteredWindowType(
158 wm::WindowState* window_state) { 171 wm::WindowState* window_state) {
159 return window_state->CanMaximize() ? wm::WINDOW_STATE_TYPE_MAXIMIZED 172 return window_state->CanMaximize() ? wm::WINDOW_STATE_TYPE_MAXIMIZED
160 : wm::WINDOW_STATE_TYPE_NORMAL; 173 : wm::WINDOW_STATE_TYPE_NORMAL;
161 } 174 }
162 175
163 void LockWindowState::UpdateBounds(wm::WindowState* window_state) { 176 gfx::Rect LockWindowState::GetWindowBounds(aura::Window* window) {
164 if (!window_state->IsMaximized() && !window_state->IsFullscreen()) 177 if (shelf_visible_)
165 return; 178 return ScreenUtil::GetDisplayWorkAreaBoundsInParentForLockScreen(window);
166 179
167 keyboard::KeyboardController* keyboard_controller = 180 keyboard::KeyboardController* keyboard_controller =
168 keyboard::KeyboardController::GetInstance(); 181 keyboard::KeyboardController::GetInstance();
169 gfx::Rect keyboard_bounds; 182 gfx::Rect keyboard_bounds;
170 183
171 if (keyboard_controller && !keyboard::IsKeyboardOverscrollEnabled() && 184 if (keyboard_controller && !keyboard::IsKeyboardOverscrollEnabled() &&
172 keyboard_controller->keyboard_visible()) { 185 keyboard_controller->keyboard_visible()) {
173 keyboard_bounds = keyboard_controller->current_keyboard_bounds(); 186 keyboard_bounds = keyboard_controller->current_keyboard_bounds();
174 } 187 }
175 gfx::Rect bounds = ScreenUtil::GetDisplayBoundsWithShelf(
176 window_state->window()->aura_window());
177 bounds.set_height(bounds.height() - keyboard_bounds.height());
178 188
189 gfx::Rect bounds = ScreenUtil::GetDisplayBoundsWithShelf(window);
190 bounds.Inset(0, 0, 0, keyboard_bounds.height());
191 return bounds;
192 }
193
194 void LockWindowState::UpdateBounds(wm::WindowState* window_state) {
195 if (!window_state->IsMaximized() && !window_state->IsFullscreen())
196 return;
197
198 gfx::Rect bounds = GetWindowBounds(window_state->window()->aura_window());
179 VLOG(1) << "Updating window bounds to: " << bounds.ToString(); 199 VLOG(1) << "Updating window bounds to: " << bounds.ToString();
180 window_state->SetBoundsDirect(bounds); 200 window_state->SetBoundsDirect(bounds);
181 } 201 }
182 202
183 } // namespace ash 203 } // namespace ash
OLDNEW
« ash/wm/lock_action_handler_layout_manager.cc ('K') | « ash/wm/lock_window_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698