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

Side by Side Diff: chrome/browser/ui/views/tabs/tab_drag_controller.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 (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 "chrome/browser/ui/views/tabs/tab_drag_controller.h" 5 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <set> 8 #include <set>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 // Delay for moving tabs after the initial delay has passed. 71 // Delay for moving tabs after the initial delay has passed.
72 const int kMoveAttachedSubsequentDelay = 300; 72 const int kMoveAttachedSubsequentDelay = 300;
73 73
74 const int kHorizontalMoveThreshold = 16; // Pixels. 74 const int kHorizontalMoveThreshold = 16; // Pixels.
75 75
76 // Distance from the next/previous stacked before before we consider the tab 76 // Distance from the next/previous stacked before before we consider the tab
77 // close enough to trigger moving. 77 // close enough to trigger moving.
78 const int kStackedDistance = 36; 78 const int kStackedDistance = 36;
79 79
80 // Dragged window is forced to be a bit smaller than maximized bounds during a
msw 2015/06/05 17:20:51 nit: "Dragged windows are" or "A dragged window"
varkha 2015/06/05 17:55:28 Done.
81 // drag. This prevents the dragged browser widget from getting maximized at
82 // creation and makes it easier to drag tabs out of a restored window that had
83 // maximized size.
84 const int kMaximizedWindowInset = 10; // Pixels.
85
80 #if defined(USE_ASH) 86 #if defined(USE_ASH)
81 void SetWindowPositionManaged(gfx::NativeWindow window, bool value) { 87 void SetWindowPositionManaged(gfx::NativeWindow window, bool value) {
82 ash::wm::GetWindowState(window)->set_window_position_managed(value); 88 ash::wm::GetWindowState(window)->set_window_position_managed(value);
83 } 89 }
84 90
85 // Returns true if |tab_strip| browser window is docked. 91 // Returns true if |tab_strip| browser window is docked.
86 bool IsDockedOrSnapped(const TabStrip* tab_strip) { 92 bool IsDockedOrSnapped(const TabStrip* tab_strip) {
87 DCHECK(tab_strip); 93 DCHECK(tab_strip);
88 ash::wm::WindowState* window_state = 94 ash::wm::WindowState* window_state =
89 ash::wm::GetWindowState(tab_strip->GetWidget()->GetNativeWindow()); 95 ash::wm::GetWindowState(tab_strip->GetWidget()->GetNativeWindow());
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 return true; 1639 return true;
1634 } 1640 }
1635 1641
1636 gfx::Rect TabDragController::CalculateDraggedBrowserBounds( 1642 gfx::Rect TabDragController::CalculateDraggedBrowserBounds(
1637 TabStrip* source, 1643 TabStrip* source,
1638 const gfx::Point& point_in_screen, 1644 const gfx::Point& point_in_screen,
1639 std::vector<gfx::Rect>* drag_bounds) { 1645 std::vector<gfx::Rect>* drag_bounds) {
1640 gfx::Point center(0, source->height() / 2); 1646 gfx::Point center(0, source->height() / 2);
1641 views::View::ConvertPointToWidget(source, &center); 1647 views::View::ConvertPointToWidget(source, &center);
1642 gfx::Rect new_bounds(source->GetWidget()->GetRestoredBounds()); 1648 gfx::Rect new_bounds(source->GetWidget()->GetRestoredBounds());
1649
1650 // If the restore bounds is larger than work area make dragging window
msw 2015/06/05 17:20:51 nit: comma here "area," and "make the dragging"
msw 2015/06/05 17:20:51 ditto nit: comment redundancy
varkha 2015/06/05 17:55:28 Done (removed the original comment here in favour
1651 // slightly smaller and behave as if it was maximized at the start of a drag.
1652 gfx::Rect work_area =
1653 screen_->GetDisplayNearestPoint(last_point_in_screen_).work_area();
1654 if (new_bounds.size().width() >= work_area.size().width() &&
1655 new_bounds.size().height() >= work_area.size().height()) {
1656 new_bounds = work_area;
1657 new_bounds.Inset(kMaximizedWindowInset, kMaximizedWindowInset,
1658 kMaximizedWindowInset, kMaximizedWindowInset);
1659 was_source_maximized_ = true;
1660 }
1661
1643 if (source->GetWidget()->IsMaximized()) { 1662 if (source->GetWidget()->IsMaximized()) {
1644 // If the restore bounds is really small, we don't want to honor it 1663 // If the restore bounds is really small, we don't want to honor it
1645 // (dragging a really small window looks wrong), instead make sure the new 1664 // (dragging a really small window looks wrong), instead make sure the new
1646 // window is at least 50% the size of the old. 1665 // window is at least 50% the size of the old.
1647 const gfx::Size max_size( 1666 const gfx::Size max_size(
1648 source->GetWidget()->GetWindowBoundsInScreen().size()); 1667 source->GetWidget()->GetWindowBoundsInScreen().size());
1649 new_bounds.set_width( 1668 new_bounds.set_width(
1650 std::max(max_size.width() / 2, new_bounds.width())); 1669 std::max(max_size.width() / 2, new_bounds.width()));
1651 new_bounds.set_height( 1670 new_bounds.set_height(
1652 std::max(max_size.height() / 2, new_bounds.height())); 1671 std::max(max_size.height() / 2, new_bounds.height()));
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 it != browser_list->end(); ++it) { 1815 it != browser_list->end(); ++it) {
1797 if ((*it)->tab_strip_model()->empty()) 1816 if ((*it)->tab_strip_model()->empty())
1798 exclude.insert((*it)->window()->GetNativeWindow()); 1817 exclude.insert((*it)->window()->GetNativeWindow());
1799 } 1818 }
1800 #endif 1819 #endif
1801 return GetLocalProcessWindowAtPoint(host_desktop_type_, 1820 return GetLocalProcessWindowAtPoint(host_desktop_type_,
1802 screen_point, 1821 screen_point,
1803 exclude); 1822 exclude);
1804 1823
1805 } 1824 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698