diff --git a/widget/src/gtk2/nsWindow.cpp b/widget/src/gtk2/nsWindow.cpp index d3503f0f0f5..b98562c4903 100644 --- a/widget/src/gtk2/nsWindow.cpp +++ b/widget/src/gtk2/nsWindow.cpp @@ -290,7 +290,7 @@ UpdateLastInputEventTime() } // this is the last window that had a drag event happen on it. -nsWindow *nsWindow::mLastDragMotionWindow = NULL; +nsWindow *nsWindow::sLastDragMotionWindow = NULL; PRBool nsWindow::sIsDraggingOutOf = PR_FALSE; // This is the time of the last button press event. The drag service @@ -419,14 +419,6 @@ nsWindow::nsWindow() initialize_prefs(); } - if (mLastDragMotionWindow == this) - mLastDragMotionWindow = NULL; - mDragMotionWidget = 0; - mDragMotionContext = 0; - mDragMotionX = 0; - mDragMotionY = 0; - mDragMotionTime = 0; - mDragMotionTimerID = 0; mLastMotionPressure = 0; #ifdef ACCESSIBILITY @@ -453,8 +445,8 @@ nsWindow::nsWindow() nsWindow::~nsWindow() { LOG(("nsWindow::~nsWindow() [%p]\n", (void *)this)); - if (mLastDragMotionWindow == this) { - mLastDragMotionWindow = NULL; + if (sLastDragMotionWindow == this) { + sLastDragMotionWindow = NULL; } delete[] mTransparencyBitmap; @@ -765,11 +757,6 @@ nsWindow::Destroy(void) // the surface after its X Window. mThebesSurface = nsnull; - if (mDragMotionTimerID) { - g_source_remove(mDragMotionTimerID); - mDragMotionTimerID = 0; - } - if (mDragLeaveTimer) { mDragLeaveTimer->Cancel(); mDragLeaveTimer = nsnull; @@ -3450,16 +3437,16 @@ nsWindow::CheckNeedDragLeaveEnter(nsWindow* aInnerMostWidget, nscoord aX, nscoord aY) { // check to see if there was a drag motion window already in place - if (mLastDragMotionWindow) { + if (sLastDragMotionWindow) { // same as the last window so no need for dragenter and dragleave events - if (mLastDragMotionWindow == aInnerMostWidget) { + if (sLastDragMotionWindow == aInnerMostWidget) { UpdateDragStatus(aDragContext, aDragService); return; } // send a dragleave event to the last window that got a motion event - nsRefPtr kungFuDeathGrip = mLastDragMotionWindow; - mLastDragMotionWindow->OnDragLeave(); + nsRefPtr kungFuDeathGrip = sLastDragMotionWindow; + sLastDragMotionWindow->OnDragLeave(); } // Make sure that the drag service knows we're now dragging @@ -3470,7 +3457,7 @@ nsWindow::CheckNeedDragLeaveEnter(nsWindow* aInnerMostWidget, aInnerMostWidget->OnDragEnter(aX, aY); // set the last window to the innerMostWidget - mLastDragMotionWindow = aInnerMostWidget; + sLastDragMotionWindow = aInnerMostWidget; } gboolean @@ -3502,9 +3489,6 @@ nsWindow::OnDragMotionEvent(GtkWidget *aWidget, sIsDraggingOutOf = PR_FALSE; - // Reset out drag motion timer - ResetDragMotionTimer(aWidget, aDragContext, aX, aY, aTime); - // get our drag context nsCOMPtr dragService = do_GetService(kCDragServiceCID); nsCOMPtr dragSessionGTK = do_QueryInterface(dragService); @@ -3570,9 +3554,6 @@ nsWindow::OnDragLeaveEvent(GtkWidget *aWidget, sIsDraggingOutOf = PR_TRUE; - // make sure to unset any drag motion timers here. - ResetDragMotionTimer(0, 0, 0, 0, 0); - if (mDragLeaveTimer) { return; } @@ -3662,8 +3643,8 @@ nsWindow::OnDragDropEvent(GtkWidget *aWidget, // event and and that case is handled in that handler. dragSessionGTK->TargetSetLastContext(0, 0, 0); - // clear the mLastDragMotion window - mLastDragMotionWindow = 0; + // clear the sLastDragMotion window + sLastDragMotionWindow = 0; // Make sure to end the drag session. If this drag started in a // different app, we won't get a drag_end signal to end it from. @@ -5317,10 +5298,10 @@ check_for_rollup(GdkWindow *aWindow, gdouble aMouseX, gdouble aMouseY, PRBool nsWindow::DragInProgress(void) { - // mLastDragMotionWindow means the drag arrow is over mozilla + // 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 (mLastDragMotionWindow || sIsDraggingOutOf); + return (sLastDragMotionWindow || sIsDraggingOutOf); } /* static */ @@ -6198,60 +6179,6 @@ initialize_prefs(void) return NS_OK; } -void -nsWindow::ResetDragMotionTimer(GtkWidget *aWidget, - GdkDragContext *aDragContext, - gint aX, gint aY, guint aTime) -{ - - // We have to be careful about ref ordering here. if aWidget == - // mDraMotionWidget be careful not to let the refcnt drop to zero. - // Same with the drag context. - if (aWidget) - g_object_ref(aWidget); - if (mDragMotionWidget) - g_object_unref(mDragMotionWidget); - mDragMotionWidget = aWidget; - - if (aDragContext) - g_object_ref(aDragContext); - if (mDragMotionContext) - g_object_unref(mDragMotionContext); - mDragMotionContext = aDragContext; - - mDragMotionX = aX; - mDragMotionY = aY; - mDragMotionTime = aTime; - - // always clear the timer - if (mDragMotionTimerID) { - g_source_remove(mDragMotionTimerID); - mDragMotionTimerID = 0; - LOG(("*** canceled motion timer\n")); - } - - // if no widget was passed in, just return instead of setting a new - // timer - if (!aWidget) { - return; - } - - // otherwise we create a new timer - mDragMotionTimerID = g_timeout_add(100, - (GtkFunction)DragMotionTimerCallback, - this); -} - -void -nsWindow::FireDragMotionTimer(void) -{ - LOGDRAG(("nsWindow::FireDragMotionTimer(%p)\n", (void*)this)); - - OnDragMotionEvent(mDragMotionWidget, mDragMotionContext, - mDragMotionX, mDragMotionY, mDragMotionTime, - this); -} - void nsWindow::FireDragLeaveTimer(void) { @@ -6260,23 +6187,14 @@ nsWindow::FireDragLeaveTimer(void) mDragLeaveTimer = nsnull; // clean up any pending drag motion window info - if (mLastDragMotionWindow) { - nsRefPtr kungFuDeathGrip = mLastDragMotionWindow; + if (sLastDragMotionWindow) { + nsRefPtr kungFuDeathGrip = sLastDragMotionWindow; // send our leave signal - mLastDragMotionWindow->OnDragLeave(); - mLastDragMotionWindow = 0; + sLastDragMotionWindow->OnDragLeave(); + sLastDragMotionWindow = 0; } } -/* static */ -guint -nsWindow::DragMotionTimerCallback(gpointer aClosure) -{ - nsRefPtr window = static_cast(aClosure); - window->FireDragMotionTimer(); - return FALSE; -} - /* static */ void nsWindow::DragLeaveTimerCallback(nsITimer *aTimer, void *aClosure) diff --git a/widget/src/gtk2/nsWindow.h b/widget/src/gtk2/nsWindow.h index 30ef10e3fb3..60b1de713ec 100644 --- a/widget/src/gtk2/nsWindow.h +++ b/widget/src/gtk2/nsWindow.h @@ -469,19 +469,11 @@ private: // all of our DND stuff // this is the last window that had a drag event happen on it. - static nsWindow *mLastDragMotionWindow; + static nsWindow *sLastDragMotionWindow; void InitDragEvent (nsDragEvent &aEvent); void UpdateDragStatus (GdkDragContext *aDragContext, nsIDragService *aDragService); - // this is everything we need to be able to fire motion events - // repeatedly - GtkWidget *mDragMotionWidget; - GdkDragContext *mDragMotionContext; - gint mDragMotionX; - gint mDragMotionY; - guint mDragMotionTime; - guint mDragMotionTimerID; nsCOMPtr mDragLeaveTimer; float mLastMotionPressure; @@ -493,14 +485,7 @@ private: // drag in progress static PRBool DragInProgress(void); - void ResetDragMotionTimer (GtkWidget *aWidget, - GdkDragContext *aDragContext, - gint aX, - gint aY, - guint aTime); - void FireDragMotionTimer (void); void FireDragLeaveTimer (void); - static guint DragMotionTimerCallback (gpointer aClosure); static void DragLeaveTimerCallback (nsITimer *aTimer, void *aClosure); void DispatchMissedButtonReleases(GdkEventCrossing *aGdkEvent);