backported chnage in 1.115 of src/gtk/dnd.cpp (bug 1531348)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43426 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-11-14 22:50:24 +00:00
parent c25f90f60c
commit 91fca3d2bd

View File

@@ -58,6 +58,10 @@ static long gs_flagsForDrag = 0;
// (there are quite a few of them, so don't enable this by default) // (there are quite a few of them, so don't enable this by default)
static const wxChar *TRACE_DND = _T("dnd"); static const wxChar *TRACE_DND = _T("dnd");
extern GdkEvent *g_lastMouseEvent;
extern int g_lastButtonNumber;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// standard icons // standard icons
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -871,29 +875,8 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
} }
delete[] array; 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 */ /* don't start dragging if no button is down */
if (button_number) if (g_lastButtonNumber)
{ {
int action = GDK_ACTION_COPY; int action = GDK_ACTION_COPY;
if ( flags & wxDrag_AllowMove ) if ( flags & wxDrag_AllowMove )
@@ -907,8 +890,8 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
GdkDragContext *context = gtk_drag_begin( m_widget, GdkDragContext *context = gtk_drag_begin( m_widget,
target_list, target_list,
(GdkDragAction)action, (GdkDragAction)action,
button_number, /* number of mouse button which started drag */ g_lastButtonNumber, // number of mouse button which started drag
(GdkEvent*) &event ); (GdkEvent*) g_lastMouseEvent );
m_dragContext = context; m_dragContext = context;
@@ -922,22 +905,10 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
m_retValue = wxDragCancel; m_retValue = wxDragCancel;
} }
#if wxUSE_THREADS
/* re-enable GUI threads */
#endif
g_blockEventsOnDrag = false; g_blockEventsOnDrag = false;
UnregisterWindow(); 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; return m_retValue;
} }