diff options
-rw-r--r-- | chrome/browser/dock_info.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/tabs/dragged_tab_controller.cc | 34 | ||||
-rw-r--r-- | chrome/browser/views/tabs/dragged_tab_controller.h | 8 |
3 files changed, 43 insertions, 1 deletions
diff --git a/chrome/browser/dock_info.cc b/chrome/browser/dock_info.cc index fdf9f57..74a631a 100644 --- a/chrome/browser/dock_info.cc +++ b/chrome/browser/dock_info.cc @@ -465,7 +465,7 @@ void DockInfo::AdjustOtherWindowBounds() const { ::SetWindowPos(hwnd_, HWND_TOP, other_window_bounds.x(), other_window_bounds.y(), other_window_bounds.width(), other_window_bounds.height(), - SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER); + SWP_NOACTIVATE | SWP_NOOWNERZORDER); } bool DockInfo::CheckMonitorPoint(const gfx::Point& screen_loc, 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); + } +} diff --git a/chrome/browser/views/tabs/dragged_tab_controller.h b/chrome/browser/views/tabs/dragged_tab_controller.h index 0363d93..8141c67 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.h +++ b/chrome/browser/views/tabs/dragged_tab_controller.h @@ -7,6 +7,7 @@ #include "base/gfx/rect.h" #include "base/message_loop.h" +#include "base/timer.h" #include "chrome/browser/dock_info.h" #include "chrome/browser/tab_contents_delegate.h" #include "chrome/browser/tabs/tab_strip_model.h" @@ -225,6 +226,8 @@ class DraggedTabController : public TabContentsDelegate, void DockDisplayerDestroyed(DockDisplayer* controller); + void BringWindowUnderMouseToFront(); + // The TabContents being dragged. This can get replaced during the drag if // the associated NavigationController is navigated to a different // TabContentsType. @@ -296,6 +299,11 @@ class DraggedTabController : public TabContentsDelegate, std::set<HWND> dock_windows_; std::vector<DockDisplayer*> dock_controllers_; + // Timer used to bring the window under the cursor to front. If the user + // stops moving the mouse for a brief time over a browser window, it is + // brought to front. + base::OneShotTimer<DraggedTabController> bring_to_front_timer_; + DISALLOW_COPY_AND_ASSIGN(DraggedTabController); }; |