[gtk/label-copy-link-fix: 1/2] label: Be more selective when selecting on focus-in
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/label-copy-link-fix: 1/2] label: Be more selective when selecting on focus-in
- Date: Sun, 2 Aug 2020 02:04:32 +0000 (UTC)
commit 64ed69c56fe79aae9940d909494c708e01b266c9
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Aug 1 22:01:52 2020 -0400
label: 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 label to
be selected, unexpected things happen, since the action
applies to the current selection.
This is the equivalent of cd9f5733b3e354301f2 for GtkLabel.
gtk/gtklabel.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 453f6023c7..c39699fed1 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -3710,10 +3710,13 @@ gtk_label_grab_focus (GtkWidget *widget)
{
GtkLabel *self = GTK_LABEL (widget);
gboolean select_on_focus;
+ GtkWidget *prev_focus;
if (self->select_info == NULL)
return FALSE;
+ prev_focus = gtk_root_get_focus (gtk_widget_get_root (widget));
+
if (!GTK_WIDGET_CLASS (gtk_label_parent_class)->grab_focus (widget))
return FALSE;
@@ -3724,12 +3727,14 @@ gtk_label_grab_focus (GtkWidget *widget)
&select_on_focus,
NULL);
- if (select_on_focus && !self->in_click)
+ if (select_on_focus && !self->in_click &&
+ !(prev_focus && gtk_widget_is_ancestor (prev_focus, widget)))
gtk_label_select_region (self, 0, -1);
}
else
{
- if (self->select_info->links && !self->in_click)
+ if (self->select_info->links && !self->in_click &&
+ !(prev_focus && gtk_widget_is_ancestor (prev_focus, widget)))
{
guint i;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]