[gtk/matthiasc/for-master] text: Be more selective when selecting on focus-in
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master] text: Be more selective when selecting on focus-in
- Date: Fri, 26 Jun 2020 19:53:17 +0000 (UTC)
commit cd9f5733b3e354301f29f1526744fec2da6fdfc8
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jun 26 15:49:39 2020 -0400
text: Be more selective when selecting on focus-in
We don't want to select on focus-in when the focus
comes from a child. The case where this does harm
is when you activate copy or paste actions from the
context menu. We close the menu before triggering the
action, and if that causes the text in the entry to
be selected, unexpected things happen, since the action
applies to the current selection.
Fixes: #2869
gtk/gtktext.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 67400607a9..ff6fde8e5b 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -3193,11 +3193,15 @@ gtk_text_grab_focus (GtkWidget *widget)
GtkText *self = GTK_TEXT (widget);
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
gboolean select_on_focus;
+ GtkWidget *prev_focus;
+
+ prev_focus = gtk_root_get_focus (gtk_widget_get_root (widget));
if (!GTK_WIDGET_CLASS (gtk_text_parent_class)->grab_focus (GTK_WIDGET (self)))
return FALSE;
- if (priv->editable && !priv->in_click)
+ if (priv->editable && !priv->in_click &&
+ !(prev_focus && gtk_widget_is_ancestor (prev_focus, widget)))
{
g_object_get (gtk_widget_get_settings (widget),
"gtk-entry-select-on-focus",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]