X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6041f69ca7bbb7c39e4ba64e407bc3ac39e3687f..89041b2513594c7a1bd92f5895795437d53c1e92:/src/gtk/window.cpp?ds=sidebyside diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 1a3f1065b0..526a47f492 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1068,6 +1068,21 @@ gtk_window_key_release_callback( GtkWidget * WXUNUSED(widget), } } +//----------------------------------------------------------------------------- +// key and mouse events, after, from m_widget +//----------------------------------------------------------------------------- + +extern "C" { +static gboolean key_and_mouse_event_after(GtkWidget* widget, GdkEventKey*, wxWindow*) +{ + // If a widget does not handle a key or mouse event, GTK+ sends it up the + // parent chain until it is handled. These events are not supposed to + // propagate in wxWidgets, so prevent it unless widget is in a native + // container. + return WX_IS_PIZZA(gtk_widget_get_parent(widget)); +} +} + // ============================================================================ // the mouse events // ============================================================================ @@ -2357,6 +2372,18 @@ void wxWindowGTK::PostCreation() ConnectWidget( connect_widget ); + // connect handler to prevent events from propagating up parent chain + g_signal_connect_after(m_widget, + "key_press_event", G_CALLBACK(key_and_mouse_event_after), this); + g_signal_connect_after(m_widget, + "key_release_event", G_CALLBACK(key_and_mouse_event_after), this); + g_signal_connect_after(m_widget, + "button_press_event", G_CALLBACK(key_and_mouse_event_after), this); + g_signal_connect_after(m_widget, + "button_release_event", G_CALLBACK(key_and_mouse_event_after), this); + g_signal_connect_after(m_widget, + "motion_notify_event", G_CALLBACK(key_and_mouse_event_after), this); + // We cannot set colours, fonts and cursors before the widget has been // realized, so we do this directly after realization -- unless the widget // was in fact realized already.