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

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 (nits) 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 the same.
36 // This makes it easier to resize the window.
37 const int kMaximizedWindowInset = 10; // Pixels.
sky 2015/06/06 17:59:30 Is this really pixels?
varkha 2015/06/06 20:13:17 I thought so. Isn't that what window bounds are ex
sky 2015/06/07 00:05:20 It may depend upon the platform, but I have to loo
oshima 2015/06/07 01:19:02 This is DIP.
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 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 gfx::Rect work_area_in_parent = 641 gfx::Rect work_area_in_parent =
637 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_state->window()); 642 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_state->window());
638 if (window_state->HasRestoreBounds()) { 643 if (window_state->HasRestoreBounds()) {
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
647 // the work area bounds and it is easier to resize the window.
648 bounds_in_parent = work_area_in_parent; 651 bounds_in_parent = work_area_in_parent;
649 bounds_in_parent.Inset(10, 10, 10, 10); 652 bounds_in_parent.Inset(kMaximizedWindowInset, kMaximizedWindowInset,
653 kMaximizedWindowInset, kMaximizedWindowInset);
650 } 654 }
651 } else { 655 } else {
652 bounds_in_parent = window->bounds(); 656 bounds_in_parent = window->bounds();
653 } 657 }
654 // Make sure that part of the window is always visible. 658 // Make sure that part of the window is always visible.
655 AdjustBoundsToEnsureMinimumWindowVisibility( 659 AdjustBoundsToEnsureMinimumWindowVisibility(
656 work_area_in_parent, &bounds_in_parent); 660 work_area_in_parent, &bounds_in_parent);
657 break; 661 break;
658 } 662 }
659 case WINDOW_STATE_TYPE_MAXIMIZED: 663 case WINDOW_STATE_TYPE_MAXIMIZED:
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window); 737 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window);
734 center_in_parent.ClampToCenteredSize(window->bounds().size()); 738 center_in_parent.ClampToCenteredSize(window->bounds().size());
735 window_state->SetBoundsDirectAnimated(center_in_parent); 739 window_state->SetBoundsDirectAnimated(center_in_parent);
736 } 740 }
737 // Centering window is treated as if a user moved and resized the window. 741 // Centering window is treated as if a user moved and resized the window.
738 window_state->set_bounds_changed_by_user(true); 742 window_state->set_bounds_changed_by_user(true);
739 } 743 }
740 744
741 } // namespace wm 745 } // namespace wm
742 } // namespace ash 746 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698