summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-12 19:00:57 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-12 19:00:57 +0000
commite3740143c28c371adf5b6669d45176965e186052 (patch)
tree12407f902ac6c59a2f1e237694e8422c02a31a98 /chrome/browser/views
parent3c6f71f746758bc311a87bc573a9575c1f9d5123 (diff)
downloadchromium_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')
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc34
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.h8
2 files changed, 42 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);
+ }
+}
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);
};