diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2018-03-22 18:32:19 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2018-04-05 19:26:55 +0200 |
commit | 3361fe1e6273d101be6d13dd58e662f43d433e88 (patch) | |
tree | 62b82556bc53b04c9332acc91ff899d3320b98d3 /gtk/gtkeventcontrollerkey.c | |
parent | 5a34d0f81665e15e5806c0b36a9383216fe128f6 (diff) | |
download | gtk+-3361fe1e6273d101be6d13dd58e662f43d433e88.tar.gz |
gtkeventcontrollerkey: Add ::focus-in/out signals
And handle GDK_FOCUS_CHANGE events in order to emit those.
Diffstat (limited to 'gtk/gtkeventcontrollerkey.c')
-rw-r--r-- | gtk/gtkeventcontrollerkey.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gtk/gtkeventcontrollerkey.c b/gtk/gtkeventcontrollerkey.c index d1c4f52bc9..3b2700a5e4 100644 --- a/gtk/gtkeventcontrollerkey.c +++ b/gtk/gtkeventcontrollerkey.c @@ -47,6 +47,8 @@ enum { KEY_RELEASED, MODIFIERS, IM_UPDATE, + FOCUS_IN, + FOCUS_OUT, N_SIGNALS }; @@ -77,6 +79,18 @@ gtk_event_controller_key_handle_event (GtkEventController *controller, guint16 keycode; guint keyval; + if (event_type == GDK_FOCUS_CHANGE) + { + gboolean focus_in; + + if (gdk_event_get_focus_in (event, &focus_in) && focus_in) + g_signal_emit (controller, signals[FOCUS_IN], 0); + else + g_signal_emit (controller, signals[FOCUS_OUT], 0); + + return FALSE; + } + if (event_type != GDK_KEY_PRESS && event_type != GDK_KEY_RELEASE) return FALSE; @@ -168,6 +182,20 @@ gtk_event_controller_key_class_init (GtkEventControllerKeyClass *klass) 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + signals[FOCUS_IN] = + g_signal_new (I_("focus-in"), + GTK_TYPE_EVENT_CONTROLLER_KEY, + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + signals[FOCUS_OUT] = + g_signal_new (I_("focus-out"), + GTK_TYPE_EVENT_CONTROLLER_KEY, + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } static void |