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

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

Issue 169713003: Remove WindowState::IsNormalShowState() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 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/default_state.h" 5 #include "ash/wm/default_state.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/screen_util.h" 8 #include "ash/screen_util.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 bool DefaultState::ProcessCompoundEvents(WindowState* window_state, 143 bool DefaultState::ProcessCompoundEvents(WindowState* window_state,
144 WMEvent event) { 144 WMEvent event) {
145 aura::Window* window = window_state->window(); 145 aura::Window* window = window_state->window();
146 146
147 switch (event) { 147 switch (event) {
148 case TOGGLE_MAXIMIZE_CAPTION: 148 case TOGGLE_MAXIMIZE_CAPTION:
149 if (window_state->IsFullscreen()) { 149 if (window_state->IsFullscreen()) {
150 window_state->ToggleFullscreen(); 150 window_state->ToggleFullscreen();
151 } else if (window_state->IsMaximized()) { 151 } else if (window_state->IsMaximized()) {
152 window_state->Restore(); 152 window_state->Restore();
153 } else if (window_state->IsNormalShowType() || 153 } else if (window_state->IsNormalOrSnapped()) {
154 window_state->IsSnapped()) {
155 if (window_state->CanMaximize()) 154 if (window_state->CanMaximize())
156 window_state->Maximize(); 155 window_state->Maximize();
157 } 156 }
158 return true; 157 return true;
159 case TOGGLE_MAXIMIZE: 158 case TOGGLE_MAXIMIZE:
160 if (window_state->IsFullscreen()) 159 if (window_state->IsFullscreen())
161 window_state->ToggleFullscreen(); 160 window_state->ToggleFullscreen();
162 else if (window_state->IsMaximized()) 161 else if (window_state->IsMaximized())
163 window_state->Restore(); 162 window_state->Restore();
164 else if (window_state->CanMaximize()) 163 else if (window_state->CanMaximize())
(...skipping 24 matching lines...) Expand all
189 work_area.height())); 188 work_area.height()));
190 } 189 }
191 return true; 190 return true;
192 } 191 }
193 case TOGGLE_HORIZONTAL_MAXIMIZE: { 192 case TOGGLE_HORIZONTAL_MAXIMIZE: {
194 // Maximize horizontally if: 193 // Maximize horizontally if:
195 // - The window does not have a max width defined. 194 // - The window does not have a max width defined.
196 // - The window is snapped or has the normal show type. 195 // - The window is snapped or has the normal show type.
197 if (window->delegate()->GetMaximumSize().width() != 0) 196 if (window->delegate()->GetMaximumSize().width() != 0)
198 return true; 197 return true;
199 if (!window_state->IsNormalShowType() && !window_state->IsSnapped()) 198 if (!window_state->IsNormalOrSnapped())
200 return true; 199 return true;
201 gfx::Rect work_area = 200 gfx::Rect work_area =
202 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window); 201 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window);
203 if (window_state->IsNormalShowType() && 202 if (window_state->IsNormalShowType() &&
204 window_state->HasRestoreBounds() && 203 window_state->HasRestoreBounds() &&
205 (window->bounds().width() == work_area.width() && 204 (window->bounds().width() == work_area.width() &&
206 window->bounds().x() == work_area.x())) { 205 window->bounds().x() == work_area.x())) {
207 window_state->SetAndClearRestoreBounds(); 206 window_state->SetAndClearRestoreBounds();
208 } else { 207 } else {
209 gfx::Rect new_bounds(work_area.x(), 208 gfx::Rect new_bounds(work_area.x(),
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 !IsMaximizedOrFullscreenWindowShowType(old_show_type)) { 358 !IsMaximizedOrFullscreenWindowShowType(old_show_type)) {
360 window_state->SaveCurrentBoundsForRestore(); 359 window_state->SaveCurrentBoundsForRestore();
361 } 360 }
362 361
363 // When restoring from a minimized state, we want to restore to the previous 362 // When restoring from a minimized state, we want to restore to the previous
364 // bounds. However, we want to maintain the restore bounds. (The restore 363 // bounds. However, we want to maintain the restore bounds. (The restore
365 // bounds are set if a user maximized the window in one axis by double 364 // bounds are set if a user maximized the window in one axis by double
366 // clicking the window border for example). 365 // clicking the window border for example).
367 gfx::Rect restore; 366 gfx::Rect restore;
368 if (old_show_type == SHOW_TYPE_MINIMIZED && 367 if (old_show_type == SHOW_TYPE_MINIMIZED &&
369 window_state->IsNormalShowState() && 368 window_state->IsNormalOrSnapped() &&
370 window_state->HasRestoreBounds() && 369 window_state->HasRestoreBounds() &&
371 !window_state->unminimize_to_restore_bounds()) { 370 !window_state->unminimize_to_restore_bounds()) {
372 restore = window_state->GetRestoreBoundsInScreen(); 371 restore = window_state->GetRestoreBoundsInScreen();
373 window_state->SaveCurrentBoundsForRestore(); 372 window_state->SaveCurrentBoundsForRestore();
374 } 373 }
375 374
376 if (window_state->IsMaximizedOrFullscreen()) 375 if (window_state->IsMaximizedOrFullscreen())
377 MoveToDisplayForRestore(window_state); 376 MoveToDisplayForRestore(window_state);
378 377
379 WindowShowType show_type = window_state->window_show_type(); 378 WindowShowType show_type = window_state->window_show_type();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 !window_state->window()->layer()->visible()) { 444 !window_state->window()->layer()->visible()) {
446 // The layer may be hidden if the window was previously minimized. Make 445 // The layer may be hidden if the window was previously minimized. Make
447 // sure it's visible. 446 // sure it's visible.
448 window_state->window()->Show(); 447 window_state->window()->Show();
449 if (old_show_type == SHOW_TYPE_MINIMIZED && 448 if (old_show_type == SHOW_TYPE_MINIMIZED &&
450 !window_state->IsMaximizedOrFullscreen()) { 449 !window_state->IsMaximizedOrFullscreen()) {
451 window_state->set_unminimize_to_restore_bounds(false); 450 window_state->set_unminimize_to_restore_bounds(false);
452 } 451 }
453 } 452 }
454 453
455 if (window_state->IsNormalShowState()) 454 if (window_state->IsNormalOrSnapped())
456 window_state->ClearRestoreBounds(); 455 window_state->ClearRestoreBounds();
457 456
458 // Set the restore rectangle to the previously set restore rectangle. 457 // Set the restore rectangle to the previously set restore rectangle.
459 if (!restore.IsEmpty()) 458 if (!restore.IsEmpty())
460 window_state->SetRestoreBoundsInScreen(restore); 459 window_state->SetRestoreBoundsInScreen(restore);
461 } 460 }
462 461
463 bool DefaultState::SetMaximizedOrFullscreenBounds(WindowState* window_state) { 462 bool DefaultState::SetMaximizedOrFullscreenBounds(WindowState* window_state) {
464 DCHECK(!window_state->is_dragged()); 463 DCHECK(!window_state->is_dragged());
465 if (window_state->IsMaximized()) { 464 if (window_state->IsMaximized()) {
466 window_state->SetBoundsDirect( 465 window_state->SetBoundsDirect(
467 ScreenUtil::GetMaximizedWindowBoundsInParent(window_state->window())); 466 ScreenUtil::GetMaximizedWindowBoundsInParent(window_state->window()));
468 return true; 467 return true;
469 } 468 }
470 if (window_state->IsFullscreen()) { 469 if (window_state->IsFullscreen()) {
471 window_state->SetBoundsDirect( 470 window_state->SetBoundsDirect(
472 ScreenUtil::GetDisplayBoundsInParent(window_state->window())); 471 ScreenUtil::GetDisplayBoundsInParent(window_state->window()));
473 return true; 472 return true;
474 } 473 }
475 return false; 474 return false;
476 } 475 }
477 476
478 } // namespace wm 477 } // namespace wm
479 } // namespace ash 478 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/caption_buttons/frame_maximize_button_unittest.cc ('k') | ash/wm/dock/docked_window_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698