Stop using wxCOMMON_CALLBACK_PROLOGUE macro in wxGTK callbacks
No real changes, just simplify the code and stop using a macro unnecessarily when we can use a simple inline function instead.
This commit is contained in:
parent
28ba50fa45
commit
ccce75f3cc
2 changed files with 21 additions and 37 deletions
|
|
@ -171,14 +171,9 @@ public:
|
||||||
virtual GtkWidget* GetConnectWidget();
|
virtual GtkWidget* GetConnectWidget();
|
||||||
void ConnectWidget( GtkWidget *widget );
|
void ConnectWidget( GtkWidget *widget );
|
||||||
|
|
||||||
// Called from several event handlers, if it returns true or false, the
|
|
||||||
// same value should be immediately returned by the handler without doing
|
|
||||||
// anything else. If it returns -1, the handler should continue as usual
|
|
||||||
int GTKCallbackCommonPrologue(struct _GdkEventAny *event) const;
|
|
||||||
|
|
||||||
// Simplified form of GTKCallbackCommonPrologue() which can be used from
|
// Returns true if GTK callbacks are blocked due to a drag event being in
|
||||||
// GTK callbacks without return value to check if the event should be
|
// progress.
|
||||||
// ignored: if this returns true, the event shouldn't be handled
|
|
||||||
bool GTKShouldIgnoreEvent() const;
|
bool GTKShouldIgnoreEvent() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1669,35 +1669,19 @@ bool wxWindowGTK::GTKShouldIgnoreEvent() const
|
||||||
return g_blockEventsOnDrag;
|
return g_blockEventsOnDrag;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxWindowGTK::GTKCallbackCommonPrologue(GdkEventAny* WXUNUSED(event)) const
|
// Some callbacks check for just g_blockEventsOnDrag but others check for both
|
||||||
|
// it and g_blockEventsOnScroll. It's not really clear why, but define a helper
|
||||||
|
// function performing the latter check too for now to avoid changing the
|
||||||
|
// behaviour of the existing code.
|
||||||
|
namespace
|
||||||
{
|
{
|
||||||
if (g_blockEventsOnDrag)
|
|
||||||
return TRUE;
|
|
||||||
if (g_blockEventsOnScroll)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
return -1;
|
bool AreGTKEventsBlocked()
|
||||||
|
{
|
||||||
|
return g_blockEventsOnDrag || g_blockEventsOnScroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
// overloads for all GDK event types we use here: we need to have this as
|
} // anonymous namespace
|
||||||
// GdkEventXXX can't be implicitly cast to GdkEventAny even if it, in fact,
|
|
||||||
// derives from it in the sense that the structs have the same layout
|
|
||||||
#define wxDEFINE_COMMON_PROLOGUE_OVERLOAD(T) \
|
|
||||||
static int wxGtkCallbackCommonPrologue(T *event, wxWindowGTK *win) \
|
|
||||||
{ \
|
|
||||||
return win->GTKCallbackCommonPrologue((GdkEventAny *)event); \
|
|
||||||
}
|
|
||||||
|
|
||||||
wxDEFINE_COMMON_PROLOGUE_OVERLOAD(GdkEventButton)
|
|
||||||
wxDEFINE_COMMON_PROLOGUE_OVERLOAD(GdkEventMotion)
|
|
||||||
wxDEFINE_COMMON_PROLOGUE_OVERLOAD(GdkEventCrossing)
|
|
||||||
|
|
||||||
#undef wxDEFINE_COMMON_PROLOGUE_OVERLOAD
|
|
||||||
|
|
||||||
#define wxCOMMON_CALLBACK_PROLOGUE(event, win) \
|
|
||||||
const int rc = wxGtkCallbackCommonPrologue(event, win); \
|
|
||||||
if ( rc != -1 ) \
|
|
||||||
return rc
|
|
||||||
|
|
||||||
// all event handlers must have C linkage as they're called from GTK+ C code
|
// all event handlers must have C linkage as they're called from GTK+ C code
|
||||||
extern "C"
|
extern "C"
|
||||||
|
|
@ -1721,7 +1705,8 @@ gtk_window_button_press_callback( GtkWidget* WXUNUSED_IN_GTK3(widget),
|
||||||
|
|
||||||
wxPROCESS_EVENT_ONCE(GdkEventButton, gdk_event);
|
wxPROCESS_EVENT_ONCE(GdkEventButton, gdk_event);
|
||||||
|
|
||||||
wxCOMMON_CALLBACK_PROLOGUE(gdk_event, win);
|
if ( AreGTKEventsBlocked() )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
g_lastButtonNumber = gdk_event->button;
|
g_lastButtonNumber = gdk_event->button;
|
||||||
|
|
||||||
|
|
@ -1855,7 +1840,8 @@ gtk_window_button_release_callback( GtkWidget *WXUNUSED(widget),
|
||||||
{
|
{
|
||||||
wxPROCESS_EVENT_ONCE(GdkEventButton, gdk_event);
|
wxPROCESS_EVENT_ONCE(GdkEventButton, gdk_event);
|
||||||
|
|
||||||
wxCOMMON_CALLBACK_PROLOGUE(gdk_event, win);
|
if ( AreGTKEventsBlocked() )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
g_lastButtonNumber = 0;
|
g_lastButtonNumber = 0;
|
||||||
|
|
||||||
|
|
@ -1957,7 +1943,8 @@ gtk_window_motion_notify_callback( GtkWidget * WXUNUSED(widget),
|
||||||
{
|
{
|
||||||
wxPROCESS_EVENT_ONCE(GdkEventMotion, gdk_event);
|
wxPROCESS_EVENT_ONCE(GdkEventMotion, gdk_event);
|
||||||
|
|
||||||
wxCOMMON_CALLBACK_PROLOGUE(gdk_event, win);
|
if ( AreGTKEventsBlocked() )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
g_lastMouseEvent = (GdkEvent*) gdk_event;
|
g_lastMouseEvent = (GdkEvent*) gdk_event;
|
||||||
|
|
||||||
|
|
@ -2254,7 +2241,8 @@ gtk_window_enter_callback( GtkWidget* widget,
|
||||||
wxLogTrace(TRACE_MOUSE, "Window enter in %s (window %p) for window %p",
|
wxLogTrace(TRACE_MOUSE, "Window enter in %s (window %p) for window %p",
|
||||||
wxDumpWindow(win), gtk_widget_get_window(widget), gdk_event->window);
|
wxDumpWindow(win), gtk_widget_get_window(widget), gdk_event->window);
|
||||||
|
|
||||||
wxCOMMON_CALLBACK_PROLOGUE(gdk_event, win);
|
if ( AreGTKEventsBlocked() )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
// Event was emitted after a grab
|
// Event was emitted after a grab
|
||||||
if (gdk_event->mode != GDK_CROSSING_NORMAL)
|
if (gdk_event->mode != GDK_CROSSING_NORMAL)
|
||||||
|
|
@ -2284,7 +2272,8 @@ gtk_window_leave_callback( GtkWidget* widget,
|
||||||
wxLogTrace(TRACE_MOUSE, "Window leave in %s (window %p) for window %p",
|
wxLogTrace(TRACE_MOUSE, "Window leave in %s (window %p) for window %p",
|
||||||
wxDumpWindow(win), gtk_widget_get_window(widget), gdk_event->window);
|
wxDumpWindow(win), gtk_widget_get_window(widget), gdk_event->window);
|
||||||
|
|
||||||
wxCOMMON_CALLBACK_PROLOGUE(gdk_event, win);
|
if ( AreGTKEventsBlocked() )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (win->m_needCursorReset)
|
if (win->m_needCursorReset)
|
||||||
win->GTKUpdateCursor();
|
win->GTKUpdateCursor();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue