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

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

Issue 21979005: Make sure that 30%of restored window is always visible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/base_layout_manager.h" 5 #include "ash/wm/base_layout_manager.h"
6 6
7 #include "ash/screen_ash.h" 7 #include "ash/screen_ash.h"
8 #include "ash/session_state_delegate.h" 8 #include "ash/session_state_delegate.h"
9 #include "ash/shelf/shelf_layout_manager.h" 9 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 child_bounds = ScreenAsh::GetMaximizedWindowBoundsInParent(child); 100 child_bounds = ScreenAsh::GetMaximizedWindowBoundsInParent(child);
101 else if (wm::IsWindowFullscreen(child)) 101 else if (wm::IsWindowFullscreen(child))
102 child_bounds = ScreenAsh::GetDisplayBoundsInParent(child); 102 child_bounds = ScreenAsh::GetDisplayBoundsInParent(child);
103 SetChildBoundsDirect(child, child_bounds); 103 SetChildBoundsDirect(child, child_bounds);
104 } 104 }
105 105
106 ///////////////////////////////////////////////////////////////////////////// 106 /////////////////////////////////////////////////////////////////////////////
107 // BaseLayoutManager, ash::ShellObserver overrides: 107 // BaseLayoutManager, ash::ShellObserver overrides:
108 108
109 void BaseLayoutManager::OnDisplayWorkAreaInsetsChanged() { 109 void BaseLayoutManager::OnDisplayWorkAreaInsetsChanged() {
110 AdjustWindowSizesForScreenChange(ADJUST_WINDOW_DISPLAY_INSETS_CHANGED); 110 AdjustWindowsBounds(ADJUST_WINDOW_WORK_AREA_INSETS_CHANGED);
111 } 111 }
112 112
113 ///////////////////////////////////////////////////////////////////////////// 113 /////////////////////////////////////////////////////////////////////////////
114 // BaseLayoutManager, WindowObserver overrides: 114 // BaseLayoutManager, WindowObserver overrides:
115 115
116 void BaseLayoutManager::OnWindowPropertyChanged(aura::Window* window, 116 void BaseLayoutManager::OnWindowPropertyChanged(aura::Window* window,
117 const void* key, 117 const void* key,
118 intptr_t old) { 118 intptr_t old) {
119 if (key == aura::client::kShowStateKey) { 119 if (key == aura::client::kShowStateKey) {
120 ui::WindowShowState old_state = static_cast<ui::WindowShowState>(old); 120 ui::WindowShowState old_state = static_cast<ui::WindowShowState>(old);
(...skipping 17 matching lines...) Expand all
138 if (root_window_ == window) { 138 if (root_window_ == window) {
139 root_window_->RemoveObserver(this); 139 root_window_->RemoveObserver(this);
140 root_window_ = NULL; 140 root_window_ = NULL;
141 } 141 }
142 } 142 }
143 143
144 void BaseLayoutManager::OnWindowBoundsChanged(aura::Window* window, 144 void BaseLayoutManager::OnWindowBoundsChanged(aura::Window* window,
145 const gfx::Rect& old_bounds, 145 const gfx::Rect& old_bounds,
146 const gfx::Rect& new_bounds) { 146 const gfx::Rect& new_bounds) {
147 if (root_window_ == window) 147 if (root_window_ == window)
148 AdjustWindowSizesForScreenChange(ADJUST_WINDOW_SCREEN_SIZE_CHANGED); 148 AdjustWindowsBounds(ADJUST_WINDOW_DISPLAY_SIZE_CHANGED);
149 } 149 }
150 150
151 ////////////////////////////////////////////////////////////////////////////// 151 //////////////////////////////////////////////////////////////////////////////
152 // BaseLayoutManager, aura::client::ActivationChangeObserver implementation: 152 // BaseLayoutManager, aura::client::ActivationChangeObserver implementation:
153 153
154 void BaseLayoutManager::OnWindowActivated(aura::Window* gained_active, 154 void BaseLayoutManager::OnWindowActivated(aura::Window* gained_active,
155 aura::Window* lost_active) { 155 aura::Window* lost_active) {
156 if (views::corewm::UseFocusController()) { 156 if (views::corewm::UseFocusController()) {
157 if (gained_active && wm::IsWindowMinimized(gained_active) && 157 if (gained_active && wm::IsWindowMinimized(gained_active) &&
158 !gained_active->IsVisible()) { 158 !gained_active->IsVisible()) {
(...skipping 26 matching lines...) Expand all
185 // sure it's visible. 185 // sure it's visible.
186 window->Show(); 186 window->Show();
187 if (last_show_state == ui::SHOW_STATE_MINIMIZED && 187 if (last_show_state == ui::SHOW_STATE_MINIMIZED &&
188 !wm::IsWindowMaximized(window) && 188 !wm::IsWindowMaximized(window) &&
189 !wm::IsWindowFullscreen(window)) { 189 !wm::IsWindowFullscreen(window)) {
190 window->ClearProperty(internal::kWindowRestoresToRestoreBounds); 190 window->ClearProperty(internal::kWindowRestoresToRestoreBounds);
191 } 191 }
192 } 192 }
193 } 193 }
194 194
195 void BaseLayoutManager::AdjustWindowSizesForScreenChange( 195 void BaseLayoutManager::AdjustWindowsBounds(
196 AdjustWindowReason reason) { 196 AdjustWindowReason reason) {
197 // Don't do any adjustments of the insets while we are in screen locked mode. 197 // Don't do any adjustments of the insets while we are in screen locked mode.
198 // This would happen if the launcher was auto hidden before the login screen 198 // This would happen if the launcher was auto hidden before the login screen
199 // was shown and then gets shown when the login screen gets presented. 199 // was shown and then gets shown when the login screen gets presented.
200 if (reason == ADJUST_WINDOW_DISPLAY_INSETS_CHANGED && 200 if (reason == ADJUST_WINDOW_WORK_AREA_INSETS_CHANGED &&
201 Shell::GetInstance()->session_state_delegate()->IsScreenLocked()) 201 Shell::GetInstance()->session_state_delegate()->IsScreenLocked())
202 return; 202 return;
203 203
204 // If a user plugs an external display into a laptop running Aura the 204 // If a user plugs an external display into a laptop running Aura the
205 // display size will change. Maximized windows need to resize to match. 205 // display size will change. Maximized windows need to resize to match.
206 // We also do this when developers running Aura on a desktop manually resize 206 // We also do this when developers running Aura on a desktop manually resize
207 // the host window. 207 // the host window.
208 // We also need to do this when the work area insets changes. 208 // We also need to do this when the work area insets changes.
209 for (WindowSet::const_iterator it = windows_.begin(); 209 for (WindowSet::const_iterator it = windows_.begin();
210 it != windows_.end(); 210 it != windows_.end();
211 ++it) { 211 ++it) {
212 AdjustWindowSizeForScreenChange(*it, reason); 212 AdjustWindowBounds(*it, reason);
213 } 213 }
214 } 214 }
215 215
216 void BaseLayoutManager::AdjustWindowSizeForScreenChange( 216 void BaseLayoutManager::AdjustWindowBounds(
217 aura::Window* window, 217 aura::Window* window,
218 AdjustWindowReason reason) { 218 AdjustWindowReason reason) {
219 if (wm::IsWindowMaximized(window)) { 219 if (wm::IsWindowMaximized(window)) {
220 SetChildBoundsDirect( 220 SetChildBoundsDirect(
221 window, ScreenAsh::GetMaximizedWindowBoundsInParent(window)); 221 window, ScreenAsh::GetMaximizedWindowBoundsInParent(window));
222 } else if (wm::IsWindowFullscreen(window)) { 222 } else if (wm::IsWindowFullscreen(window)) {
223 SetChildBoundsDirect( 223 SetChildBoundsDirect(
224 window, ScreenAsh::GetDisplayBoundsInParent(window)); 224 window, ScreenAsh::GetDisplayBoundsInParent(window));
225 } else { 225 } else {
226 // The work area may be smaller than the full screen. 226 // The work area may be smaller than the full screen.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 window, ScreenAsh::GetDisplayBoundsInParent(window)); 264 window, ScreenAsh::GetDisplayBoundsInParent(window));
265 break; 265 break;
266 266
267 default: 267 default:
268 break; 268 break;
269 } 269 }
270 } 270 }
271 271
272 } // namespace internal 272 } // namespace internal
273 } // namespace ash 273 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698