]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/window.cpp
[ 1596568 ] Fix for bug 1595339
[wxWidgets.git] / src / gtk / window.cpp
index c631f3b014e8dc5e0626a60e35d26254424d79bb..e8851e90a436861410b3bdb791dbfac343c7282d 100644 (file)
@@ -210,6 +210,11 @@ wxWindowGTK *g_focusWindowLast = (wxWindowGTK*) NULL;
 // yet, defer setting the focus to idle time.
 wxWindowGTK *g_delayedFocus = (wxWindowGTK*) NULL;
 
+// global variables because GTK+ DnD want to have the
+// mouse event that caused it
+GdkEvent    *g_lastMouseEvent = (GdkEvent*) NULL;
+int          g_lastButtonNumber = 0;
+
 extern bool g_mainThreadLocked;
 
 //-----------------------------------------------------------------------------
@@ -1462,6 +1467,8 @@ gtk_window_button_press_callback( GtkWidget *widget,
 {
     wxCOMMON_CALLBACK_PROLOGUE(gdk_event, win);
 
+    g_lastButtonNumber = gdk_event->button;
+
     if (win->m_wxwindow && (g_focusWindow != win) && win->AcceptsFocus())
     {
         gtk_widget_grab_focus( win->m_wxwindow );
@@ -1578,6 +1585,8 @@ gtk_window_button_press_callback( GtkWidget *widget,
         return FALSE;
     }
 
+    g_lastMouseEvent = (GdkEvent*) gdk_event;
+    
     wxMouseEvent event( event_type );
     InitMouseEvent( win, event, gdk_event );
 
@@ -1599,8 +1608,10 @@ gtk_window_button_press_callback( GtkWidget *widget,
 
     if (win->GTKProcessEvent( event ))
     {
+        g_lastMouseEvent = NULL;
         return TRUE;
     }
+    g_lastMouseEvent = NULL;
 
     if (event_type == wxEVT_RIGHT_DOWN)
     {
@@ -1633,6 +1644,8 @@ gtk_window_button_release_callback( GtkWidget *widget,
 {
     wxCOMMON_CALLBACK_PROLOGUE(gdk_event, win);
 
+    g_lastButtonNumber = 0;
+
     wxEventType event_type = wxEVT_NULL;
 
     switch (gdk_event->button)
@@ -1654,6 +1667,8 @@ gtk_window_button_release_callback( GtkWidget *widget,
             return FALSE;
     }
 
+    g_lastMouseEvent = (GdkEvent*) gdk_event;
+    
     wxMouseEvent event( event_type );
     InitMouseEvent( win, event, gdk_event );
 
@@ -1693,6 +1708,8 @@ gtk_window_motion_notify_callback( GtkWidget *widget,
         gdk_event->y = y;
     }
 
+    g_lastMouseEvent = (GdkEvent*) gdk_event;
+
     wxMouseEvent event( wxEVT_MOTION );
     InitMouseEvent(win, event, gdk_event);
 
@@ -1735,7 +1752,11 @@ gtk_window_motion_notify_callback( GtkWidget *widget,
         }
     }
 
-    return win->GTKProcessEvent(event);
+    bool ret = win->GTKProcessEvent(event);
+    
+    g_lastMouseEvent = NULL;
+
+    return ret;
 }
 
 //-----------------------------------------------------------------------------
@@ -4236,6 +4257,7 @@ void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
 
     m_clipPaintRegion = false;
 
+#if wxUSE_CARET
     bool restoreCaret = (GetCaret() != NULL && GetCaret()->IsVisible());
     if (restoreCaret)
     {
@@ -4255,6 +4277,7 @@ void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
      
         RefreshRect(caretRect);
     }
+#endif
 }
 
 void wxWindowGTK::GtkScrolledWindowSetBorder(GtkWidget* w, int wxstyle)