summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/tabs
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-11 20:53:30 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-11 20:53:30 +0000
commit6a6ccee4e22baae35e4aa595cd24c738fdb2b380 (patch)
tree7656381d22aef8d37f8d31733be3ceee190fcabe /chrome/browser/gtk/tabs
parent77384a34070c268779dcf9d6aff3d1e80c6a4d25 (diff)
downloadchromium_src-6a6ccee4e22baae35e4aa595cd24c738fdb2b380.zip
chromium_src-6a6ccee4e22baae35e4aa595cd24c738fdb2b380.tar.gz
chromium_src-6a6ccee4e22baae35e4aa595cd24c738fdb2b380.tar.bz2
Use the MessageLoopForUI::Observer interface to listen for mouse motion events instead of hooking up to the global gdk event handler. Once we hook up to the global handler and disconnect from it, the MessageLoopForUI will be broken because we stole the handler from it.
BUG=none TEST=Exhaustively test dragging tabs in and out of multiple tabstrips. Review URL: http://codereview.chromium.org/126001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18194 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/tabs')
-rw-r--r--chrome/browser/gtk/tabs/tab_gtk.cc43
-rw-r--r--chrome/browser/gtk/tabs/tab_gtk.h18
2 files changed, 27 insertions, 34 deletions
diff --git a/chrome/browser/gtk/tabs/tab_gtk.cc b/chrome/browser/gtk/tabs/tab_gtk.cc
index 25bb1db..d188cac 100644
--- a/chrome/browser/gtk/tabs/tab_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_gtk.cc
@@ -143,17 +143,6 @@ TabGtk::~TabGtk() {
}
// static
-void TabGtk::GdkEventHandler(GdkEvent* event, void* data) {
- TabGtk* tab = static_cast<TabGtk*>(data);
-
- if (event->type == GDK_MOTION_NOTIFY && tab && tab->dragging_) {
- tab->delegate_->ContinueDrag(NULL);
- }
-
- gtk_main_do_event(event);
-}
-
-// static
gboolean TabGtk::OnMousePress(GtkWidget* widget, GdkEventButton* event,
TabGtk* tab) {
if (event->button == 1) {
@@ -198,7 +187,7 @@ gboolean TabGtk::OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event,
// static
void TabGtk::OnDragBegin(GtkWidget* widget, GdkDragContext* context,
TabGtk* tab) {
- gdk_event_handler_set(TabGtk::GdkEventHandler, tab, NULL);
+ MessageLoopForUI::current()->AddObserver(tab);
int x, y;
gdk_window_get_pointer(tab->event_box_->window, &x, &y, NULL);
@@ -219,18 +208,7 @@ void TabGtk::OnDragEnd(GtkWidget* widget, GdkDragContext* context,
// Clean up the drag helper, which is re-created on the next mouse press.
tab->delegate_->EndDrag(false);
- // Reset the user data pointer for our event handler.
- gdk_event_handler_set(TabGtk::GdkEventHandler, NULL, NULL);
-}
-
-// static
-gboolean TabGtk::OnDragMotion(GtkWidget* widget,
- GdkDragContext* context,
- guint x, guint y,
- guint time,
- TabGtk* tab) {
- tab->delegate_->ContinueDrag(context);
- return TRUE;
+ MessageLoopForUI::current()->RemoveObserver(tab);
}
// static
@@ -245,6 +223,23 @@ gboolean TabGtk::OnDragFailed(GtkWidget* widget, GdkDragContext* context,
}
///////////////////////////////////////////////////////////////////////////////
+// TabGtk, MessageLoop::Observer implementation:
+
+void TabGtk::WillProcessEvent(GdkEvent* event) {
+ // Nothing to do.
+}
+
+void TabGtk::DidProcessEvent(GdkEvent* event) {
+ switch (event->type) {
+ case GDK_MOTION_NOTIFY:
+ delegate_->ContinueDrag(NULL);
+ break;
+ default:
+ break;
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
// TabGtk, TabRendererGtk overrides:
bool TabGtk::IsSelected() const {
diff --git a/chrome/browser/gtk/tabs/tab_gtk.h b/chrome/browser/gtk/tabs/tab_gtk.h
index 195d04c..9abe929 100644
--- a/chrome/browser/gtk/tabs/tab_gtk.h
+++ b/chrome/browser/gtk/tabs/tab_gtk.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_GTK_TABS_TAB_GTK_H_
#include "base/basictypes.h"
+#include "base/message_loop.h"
#include "chrome/browser/gtk/tabs/tab_renderer_gtk.h"
#include "chrome/browser/tabs/tab_strip_model.h"
@@ -13,7 +14,8 @@ namespace gfx {
class Path;
}
-class TabGtk : public TabRendererGtk {
+class TabGtk : public TabRendererGtk,
+ public MessageLoopForUI::Observer {
public:
// An interface implemented by an object that can help this Tab complete
// various actions. The index parameter is the index of this Tab in the
@@ -83,10 +85,6 @@ class TabGtk : public TabRendererGtk {
virtual void CloseButtonClicked();
virtual void UpdateData(TabContents* contents, bool loading_only);
- // The callback that is called for every gdk event. We use it to inspect for
- // drag-motion events when the drag is outside of the source tab.
- static void GdkEventHandler(GdkEvent* event, void* tab);
-
// button-press-event handler that handles mouse clicks.
static gboolean OnMousePress(GtkWidget* widget, GdkEventButton* event,
TabGtk* tab);
@@ -111,15 +109,15 @@ class TabGtk : public TabRendererGtk {
static void OnDragEnd(GtkWidget* widget, GdkDragContext* context,
TabGtk* tab);
- // drag-motion handler that handles drag movements in the tabstrip.
- static gboolean OnDragMotion(GtkWidget* widget, GdkDragContext* context,
- guint x, guint y, guint time,
- TabGtk* tab);
-
// drag-failed handler that is emitted when the drag fails.
static gboolean OnDragFailed(GtkWidget* widget, GdkDragContext* context,
GtkDragResult result, TabGtk* tab);
+ protected:
+ // MessageLoop::Observer implementation:
+ virtual void WillProcessEvent(GdkEvent* event);
+ virtual void DidProcessEvent(GdkEvent* event);
+
private:
class ContextMenuController;
friend class ContextMenuController;