From 6254686d113f977626e824b02e8cb676556734ec Mon Sep 17 00:00:00 2001 From: "ben@chromium.org" Date: Thu, 4 Jun 2009 18:27:17 +0000 Subject: Make tab resize relayout on mouse out work. BUG=none TEST=none Review URL: http://codereview.chromium.org/118228 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17640 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/views/tabs/tab_strip.cc | 49 +++++++++++++++++++++------------- chrome/browser/views/tabs/tab_strip.h | 4 +++ 2 files changed, 35 insertions(+), 18 deletions(-) (limited to 'chrome') diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc index 1a2cf23..84b1ca3 100644 --- a/chrome/browser/views/tabs/tab_strip.cc +++ b/chrome/browser/views/tabs/tab_strip.cc @@ -1042,21 +1042,7 @@ void TabStrip::DidProcessMessage(const MSG& msg) { case WM_MOUSEMOVE: case WM_MOUSELEAVE: case WM_NCMOUSELEAVE: - if (!IsCursorInTabStripZone()) { - // Mouse moved outside the tab slop zone, start a timer to do a resize - // layout after a short while... - if (resize_layout_factory_.empty()) { - MessageLoop::current()->PostDelayedTask(FROM_HERE, - resize_layout_factory_.NewRunnableMethod( - &TabStrip::ResizeLayoutTabs), - kResizeTabsTimeMs); - } - } else { - // Mouse moved quickly out of the tab strip and then into it again, so - // cancel the timer so that the strip doesn't move when the mouse moves - // back over it. - resize_layout_factory_.RevokeAll(); - } + HandleGlobalMouseMoveEvent(); break; } } @@ -1065,7 +1051,14 @@ void TabStrip::WillProcessEvent(GdkEvent* event) { } void TabStrip::DidProcessEvent(GdkEvent* event) { - NOTIMPLEMENTED(); + switch (event->type) { + case GDK_MOTION_NOTIFY: + case GDK_LEAVE_NOTIFY: + HandleGlobalMouseMoveEvent(); + break; + default: + break; + } } #endif @@ -1219,10 +1212,12 @@ bool TabStrip::IsCursorInTabStripZone() { CPoint cursor_point_c; GetCursorPos(&cursor_point_c); gfx::Point cursor_point(cursor_point_c); -#else +#elif defined(OS_LINUX) // TODO: make sure this is right with multiple monitors. + GdkScreen* screen = gdk_screen_get_default(); + GdkDisplay* display = gdk_screen_get_display(screen); gint x, y; - gdk_display_get_pointer(NULL, NULL, &x, &y, NULL); + gdk_display_get_pointer(display, NULL, &x, &y, NULL); gfx::Point cursor_point(x, y); #endif @@ -1558,3 +1553,21 @@ void TabStrip::RemoveTabAt(int index) { delete removed; } } + +void TabStrip::HandleGlobalMouseMoveEvent() { + if (!IsCursorInTabStripZone()) { + // Mouse moved outside the tab slop zone, start a timer to do a resize + // layout after a short while... + if (resize_layout_factory_.empty()) { + MessageLoop::current()->PostDelayedTask(FROM_HERE, + resize_layout_factory_.NewRunnableMethod( + &TabStrip::ResizeLayoutTabs), + kResizeTabsTimeMs); + } + } else { + // Mouse moved quickly out of the tab strip and then into it again, so + // cancel the timer so that the strip doesn't move when the mouse moves + // back over it. + resize_layout_factory_.RevokeAll(); + } +} diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h index bd05283..fb85d20 100644 --- a/chrome/browser/views/tabs/tab_strip.h +++ b/chrome/browser/views/tabs/tab_strip.h @@ -277,6 +277,10 @@ class TabStrip : public views::View, // called from the tab animation code and is not a general-purpose method. void RemoveTabAt(int index); + // Called from the message loop observer when a mouse movement has occurred + // anywhere over our containing window. + void HandleGlobalMouseMoveEvent(); + // -- Member Variables ------------------------------------------------------ // Our model. -- cgit v1.1