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);
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;

View File

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