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

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

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

Powered by Google App Engine
This is Rietveld 408576698