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

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

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/aura/wm_window_aura.h" 9 #include "ash/aura/wm_window_aura.h"
10 #include "ash/common/wm/window_animation_types.h" 10 #include "ash/common/wm/window_animation_types.h"
(...skipping 11 matching lines...) Expand all
22 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
23 #include "ui/aura/window_delegate.h" 23 #include "ui/aura/window_delegate.h"
24 #include "ui/gfx/geometry/rect.h" 24 #include "ui/gfx/geometry/rect.h"
25 #include "ui/keyboard/keyboard_controller.h" 25 #include "ui/keyboard/keyboard_controller.h"
26 #include "ui/keyboard/keyboard_util.h" 26 #include "ui/keyboard/keyboard_util.h"
27 #include "ui/wm/core/window_animations.h" 27 #include "ui/wm/core/window_animations.h"
28 28
29 namespace ash { 29 namespace ash {
30 30
31 LockWindowState::LockWindowState(aura::Window* window) 31 LockWindowState::LockWindowState(aura::Window* window)
32 : current_state_type_(wm::GetWindowState(window)->GetStateType()) { 32 : current_state_type_(wm::GetWindowState(window)->GetStateType()) {}
33 }
34 33
35 LockWindowState::~LockWindowState() { 34 LockWindowState::~LockWindowState() {}
36 }
37 35
38 void LockWindowState::OnWMEvent(wm::WindowState* window_state, 36 void LockWindowState::OnWMEvent(wm::WindowState* window_state,
39 const wm::WMEvent* event) { 37 const wm::WMEvent* event) {
40 switch (event->type()) { 38 switch (event->type()) {
41 case wm::WM_EVENT_TOGGLE_FULLSCREEN: 39 case wm::WM_EVENT_TOGGLE_FULLSCREEN:
42 ToggleFullScreen(window_state, window_state->delegate()); 40 ToggleFullScreen(window_state, window_state->delegate());
43 break; 41 break;
44 case wm::WM_EVENT_FULLSCREEN: 42 case wm::WM_EVENT_FULLSCREEN:
45 UpdateWindow(window_state, wm::WINDOW_STATE_TYPE_FULLSCREEN); 43 UpdateWindow(window_state, wm::WINDOW_STATE_TYPE_FULLSCREEN);
46 break; 44 break;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 96 }
99 97
100 void LockWindowState::AttachState(wm::WindowState* window_state, 98 void LockWindowState::AttachState(wm::WindowState* window_state,
101 wm::WindowState::State* previous_state) { 99 wm::WindowState::State* previous_state) {
102 current_state_type_ = previous_state->GetType(); 100 current_state_type_ = previous_state->GetType();
103 101
104 // Initialize the state to a good preset. 102 // Initialize the state to a good preset.
105 if (current_state_type_ != wm::WINDOW_STATE_TYPE_MAXIMIZED && 103 if (current_state_type_ != wm::WINDOW_STATE_TYPE_MAXIMIZED &&
106 current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED && 104 current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED &&
107 current_state_type_ != wm::WINDOW_STATE_TYPE_FULLSCREEN) { 105 current_state_type_ != wm::WINDOW_STATE_TYPE_FULLSCREEN) {
108 UpdateWindow(window_state, 106 UpdateWindow(window_state, GetMaximizedOrCenteredWindowType(window_state));
109 GetMaximizedOrCenteredWindowType(window_state));
110 } 107 }
111 } 108 }
112 109
113 void LockWindowState::DetachState(wm::WindowState* window_state) { 110 void LockWindowState::DetachState(wm::WindowState* window_state) {}
114 }
115 111
116 // static 112 // static
117 wm::WindowState* LockWindowState::SetLockWindowState(aura::Window* window) { 113 wm::WindowState* LockWindowState::SetLockWindowState(aura::Window* window) {
118 std::unique_ptr<wm::WindowState::State> lock_state( 114 std::unique_ptr<wm::WindowState::State> lock_state(
119 new LockWindowState(window)); 115 new LockWindowState(window));
120 std::unique_ptr<wm::WindowState::State> old_state( 116 std::unique_ptr<wm::WindowState::State> old_state(
121 wm::GetWindowState(window)->SetStateObject(std::move(lock_state))); 117 wm::GetWindowState(window)->SetStateObject(std::move(lock_state)));
122 return wm::GetWindowState(window); 118 return wm::GetWindowState(window);
123 } 119 }
124 120
125 void LockWindowState::UpdateWindow(wm::WindowState* window_state, 121 void LockWindowState::UpdateWindow(wm::WindowState* window_state,
126 wm::WindowStateType target_state) { 122 wm::WindowStateType target_state) {
127 DCHECK(target_state == wm::WINDOW_STATE_TYPE_MINIMIZED || 123 DCHECK(target_state == wm::WINDOW_STATE_TYPE_MINIMIZED ||
128 target_state == wm::WINDOW_STATE_TYPE_MAXIMIZED || 124 target_state == wm::WINDOW_STATE_TYPE_MAXIMIZED ||
129 (target_state == wm::WINDOW_STATE_TYPE_NORMAL && 125 (target_state == wm::WINDOW_STATE_TYPE_NORMAL &&
130 !window_state->CanMaximize()) || 126 !window_state->CanMaximize()) ||
131 target_state == wm::WINDOW_STATE_TYPE_FULLSCREEN); 127 target_state == wm::WINDOW_STATE_TYPE_FULLSCREEN);
132 128
133 if (target_state == wm::WINDOW_STATE_TYPE_MINIMIZED) { 129 if (target_state == wm::WINDOW_STATE_TYPE_MINIMIZED) {
134 if (current_state_type_ == wm::WINDOW_STATE_TYPE_MINIMIZED) 130 if (current_state_type_ == wm::WINDOW_STATE_TYPE_MINIMIZED)
135 return; 131 return;
136 132
137 current_state_type_ = target_state; 133 current_state_type_ = target_state;
138 window_state->window()->SetVisibilityAnimationType( 134 window_state->window()->SetVisibilityAnimationType(
139 wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); 135 wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
140 window_state->window()->Hide(); 136 window_state->window()->Hide();
(...skipping 18 matching lines...) Expand all
159 if ((window_state->window()->GetTargetVisibility() || 155 if ((window_state->window()->GetTargetVisibility() ||
160 old_state_type == wm::WINDOW_STATE_TYPE_MINIMIZED) && 156 old_state_type == wm::WINDOW_STATE_TYPE_MINIMIZED) &&
161 !window_state->window()->GetLayer()->visible()) { 157 !window_state->window()->GetLayer()->visible()) {
162 // The layer may be hidden if the window was previously minimized. Make 158 // The layer may be hidden if the window was previously minimized. Make
163 // sure it's visible. 159 // sure it's visible.
164 window_state->window()->Show(); 160 window_state->window()->Show();
165 } 161 }
166 } 162 }
167 163
168 wm::WindowStateType LockWindowState::GetMaximizedOrCenteredWindowType( 164 wm::WindowStateType LockWindowState::GetMaximizedOrCenteredWindowType(
169 wm::WindowState* window_state) { 165 wm::WindowState* window_state) {
170 return window_state->CanMaximize() ? wm::WINDOW_STATE_TYPE_MAXIMIZED : 166 return window_state->CanMaximize() ? wm::WINDOW_STATE_TYPE_MAXIMIZED
171 wm::WINDOW_STATE_TYPE_NORMAL; 167 : wm::WINDOW_STATE_TYPE_NORMAL;
172 } 168 }
173 169
174 gfx::Rect GetBoundsForLockWindow(aura::Window* window) { 170 gfx::Rect GetBoundsForLockWindow(aura::Window* window) {
175 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 171 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
176 if (display_manager->IsInUnifiedMode()) { 172 if (display_manager->IsInUnifiedMode()) {
177 const display::Display& first = 173 const display::Display& first =
178 display_manager->software_mirroring_display_list()[0]; 174 display_manager->software_mirroring_display_list()[0];
179 return first.bounds(); 175 return first.bounds();
180 } else { 176 } else {
181 return ScreenUtil::GetDisplayBoundsInParent(window); 177 return ScreenUtil::GetDisplayBoundsInParent(window);
182 } 178 }
183 } 179 }
184 180
185 void LockWindowState::UpdateBounds(wm::WindowState* window_state) { 181 void LockWindowState::UpdateBounds(wm::WindowState* window_state) {
186 if (!window_state->IsMaximized() && !window_state->IsFullscreen()) 182 if (!window_state->IsMaximized() && !window_state->IsFullscreen())
187 return; 183 return;
188 184
189 keyboard::KeyboardController* keyboard_controller = 185 keyboard::KeyboardController* keyboard_controller =
190 keyboard::KeyboardController::GetInstance(); 186 keyboard::KeyboardController::GetInstance();
191 gfx::Rect keyboard_bounds; 187 gfx::Rect keyboard_bounds;
192 188
193 if (keyboard_controller && 189 if (keyboard_controller && !keyboard::IsKeyboardOverscrollEnabled() &&
194 !keyboard::IsKeyboardOverscrollEnabled() &&
195 keyboard_controller->keyboard_visible()) { 190 keyboard_controller->keyboard_visible()) {
196 keyboard_bounds = keyboard_controller->current_keyboard_bounds(); 191 keyboard_bounds = keyboard_controller->current_keyboard_bounds();
197 } 192 }
198 gfx::Rect bounds = ScreenUtil::GetShelfDisplayBoundsInRoot( 193 gfx::Rect bounds = ScreenUtil::GetShelfDisplayBoundsInRoot(
199 ash::WmWindowAura::GetAuraWindow(window_state->window())); 194 ash::WmWindowAura::GetAuraWindow(window_state->window()));
200 195
201 bounds.set_height(bounds.height() - keyboard_bounds.height()); 196 bounds.set_height(bounds.height() - keyboard_bounds.height());
202 197
203 VLOG(1) << "Updating window bounds to: " << bounds.ToString(); 198 VLOG(1) << "Updating window bounds to: " << bounds.ToString();
204 window_state->SetBoundsDirect(bounds); 199 window_state->SetBoundsDirect(bounds);
205 } 200 }
206 201
207 } // namespace ash 202 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/lock_state_controller_unittest.cc ('k') | ash/wm/maximize_mode/accelerometer_test_data_literals.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698