b=497498 use nsIDragSession::getCurrentSession to remove sIsDraggingOutOf r=roc
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 17 Apr 2012 13:00:26 +1200
changeset 91819 cf998e4853002e2c41b939c23a7b28418a679188
parent 91818 7f5e0ef6ad589a7adf8ca866246f4e1ab3a8f060
child 91820 4e72b79e7cee1f1942c430bd9b4f976fd124ec22
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersroc
bugs497498
milestone14.0a1
b=497498 use nsIDragSession::getCurrentSession to remove sIsDraggingOutOf r=roc
widget/gtk2/nsWindow.cpp
widget/gtk2/nsWindow.h
--- a/widget/gtk2/nsWindow.cpp
+++ b/widget/gtk2/nsWindow.cpp
@@ -269,17 +269,16 @@ static void    drag_data_received_event_
                                            guint32 aTime,
                                            gpointer aData);
 
 /* 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;
-bool nsWindow::sIsDraggingOutOf = false;
 
 // 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 sLastUserInputTime = GDK_CURRENT_TIME;
 static guint32 sRetryGrabTime;
 
 static NS_DEFINE_IID(kCDragServiceCID,  NS_DRAGSERVICE_CID);
@@ -2509,20 +2508,16 @@ nsWindow::OnLeaveNotifyEvent(GtkWidget *
 
     nsEventStatus status;
     DispatchEvent(&event, status);
 }
 
 void
 nsWindow::OnMotionNotifyEvent(GtkWidget *aWidget, GdkEventMotion *aEvent)
 {
-    // when we receive this, it must be that the gtk dragging is over,
-    // it is dropped either in or out of mozilla, clear the flag
-    sIsDraggingOutOf = false;
-
     // see if we can compress this event
     // XXXldb Why skip every other motion event when we have multiple,
     // but not more than that?
     bool synthEvent = false;
 #ifdef MOZ_X11
     XEvent xevent;
 
     while (XPending (GDK_WINDOW_XDISPLAY(aEvent->window))) {
@@ -3393,18 +3388,16 @@ nsWindow::OnDragMotionEvent(GtkWidget *a
       event.button.button = 1;
       sLastButtonReleaseTime = 0;
       if (widget) {
         g_signal_emit_by_name(widget, "button_release_event", &event, &retval);
         return TRUE;
       }
     }
 
-    sIsDraggingOutOf = false;
-
     // 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;
@@ -3447,18 +3440,16 @@ nsWindow::OnDragLeaveEvent(GtkWidget *aW
                            GdkDragContext *aDragContext,
                            guint aTime,
                            gpointer aData)
 {
     // XXX Do we want to pass this on only if the event's subwindow is null?
 
     LOGDRAG(("nsWindow::OnDragLeaveSignal(%p)\n", (void*)this));
 
-    sIsDraggingOutOf = true;
-
     if (mDragLeaveTimer) {
         return;
     }
 
     // create a fast timer - we're delaying the drag leave until the
     // next mainloop in hopes that we might be able to get a drag drop
     // signal
     mDragLeaveTimer = do_CreateInstance("@mozilla.org/timer;1");
@@ -5107,20 +5098,25 @@ check_for_rollup(gdouble aMouseX, gdoubl
 
     return retVal;
 }
 
 /* static */
 bool
 nsWindow::DragInProgress(void)
 {
-    // sLastDragMotionWindow means the drag arrow is over mozilla
-    // sIsDraggingOutOf means the drag arrow is out of mozilla
-    // both cases mean the dragging is happenning.
-    return (sLastDragMotionWindow || sIsDraggingOutOf);
+    nsCOMPtr<nsIDragService> dragService = do_GetService(kCDragServiceCID);
+
+    if (!dragService)
+        return false;
+
+    nsCOMPtr<nsIDragSession> currentDragSession;
+    dragService->GetCurrentSession(getter_AddRefs(currentDragSession));
+
+    return currentDragSession != nsnull;
 }
 
 static bool
 is_mouse_in_window (GdkWindow* aWindow, gdouble aMouseX, gdouble aMouseY)
 {
     gint x = 0;
     gint y = 0;
     gint w, h;
--- a/widget/gtk2/nsWindow.h
+++ b/widget/gtk2/nsWindow.h
@@ -502,18 +502,16 @@ private:
 
     nsCOMPtr<nsITimer> mDragLeaveTimer;
     float              mLastMotionPressure;
 
     // Remember the last sizemode so that we can restore it when
     // leaving fullscreen
     nsSizeMode         mLastSizeMode;
 
-    static bool        sIsDraggingOutOf;
-    // drag in progress
     static bool DragInProgress(void);
 
     void         FireDragLeaveTimer       (void);
     static void  DragLeaveTimerCallback  (nsITimer *aTimer, void *aClosure);
 
     void DispatchMissedButtonReleases(GdkEventCrossing *aGdkEvent);
 
     /**