backported changes from gtk/window.cpp 1.679 and dnd.cpp 1.116 checking that the drag and drop is started from a mouse click handler
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43757 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -53,13 +53,16 @@ extern bool g_blockEventsOnDrag;
|
|||||||
// the flags used for the last DoDragDrop()
|
// the flags used for the last DoDragDrop()
|
||||||
static long gs_flagsForDrag = 0;
|
static long gs_flagsForDrag = 0;
|
||||||
|
|
||||||
|
#ifdef __WXDEBUG__
|
||||||
// the trace mask we use with wxLogTrace() - call
|
// the trace mask we use with wxLogTrace() - call
|
||||||
// wxLog::AddTraceMask(TRACE_DND) to enable the trace messages from here
|
// 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)
|
// (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");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// global variables because GTK+ DnD want to have the
|
||||||
|
// mouse event that caused it
|
||||||
extern GdkEvent *g_lastMouseEvent;
|
extern GdkEvent *g_lastMouseEvent;
|
||||||
|
|
||||||
extern int g_lastButtonNumber;
|
extern int g_lastButtonNumber;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -855,6 +858,14 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
|
|||||||
if (g_blockEventsOnDrag)
|
if (g_blockEventsOnDrag)
|
||||||
return wxDragNone;
|
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
|
// disabled for now
|
||||||
g_blockEventsOnDrag = true;
|
g_blockEventsOnDrag = true;
|
||||||
|
|
||||||
@@ -875,9 +886,6 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
|
|||||||
}
|
}
|
||||||
delete[] array;
|
delete[] array;
|
||||||
|
|
||||||
/* don't start dragging if no button is down */
|
|
||||||
if (g_lastButtonNumber)
|
|
||||||
{
|
|
||||||
int action = GDK_ACTION_COPY;
|
int action = GDK_ACTION_COPY;
|
||||||
if ( flags & wxDrag_AllowMove )
|
if ( flags & wxDrag_AllowMove )
|
||||||
action |= GDK_ACTION_MOVE;
|
action |= GDK_ACTION_MOVE;
|
||||||
@@ -903,7 +911,6 @@ wxDragResult wxDropSource::DoDragDrop(int flags)
|
|||||||
m_retValue = ConvertFromGTK(context->action);
|
m_retValue = ConvertFromGTK(context->action);
|
||||||
if ( m_retValue == wxDragNone )
|
if ( m_retValue == wxDragNone )
|
||||||
m_retValue = wxDragCancel;
|
m_retValue = wxDragCancel;
|
||||||
}
|
|
||||||
|
|
||||||
g_blockEventsOnDrag = false;
|
g_blockEventsOnDrag = false;
|
||||||
|
|
||||||
|
@@ -225,7 +225,8 @@ wxWindowGTK *g_delayedFocus = (wxWindowGTK*) NULL;
|
|||||||
// the last click here (extern: used from gtk/menu.cpp)
|
// the last click here (extern: used from gtk/menu.cpp)
|
||||||
guint32 wxGtkTimeLastClick = 0;
|
guint32 wxGtkTimeLastClick = 0;
|
||||||
|
|
||||||
// Save the last mouse event for drag start
|
// global variables because GTK+ DnD want to have the
|
||||||
|
// mouse event that caused it
|
||||||
GdkEvent *g_lastMouseEvent = (GdkEvent*) NULL;
|
GdkEvent *g_lastMouseEvent = (GdkEvent*) NULL;
|
||||||
int g_lastButtonNumber = 0;
|
int g_lastButtonNumber = 0;
|
||||||
|
|
||||||
@@ -1615,8 +1616,10 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
|
|||||||
if (win->GetEventHandler()->ProcessEvent( event ))
|
if (win->GetEventHandler()->ProcessEvent( event ))
|
||||||
{
|
{
|
||||||
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_press_event" );
|
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_press_event" );
|
||||||
|
g_lastMouseEvent = NULL;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
g_lastMouseEvent = NULL;
|
||||||
|
|
||||||
if (event_type == wxEVT_RIGHT_DOWN)
|
if (event_type == wxEVT_RIGHT_DOWN)
|
||||||
{
|
{
|
||||||
@@ -1773,13 +1776,15 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget,
|
|||||||
win = FindWindowForMouseEvent(win, event.m_x, event.m_y);
|
win = FindWindowForMouseEvent(win, event.m_x, event.m_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (win->GetEventHandler()->ProcessEvent( event ))
|
bool ret = win->GetEventHandler()->ProcessEvent( event );
|
||||||
|
g_lastMouseEvent = NULL;
|
||||||
|
|
||||||
|
if ( ret )
|
||||||
{
|
{
|
||||||
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "motion_notify_event" );
|
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "motion_notify_event" );
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return ret ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user