diff --git a/widget/src/gtk/nsToolkit.cpp b/widget/src/gtk/nsToolkit.cpp index 07d174051799..224208a55058 100644 --- a/widget/src/gtk/nsToolkit.cpp +++ b/widget/src/gtk/nsToolkit.cpp @@ -38,6 +38,8 @@ nsToolkit::nsToolkit() //------------------------------------------------------------------------- nsToolkit::~nsToolkit() { + if (mSharedGC) + gdk_gc_unref(mSharedGC); } //------------------------------------------------------------------------- @@ -58,12 +60,12 @@ void nsToolkit::CreateSharedGC(void) pixmap = ::gdk_pixmap_new (NULL, 1, 1, gdk_rgb_get_visual()->depth); mSharedGC = ::gdk_gc_new (pixmap); gdk_pixmap_unref (pixmap); + mSharedGC = gdk_gc_ref(mSharedGC); } GdkGC *nsToolkit::GetSharedGC(void) { - mSharedGC = gdk_gc_ref(mSharedGC); - return mSharedGC; + return gdk_gc_ref(mSharedGC); } //------------------------------------------------------------------------- diff --git a/widget/src/gtk/nsWidget.cpp b/widget/src/gtk/nsWidget.cpp index 77abb196969d..439bc3cb5e78 100644 --- a/widget/src/gtk/nsWidget.cpp +++ b/widget/src/gtk/nsWidget.cpp @@ -1345,17 +1345,15 @@ nsWidget::OnMotionNotifySignal(GdkEventMotion * aGdkMotionEvent) event.point.x = nscoord(x); event.point.y = nscoord(y); - event.widget = this; } -#if 0 - if (nsnull != sButtonMotionTarget) + if (sButtonMotionTarget) { gint diffX; gint diffY; - if (aGdkMotionEvent != NULL) + if (aGdkMotionEvent) { // Compute the difference between the original root coordinates diffX = (gint) aGdkMotionEvent->x_root - sButtonMotionRootX; @@ -1373,22 +1371,26 @@ nsWidget::OnMotionNotifySignal(GdkEventMotion * aGdkMotionEvent) { event.widget = this; - if (aGdkMotionEvent != NULL) + if (aGdkMotionEvent) { - event.point.x = nscoord(aGdkMotionEvent->x); - event.point.y = nscoord(aGdkMotionEvent->y); + event.point.x = nscoord(x); + event.point.y = nscoord(y); } } - if (aGdkMotionEvent != NULL) + if (aGdkMotionEvent) { event.time = aGdkMotionEvent->time; } -#endif + + printf("x=%i , y=%i target=%p\n", event.point.x, event.point.y, event.widget); AddRef(); - DispatchMouseEvent(event); + if (sButtonMotionTarget) + sButtonMotionTarget->DispatchMouseEvent(event); + else + DispatchMouseEvent(event); Release(); } @@ -1715,8 +1717,16 @@ nsWidget::OnButtonReleaseSignal(GdkEventButton * aGdkButtonEvent) break; } + InitMouseEvent(aGdkButtonEvent, event, eventType); + event.widget = sButtonMotionTarget ? sButtonMotionTarget : this; + + NS_ADDREF(event.widget); + NS_STATIC_CAST(nsWidget*,event.widget)->DispatchMouseEvent(event); + NS_IF_RELEASE(event.widget); + + if (sButtonMotionTarget) { sButtonMotionTarget = nsnull; @@ -1724,12 +1734,6 @@ nsWidget::OnButtonReleaseSignal(GdkEventButton * aGdkButtonEvent) sButtonMotionRootX = -1; sButtonMotionRootY = -1; } - - AddRef(); - - DispatchMouseEvent(event); - - Release(); } ////////////////////////////////////////////////////////////////////// /* virtual */ void