settings: Handle window scaling factor internally

We want the settings object to handle setting and getting the
window scaling factor value, both through backend-specific settings and
through the CLUTTER_SCALE environment variable. This means turning the
ClutterSettings:window-scaling-factor property into a readwrite one,
instead of write-only, so that ClutterStage implementations will be able
to query the window scaling factor on construction.

https://bugzilla.gnome.org/show_bug.cgi?id=705915
This commit is contained in:
Emmanuele Bassi 2014-01-16 12:11:22 +00:00
parent b7b09bd0ce
commit afd87abb70

View File

@ -77,6 +77,7 @@ struct _ClutterSettings
gint window_scaling_factor; gint window_scaling_factor;
gint unscaled_font_dpi; gint unscaled_font_dpi;
guint fixed_scaling_factor : 1;
}; };
struct _ClutterSettingsClass struct _ClutterSettingsClass
@ -361,8 +362,11 @@ clutter_settings_set_property (GObject *gobject,
break; break;
case PROP_WINDOW_SCALING_FACTOR: case PROP_WINDOW_SCALING_FACTOR:
if (!self->fixed_scaling_factor)
{
self->window_scaling_factor = g_value_get_int (value); self->window_scaling_factor = g_value_get_int (value);
settings_update_window_scale (self); settings_update_window_scale (self);
}
break; break;
case PROP_UNSCALED_FONT_DPI: case PROP_UNSCALED_FONT_DPI:
@ -430,6 +434,10 @@ clutter_settings_get_property (GObject *gobject,
g_value_set_uint (value, self->password_hint_time); g_value_set_uint (value, self->password_hint_time);
break; break;
case PROP_WINDOW_SCALING_FACTOR:
g_value_set_int (value, self->window_scaling_factor);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break; break;
@ -674,7 +682,7 @@ clutter_settings_class_init (ClutterSettingsClass *klass)
P_("The scaling factor to be applied to windows"), P_("The scaling factor to be applied to windows"),
1, G_MAXINT, 1, G_MAXINT,
1, 1,
CLUTTER_PARAM_WRITABLE); CLUTTER_PARAM_READWRITE);
obj_props[PROP_FONTCONFIG_TIMESTAMP] = obj_props[PROP_FONTCONFIG_TIMESTAMP] =
g_param_spec_uint ("fontconfig-timestamp", g_param_spec_uint ("fontconfig-timestamp",
@ -713,6 +721,8 @@ clutter_settings_class_init (ClutterSettingsClass *klass)
static void static void
clutter_settings_init (ClutterSettings *self) clutter_settings_init (ClutterSettings *self)
{ {
const char *scale_str;
self->resolution = -1.0; self->resolution = -1.0;
self->double_click_time = 250; self->double_click_time = 250;
@ -728,6 +738,18 @@ clutter_settings_init (ClutterSettings *self)
self->xft_rgba = NULL; self->xft_rgba = NULL;
self->long_press_duration = 500; self->long_press_duration = 500;
/* if the scaling factor was set by the environment we ignore
* any explicit setting
*/
scale_str = g_getenv ("CLUTTER_SCALE");
if (scale_str != NULL)
{
self->window_scaling_factor = atol (scale_str);
self->fixed_scaling_factor = TRUE;
}
else
self->window_scaling_factor = 1;
} }
/** /**