X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/de6185e212ebc37ff11ff70278e3c4f68419b097..0c606d1239c589ef094b9a969aee4aef0fe98d87:/src/gtk1/dnd.cpp diff --git a/src/gtk1/dnd.cpp b/src/gtk1/dnd.cpp index 1d128192e1..47ce58b017 100644 --- a/src/gtk1/dnd.cpp +++ b/src/gtk1/dnd.cpp @@ -19,11 +19,10 @@ #include "wx/log.h" #include "wx/app.h" #include "wx/utils.h" + #include "wx/window.h" + #include "wx/gdicmn.h" #endif -#include "wx/window.h" -#include "wx/gdicmn.h" - #include "wx/gtk1/private.h" #include @@ -57,7 +56,12 @@ static long gs_flagsForDrag = 0; // the trace mask we use with wxLogTrace() - call // wxLog::AddTraceMask(TRACE_DND) to enable the trace messages from here // (there are quite a few of them, so don't enable this by default) -static const wxChar *TRACE_DND = _T("dnd"); +#define TRACE_DND _T("dnd") + +// global variables because GTK+ DnD want to have the +// mouse event that caused it +extern GdkEvent *g_lastMouseEvent; +extern int g_lastButtonNumber; //---------------------------------------------------------------------------- // standard icons @@ -673,7 +677,7 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget), extern "C" { static void source_drag_data_delete( GtkWidget *WXUNUSED(widget), - GdkDragContext *context, + GdkDragContext *WXUNUSED(context), wxDropSource *WXUNUSED(drop_source) ) { if (g_isIdle) @@ -852,6 +856,14 @@ wxDragResult wxDropSource::DoDragDrop(int flags) if (g_blockEventsOnDrag) return wxDragNone; + // don't start dragging if no button is down + if (g_lastButtonNumber == 0) + return wxDragNone; + + // we can only start a drag after a mouse event + if (g_lastMouseEvent == NULL) + return wxDragNone; + // disabled for now g_blockEventsOnDrag = true; @@ -872,30 +884,6 @@ wxDragResult wxDropSource::DoDragDrop(int flags) } delete[] array; - GdkEventMotion event; - event.window = m_widget->window; - int x = 0; - int y = 0; - GdkModifierType state; - gdk_window_get_pointer( event.window, &x, &y, &state ); - event.x = x; - event.y = y; - event.state = state; - event.time = (guint32)GDK_CURRENT_TIME; - - /* GTK wants to know which button was pressed which caused the dragging */ - int button_number = 0; - if (event.state & GDK_BUTTON1_MASK) button_number = 1; - else if (event.state & GDK_BUTTON2_MASK) button_number = 2; - else if (event.state & GDK_BUTTON3_MASK) button_number = 3; - -#if wxUSE_THREADS - /* disable GUI threads */ -#endif - - /* don't start dragging if no button is down */ - if (button_number) - { int action = GDK_ACTION_COPY; if ( flags & wxDrag_AllowMove ) action |= GDK_ACTION_MOVE; @@ -908,8 +896,8 @@ wxDragResult wxDropSource::DoDragDrop(int flags) GdkDragContext *context = gtk_drag_begin( m_widget, target_list, (GdkDragAction)action, - button_number, /* number of mouse button which started drag */ - (GdkEvent*) &event ); + g_lastButtonNumber, // number of mouse button which started drag + (GdkEvent*) g_lastMouseEvent ); m_dragContext = context; @@ -921,11 +909,6 @@ wxDragResult wxDropSource::DoDragDrop(int flags) m_retValue = ConvertFromGTK(context->action); if ( m_retValue == wxDragNone ) m_retValue = wxDragCancel; - } - -#if wxUSE_THREADS - /* re-enable GUI threads */ -#endif g_blockEventsOnDrag = false;