forked from AuroraMiddleware/gtk
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
This commit is contained in:
parent
1a8a35f347
commit
72801a27eb
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user