summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-23 00:59:53 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-23 00:59:53 +0000
commit44e89e20218689fc5270f639a2e6f711f63a2383 (patch)
tree3186751173280697b9ffaa35768b505f2806ba76 /chrome/browser/gtk
parentab61ec6bd60b56436693c20a2d71d55ad0a8bfa5 (diff)
downloadchromium_src-44e89e20218689fc5270f639a2e6f711f63a2383.zip
chromium_src-44e89e20218689fc5270f639a2e6f711f63a2383.tar.gz
chromium_src-44e89e20218689fc5270f639a2e6f711f63a2383.tar.bz2
Bring the potential drag destination window to the front when the mouse moves over the window.
BUG=none TEST=Open two browser windows with multiple tabs. Make sure the windows overlap. Drag a tab from the top-level window into the frame of the other window. The lower window should be raised after a delay. Review URL: http://codereview.chromium.org/146004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18997 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc28
1 files changed, 27 insertions, 1 deletions
diff --git a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
index 3b3c1f4..3b5947f 100644
--- a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
+++ b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
@@ -16,6 +16,9 @@
namespace {
+// Delay, in ms, during dragging before we bring a window to front.
+const int kBringToFrontDelay = 750;
+
// Used to determine how far a tab must obscure another tab in order to swap
// their indexes.
const int kHorizontalMoveThreshold = 16; // pixels
@@ -59,6 +62,8 @@ void DraggedTabControllerGtk::Drag() {
if (!source_tab_)
return;
+ 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()) {
@@ -233,7 +238,11 @@ void DraggedTabControllerGtk::ContinueDragging() {
Attach(target_tabstrip, screen_point);
}
- // TODO(jhawkins): Start the bring_to_front timer.
+ if (!target_tabstrip) {
+ bring_to_front_timer_.Start(
+ base::TimeDelta::FromMilliseconds(kBringToFrontDelay), this,
+ &DraggedTabControllerGtk::BringWindowUnderMouseToFront);
+ }
MoveTab(screen_point);
}
@@ -520,6 +529,8 @@ bool DraggedTabControllerGtk::EndDragImpl(EndDragType type) {
if (!dragged_tab_.get())
return true;
+ bring_to_front_timer_.Stop();
+
// WARNING: this may be invoked multiple times. In particular, if deletion
// occurs after a delay (as it does when the tab is released in the original
// tab strip) and the navigation controller/tab contents is deleted before
@@ -704,3 +715,18 @@ void DraggedTabControllerGtk::OnAnimateToBoundsComplete() {
if (!in_destructor_)
source_tabstrip_->DestroyDragController();
}
+
+void DraggedTabControllerGtk::BringWindowUnderMouseToFront() {
+ // If we're going to dock to another window, bring it to the front.
+ gfx::NativeWindow window = dock_info_.window();
+ if (!window) {
+ gfx::NativeView dragged_tab = dragged_tab_->widget();
+ dock_windows_.insert(dragged_tab);
+ window = DockInfo::GetLocalProcessWindowAtPoint(GetCursorScreenPoint(),
+ dock_windows_);
+ dock_windows_.erase(dragged_tab);
+ }
+
+ if (window)
+ gtk_window_present(GTK_WINDOW(window));
+}