From 04754d753b1370b0026b83d89bfa6d14bd343028 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 12 May 2019 18:00:19 +0000 Subject: [PATCH] Reinstate the activate-focus keybinding Commit 3b62d9c027186fe0fddfb9 was a bit overzealous in removing not just the public API for activating the focus widget, but also the plumbing needed to make the keybinding work. Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1879 --- gtk/gtkwindow.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index d9bcf9ad65..fa65a9933d 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -431,6 +431,7 @@ static void gtk_window_move_focus (GtkWidget *widget, GtkDirectionType dir); static void gtk_window_real_activate_default (GtkWindow *window); +static void gtk_window_real_activate_focus (GtkWindow *window); static void gtk_window_keys_changed (GtkWindow *window); static gboolean gtk_window_enable_debugging (GtkWindow *window, gboolean toggle); @@ -804,6 +805,7 @@ gtk_window_class_init (GtkWindowClass *klass) container_class->forall = gtk_window_forall; klass->activate_default = gtk_window_real_activate_default; + klass->activate_focus = gtk_window_real_activate_focus; klass->keys_changed = gtk_window_keys_changed; klass->enable_debugging = gtk_window_enable_debugging; klass->close_request = gtk_window_close_request; @@ -6232,6 +6234,15 @@ get_active_region_type (GtkWindow *window, gint x, gint y) return GTK_WINDOW_REGION_CONTENT; } +static void +gtk_window_real_activate_focus (GtkWindow *window) +{ + GtkWindowPrivate *priv = gtk_window_get_instance_private (window); + + if (priv->focus_widget && gtk_widget_is_sensitive (priv->focus_widget)) + gtk_widget_activate (priv->focus_widget); +} + static gboolean gtk_window_has_mnemonic_modifier_pressed (GtkWindow *window) {