Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // A dragged window is forced to be a bit smaller than maximized bounds during a | |
| 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. | |
|
sky
2015/06/06 17:59:30
Again, is this really pixels?
varkha
2015/06/06 20:13:17
I thought so. This is same units as mouse travel,
| |
| 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 Loading... | |
| 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, ¢er); | 1647 views::View::ConvertPointToWidget(source, ¢er); |
| 1642 gfx::Rect new_bounds(source->GetWidget()->GetRestoredBounds()); | 1648 gfx::Rect new_bounds(source->GetWidget()->GetRestoredBounds()); |
| 1649 | |
| 1650 gfx::Rect work_area = | |
| 1651 screen_->GetDisplayNearestPoint(last_point_in_screen_).work_area(); | |
|
sky
2015/06/05 19:24:27
Shouldn't this be an else condition of maximized?
varkha
2015/06/05 19:48:48
I thinks this should be complimentary rather than
| |
| 1652 if (new_bounds.size().width() >= work_area.size().width() && | |
| 1653 new_bounds.size().height() >= work_area.size().height()) { | |
| 1654 new_bounds = work_area; | |
| 1655 new_bounds.Inset(kMaximizedWindowInset, kMaximizedWindowInset, | |
| 1656 kMaximizedWindowInset, kMaximizedWindowInset); | |
| 1657 // Behave as if the |source| was maximized at the start of a drag since this | |
| 1658 // is consistent with a browser window creation logic in case of windows | |
| 1659 // that are as large as the |work_area|. | |
| 1660 was_source_maximized_ = true; | |
| 1661 } | |
| 1662 | |
| 1643 if (source->GetWidget()->IsMaximized()) { | 1663 if (source->GetWidget()->IsMaximized()) { |
| 1644 // If the restore bounds is really small, we don't want to honor it | 1664 // 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 | 1665 // (dragging a really small window looks wrong), instead make sure the new |
| 1646 // window is at least 50% the size of the old. | 1666 // window is at least 50% the size of the old. |
| 1647 const gfx::Size max_size( | 1667 const gfx::Size max_size( |
| 1648 source->GetWidget()->GetWindowBoundsInScreen().size()); | 1668 source->GetWidget()->GetWindowBoundsInScreen().size()); |
| 1649 new_bounds.set_width( | 1669 new_bounds.set_width( |
| 1650 std::max(max_size.width() / 2, new_bounds.width())); | 1670 std::max(max_size.width() / 2, new_bounds.width())); |
| 1651 new_bounds.set_height( | 1671 new_bounds.set_height( |
| 1652 std::max(max_size.height() / 2, new_bounds.height())); | 1672 std::max(max_size.height() / 2, new_bounds.height())); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1796 it != browser_list->end(); ++it) { | 1816 it != browser_list->end(); ++it) { |
| 1797 if ((*it)->tab_strip_model()->empty()) | 1817 if ((*it)->tab_strip_model()->empty()) |
| 1798 exclude.insert((*it)->window()->GetNativeWindow()); | 1818 exclude.insert((*it)->window()->GetNativeWindow()); |
| 1799 } | 1819 } |
| 1800 #endif | 1820 #endif |
| 1801 return GetLocalProcessWindowAtPoint(host_desktop_type_, | 1821 return GetLocalProcessWindowAtPoint(host_desktop_type_, |
| 1802 screen_point, | 1822 screen_point, |
| 1803 exclude); | 1823 exclude); |
| 1804 | 1824 |
| 1805 } | 1825 } |
| OLD | NEW |