From 72801a27eba06c542136aee74f3af70db5039ac7 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Mon, 9 Jan 2017 00:11:29 +0000 Subject: [PATCH] widget: propagate scale factor upon reparenting a widget When a widget is created, its default scale is the scale of the primary screen (for instance 2). But once parented to another widget its scale factor should be the one of its parent (if parented to a widget on a screen at scale factor 1, it should be 1). The problem is that we don't emit the notify::scale-factor signal when reparenting happens. https://bugzilla.gnome.org/show_bug.cgi?id=776821 --- gtk/gtkwidget.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 5e406a5d6f..838630d5f1 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -606,6 +606,8 @@ struct _GtkStateData { guint flags_to_set; guint flags_to_unset; + + gint old_scale_factor; }; /* --- prototypes --- */ @@ -7882,6 +7884,7 @@ gtk_widget_update_state_flags (GtkWidget *widget, { GtkStateData data; + data.old_scale_factor = gtk_widget_get_scale_factor (widget); data.flags_to_set = flags_to_set; data.flags_to_unset = flags_to_unset; @@ -8304,6 +8307,8 @@ gtk_widget_set_sensitive (GtkWidget *widget, { GtkStateData data; + data.old_scale_factor = gtk_widget_get_scale_factor (widget); + if (sensitive) { data.flags_to_set = 0; @@ -8399,6 +8404,8 @@ gtk_widget_set_parent (GtkWidget *widget, return; } + data.old_scale_factor = gtk_widget_get_scale_factor (widget); + /* keep this function in sync with gtk_menu_attach_to_widget() */ @@ -11120,6 +11127,7 @@ gtk_widget_propagate_state (GtkWidget *widget, GtkStateFlags new_flags, old_flags = priv->state_flags; GtkStateData child_data; GtkWidget *child; + gint new_scale_factor = gtk_widget_get_scale_factor (widget); priv->state_flags |= data->flags_to_set; priv->state_flags &= ~(data->flags_to_unset); @@ -11140,6 +11148,9 @@ gtk_widget_propagate_state (GtkWidget *widget, new_flags = priv->state_flags; + if (data->old_scale_factor != new_scale_factor) + _gtk_widget_scale_changed (widget); + if (old_flags != new_flags) { g_object_ref (widget); @@ -11193,6 +11204,7 @@ gtk_widget_propagate_state (GtkWidget *widget, /* Make sure to only propagate the right states further */ + child_data.old_scale_factor = new_scale_factor; child_data.flags_to_set = data->flags_to_set & GTK_STATE_FLAGS_DO_PROPAGATE; child_data.flags_to_unset = data->flags_to_unset & GTK_STATE_FLAGS_DO_PROPAGATE;