]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/dnd.cpp
Another RTL fix.
[wxWidgets.git] / src / gtk / dnd.cpp
index b9e4d38b87ca2e409e4f00897583b446ddcf1c35..7565e877badfd21c90e690e25e26813639933a6e 100644 (file)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        dnd.cpp
+// Name:        src/gtk/dnd.cpp
 // Purpose:     wxDropTarget class
 // Author:      Robert Roebling
 // Id:          $Id$
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
-#include "wx/dnd.h"
-#include "wx/log.h"
-
-
 #if wxUSE_DRAG_AND_DROP
 
-#include "wx/window.h"
-#include "wx/app.h"
-#include "wx/gdicmn.h"
-#include "wx/intl.h"
-#include "wx/utils.h"
+#include "wx/dnd.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/intl.h"
+    #include "wx/log.h"
+    #include "wx/app.h"
+    #include "wx/utils.h"
+    #include "wx/window.h"
+    #include "wx/gdicmn.h"
+#endif
 
 #include "wx/gtk/private.h"
 
 #include <gtk/gtkdnd.h>
 #include <gtk/gtkselection.h>
 
-//-----------------------------------------------------------------------------
-// idle system
-//-----------------------------------------------------------------------------
-
-extern void wxapp_install_idle_handler();
-extern bool g_isIdle;
-
-//-----------------------------------------------------------------------------
-// thread system
-//-----------------------------------------------------------------------------
-
-#if wxUSE_THREADS
-#endif
-
 //----------------------------------------------------------------------------
 // global data
 //----------------------------------------------------------------------------
@@ -350,7 +337,7 @@ static gboolean target_drag_drop( GtkWidget *widget,
     }
     else
     {
-        wxLogTrace(TRACE_DND, wxT( "Drop target: OnDrop returned TRUE") );
+        wxLogTrace(TRACE_DND, wxT( "Drop target: OnDrop returned true") );
 
 #if wxUSE_THREADS
         /* disable GUI threads */
@@ -359,7 +346,7 @@ static gboolean target_drag_drop( GtkWidget *widget,
         GdkAtom format = drop_target->GetMatchingPair();
 
         // this does happen somehow, see bug 555111
-        wxCHECK_MSG( format, FALSE, _T("no matching GdkAtom for format?") )
+        wxCHECK_MSG( format, FALSE, _T("no matching GdkAtom for format?") );
 
 /*
         GdkDragAction action = GDK_ACTION_MOVE;
@@ -428,7 +415,7 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
 
     if ( wxIsDragResultOk( drop_target->OnData( x, y, result ) ) )
     {
-        wxLogTrace(TRACE_DND, wxT( "Drop target: OnData returned TRUE") );
+        wxLogTrace(TRACE_DND, wxT( "Drop target: OnData returned true") );
 
         /* tell GTK that data transfer was successful */
         gtk_drag_finish( context, TRUE, FALSE, time );
@@ -719,8 +706,7 @@ extern "C" {
 static gint
 gtk_dnd_window_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxDropSource *source )
 {
-    if (g_isIdle)
-        wxapp_install_idle_handler();
+    // don't need to install idle handler, its done from "event" signal
 
     source->GiveFeedback( ConvertFromGTK(source->m_dragContext->action) );
 
@@ -811,7 +797,7 @@ void wxDropSource::PrepareIcon( int action, GdkDragContext *context )
     GdkPixmap *pixmap = icon->GetPixmap();
 
     gint width,height;
-    gdk_window_get_size (pixmap, &width, &height);
+    gdk_drawable_get_size (pixmap, &width, &height);
 
     GdkColormap *colormap = gtk_widget_get_colormap( m_widget );
     gtk_widget_push_colormap (colormap);
@@ -924,6 +910,14 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
 
     UnregisterWindow();
 
+    // this shouldn't be needed but somehow, sometimes, without this the cursor
+    // stays grabbed even when the DND operation ends and the application
+    // becomes unresponsive and has to be killed resulting in loss of all
+    // unsaved data, so while this fix is ugly it's still better than
+    // alternative
+    if ( gdk_pointer_is_grabbed() )
+        gdk_pointer_ungrab(GDK_CURRENT_TIME);
+
     return m_retValue;
 }