b=497498 move early drag end code to drag_motion_event_cb and correct return value r=roc
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 17 Apr 2012 13:00:26 +1200
changeset 95133 4e72b79e7cee1f1942c430bd9b4f976fd124ec22
parent 95132 cf998e4853002e2c41b939c23a7b28418a679188
child 95134 b73de501ea5ee5a7f9838cb33d20c8976aca8683
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs497498
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
b=497498 move early drag end code to drag_motion_event_cb and correct return value r=roc
widget/gtk2/nsWindow.cpp
widget/gtk2/nsWindow.h
--- a/widget/gtk2/nsWindow.cpp
+++ b/widget/gtk2/nsWindow.cpp
@@ -272,17 +272,17 @@ static void    drag_data_received_event_
 /* initialization static functions */
 static nsresult    initialize_prefs        (void);
 
 // this is the last window that had a drag event happen on it.
 nsWindow *nsWindow::sLastDragMotionWindow = NULL;
 
 // Time of the last button release event. We use it to detect when the
 // drag ended before we could properly setup drag and drop.
-guint32   nsWindow::sLastButtonReleaseTime = 0;
+static guint32 sLastButtonReleaseTime = 0;
 static guint32 sLastUserInputTime = GDK_CURRENT_TIME;
 static guint32 sRetryGrabTime;
 
 static NS_DEFINE_IID(kCDragServiceCID,  NS_DRAGSERVICE_CID);
 
 // The window from which the focus manager asks us to dispatch key events.
 static nsWindow         *gFocusWindow          = NULL;
 static bool              gBlockActivateEvent   = false;
@@ -3371,33 +3371,16 @@ nsWindow::OnDragMotionEvent(GtkWidget *a
                             GdkDragContext *aDragContext,
                             gint aX,
                             gint aY,
                             guint aTime,
                             gpointer aData)
 {
     LOGDRAG(("nsWindow::OnDragMotionSignal\n"));
 
-    if (sLastButtonReleaseTime) {
-      // The drag ended before it was even setup to handle the end of the drag
-      // So, we fake the button getting released again to release the drag
-      GtkWidget *widget = gtk_grab_get_current();
-      GdkEvent event;
-      gboolean retval;
-      memset(&event, 0, sizeof(event));
-      event.type = GDK_BUTTON_RELEASE;
-      event.button.time = sLastButtonReleaseTime;
-      event.button.button = 1;
-      sLastButtonReleaseTime = 0;
-      if (widget) {
-        g_signal_emit_by_name(widget, "button_release_event", &event, &retval);
-        return TRUE;
-      }
-    }
-
     // get our drag context
     nsCOMPtr<nsIDragService> dragService = do_GetService(kCDragServiceCID);
     nsDragService *dragServiceGTK =
         static_cast<nsDragService*>(dragService.get());
 
     // first, figure out which internal widget this drag motion actually
     // happened on
     nscoord retx = 0;
@@ -5947,16 +5930,34 @@ drag_motion_event_cb(GtkWidget *aWidget,
                      gint aY,
                      guint aTime,
                      gpointer aData)
 {
     nsRefPtr<nsWindow> window = get_window_for_gtk_widget(aWidget);
     if (!window)
         return FALSE;
 
+    if (sLastButtonReleaseTime) {
+      // The drag ended before it was even setup to handle the end of the drag
+      // So, we fake the button getting released again to release the drag
+      GtkWidget *widget = gtk_grab_get_current();
+      GdkEvent event;
+      gboolean retval;
+      memset(&event, 0, sizeof(event));
+      event.type = GDK_BUTTON_RELEASE;
+      event.button.time = sLastButtonReleaseTime;
+      event.button.button = 1;
+      sLastButtonReleaseTime = 0;
+      if (widget) {
+        g_signal_emit_by_name(widget, "button_release_event", &event, &retval);
+        // FALSE means we won't reply with a status message.
+        return FALSE;
+      }
+    }
+
     return window->OnDragMotionEvent(aWidget,
                                      aDragContext,
                                      aX, aY, aTime, aData);
 }
 
 static void
 drag_leave_event_cb(GtkWidget *aWidget,
                     GdkDragContext *aDragContext,
--- a/widget/gtk2/nsWindow.h
+++ b/widget/gtk2/nsWindow.h
@@ -302,17 +302,16 @@ public:
                             GdkDragContext *aDragContext,
                             nscoord aX, nscoord aY);
 
 #ifdef MOZ_X11
     Window             mOldFocusWindow;
 #endif /* MOZ_X11 */
 
     static guint32     sLastButtonPressTime;
-    static guint32     sLastButtonReleaseTime;
 
     NS_IMETHOD         BeginResizeDrag(nsGUIEvent* aEvent, PRInt32 aHorizontal, PRInt32 aVertical);
     NS_IMETHOD         BeginMoveDrag(nsMouseEvent* aEvent);
 
     MozContainer*      GetMozContainer() { return mContainer; }
     GdkWindow*         GetGdkWindow() { return mGdkWindow; }
     bool               IsDestroyed() { return mIsDestroyed; }