Merge branch 'label-copy-link-fix' into 'master'

Label copy link fix

See merge request GNOME/gtk!2337
This commit is contained in:
Matthias Clasen 2020-08-02 02:45:53 +00:00
commit 7bc553a5cc
2 changed files with 10 additions and 4 deletions

View File

@ -3710,10 +3710,13 @@ gtk_label_grab_focus (GtkWidget *widget)
{ {
GtkLabel *self = GTK_LABEL (widget); GtkLabel *self = GTK_LABEL (widget);
gboolean select_on_focus; gboolean select_on_focus;
GtkWidget *prev_focus;
if (self->select_info == NULL) if (self->select_info == NULL)
return FALSE; return FALSE;
prev_focus = gtk_root_get_focus (gtk_widget_get_root (widget));
if (!GTK_WIDGET_CLASS (gtk_label_parent_class)->grab_focus (widget)) if (!GTK_WIDGET_CLASS (gtk_label_parent_class)->grab_focus (widget))
return FALSE; return FALSE;
@ -3724,12 +3727,14 @@ gtk_label_grab_focus (GtkWidget *widget)
&select_on_focus, &select_on_focus,
NULL); 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); gtk_label_select_region (self, 0, -1);
} }
else 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; guint i;

View File

@ -189,8 +189,9 @@ gtk_popover_item_activate (GtkWidget *button,
/* Activating the item could cause the popover /* Activating the item could cause the popover
* to be free'd, for example if it is a Quit item * to be free'd, for example if it is a Quit item
*/ */
popover = g_object_ref (gtk_widget_get_ancestor (button, popover = gtk_widget_get_ancestor (button, GTK_TYPE_POPOVER);
GTK_TYPE_POPOVER)); if (popover)
g_object_ref (popover);
} }
gtk_menu_tracker_item_activated (item); gtk_menu_tracker_item_activated (item);