Compare commits

...

1 Commits

Author SHA1 Message Date
Nelson Benítez León
64a1305cdd Move focus to parent when hiding a focused child
because otherwise the focus will jump forward
to next widget, while expected behaviour is
for focus to come back to parent widget when
such parent is focusable.

As we now do this toolkit wide in
_gtk_window_unset_focus_and_default(),
there's no need for individual widgets to do
that explicitly, so we remove such explicit
calls by the GtkText and GtkTextView widgets.

Fixes issue #4903
2022-09-01 20:52:15 -04:00
3 changed files with 14 additions and 4 deletions

View File

@@ -6919,7 +6919,6 @@ gtk_text_insert_emoji (GtkText *self)
gtk_widget_set_parent (chooser, GTK_WIDGET (self));
g_signal_connect (chooser, "emoji-picked", G_CALLBACK (emoji_picked), self);
g_signal_connect_swapped (chooser, "hide", G_CALLBACK (gtk_text_grab_focus_without_selecting), self);
}
gtk_popover_popup (GTK_POPOVER (chooser));

View File

@@ -10070,7 +10070,6 @@ gtk_text_view_insert_emoji (GtkTextView *text_view)
gtk_widget_set_parent (chooser, GTK_WIDGET (text_view));
g_signal_connect (chooser, "emoji-picked", G_CALLBACK (emoji_picked), text_view);
g_signal_connect_swapped (chooser, "hide", G_CALLBACK (gtk_widget_grab_focus), text_view);
}
buffer = get_buffer (text_view);

View File

@@ -59,6 +59,7 @@
#include "gtkshortcuttrigger.h"
#include "gtksizerequest.h"
#include "gtksnapshot.h"
#include "gtktext.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
#include "gtkwindowgroup.h"
@@ -5130,11 +5131,22 @@ _gtk_window_unset_focus_and_default (GtkWindow *window,
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GtkWidget *child;
GtkWidget *child, *parent;
child = priv->focus_widget;
if (child && (child == widget || gtk_widget_is_ancestor (child, widget)))
priv->move_focus = TRUE;
{
parent = gtk_widget_get_parent (widget);
if (parent && gtk_widget_get_focusable (parent))
{
if (GTK_IS_TEXT (parent))
gtk_text_grab_focus_without_selecting (GTK_TEXT (parent));
else
gtk_widget_grab_focus (parent);
}
else
priv->move_focus = TRUE;
}
child = priv->default_widget;
if (child && (child == widget || gtk_widget_is_ancestor (child, widget)))