diff options
author | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-12 19:00:57 +0000 |
---|---|---|
committer | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-12 19:00:57 +0000 |
commit | e3740143c28c371adf5b6669d45176965e186052 (patch) | |
tree | 12407f902ac6c59a2f1e237694e8422c02a31a98 /chrome/browser/views/tabs/dragged_tab_controller.cc | |
parent | 3c6f71f746758bc311a87bc573a9575c1f9d5123 (diff) | |
download | chromium_src-e3740143c28c371adf5b6669d45176965e186052.zip chromium_src-e3740143c28c371adf5b6669d45176965e186052.tar.gz chromium_src-e3740143c28c371adf5b6669d45176965e186052.tar.bz2 |
During tab dragging if you hover over a browser window we now move it
to front after a delay. Also made docking to another window bring the
other window to front.
BUG=2038
TEST=Create two window with two tabs each. Drag a tab from one window
onto the other window (not the tab area), hold it for a second and
make sure the other window comes to front.
Review URL: http://codereview.chromium.org/14057
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6909 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/tabs/dragged_tab_controller.cc')
-rw-r--r-- | chrome/browser/views/tabs/dragged_tab_controller.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc index 0ff61d5..2b3c22c 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.cc +++ b/chrome/browser/views/tabs/dragged_tab_controller.cc @@ -29,6 +29,9 @@ namespace { // be sure and update the constants in DockInfo (kEnableDeltaX/kEnableDeltaY). const int kDropWindowSize = 100; +// Delay, in ms, during dragging before we bring a window to front. +const int kBringToFrontDelay = 750; + // TODO (glen): nuke this class in favor of something pretty. Consider this // class a placeholder for the real thing. class DockView : public views::View { @@ -339,6 +342,8 @@ void DraggedTabController::CaptureDragInfo(const gfx::Point& mouse_offset) { } void DraggedTabController::Drag() { + bring_to_front_timer_.Stop(); + // Before we get to dragging anywhere, ensure that we consider ourselves // attached to the source tabstrip. if (source_tab_->IsVisible() && CanStartDrag()) @@ -612,6 +617,11 @@ void DraggedTabController::ContinueDragging() { if (target_tabstrip) Attach(target_tabstrip, screen_point); } + if (!target_tabstrip) { + bring_to_front_timer_.Start( + base::TimeDelta::FromMilliseconds(kBringToFrontDelay), this, + &DraggedTabController::BringWindowUnderMouseToFront); + } UpdateDockInfo(screen_point); @@ -912,6 +922,8 @@ Tab* DraggedTabController::GetTabMatchingDraggedContents( } void DraggedTabController::EndDragImpl(EndDragType type) { + bring_to_front_timer_.Stop(); + // Hide the current dock controllers. for (size_t i = 0; i < dock_controllers_.size(); ++i) { // Be sure and clear the controller first, that way if Hide ends up @@ -1164,3 +1176,25 @@ void DraggedTabController::DockDisplayerDestroyed( else NOTREACHED(); } + +void DraggedTabController::BringWindowUnderMouseToFront() { + // If we're going to dock to another window, bring it to the front. + HWND hwnd = dock_info_.hwnd(); + if (!hwnd) { + HWND dragged_hwnd = view_->GetWidget()->GetHWND(); + dock_windows_.insert(dragged_hwnd); + hwnd = DockInfo::GetLocalProcessWindowAtPoint(GetCursorScreenPoint(), + dock_windows_); + dock_windows_.erase(dragged_hwnd); + } + if (hwnd) { + // Move the window to the front. + SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); + + // The previous call made the window appear on top of the dragged window, + // move the dragged window to the front. + SetWindowPos(view_->GetWidget()->GetHWND(), HWND_TOP, 0, 0, 0, 0, + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); + } +} |