Merge lp:~3v1n0/unity-settings-daemon/use-ubuntu-schemas-for-scaling into lp:unity-settings-daemon

Proposed by Marco Trevisan (Treviño) on 2017-09-22
Status: Merged
Approved by: Didier Roche on 2017-10-04
Approved revision: 4176
Merged at revision: 4172
Proposed branch: lp:~3v1n0/unity-settings-daemon/use-ubuntu-schemas-for-scaling
Merge into: lp:unity-settings-daemon
Diff against target: 270 lines (+106/-16)
3 files modified
debian/control (+1/-1)
plugins/media-keys/gsd-media-keys-manager.c (+42/-4)
plugins/xsettings/gsd-xsettings-manager.c (+63/-11)
To merge this branch: bzr merge lp:~3v1n0/unity-settings-daemon/use-ubuntu-schemas-for-scaling
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve on 2017-10-03
Unity Settings Daemon Development Team 2017-09-22 Pending
Review via email: mp+331178@code.launchpad.net

Commit message

XSettings: under unity use com.ubuntu.user-interface.desktop keys for scaling settings

Unity would override them with computed values, so we need to store them in different keys
not to interfere with any other installed gnome out there.

Also migrate changes to old keys to the new ones, if they happen when running unity.

To post a comment you must log in.
Andrea Azzarone (azzar1) wrote :

Looks good now. +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2017-09-06 14:47:10 +0000
3+++ debian/control 2017-10-03 05:07:54 +0000
4@@ -57,7 +57,7 @@
5 gsettings-desktop-schemas (>= 3.15.4),
6 nautilus-data (>= 2.91.3-1),
7 gnome-settings-daemon-schemas (>= 3.16),
8- gsettings-ubuntu-schemas (>= 0.0.1+14.04.20140224),
9+ gsettings-ubuntu-schemas (>= 0.0.7+17.10.20170922),
10 Recommends: ibus (>= 1.5.0),
11 pulseaudio,
12 systemd-services
13
14=== modified file 'plugins/media-keys/gsd-media-keys-manager.c'
15--- plugins/media-keys/gsd-media-keys-manager.c 2017-04-18 11:51:12 +0000
16+++ plugins/media-keys/gsd-media-keys-manager.c 2017-10-03 05:07:54 +0000
17@@ -113,8 +113,12 @@
18 #define SETTINGS_POWER_DIR "org.gnome.settings-daemon.plugins.power"
19 #define SETTINGS_XSETTINGS_DIR "org.gnome.settings-daemon.plugins.xsettings"
20 #define SETTINGS_TOUCHPAD_DIR "org.gnome.desktop.peripherals.touchpad"
21+#define UNITY_SETTINGS_INTERFACE_DIR "com.canonical.Unity.Interface"
22+
23 #define TOUCHPAD_ENABLED_KEY "send-events"
24 #define HIGH_CONTRAST "HighContrast"
25+#define TEXT_SCALING_FACTOR_KEY (in_desktop ("Unity") ? \
26+ "text-scale-factor" : "text-scaling-factor")
27
28 #define VOLUME_STEP 6 /* percents for one volume button press */
29
30@@ -313,6 +317,29 @@
31 NULL
32 };
33
34+static gboolean
35+in_desktop (const gchar *name)
36+{
37+ const gchar *desktop_name_list;
38+ gchar **names;
39+ gboolean in_list = FALSE;
40+ gint i;
41+
42+ desktop_name_list = g_getenv ("XDG_CURRENT_DESKTOP");
43+ if (!desktop_name_list)
44+ return FALSE;
45+
46+ names = g_strsplit (desktop_name_list, ":", -1);
47+ for (i = 0; names[i] && !in_list; i++)
48+ if (strcmp (names[i], name) == 0) {
49+ in_list = TRUE;
50+ break;
51+ }
52+ g_strfreev (names);
53+
54+ return in_list;
55+}
56+
57 static const char *
58 calculate_icon_name (gint value, const char **icon_names)
59 {
60@@ -2070,7 +2097,8 @@
61 do_text_size_action (GsdMediaKeysManager *manager,
62 MediaKeyType type)
63 {
64- gdouble factor, best, distance;
65+ GSettings *settings;
66+ gdouble factor, best, distance;
67 guint i;
68
69 /* Same values used in the Seeing tab of the Universal Access panel */
70@@ -2081,8 +2109,16 @@
71 1.5
72 };
73
74+ const gchar *text_scaling_key = TEXT_SCALING_FACTOR_KEY;
75+
76+ if (in_desktop ("Unity")) {
77+ settings = g_settings_new (UNITY_SETTINGS_INTERFACE_DIR);
78+ } else {
79+ settings = g_object_ref (manager->priv->interface_settings);
80+ }
81+
82 /* Figure out the current DPI scaling factor */
83- factor = g_settings_get_double (manager->priv->interface_settings, "text-scaling-factor");
84+ factor = g_settings_get_double (settings, text_scaling_key);
85 factor += (type == INCREASE_TEXT_KEY ? 0.25 : -0.25);
86
87 /* Try to find a matching value */
88@@ -2098,9 +2134,11 @@
89 }
90
91 if (best == 1.0)
92- g_settings_reset (manager->priv->interface_settings, "text-scaling-factor");
93+ g_settings_reset (settings, text_scaling_key);
94 else
95- g_settings_set_double (manager->priv->interface_settings, "text-scaling-factor", best);
96+ g_settings_set_double (settings, text_scaling_key, best);
97+
98+ g_object_unref (settings);
99 }
100
101 static void
102
103=== modified file 'plugins/xsettings/gsd-xsettings-manager.c'
104--- plugins/xsettings/gsd-xsettings-manager.c 2016-08-18 10:59:20 +0000
105+++ plugins/xsettings/gsd-xsettings-manager.c 2017-10-03 05:07:54 +0000
106@@ -50,6 +50,7 @@
107
108 #define MOUSE_SETTINGS_SCHEMA "org.gnome.settings-daemon.peripherals.mouse"
109 #define INTERFACE_SETTINGS_SCHEMA "org.gnome.desktop.interface"
110+#define UNITY_INTERFACE_SETTINGS_SCHEMA "com.ubuntu.user-interface.desktop"
111 #define SOUND_SETTINGS_SCHEMA "org.gnome.desktop.sound"
112 #define PRIVACY_SETTINGS_SCHEMA "org.gnome.desktop.privacy"
113 #define WM_SETTINGS_SCHEMA "org.gnome.desktop.wm.preferences"
114@@ -69,6 +70,12 @@
115 #define FONT_HINTING_KEY "hinting"
116 #define FONT_RGBA_ORDER_KEY "rgba-order"
117
118+#define SCALING_SETTINGS_SCHEMA_FOR_DESKTOP (in_desktop ("Unity") ? \
119+ UNITY_INTERFACE_SETTINGS_SCHEMA : \
120+ INTERFACE_SETTINGS_SCHEMA)
121+
122+static gboolean in_desktop (const gchar *name);
123+
124 /* As we cannot rely on the X server giving us good DPI information, and
125 * that we don't want multi-monitor screens to have different DPIs (thus
126 * different text sizes), we'll hard-code the value of the DPI
127@@ -255,6 +262,7 @@
128 gboolean have_unity;
129
130 guint notify_idle_id;
131+ guint freeze_settings_migrate_id;
132 };
133
134 #define GSD_XSETTINGS_ERROR gsd_xsettings_error_quark ()
135@@ -426,7 +434,7 @@
136 double dpi;
137 double factor;
138
139- interface_settings = g_hash_table_lookup (manager->priv->settings, INTERFACE_SETTINGS_SCHEMA);
140+ interface_settings = g_hash_table_lookup (manager->priv->settings, SCALING_SETTINGS_SCHEMA_FOR_DESKTOP);
141 factor = g_settings_get_double (interface_settings, TEXT_SCALING_FACTOR_KEY);
142
143 dpi = DPI_FALLBACK;
144@@ -469,7 +477,7 @@
145 int monitor_scale;
146 double dpi_x, dpi_y;
147
148- interface_settings = g_hash_table_lookup (manager->priv->settings, INTERFACE_SETTINGS_SCHEMA);
149+ interface_settings = g_hash_table_lookup (manager->priv->settings, SCALING_SETTINGS_SCHEMA_FOR_DESKTOP);
150 window_scale =
151 g_settings_get_uint (interface_settings, SCALING_FACTOR_KEY);
152 if (window_scale == 0) {
153@@ -526,7 +534,7 @@
154 xft_settings_get (GnomeXSettingsManager *manager,
155 GnomeXftSettings *settings)
156 {
157- GSettings *interface_settings;
158+ GSettings *interface_settings, *scaling_settings;
159 GsdFontAntialiasingMode antialiasing;
160 GsdFontHinting hinting;
161 GsdFontRgbaOrder order;
162@@ -535,6 +543,7 @@
163 int cursor_size;
164
165 interface_settings = g_hash_table_lookup (manager->priv->settings, INTERFACE_SETTINGS_SCHEMA);
166+ scaling_settings = g_hash_table_lookup (manager->priv->settings, SCALING_SETTINGS_SCHEMA_FOR_DESKTOP);
167
168 antialiasing = g_settings_get_enum (manager->priv->plugin_settings, FONT_ANTIALIASING_KEY);
169 hinting = g_settings_get_enum (manager->priv->plugin_settings, FONT_HINTING_KEY);
170@@ -546,7 +555,7 @@
171 dpi = get_dpi_from_gsettings (manager);
172 settings->dpi = dpi * 1024; /* Xft wants 1/1024ths of an inch */
173 settings->scaled_dpi = dpi * settings->window_scale * 1024;
174- cursor_size = g_settings_get_int (interface_settings, CURSOR_SIZE_KEY);
175+ cursor_size = g_settings_get_int (scaling_settings, CURSOR_SIZE_KEY);
176 settings->cursor_size = cursor_size * settings->window_scale;
177 settings->cursor_theme = g_settings_get_string (interface_settings, CURSOR_THEME_KEY);
178 settings->rgba = "rgb";
179@@ -943,11 +952,38 @@
180
181 if (g_str_equal (key, TEXT_SCALING_FACTOR_KEY) ||
182 g_str_equal (key, SCALING_FACTOR_KEY) ||
183- g_str_equal (key, CURSOR_SIZE_KEY) ||
184- g_str_equal (key, CURSOR_THEME_KEY)) {
185- xft_callback (NULL, key, manager);
186- return;
187- }
188+ g_str_equal (key, CURSOR_SIZE_KEY)) {
189+ gchar *schema_id;
190+ g_object_get (settings, "schema-id", &schema_id, NULL);
191+
192+ if (g_str_equal (schema_id, SCALING_SETTINGS_SCHEMA_FOR_DESKTOP)) {
193+ update_xft_settings (manager);
194+ queue_notify (manager);
195+ } else if (manager->priv->freeze_settings_migrate_id == 0 &&
196+ in_desktop ("Unity") &&
197+ g_str_equal (schema_id, INTERFACE_SETTINGS_SCHEMA)) {
198+ GSettings *unity_interface_settings;
199+ GVariant *setting_value;
200+
201+ setting_value = g_settings_get_value (settings, key);
202+ unity_interface_settings =
203+ g_hash_table_lookup (manager->priv->settings,
204+ UNITY_INTERFACE_SETTINGS_SCHEMA);
205+
206+ g_settings_set_value (unity_interface_settings, key,
207+ setting_value);
208+ g_variant_unref (setting_value);
209+ }
210+
211+ g_free (schema_id);
212+ return;
213+ }
214+
215+ if (g_str_equal (key, CURSOR_THEME_KEY)) {
216+ update_xft_settings (manager);
217+ queue_notify (manager);
218+ return;
219+ }
220
221 trans = find_translation_entry (settings, key);
222 if (trans == NULL) {
223@@ -1051,6 +1087,14 @@
224 NULL);
225 }
226
227+static gboolean
228+on_freeze_settings_migrate_timeout (gpointer data)
229+{
230+ GnomeXSettingsManager *manager = data;
231+ manager->priv->freeze_settings_migrate_id = 0;
232+ return FALSE;
233+}
234+
235 gboolean
236 gnome_xsettings_manager_start (GnomeXSettingsManager *manager,
237 GError **error)
238@@ -1077,6 +1121,8 @@
239 g_hash_table_insert (manager->priv->settings,
240 INTERFACE_SETTINGS_SCHEMA, g_settings_new (INTERFACE_SETTINGS_SCHEMA));
241 g_hash_table_insert (manager->priv->settings,
242+ UNITY_INTERFACE_SETTINGS_SCHEMA, g_settings_new (UNITY_INTERFACE_SETTINGS_SCHEMA));
243+ g_hash_table_insert (manager->priv->settings,
244 SOUND_SETTINGS_SCHEMA, g_settings_new (SOUND_SETTINGS_SCHEMA));
245 g_hash_table_insert (manager->priv->settings,
246 PRIVACY_SETTINGS_SCHEMA, g_settings_new (PRIVACY_SETTINGS_SCHEMA));
247@@ -1135,6 +1181,9 @@
248 queue_notify (manager);
249 g_variant_unref (overrides);
250
251+ /* Ingore migration of gnome settings to unity at startup */
252+ manager->priv->freeze_settings_migrate_id =
253+ g_timeout_add_seconds (5, on_freeze_settings_migrate_timeout, manager);
254
255 gnome_settings_profile_end (NULL);
256
257@@ -1168,8 +1217,11 @@
258
259 stop_fontconfig_monitor (manager);
260
261- if (manager->priv->unity_name_watch_id > 0)
262- g_bus_unwatch_name (manager->priv->unity_name_watch_id);
263+ if (p->unity_name_watch_id > 0)
264+ g_bus_unwatch_name (p->unity_name_watch_id);
265+
266+ if (p->freeze_settings_migrate_id != 0)
267+ g_source_remove (p->freeze_settings_migrate_id);
268
269 if (p->settings != NULL) {
270 g_hash_table_destroy (p->settings);

Subscribers

People subscribed via source and target branches