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

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

Issue 1156893008: Fixes tab dragging out of a window with maximzied bounds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes tab dragging out of a window with maximzied bounds (test) Created 5 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/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 13 matching lines...) Expand all
24 #include "ui/gfx/geometry/rect.h" 24 #include "ui/gfx/geometry/rect.h"
25 25
26 namespace ash { 26 namespace ash {
27 namespace wm { 27 namespace wm {
28 namespace { 28 namespace {
29 29
30 // This specifies how much percent (30%) of a window rect 30 // This specifies how much percent (30%) of a window rect
31 // must be visible when the window is added to the workspace. 31 // must be visible when the window is added to the workspace.
32 const float kMinimumPercentOnScreenArea = 0.3f; 32 const float kMinimumPercentOnScreenArea = 0.3f;
33 33
34 // When a window that has restore bounds at least as large as a work area is
35 // unmaximized inset the bounds slightly so that they are not exactly same. This
msw 2015/06/05 17:20:51 nit: comma here: "unmaximized," and "exactly the s
varkha 2015/06/05 17:55:28 Done.
36 // makes it easier to resize the window.
37 const int kMaximizedWindowInset = 10; // Pixels.
38
34 bool IsMinimizedWindowState(const WindowStateType state_type) { 39 bool IsMinimizedWindowState(const WindowStateType state_type) {
35 return state_type == WINDOW_STATE_TYPE_MINIMIZED || 40 return state_type == WINDOW_STATE_TYPE_MINIMIZED ||
36 state_type == WINDOW_STATE_TYPE_DOCKED_MINIMIZED; 41 state_type == WINDOW_STATE_TYPE_DOCKED_MINIMIZED;
37 } 42 }
38 43
39 void MoveToDisplayForRestore(WindowState* window_state) { 44 void MoveToDisplayForRestore(WindowState* window_state) {
40 if (!window_state->HasRestoreBounds()) 45 if (!window_state->HasRestoreBounds())
41 return; 46 return;
42 const gfx::Rect& restore_bounds = window_state->GetRestoreBoundsInScreen(); 47 const gfx::Rect& restore_bounds = window_state->GetRestoreBoundsInScreen();
43 48
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 bounds_in_parent = window_state->GetRestoreBoundsInParent(); 644 bounds_in_parent = window_state->GetRestoreBoundsInParent();
640 // Check if the |window|'s restored size is bigger than the working area 645 // Check if the |window|'s restored size is bigger than the working area
641 // This may happen if a window was resized to maximized bounds or if the 646 // This may happen if a window was resized to maximized bounds or if the
642 // display resolution changed while the window was maximized. 647 // display resolution changed while the window was maximized.
643 if (previous_state_type == WINDOW_STATE_TYPE_MAXIMIZED && 648 if (previous_state_type == WINDOW_STATE_TYPE_MAXIMIZED &&
644 bounds_in_parent.width() >= work_area_in_parent.width() && 649 bounds_in_parent.width() >= work_area_in_parent.width() &&
645 bounds_in_parent.height() >= work_area_in_parent.height()) { 650 bounds_in_parent.height() >= work_area_in_parent.height()) {
646 // Inset the bounds slightly so that they are not exactly same as 651 // Inset the bounds slightly so that they are not exactly same as
647 // the work area bounds and it is easier to resize the window. 652 // the work area bounds and it is easier to resize the window.
648 bounds_in_parent = work_area_in_parent; 653 bounds_in_parent = work_area_in_parent;
649 bounds_in_parent.Inset(10, 10, 10, 10); 654 bounds_in_parent.Inset(kMaximizedWindowInset, kMaximizedWindowInset,
655 kMaximizedWindowInset, kMaximizedWindowInset);
650 } 656 }
651 } else { 657 } else {
652 bounds_in_parent = window->bounds(); 658 bounds_in_parent = window->bounds();
653 } 659 }
654 // Make sure that part of the window is always visible. 660 // Make sure that part of the window is always visible.
655 AdjustBoundsToEnsureMinimumWindowVisibility( 661 AdjustBoundsToEnsureMinimumWindowVisibility(
656 work_area_in_parent, &bounds_in_parent); 662 work_area_in_parent, &bounds_in_parent);
657 break; 663 break;
658 } 664 }
659 case WINDOW_STATE_TYPE_MAXIMIZED: 665 case WINDOW_STATE_TYPE_MAXIMIZED:
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window); 739 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window);
734 center_in_parent.ClampToCenteredSize(window->bounds().size()); 740 center_in_parent.ClampToCenteredSize(window->bounds().size());
735 window_state->SetBoundsDirectAnimated(center_in_parent); 741 window_state->SetBoundsDirectAnimated(center_in_parent);
736 } 742 }
737 // Centering window is treated as if a user moved and resized the window. 743 // Centering window is treated as if a user moved and resized the window.
738 window_state->set_bounds_changed_by_user(true); 744 window_state->set_bounds_changed_by_user(true);
739 } 745 }
740 746
741 } // namespace wm 747 } // namespace wm
742 } // namespace ash 748 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698