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

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

Issue 2354533004: Ports LockLayoutManager/LockWindowState to ash/common (Closed)
Patch Set: Created 4 years, 3 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/common/wm/lock_window_state.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/aura/wm_window_aura.h" 9 #include "ash/common/wm/lock_layout_manager.h"
10 #include "ash/common/wm/window_animation_types.h" 10 #include "ash/common/wm/window_animation_types.h"
11 #include "ash/common/wm/window_state.h" 11 #include "ash/common/wm/window_state.h"
12 #include "ash/common/wm/window_state_delegate.h" 12 #include "ash/common/wm/window_state_delegate.h"
13 #include "ash/common/wm/window_state_util.h" 13 #include "ash/common/wm/window_state_util.h"
14 #include "ash/common/wm/wm_event.h" 14 #include "ash/common/wm/wm_event.h"
15 #include "ash/common/wm/wm_screen_util.h" 15 #include "ash/common/wm/wm_screen_util.h"
16 #include "ash/common/wm_shell.h" 16 #include "ash/common/wm_shell.h"
17 #include "ash/display/display_manager.h" 17 #include "ash/common/wm_window.h"
18 #include "ash/shell.h"
19 #include "ash/wm/lock_layout_manager.h"
20 #include "ash/wm/window_animations.h"
21 #include "ash/wm/window_state_aura.h"
22 #include "ash/wm/window_util.h"
23 #include "ui/aura/window.h"
24 #include "ui/aura/window_delegate.h"
25 #include "ui/gfx/geometry/rect.h" 18 #include "ui/gfx/geometry/rect.h"
26 #include "ui/keyboard/keyboard_controller.h" 19 #include "ui/keyboard/keyboard_controller.h"
27 #include "ui/keyboard/keyboard_util.h" 20 #include "ui/keyboard/keyboard_util.h"
28 #include "ui/wm/core/window_animations.h"
29 21
30 namespace ash { 22 namespace ash {
31 23
32 LockWindowState::LockWindowState(aura::Window* window) 24 LockWindowState::LockWindowState(WmWindow* window)
33 : current_state_type_(wm::GetWindowState(window)->GetStateType()) {} 25 : current_state_type_(window->GetWindowState()->GetStateType()) {}
34 26
35 LockWindowState::~LockWindowState() {} 27 LockWindowState::~LockWindowState() {}
36 28
37 void LockWindowState::OnWMEvent(wm::WindowState* window_state, 29 void LockWindowState::OnWMEvent(wm::WindowState* window_state,
38 const wm::WMEvent* event) { 30 const wm::WMEvent* event) {
39 switch (event->type()) { 31 switch (event->type()) {
40 case wm::WM_EVENT_TOGGLE_FULLSCREEN: 32 case wm::WM_EVENT_TOGGLE_FULLSCREEN:
41 ToggleFullScreen(window_state, window_state->delegate()); 33 ToggleFullScreen(window_state, window_state->delegate());
42 break; 34 break;
43 case wm::WM_EVENT_FULLSCREEN: 35 case wm::WM_EVENT_FULLSCREEN:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 if (current_state_type_ != wm::WINDOW_STATE_TYPE_MAXIMIZED && 97 if (current_state_type_ != wm::WINDOW_STATE_TYPE_MAXIMIZED &&
106 current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED && 98 current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED &&
107 current_state_type_ != wm::WINDOW_STATE_TYPE_FULLSCREEN) { 99 current_state_type_ != wm::WINDOW_STATE_TYPE_FULLSCREEN) {
108 UpdateWindow(window_state, GetMaximizedOrCenteredWindowType(window_state)); 100 UpdateWindow(window_state, GetMaximizedOrCenteredWindowType(window_state));
109 } 101 }
110 } 102 }
111 103
112 void LockWindowState::DetachState(wm::WindowState* window_state) {} 104 void LockWindowState::DetachState(wm::WindowState* window_state) {}
113 105
114 // static 106 // static
115 wm::WindowState* LockWindowState::SetLockWindowState(aura::Window* window) { 107 wm::WindowState* LockWindowState::SetLockWindowState(WmWindow* window) {
116 std::unique_ptr<wm::WindowState::State> lock_state( 108 std::unique_ptr<wm::WindowState::State> lock_state =
117 new LockWindowState(window)); 109 base::MakeUnique<LockWindowState>(window);
118 std::unique_ptr<wm::WindowState::State> old_state( 110 std::unique_ptr<wm::WindowState::State> old_state(
James Cook 2016/09/20 18:22:47 Aside: old_state is unused. Do you know if we have
119 wm::GetWindowState(window)->SetStateObject(std::move(lock_state))); 111 window->GetWindowState()->SetStateObject(std::move(lock_state)));
120 return wm::GetWindowState(window); 112 return window->GetWindowState();
121 } 113 }
122 114
123 void LockWindowState::UpdateWindow(wm::WindowState* window_state, 115 void LockWindowState::UpdateWindow(wm::WindowState* window_state,
124 wm::WindowStateType target_state) { 116 wm::WindowStateType target_state) {
125 DCHECK(target_state == wm::WINDOW_STATE_TYPE_MINIMIZED || 117 DCHECK(target_state == wm::WINDOW_STATE_TYPE_MINIMIZED ||
126 target_state == wm::WINDOW_STATE_TYPE_MAXIMIZED || 118 target_state == wm::WINDOW_STATE_TYPE_MAXIMIZED ||
127 (target_state == wm::WINDOW_STATE_TYPE_NORMAL && 119 (target_state == wm::WINDOW_STATE_TYPE_NORMAL &&
128 !window_state->CanMaximize()) || 120 !window_state->CanMaximize()) ||
129 target_state == wm::WINDOW_STATE_TYPE_FULLSCREEN); 121 target_state == wm::WINDOW_STATE_TYPE_FULLSCREEN);
130 122
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 window_state->window()->Show(); 154 window_state->window()->Show();
163 } 155 }
164 } 156 }
165 157
166 wm::WindowStateType LockWindowState::GetMaximizedOrCenteredWindowType( 158 wm::WindowStateType LockWindowState::GetMaximizedOrCenteredWindowType(
167 wm::WindowState* window_state) { 159 wm::WindowState* window_state) {
168 return window_state->CanMaximize() ? wm::WINDOW_STATE_TYPE_MAXIMIZED 160 return window_state->CanMaximize() ? wm::WINDOW_STATE_TYPE_MAXIMIZED
169 : wm::WINDOW_STATE_TYPE_NORMAL; 161 : wm::WINDOW_STATE_TYPE_NORMAL;
170 } 162 }
171 163
172 gfx::Rect GetBoundsForLockWindow(aura::Window* window) {
James Cook 2016/09/20 18:22:47 Hooray for dead code removal!
173 if (WmShell::Get()->IsInUnifiedMode())
174 return WmShell::Get()->GetFirstDisplay().bounds();
175 return wm::GetDisplayBoundsInParent(WmWindowAura::Get(window));
176 }
177
178 void LockWindowState::UpdateBounds(wm::WindowState* window_state) { 164 void LockWindowState::UpdateBounds(wm::WindowState* window_state) {
179 if (!window_state->IsMaximized() && !window_state->IsFullscreen()) 165 if (!window_state->IsMaximized() && !window_state->IsFullscreen())
180 return; 166 return;
181 167
182 keyboard::KeyboardController* keyboard_controller = 168 keyboard::KeyboardController* keyboard_controller =
183 keyboard::KeyboardController::GetInstance(); 169 keyboard::KeyboardController::GetInstance();
184 gfx::Rect keyboard_bounds; 170 gfx::Rect keyboard_bounds;
185 171
186 if (keyboard_controller && !keyboard::IsKeyboardOverscrollEnabled() && 172 if (keyboard_controller && !keyboard::IsKeyboardOverscrollEnabled() &&
187 keyboard_controller->keyboard_visible()) { 173 keyboard_controller->keyboard_visible()) {
188 keyboard_bounds = keyboard_controller->current_keyboard_bounds(); 174 keyboard_bounds = keyboard_controller->current_keyboard_bounds();
189 } 175 }
190 gfx::Rect bounds = wm::GetDisplayBoundsWithShelf(window_state->window()); 176 gfx::Rect bounds = wm::GetDisplayBoundsWithShelf(window_state->window());
191 bounds.set_height(bounds.height() - keyboard_bounds.height()); 177 bounds.set_height(bounds.height() - keyboard_bounds.height());
192 178
193 VLOG(1) << "Updating window bounds to: " << bounds.ToString(); 179 VLOG(1) << "Updating window bounds to: " << bounds.ToString();
194 window_state->SetBoundsDirect(bounds); 180 window_state->SetBoundsDirect(bounds);
195 } 181 }
196 182
197 } // namespace ash 183 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698