Do not propagate key events if the target widget has been unrealized.
[GB.GTK] * BUG: Do not propagate key events if the target widget has been unrealized. [GB.GTK3] * BUG: Do not propagate key events if the target widget has been unrealized.
This commit is contained in:
parent
07d1f2d329
commit
f4d89af3ce
1 changed files with 29 additions and 0 deletions
|
@ -321,6 +321,9 @@ static gboolean my_key_press_event(GtkWidget *widget, GdkEventKey *event)
|
|||
focus = gtk_window_get_focus(window);
|
||||
if (focus)
|
||||
{
|
||||
if (!gtk_widget_get_realized(focus))
|
||||
return handled;
|
||||
|
||||
if (GTK_IS_ENTRY(focus) || GTK_IS_TEXT_VIEW(focus))
|
||||
{
|
||||
propagated = TRUE;
|
||||
|
@ -350,6 +353,31 @@ static gboolean my_key_press_event(GtkWidget *widget, GdkEventKey *event)
|
|||
}
|
||||
|
||||
|
||||
static gboolean my_key_release_event(GtkWidget *widget, GdkEventKey *event)
|
||||
{
|
||||
GtkWindow *window = GTK_WINDOW (widget);
|
||||
gboolean handled = FALSE;
|
||||
GtkWidget *focus;
|
||||
|
||||
focus = gtk_window_get_focus(window);
|
||||
if (focus && !gtk_widget_get_realized(focus))
|
||||
return handled;
|
||||
|
||||
/* handle focus widget key events */
|
||||
if (!handled)
|
||||
handled = gtk_window_propagate_key_event(window, event);
|
||||
|
||||
/* Chain up, invokes binding set */
|
||||
if (!handled)
|
||||
{
|
||||
GtkWidgetClass *parent_klass = (GtkWidgetClass*)g_type_class_peek(g_type_parent(GTK_TYPE_WINDOW));
|
||||
handled = parent_klass->key_release_event(widget, event);
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
void gMainWindow::initialize()
|
||||
|
@ -469,6 +497,7 @@ static void workaround_accel_management()
|
|||
|
||||
GtkWidgetClass *klass = (GtkWidgetClass*)g_type_class_peek(GTK_TYPE_WINDOW);
|
||||
klass->key_press_event = my_key_press_event;
|
||||
klass->key_release_event = my_key_release_event;
|
||||
_init = TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue