projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Various changes to make pop up menus work
[wxWidgets.git]
/
src
/
gtk
/
dnd.cpp
diff --git
a/src/gtk/dnd.cpp
b/src/gtk/dnd.cpp
index 745dec2fdb162fe8c298489e8a37b6356d0ce99d..0be1c854adf73ce56a6681903e7aaa0b530fb78f 100644
(file)
--- a/
src/gtk/dnd.cpp
+++ b/
src/gtk/dnd.cpp
@@
-40,8
+40,6
@@
extern bool g_isIdle;
//-----------------------------------------------------------------------------
#if wxUSE_THREADS
//-----------------------------------------------------------------------------
#if wxUSE_THREADS
-extern void wxapp_install_thread_wakeup();
-extern void wxapp_uninstall_thread_wakeup();
#endif
//----------------------------------------------------------------------------
#endif
//----------------------------------------------------------------------------
@@
-50,12
+48,17
@@
extern void wxapp_uninstall_thread_wakeup();
extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnDrag;
+// 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");
+
//----------------------------------------------------------------------------
// standard icons
//----------------------------------------------------------------------------
/* XPM */
//----------------------------------------------------------------------------
// standard icons
//----------------------------------------------------------------------------
/* XPM */
-static char * page_xpm[] = {
+static c
onst c
har * page_xpm[] = {
/* width height ncolors chars_per_pixel */
"32 32 5 1",
/* colors */
/* width height ncolors chars_per_pixel */
"32 32 5 1",
/* colors */
@@
-150,6
+153,8
@@
static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget),
wxDragResult result;
if ( context->suggested_action == GDK_ACTION_COPY )
result = wxDragCopy;
wxDragResult result;
if ( context->suggested_action == GDK_ACTION_COPY )
result = wxDragCopy;
+ else if ( context->suggested_action == GDK_ACTION_LINK )
+ result = wxDragLink;
else
result = wxDragMove;
else
result = wxDragMove;
@@
-170,6
+175,8
@@
static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget),
GdkDragAction action;
if (result == wxDragCopy)
action = GDK_ACTION_COPY;
GdkDragAction action;
if (result == wxDragCopy)
action = GDK_ACTION_COPY;
+ else if (result == wxDragLink)
+ action = GDK_ACTION_LINK;
else
action = GDK_ACTION_MOVE;
else
action = GDK_ACTION_MOVE;
@@
-226,11
+233,16
@@
static gboolean target_drag_drop( GtkWidget *widget,
if (context->suggested_action == GDK_ACTION_COPY) result = wxDragCopy;
*/
if (context->suggested_action == GDK_ACTION_COPY) result = wxDragCopy;
*/
+ /* reset the block here as someone might very well
+ show a dialog as a reaction to a drop and this
+ wouldn't work without events */
+ g_blockEventsOnDrag = FALSE;
+
bool ret = drop_target->OnDrop( x, y );
if (!ret)
{
bool ret = drop_target->OnDrop( x, y );
if (!ret)
{
- wxLog
Debug(
wxT( "Drop target: OnDrop returned FALSE") );
+ wxLog
Trace(TRACE_DND,
wxT( "Drop target: OnDrop returned FALSE") );
/* cancel the whole thing */
gtk_drag_finish( context,
/* cancel the whole thing */
gtk_drag_finish( context,
@@
-240,11
+252,10
@@
static gboolean target_drag_drop( GtkWidget *widget,
}
else
{
}
else
{
- wxLog
Debug(
wxT( "Drop target: OnDrop returned TRUE") );
+ wxLog
Trace(TRACE_DND,
wxT( "Drop target: OnDrop returned TRUE") );
#if wxUSE_THREADS
/* disable GUI threads */
#if wxUSE_THREADS
/* disable GUI threads */
- wxapp_uninstall_thread_wakeup();
#endif
GdkAtom format = drop_target->GetMatchingPair();
#endif
GdkAtom format = drop_target->GetMatchingPair();
@@
-263,7
+274,6
@@
static gboolean target_drag_drop( GtkWidget *widget,
#if wxUSE_THREADS
/* re-enable GUI threads */
#if wxUSE_THREADS
/* re-enable GUI threads */
- wxapp_install_thread_wakeup();
#endif
}
#endif
}
@@
-306,7
+316,7
@@
static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
return;
}
return;
}
- wxLog
Debug(
wxT( "Drop target: data received event") );
+ wxLog
Trace(TRACE_DND,
wxT( "Drop target: data received event") );
/* inform the wxDropTarget about the current GtkSelectionData.
this is only valid for the duration of this call */
/* inform the wxDropTarget about the current GtkSelectionData.
this is only valid for the duration of this call */
@@
-315,19
+325,21
@@
static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
wxDragResult result;
if ( context->suggested_action == GDK_ACTION_COPY )
result = wxDragCopy;
wxDragResult result;
if ( context->suggested_action == GDK_ACTION_COPY )
result = wxDragCopy;
+ else if ( context->suggested_action == GDK_ACTION_LINK )
+ result = wxDragLink;
else
result = wxDragMove;
if ( wxIsDragResultOk( drop_target->OnData( x, y, result ) ) )
{
else
result = wxDragMove;
if ( wxIsDragResultOk( drop_target->OnData( x, y, result ) ) )
{
- wxLog
Debug(
wxT( "Drop target: OnData returned TRUE") );
+ wxLog
Trace(TRACE_DND,
wxT( "Drop target: OnData returned TRUE") );
/* tell GTK that data transfer was successfull */
gtk_drag_finish( context, TRUE, FALSE, time );
}
else
{
/* tell GTK that data transfer was successfull */
gtk_drag_finish( context, TRUE, FALSE, time );
}
else
{
- wxLog
Debug(
wxT( "Drop target: OnData returned FALSE") );
+ wxLog
Trace(TRACE_DND,
wxT( "Drop target: OnData returned FALSE") );
/* tell GTK that data transfer was not successfull */
gtk_drag_finish( context, FALSE, FALSE, time );
/* tell GTK that data transfer was not successfull */
gtk_drag_finish( context, FALSE, FALSE, time );
@@
-401,7
+413,8
@@
GdkAtom wxDropTarget::GetMatchingPair()
wxDataFormat format( formatAtom );
#ifdef __WXDEBUG__
wxDataFormat format( formatAtom );
#ifdef __WXDEBUG__
- wxLogDebug( wxT("Drop target: drag has format: %s"), format.GetId().c_str() );
+ wxLogTrace(TRACE_DND, wxT("Drop target: drag has format: %s"),
+ format.GetId().c_str());
#endif // Debug
if (m_dataObject->IsSupportedFormat( format ))
#endif // Debug
if (m_dataObject->IsSupportedFormat( format ))
@@
-499,7
+512,8
@@
source_drag_data_get (GtkWidget *WXUNUSED(widget),
wxDataFormat format( selection_data->target );
wxDataFormat format( selection_data->target );
- wxLogDebug( wxT("Drop source: format requested: %s"), format.GetId().c_str() );
+ wxLogTrace(TRACE_DND, wxT("Drop source: format requested: %s"),
+ format.GetId().c_str());
drop_source->m_retValue = wxDragCancel;
drop_source->m_retValue = wxDragCancel;
@@
-507,19
+521,19
@@
source_drag_data_get (GtkWidget *WXUNUSED(widget),
if (!data)
{
if (!data)
{
- wxLog
Debug(
wxT("Drop source: no data object") );
+ wxLog
Trace(TRACE_DND,
wxT("Drop source: no data object") );
return;
}
if (!data->IsSupportedFormat(format))
{
return;
}
if (!data->IsSupportedFormat(format))
{
- wxLog
Debug(
wxT("Drop source: unsupported format") );
+ wxLog
Trace(TRACE_DND,
wxT("Drop source: unsupported format") );
return;
}
if (data->GetDataSize(format) == 0)
{
return;
}
if (data->GetDataSize(format) == 0)
{
- wxLog
Debug(
wxT("Drop source: empty data") );
+ wxLog
Trace(TRACE_DND,
wxT("Drop source: empty data") );
return;
}
return;
}
@@
-537,7
+551,6
@@
source_drag_data_get (GtkWidget *WXUNUSED(widget),
#if wxUSE_THREADS
/* disable GUI threads */
#if wxUSE_THREADS
/* disable GUI threads */
- wxapp_uninstall_thread_wakeup();
#endif
gtk_selection_data_set( selection_data,
#endif
gtk_selection_data_set( selection_data,
@@
-548,7
+561,6
@@
source_drag_data_get (GtkWidget *WXUNUSED(widget),
#if wxUSE_THREADS
/* enable GUI threads */
#if wxUSE_THREADS
/* enable GUI threads */
- wxapp_install_thread_wakeup();
#endif
delete[] d;
#endif
delete[] d;
@@
-558,9
+570,9
@@
source_drag_data_get (GtkWidget *WXUNUSED(widget),
// "drag_data_delete"
//----------------------------------------------------------------------------
// "drag_data_delete"
//----------------------------------------------------------------------------
-static void source_drag_data_delete( GtkWidget
*WXUNUSED(widget),
- GdkDragContext
*WXUNUSED(context)
,
- wxDropSource
*WXUNUSED(drop_source) )
+static void source_drag_data_delete( GtkWidget *WXUNUSED(widget),
+ GdkDragContext
*context
,
+ wxDropSource *WXUNUSED(drop_source) )
{
if (g_isIdle)
wxapp_install_idle_handler();
{
if (g_isIdle)
wxapp_install_idle_handler();
@@
-609,6
+621,7
@@
gtk_dnd_window_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigur
wxDragResult action = wxDragNone;
if (source->m_dragContext->action == GDK_ACTION_COPY) action = wxDragCopy;
wxDragResult action = wxDragNone;
if (source->m_dragContext->action == GDK_ACTION_COPY) action = wxDragCopy;
+ if (source->m_dragContext->action == GDK_ACTION_LINK) action = wxDragLink;
if (source->m_dragContext->action == GDK_ACTION_MOVE) action = wxDragMove;
source->GiveFeedback( action );
if (source->m_dragContext->action == GDK_ACTION_MOVE) action = wxDragMove;
source->GiveFeedback( action );
@@
-740,8
+753,12
@@
wxDragResult wxDropSource::DoDragDrop( bool allowMove )
if (m_data->GetFormatCount() == 0)
return (wxDragResult) wxDragNone;
if (m_data->GetFormatCount() == 0)
return (wxDragResult) wxDragNone;
+ // still in drag
+ if (g_blockEventsOnDrag)
+ return (wxDragResult) wxDragNone;
+
// disabled for now
// disabled for now
- g_blockEventsOnDrag =
FALS
E;
+ g_blockEventsOnDrag =
TRU
E;
RegisterWindow();
RegisterWindow();
@@
-754,7
+771,7
@@
wxDragResult wxDropSource::DoDragDrop( bool allowMove )
for (size_t i = 0; i < m_data->GetFormatCount(); i++)
{
GdkAtom atom = array[i];
for (size_t i = 0; i < m_data->GetFormatCount(); i++)
{
GdkAtom atom = array[i];
- wxLog
Debug( wxT("Drop source: Supported atom %s"), gdk_atom_name( atom )
);
+ wxLog
Trace(TRACE_DND, wxT("Drop source: Supported atom %s"), gdk_atom_name( atom )
);
gtk_target_list_add( target_list, atom, 0, 0 );
}
delete[] array;
gtk_target_list_add( target_list, atom, 0, 0 );
}
delete[] array;
@@
-778,17
+795,17
@@
wxDragResult wxDropSource::DoDragDrop( bool allowMove )
#if wxUSE_THREADS
/* disable GUI threads */
#if wxUSE_THREADS
/* disable GUI threads */
- wxapp_uninstall_thread_wakeup();
#endif
/* don't start dragging if no button is down */
if (button_number)
{
#endif
/* don't start dragging if no button is down */
if (button_number)
{
- GdkDragAction action = GDK_ACTION_COPY;
- if (allowMove) action = (GdkDragAction)(GDK_ACTION_MOVE|GDK_ACTION_COPY);
+ int action = GDK_ACTION_COPY;
+ if ( allowMove )
+ action |= GDK_ACTION_MOVE;
GdkDragContext *context = gtk_drag_begin( m_widget,
target_list,
GdkDragContext *context = gtk_drag_begin( m_widget,
target_list,
- action,
+
(GdkDragAction)
action,
button_number, /* number of mouse button which started drag */
(GdkEvent*) &event );
button_number, /* number of mouse button which started drag */
(GdkEvent*) &event );
@@
-800,13
+817,14
@@
wxDragResult wxDropSource::DoDragDrop( bool allowMove )
if (context->action == GDK_ACTION_COPY)
m_retValue = wxDragCopy;
if (context->action == GDK_ACTION_COPY)
m_retValue = wxDragCopy;
+ if (context->action == GDK_ACTION_LINK)
+ m_retValue = wxDragLink;
if (context->action == GDK_ACTION_MOVE)
m_retValue = wxDragMove;
}
#if wxUSE_THREADS
/* re-enable GUI threads */
if (context->action == GDK_ACTION_MOVE)
m_retValue = wxDragMove;
}
#if wxUSE_THREADS
/* re-enable GUI threads */
- wxapp_install_thread_wakeup();
#endif
g_blockEventsOnDrag = FALSE;
#endif
g_blockEventsOnDrag = FALSE;