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

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

Issue 2822613004: [M58] ash: Do not constrain window bounds if requested (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | ash/common/wm/maximize_mode/maximize_mode_window_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/common/wm/default_state.h" 5 #include "ash/common/wm/default_state.h"
6 6
7 #include "ash/common/ash_switches.h" 7 #include "ash/common/ash_switches.h"
8 #include "ash/common/wm/dock/docked_window_layout_manager.h" 8 #include "ash/common/wm/dock/docked_window_layout_manager.h"
9 #include "ash/common/wm/window_animation_types.h" 9 #include "ash/common/wm/window_animation_types.h"
10 #include "ash/common/wm/window_parenting_utils.h" 10 #include "ash/common/wm/window_parenting_utils.h"
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 bool DefaultState::ProcessWorkspaceEvents(WindowState* window_state, 445 bool DefaultState::ProcessWorkspaceEvents(WindowState* window_state,
446 const WMEvent* event) { 446 const WMEvent* event) {
447 switch (event->type()) { 447 switch (event->type()) {
448 case WM_EVENT_ADDED_TO_WORKSPACE: { 448 case WM_EVENT_ADDED_TO_WORKSPACE: {
449 // When a window is dragged and dropped onto a different 449 // When a window is dragged and dropped onto a different
450 // root window, the bounds will be updated after they are added 450 // root window, the bounds will be updated after they are added
451 // to the root window. 451 // to the root window.
452 // If a window is opened as maximized or fullscreen, its bounds may be 452 // If a window is opened as maximized or fullscreen, its bounds may be
453 // empty, so update the bounds now before checking empty. 453 // empty, so update the bounds now before checking empty.
454 if (window_state->is_dragged() || 454 if (window_state->is_dragged() ||
455 window_state->allow_set_bounds_direct() ||
455 SetMaximizedOrFullscreenBounds(window_state)) { 456 SetMaximizedOrFullscreenBounds(window_state)) {
456 return true; 457 return true;
457 } 458 }
458 459
459 WmWindow* window = window_state->window(); 460 WmWindow* window = window_state->window();
460 gfx::Rect bounds = window->GetBounds(); 461 gfx::Rect bounds = window->GetBounds();
461 462
462 // Don't adjust window bounds if the bounds are empty as this 463 // Don't adjust window bounds if the bounds are empty as this
463 // happens when a new views::Widget is created. 464 // happens when a new views::Widget is created.
464 if (bounds.IsEmpty()) 465 if (bounds.IsEmpty())
(...skipping 15 matching lines...) Expand all
480 int min_height = bounds.height() * wm::kMinimumPercentOnScreenArea; 481 int min_height = bounds.height() * wm::kMinimumPercentOnScreenArea;
481 wm::AdjustBoundsToEnsureWindowVisibility(display_area, min_width, 482 wm::AdjustBoundsToEnsureWindowVisibility(display_area, min_width,
482 min_height, &bounds); 483 min_height, &bounds);
483 window_state->AdjustSnappedBounds(&bounds); 484 window_state->AdjustSnappedBounds(&bounds);
484 if (window->GetBounds() != bounds) 485 if (window->GetBounds() != bounds)
485 window_state->SetBoundsConstrained(bounds); 486 window_state->SetBoundsConstrained(bounds);
486 return true; 487 return true;
487 } 488 }
488 case WM_EVENT_DISPLAY_BOUNDS_CHANGED: { 489 case WM_EVENT_DISPLAY_BOUNDS_CHANGED: {
489 if (window_state->is_dragged() || 490 if (window_state->is_dragged() ||
491 window_state->allow_set_bounds_direct() ||
490 SetMaximizedOrFullscreenBounds(window_state)) { 492 SetMaximizedOrFullscreenBounds(window_state)) {
491 return true; 493 return true;
492 } 494 }
493 gfx::Rect work_area_in_parent = 495 gfx::Rect work_area_in_parent =
494 GetDisplayWorkAreaBoundsInParent(window_state->window()); 496 GetDisplayWorkAreaBoundsInParent(window_state->window());
495 gfx::Rect bounds = window_state->window()->GetTargetBounds(); 497 gfx::Rect bounds = window_state->window()->GetTargetBounds();
496 // When display bounds has changed, make sure the entire window is fully 498 // When display bounds has changed, make sure the entire window is fully
497 // visible. 499 // visible.
498 bounds.AdjustToFit(work_area_in_parent); 500 bounds.AdjustToFit(work_area_in_parent);
499 window_state->AdjustSnappedBounds(&bounds); 501 window_state->AdjustSnappedBounds(&bounds);
500 if (window_state->window()->GetTargetBounds() != bounds) 502 if (window_state->window()->GetTargetBounds() != bounds)
501 window_state->SetBoundsDirectAnimated(bounds); 503 window_state->SetBoundsDirectAnimated(bounds);
502 return true; 504 return true;
503 } 505 }
504 case WM_EVENT_WORKAREA_BOUNDS_CHANGED: { 506 case WM_EVENT_WORKAREA_BOUNDS_CHANGED: {
505 // Don't resize the maximized window when the desktop is covered 507 // Don't resize the maximized window when the desktop is covered
506 // by fullscreen window. crbug.com/504299. 508 // by fullscreen window. crbug.com/504299.
507 bool in_fullscreen = 509 bool in_fullscreen =
508 window_state->window() 510 window_state->window()
509 ->GetRootWindowController() 511 ->GetRootWindowController()
510 ->GetWorkspaceWindowState() == WORKSPACE_WINDOW_STATE_FULL_SCREEN; 512 ->GetWorkspaceWindowState() == WORKSPACE_WINDOW_STATE_FULL_SCREEN;
511 if (in_fullscreen && window_state->IsMaximized()) 513 if (in_fullscreen && window_state->IsMaximized())
512 return true; 514 return true;
513 515
514 if (window_state->is_dragged() || 516 if (window_state->is_dragged() ||
517 window_state->allow_set_bounds_direct() ||
515 SetMaximizedOrFullscreenBounds(window_state)) { 518 SetMaximizedOrFullscreenBounds(window_state)) {
516 return true; 519 return true;
517 } 520 }
518 gfx::Rect work_area_in_parent = 521 gfx::Rect work_area_in_parent =
519 GetDisplayWorkAreaBoundsInParent(window_state->window()); 522 GetDisplayWorkAreaBoundsInParent(window_state->window());
520 gfx::Rect bounds = window_state->window()->GetTargetBounds(); 523 gfx::Rect bounds = window_state->window()->GetTargetBounds();
521 if (!window_state->window()->GetTransientParent()) { 524 if (!window_state->window()->GetTransientParent()) {
522 wm::AdjustBoundsToEnsureMinimumWindowVisibility(work_area_in_parent, 525 wm::AdjustBoundsToEnsureMinimumWindowVisibility(work_area_in_parent,
523 &bounds); 526 &bounds);
524 } 527 }
(...skipping 22 matching lines...) Expand all
547 case WM_EVENT_SHOW_INACTIVE: 550 case WM_EVENT_SHOW_INACTIVE:
548 case WM_EVENT_DOCK: 551 case WM_EVENT_DOCK:
549 break; 552 break;
550 } 553 }
551 return false; 554 return false;
552 } 555 }
553 556
554 // static 557 // static
555 bool DefaultState::SetMaximizedOrFullscreenBounds(WindowState* window_state) { 558 bool DefaultState::SetMaximizedOrFullscreenBounds(WindowState* window_state) {
556 DCHECK(!window_state->is_dragged()); 559 DCHECK(!window_state->is_dragged());
560 DCHECK(!window_state->allow_set_bounds_direct());
557 if (window_state->IsMaximized()) { 561 if (window_state->IsMaximized()) {
558 window_state->SetBoundsDirect( 562 window_state->SetBoundsDirect(
559 GetMaximizedWindowBoundsInParent(window_state->window())); 563 GetMaximizedWindowBoundsInParent(window_state->window()));
560 return true; 564 return true;
561 } 565 }
562 if (window_state->IsFullscreen()) { 566 if (window_state->IsFullscreen()) {
563 window_state->SetBoundsDirect( 567 window_state->SetBoundsDirect(
564 GetDisplayBoundsInParent(window_state->window())); 568 GetDisplayBoundsInParent(window_state->window()));
565 return true; 569 return true;
566 } 570 }
567 return false; 571 return false;
568 } 572 }
569 573
570 // static 574 // static
571 void DefaultState::SetBounds(WindowState* window_state, 575 void DefaultState::SetBounds(WindowState* window_state,
572 const SetBoundsEvent* event) { 576 const SetBoundsEvent* event) {
573 if (window_state->is_dragged()) { 577 if (window_state->is_dragged() || window_state->allow_set_bounds_direct()) {
574 // TODO(oshima|varkha): This may be no longer needed, as the dragging 578 // TODO(oshima|varkha): This may be no longer needed, as the dragging
575 // happens in docked window container. crbug.com/485612. 579 // happens in docked window container. crbug.com/485612.
576 window_state->SetBoundsDirect(event->requested_bounds()); 580 window_state->SetBoundsDirect(event->requested_bounds());
577 } else if (window_state->IsSnapped()) { 581 } else if (window_state->IsSnapped()) {
578 gfx::Rect work_area_in_parent = 582 gfx::Rect work_area_in_parent =
579 GetDisplayWorkAreaBoundsInParent(window_state->window()); 583 GetDisplayWorkAreaBoundsInParent(window_state->window());
580 gfx::Rect child_bounds(event->requested_bounds()); 584 gfx::Rect child_bounds(event->requested_bounds());
581 wm::AdjustBoundsSmallerThan(work_area_in_parent.size(), &child_bounds); 585 wm::AdjustBoundsSmallerThan(work_area_in_parent.size(), &child_bounds);
582 window_state->AdjustSnappedBounds(&child_bounds); 586 window_state->AdjustSnappedBounds(&child_bounds);
583 window_state->SetBoundsDirect(child_bounds); 587 window_state->SetBoundsDirect(child_bounds);
584 } else if (!SetMaximizedOrFullscreenBounds(window_state) || 588 } else if (!SetMaximizedOrFullscreenBounds(window_state)) {
585 window_state->allow_set_bounds_in_maximized()) {
586 window_state->SetBoundsConstrained(event->requested_bounds()); 589 window_state->SetBoundsConstrained(event->requested_bounds());
587 } 590 }
588 } 591 }
589 592
590 void DefaultState::EnterToNextState(WindowState* window_state, 593 void DefaultState::EnterToNextState(WindowState* window_state,
591 WindowStateType next_state_type) { 594 WindowStateType next_state_type) {
592 // Do nothing if we're already in the same state. 595 // Do nothing if we're already in the same state.
593 if (state_type_ == next_state_type) 596 if (state_type_ == next_state_type)
594 return; 597 return;
595 598
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 gfx::Rect center_in_parent = GetDisplayWorkAreaBoundsInParent(window); 817 gfx::Rect center_in_parent = GetDisplayWorkAreaBoundsInParent(window);
815 center_in_parent.ClampToCenteredSize(window->GetBounds().size()); 818 center_in_parent.ClampToCenteredSize(window->GetBounds().size());
816 window_state->SetBoundsDirectAnimated(center_in_parent); 819 window_state->SetBoundsDirectAnimated(center_in_parent);
817 } 820 }
818 // Centering window is treated as if a user moved and resized the window. 821 // Centering window is treated as if a user moved and resized the window.
819 window_state->set_bounds_changed_by_user(true); 822 window_state->set_bounds_changed_by_user(true);
820 } 823 }
821 824
822 } // namespace wm 825 } // namespace wm
823 } // namespace ash 826 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/common/wm/maximize_mode/maximize_mode_window_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698