Merge lp:~noskcaj/unity-settings-daemon/gnome-desktop-3.10 into lp:unity-settings-daemon
- gnome-desktop-3.10
- Merge into trunk
Proposed by
Jackson Doak
Status: | Rejected |
---|---|
Rejected by: | Sebastien Bacher |
Proposed branch: | lp:~noskcaj/unity-settings-daemon/gnome-desktop-3.10 |
Merge into: | lp:unity-settings-daemon |
Diff against target: |
1929 lines (+299/-1058) 11 files modified
debian/control (+3/-2) plugins/color/gsd-color-manager.c (+34/-34) plugins/common/gsd-keygrab.c (+6/-20) plugins/common/gsd-keygrab.h (+3/-3) plugins/cursor/gsd-cursor-manager.c (+1/-1) plugins/power/gpm-common.c (+58/-56) plugins/power/gpm-common.h (+1/-0) plugins/power/gsd-power-manager.c (+70/-57) plugins/wacom/gsd-wacom-device.c (+32/-47) plugins/wacom/gsd-wacom-manager.c (+54/-62) plugins/xrandr/gsd-xrandr-manager.c (+37/-776) |
To merge this branch: | bzr merge lp:~noskcaj/unity-settings-daemon/gnome-desktop-3.10 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sebastien Bacher | Disapprove | ||
Review via email: mp+208911@code.launchpad.net |
Commit message
Description of the change
Allows unity-settings-
See lp:1228765
To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote : | # |
(the description is misleading, it doesn't add support for 3.10, it does port to 3.10 dropping support for the Ubuntu version, that can't be done this way)
Revision history for this message
Sebastien Bacher (seb128) wrote : | # |
gnome-desktop got updated previous cycle, those changes are not needed anymore/deprecated
review:
Disapprove
Unmerged revisions
- 4030. By Jackson Doak
-
Bump b-dep on libgnome-
desktop- 3-dev to 3.10 - 4029. By Jackson Doak
-
Depend on displayconfig
- 4028. By Jackson Doak
-
support gnome desktop 3.10
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 2014-02-26 18:25:15 +0000 |
3 | +++ debian/control 2014-03-01 03:37:38 +0000 |
4 | @@ -11,7 +11,7 @@ |
5 | intltool (>= 0.37.1), |
6 | libdbus-glib-1-dev (>= 0.74), |
7 | libglib2.0-dev (>= 2.35.3), |
8 | - libgtk-3-dev (>= 3.7.8), |
9 | + libgtk-3-dev (>= 3.10), |
10 | libnotify-dev (>= 0.7.0), |
11 | libxt-dev, |
12 | libxi-dev, |
13 | @@ -20,7 +20,7 @@ |
14 | libx11-dev, |
15 | libxtst-dev, |
16 | gsettings-desktop-schemas-dev (>= 3.7.2.1), |
17 | - libgnome-desktop-3-dev (>= 3.7.90), |
18 | + libgnome-desktop-3-dev (>= 3.10), |
19 | libpulse-dev (>= 1:2.0), |
20 | libasound2-dev, |
21 | librsvg2-dev (>= 2.36.2), |
22 | @@ -53,6 +53,7 @@ |
23 | gnome-settings-daemon-schemas (>= 3.8), |
24 | gnome-settings-daemon-schemas (<< 3.10), |
25 | gsettings-ubuntu-schemas (>= 0.0.1+14.04.20140224), |
26 | + displayconfig |
27 | Recommends: ibus (>= 1.5.0), |
28 | pulseaudio, |
29 | systemd-services |
30 | |
31 | === modified file 'plugins/color/gsd-color-manager.c' |
32 | --- plugins/color/gsd-color-manager.c 2013-05-09 13:50:15 +0000 |
33 | +++ plugins/color/gsd-color-manager.c 2014-03-01 03:37:38 +0000 |
34 | @@ -762,8 +762,6 @@ |
35 | goto out; |
36 | } |
37 | for (i = 0; outputs[i] != NULL && output == NULL; i++) { |
38 | - if (!gnome_rr_output_is_connected (outputs[i])) |
39 | - continue; |
40 | output_id = gcm_session_get_output_id (manager, outputs[i]); |
41 | if (g_strcmp0 (output_id, device_id) == 0) |
42 | output = outputs[i]; |
43 | @@ -800,13 +798,11 @@ |
44 | return FALSE; |
45 | } |
46 | for (i = 0; outputs[i] != NULL; i++) { |
47 | - if (!gnome_rr_output_is_connected (outputs[i])) |
48 | - continue; |
49 | if (connected == NULL) |
50 | connected = outputs[i]; |
51 | if (gnome_rr_output_get_is_primary (outputs[i])) |
52 | has_primary = TRUE; |
53 | - if (gnome_rr_output_is_laptop (outputs[i])) |
54 | + if (gnome_rr_output_is_builtin_display (outputs[i])) |
55 | has_laptop = TRUE; |
56 | } |
57 | |
58 | @@ -816,7 +812,7 @@ |
59 | |
60 | /* choosing the internal panel is probably sane */ |
61 | if (has_laptop) |
62 | - return gnome_rr_output_is_laptop (output); |
63 | + return gnome_rr_output_is_builtin_display (output); |
64 | |
65 | /* we have to choose one, so go for the first connected device */ |
66 | if (connected != NULL) |
67 | @@ -915,7 +911,7 @@ |
68 | * calibration brightness then set this new brightness */ |
69 | brightness_profile = cd_profile_get_metadata_item (profile, |
70 | CD_PROFILE_METADATA_SCREEN_BRIGHTNESS); |
71 | - if (gnome_rr_output_is_laptop (output) && |
72 | + if (gnome_rr_output_is_builtin_display (output) && |
73 | brightness_profile != NULL) { |
74 | /* the percentage is stored in the profile metadata as |
75 | * a string, not ideal, but it's all we have... */ |
76 | @@ -1228,7 +1224,7 @@ |
77 | } |
78 | |
79 | /* prefer DMI data for the internal output */ |
80 | - ret = gnome_rr_output_is_laptop (output); |
81 | + ret = gnome_rr_output_is_builtin_display (output); |
82 | if (ret) { |
83 | model = gcm_dmi_get_name (priv->dmi); |
84 | vendor = gcm_dmi_get_vendor (priv->dmi); |
85 | @@ -1295,7 +1291,7 @@ |
86 | #if CD_CHECK_VERSION(0,1,27) |
87 | /* set this so we can call the device a 'Laptop Screen' in the |
88 | * control center main panel */ |
89 | - if (gnome_rr_output_is_laptop (output)) { |
90 | + if (gnome_rr_output_is_builtin_display (output)) { |
91 | g_hash_table_insert (device_props, |
92 | (gpointer) CD_DEVICE_PROPERTY_EMBEDDED, |
93 | NULL); |
94 | @@ -1457,9 +1453,6 @@ |
95 | return; |
96 | } |
97 | for (i = 0; outputs[i] != NULL; i++) { |
98 | - if (!gnome_rr_output_is_connected (outputs[i])) |
99 | - continue; |
100 | - |
101 | /* get CdDevice for this output */ |
102 | cd_client_find_device_by_property (manager->priv->client, |
103 | CD_DEVICE_METADATA_XRANDR_NAME, |
104 | @@ -1519,8 +1512,7 @@ |
105 | goto out; |
106 | } |
107 | for (i = 0; outputs[i] != NULL; i++) { |
108 | - if (gnome_rr_output_is_connected (outputs[i])) |
109 | - gcm_session_add_x11_output (manager, outputs[i]); |
110 | + gcm_session_add_x11_output (manager, outputs[i]); |
111 | } |
112 | |
113 | /* only connect when colord is awake */ |
114 | @@ -1549,31 +1541,39 @@ |
115 | return; |
116 | } |
117 | |
118 | +static void |
119 | +on_rr_screen_acquired (GObject *object, |
120 | + GAsyncResult *result, |
121 | + gpointer data) |
122 | +{ |
123 | + GsdColorManager *manager = data; |
124 | + GsdColorManagerPrivate *priv = manager->priv; |
125 | + GnomeRRScreen *screen; |
126 | + |
127 | + g_debug ("Starting color manager"); |
128 | + gnome_settings_profile_start (NULL); |
129 | + |
130 | + screen = gnome_rr_screen_new_finish (result, NULL); |
131 | + if (!screen) |
132 | + return; |
133 | + |
134 | + priv->x11_screen = screen; |
135 | + |
136 | + cd_client_connect (priv->client, |
137 | + NULL, |
138 | + gcm_session_client_connect_cb, |
139 | + manager); |
140 | +} |
141 | + |
142 | gboolean |
143 | gsd_color_manager_start (GsdColorManager *manager, |
144 | GError **error) |
145 | { |
146 | - GsdColorManagerPrivate *priv = manager->priv; |
147 | - gboolean ret = FALSE; |
148 | - |
149 | - g_debug ("Starting color manager"); |
150 | - gnome_settings_profile_start (NULL); |
151 | - |
152 | /* coldplug the list of screens */ |
153 | - priv->x11_screen = gnome_rr_screen_new (gdk_screen_get_default (), error); |
154 | - if (priv->x11_screen == NULL) |
155 | - goto out; |
156 | - |
157 | - cd_client_connect (priv->client, |
158 | - NULL, |
159 | - gcm_session_client_connect_cb, |
160 | - manager); |
161 | - |
162 | - /* success */ |
163 | - ret = TRUE; |
164 | -out: |
165 | - gnome_settings_profile_end (NULL); |
166 | - return ret; |
167 | + gnome_rr_screen_new_async (gdk_screen_get_default (), |
168 | + on_rr_screen_acquired, |
169 | + manager); |
170 | + return TRUE; |
171 | } |
172 | |
173 | void |
174 | |
175 | === modified file 'plugins/common/gsd-keygrab.c' |
176 | --- plugins/common/gsd-keygrab.c 2014-02-17 14:29:51 +0000 |
177 | +++ plugins/common/gsd-keygrab.c 2014-03-01 03:37:38 +0000 |
178 | @@ -673,13 +673,15 @@ |
179 | g_free (key); |
180 | } |
181 | |
182 | -static void |
183 | -grab_button_real (int deviceid, |
184 | - gboolean grab, |
185 | - GdkWindow *root) |
186 | +void |
187 | +grab_button (int deviceid, |
188 | + gboolean grab, |
189 | + GdkScreen *screen) |
190 | { |
191 | + GdkWindow *root; |
192 | XIGrabModifiers mods; |
193 | |
194 | + root = gdk_screen_get_root_window (screen); |
195 | mods.modifiers = XIAnyModifier; |
196 | |
197 | if (grab) { |
198 | @@ -713,19 +715,3 @@ |
199 | 1, &mods); |
200 | } |
201 | } |
202 | - |
203 | -void |
204 | -grab_button (int deviceid, |
205 | - gboolean grab, |
206 | - GSList *screens) |
207 | -{ |
208 | - GSList *l; |
209 | - |
210 | - for (l = screens; l; l = l->next) { |
211 | - GdkScreen *screen = l->data; |
212 | - |
213 | - grab_button_real (deviceid, |
214 | - grab, |
215 | - gdk_screen_get_root_window (screen)); |
216 | - } |
217 | -} |
218 | |
219 | === modified file 'plugins/common/gsd-keygrab.h' |
220 | --- plugins/common/gsd-keygrab.h 2014-02-17 14:29:51 +0000 |
221 | +++ plugins/common/gsd-keygrab.h 2014-03-01 03:37:38 +0000 |
222 | @@ -54,9 +54,9 @@ |
223 | Key * parse_key (const char *str); |
224 | void free_key (Key *key); |
225 | |
226 | -void grab_button (int deviceid, |
227 | - gboolean grab, |
228 | - GSList *screens); |
229 | +void grab_button (int deviceid, |
230 | + gboolean grab, |
231 | + GdkScreen *screen); |
232 | |
233 | G_END_DECLS |
234 | |
235 | |
236 | === modified file 'plugins/cursor/gsd-cursor-manager.c' |
237 | --- plugins/cursor/gsd-cursor-manager.c 2013-04-15 11:23:06 +0000 |
238 | +++ plugins/cursor/gsd-cursor-manager.c 2014-03-01 03:37:38 +0000 |
239 | @@ -167,7 +167,7 @@ |
240 | return TRUE; |
241 | |
242 | /* Create IdleMonitors for each pointer device */ |
243 | - monitor = gnome_idle_monitor_new_for_device (device); |
244 | + monitor = gnome_idle_monitor_new_for_device (device, error); |
245 | if (!monitor) { |
246 | g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, |
247 | "Per-device idletime monitor not available"); |
248 | |
249 | === modified file 'plugins/power/gpm-common.c' |
250 | --- plugins/power/gpm-common.c 2013-12-04 23:55:26 +0000 |
251 | +++ plugins/power/gpm-common.c 2014-03-01 03:37:38 +0000 |
252 | @@ -1178,10 +1178,8 @@ |
253 | goto out; |
254 | |
255 | for (i = 0; outputs[i] != NULL; i++) { |
256 | - if (gnome_rr_output_is_connected (outputs[i]) && |
257 | - gnome_rr_output_is_laptop (outputs[i]) && |
258 | - gnome_rr_output_get_backlight_min (outputs[i]) >= 0 && |
259 | - gnome_rr_output_get_backlight_max (outputs[i]) > 0) { |
260 | + if (gnome_rr_output_is_builtin_display (outputs[i]) && |
261 | + gnome_rr_output_get_backlight (outputs[i]) >= 0) { |
262 | output = outputs[i]; |
263 | break; |
264 | } |
265 | @@ -1407,8 +1405,7 @@ |
266 | /* prefer xbacklight */ |
267 | output = get_primary_output (rr_screen); |
268 | if (output != NULL) { |
269 | - return gnome_rr_output_get_backlight (output, |
270 | - error); |
271 | + return gnome_rr_output_get_backlight (output); |
272 | } |
273 | |
274 | /* fall back to the polkit helper */ |
275 | @@ -1427,10 +1424,7 @@ |
276 | /* prefer xbacklight */ |
277 | output = get_primary_output (rr_screen); |
278 | if (output != NULL) { |
279 | - |
280 | - min = gnome_rr_output_get_backlight_min (output); |
281 | - max = gnome_rr_output_get_backlight_max (output); |
282 | - now = gnome_rr_output_get_backlight (output, error); |
283 | + now = gnome_rr_output_get_backlight (output); |
284 | if (now < 0) |
285 | goto out; |
286 | value = ABS_TO_PERCENTAGE (min, max, now); |
287 | @@ -1444,7 +1438,7 @@ |
288 | now = backlight_helper_get_value ("get-brightness", error); |
289 | if (now < 0) |
290 | goto out; |
291 | - value = ABS_TO_PERCENTAGE (min, max, now); |
292 | + value = ABS_TO_PERCENTAGE (0, 100, now); |
293 | out: |
294 | return value; |
295 | } |
296 | @@ -1452,36 +1446,18 @@ |
297 | int |
298 | backlight_get_min (GnomeRRScreen *rr_screen) |
299 | { |
300 | - GnomeRROutput *output; |
301 | - |
302 | - /* if we have no xbacklight device, then hardcode zero as sysfs |
303 | - * offsets everything to 0 as min */ |
304 | - output = get_primary_output (rr_screen); |
305 | - if (output == NULL) |
306 | - return 0; |
307 | - |
308 | - /* get xbacklight value, which maybe non-zero */ |
309 | - return gnome_rr_output_get_backlight_min (output); |
310 | + return 0; |
311 | } |
312 | |
313 | int |
314 | backlight_get_max (GnomeRRScreen *rr_screen, GError **error) |
315 | { |
316 | - gint value; |
317 | GnomeRROutput *output; |
318 | |
319 | /* prefer xbacklight */ |
320 | output = get_primary_output (rr_screen); |
321 | - if (output != NULL) { |
322 | - value = gnome_rr_output_get_backlight_max (output); |
323 | - if (value < 0) { |
324 | - g_set_error (error, |
325 | - GSD_POWER_MANAGER_ERROR, |
326 | - GSD_POWER_MANAGER_ERROR_FAILED, |
327 | - "failed to get backlight max"); |
328 | - } |
329 | - return value; |
330 | - } |
331 | + if (output != NULL) |
332 | + return 100; |
333 | |
334 | /* fall back to the polkit helper */ |
335 | return backlight_helper_get_value ("get-max-brightness", error); |
336 | @@ -1500,19 +1476,8 @@ |
337 | |
338 | /* prefer xbacklight */ |
339 | output = get_primary_output (rr_screen); |
340 | - if (output != NULL) { |
341 | - min = gnome_rr_output_get_backlight_min (output); |
342 | - max = gnome_rr_output_get_backlight_max (output); |
343 | - if (min < 0 || max < 0) { |
344 | - g_warning ("no xrandr backlight capability"); |
345 | - return ret; |
346 | - } |
347 | - discrete = PERCENTAGE_TO_ABS (min, max, value); |
348 | - ret = gnome_rr_output_set_backlight (output, |
349 | - discrete, |
350 | - error); |
351 | - return ret; |
352 | - } |
353 | + if (output != NULL) |
354 | + return gnome_rr_output_set_backlight (output, value, error); |
355 | |
356 | /* fall back to the polkit helper */ |
357 | max = backlight_helper_get_value ("get-max-brightness", error); |
358 | @@ -1552,9 +1517,9 @@ |
359 | gnome_rr_output_get_name (output)); |
360 | return percentage_value; |
361 | } |
362 | - min = gnome_rr_output_get_backlight_min (output); |
363 | - max = gnome_rr_output_get_backlight_max (output); |
364 | - now = gnome_rr_output_get_backlight (output, error); |
365 | + min = 0; |
366 | + max = 100; |
367 | + now = gnome_rr_output_get_backlight (output); |
368 | if (now < 0) |
369 | return percentage_value; |
370 | step = BRIGHTNESS_STEP_AMOUNT (max - min + 1); |
371 | @@ -1611,9 +1576,9 @@ |
372 | gnome_rr_output_get_name (output)); |
373 | return percentage_value; |
374 | } |
375 | - min = gnome_rr_output_get_backlight_min (output); |
376 | - max = gnome_rr_output_get_backlight_max (output); |
377 | - now = gnome_rr_output_get_backlight (output, error); |
378 | + min = 0; |
379 | + max = 100; |
380 | + now = gnome_rr_output_get_backlight (output); |
381 | if (now < 0) |
382 | return percentage_value; |
383 | step = BRIGHTNESS_STEP_AMOUNT (max - min + 1); |
384 | @@ -1655,10 +1620,7 @@ |
385 | /* prefer xbacklight */ |
386 | output = get_primary_output (rr_screen); |
387 | if (output != NULL) { |
388 | - ret = gnome_rr_output_set_backlight (output, |
389 | - value, |
390 | - error); |
391 | - return ret; |
392 | + return gnome_rr_output_set_backlight (output, value, error); |
393 | } |
394 | |
395 | /* fall back to the polkit helper */ |
396 | @@ -1700,6 +1662,44 @@ |
397 | return gnome_rr_crtc_get_current_mode (crtc) != NULL; |
398 | } |
399 | |
400 | +#ifdef GSD_MOCK |
401 | +static void |
402 | +mock_monitor_changed (GFileMonitor *monitor, |
403 | + GFile *file, |
404 | + GFile *other_file, |
405 | + GFileMonitorEvent event_type, |
406 | + gpointer user_data) |
407 | +{ |
408 | + GnomeRRScreen *screen = (GnomeRRScreen *) user_data; |
409 | + |
410 | + g_debug ("Mock screen configuration changed"); |
411 | + g_signal_emit_by_name (G_OBJECT (screen), "changed"); |
412 | +} |
413 | + |
414 | +static void |
415 | +screen_destroyed (gpointer user_data, |
416 | + GObject *where_the_object_was) |
417 | +{ |
418 | + g_object_unref (G_OBJECT (user_data)); |
419 | +} |
420 | +#endif /* GSD_MOCK */ |
421 | + |
422 | +void |
423 | +watch_external_monitor (GnomeRRScreen *screen) |
424 | +{ |
425 | +#ifdef GSD_MOCK |
426 | + GFile *file; |
427 | + GFileMonitor *monitor; |
428 | + |
429 | + file = g_file_new_for_commandline_arg ("GSD_MOCK_EXTERNAL_MONITOR"); |
430 | + monitor = g_file_monitor (file, G_FILE_MONITOR_NONE, NULL, NULL); |
431 | + g_object_unref (file); |
432 | + g_signal_connect (monitor, "changed", |
433 | + G_CALLBACK (mock_monitor_changed), screen); |
434 | + g_object_weak_ref (G_OBJECT (screen), screen_destroyed, monitor); |
435 | +#endif /* GSD_MOCK */ |
436 | +} |
437 | + |
438 | gboolean |
439 | external_monitor_is_connected (GnomeRRScreen *screen) |
440 | { |
441 | @@ -1712,9 +1712,11 @@ |
442 | if (g_file_get_contents ("GSD_MOCK_EXTERNAL_MONITOR", &mock_external_monitor_contents, NULL, NULL)) { |
443 | if (mock_external_monitor_contents[0] == '1') { |
444 | g_free (mock_external_monitor_contents); |
445 | + g_debug ("Mock external monitor is on"); |
446 | return TRUE; |
447 | } else if (mock_external_monitor_contents[0] == '0') { |
448 | g_free (mock_external_monitor_contents); |
449 | + g_debug ("Mock external monitor is off"); |
450 | return FALSE; |
451 | } |
452 | |
453 | @@ -1727,7 +1729,7 @@ |
454 | outputs = gnome_rr_screen_list_outputs (screen); |
455 | for (i = 0; outputs[i] != NULL; i++) { |
456 | if (randr_output_is_on (outputs[i]) && |
457 | - !gnome_rr_output_is_laptop (outputs[i])) |
458 | + !gnome_rr_output_is_builtin_display (outputs[i])) |
459 | return TRUE; |
460 | } |
461 | |
462 | |
463 | === modified file 'plugins/power/gpm-common.h' |
464 | --- plugins/power/gpm-common.h 2013-01-25 19:32:56 +0000 |
465 | +++ plugins/power/gpm-common.h 2014-03-01 03:37:38 +0000 |
466 | @@ -69,6 +69,7 @@ |
467 | GError **error); |
468 | |
469 | /* RandR helpers */ |
470 | +void watch_external_monitor (GnomeRRScreen *screen); |
471 | gboolean external_monitor_is_connected (GnomeRRScreen *screen); |
472 | |
473 | /* Sound helpers */ |
474 | |
475 | === modified file 'plugins/power/gsd-power-manager.c' |
476 | --- plugins/power/gsd-power-manager.c 2014-02-08 20:53:08 +0000 |
477 | +++ plugins/power/gsd-power-manager.c 2014-03-01 03:37:38 +0000 |
478 | @@ -175,6 +175,7 @@ |
479 | gboolean screensaver_active; |
480 | |
481 | /* State */ |
482 | + gboolean lid_is_present; |
483 | gboolean lid_is_closed; |
484 | UpClient *up_client; |
485 | gchar *previous_summary; |
486 | @@ -2304,7 +2305,10 @@ |
487 | |
488 | setup_lid_closed_action (manager); |
489 | |
490 | - /* same state */ |
491 | + if (!manager->priv->lid_is_present) |
492 | + return; |
493 | + |
494 | + /* same lid state */ |
495 | tmp = up_client_get_lid_is_closed (manager->priv->up_client); |
496 | if (manager->priv->lid_is_closed == tmp) |
497 | return; |
498 | @@ -3343,6 +3347,8 @@ |
499 | { |
500 | GsdPowerManager *manager = GSD_POWER_MANAGER (user_data); |
501 | |
502 | + g_debug ("Screen configuration changed"); |
503 | + |
504 | if (suspend_on_lid_close (manager)) { |
505 | restart_inhibit_lid_switch_timer (manager); |
506 | return; |
507 | @@ -3360,15 +3366,6 @@ |
508 | setup_inhibit_lid_switch_timer (manager); |
509 | } |
510 | |
511 | -#ifdef GSD_MOCK |
512 | -static gboolean |
513 | -received_sigusr2 (GsdPowerManager *manager) |
514 | -{ |
515 | - on_randr_event (NULL, manager); |
516 | - return TRUE; |
517 | -} |
518 | -#endif /* GSD_MOCK */ |
519 | - |
520 | static void |
521 | handle_suspend_actions (GsdPowerManager *manager) |
522 | { |
523 | @@ -3416,43 +3413,34 @@ |
524 | } |
525 | } |
526 | |
527 | -gboolean |
528 | -gsd_power_manager_start (GsdPowerManager *manager, |
529 | - GError **error) |
530 | +static void |
531 | +on_rr_screen_acquired (GObject *object, |
532 | + GAsyncResult *result, |
533 | + gpointer user_data) |
534 | { |
535 | - g_debug ("Starting power manager"); |
536 | + GsdPowerManager *manager = user_data; |
537 | + |
538 | gnome_settings_profile_start (NULL); |
539 | |
540 | - /* coldplug the list of screens */ |
541 | - manager->priv->rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), error); |
542 | - if (manager->priv->rr_screen == NULL) { |
543 | - g_debug ("Couldn't detect any screens, disabling plugin"); |
544 | - return FALSE; |
545 | - } |
546 | - |
547 | - /* Check for XTEST support */ |
548 | - if (supports_xtest () == FALSE) { |
549 | - g_debug ("XTEST extension required, disabling plugin"); |
550 | - return FALSE; |
551 | - } |
552 | - |
553 | - /* Set up the logind proxy */ |
554 | - manager->priv->logind_proxy = |
555 | - g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, |
556 | - 0, |
557 | - NULL, |
558 | - SYSTEMD_DBUS_NAME, |
559 | - SYSTEMD_DBUS_PATH, |
560 | - SYSTEMD_DBUS_INTERFACE, |
561 | - NULL, |
562 | - error); |
563 | - if (manager->priv->logind_proxy == NULL) { |
564 | - g_debug ("No systemd (logind) support, disabling plugin"); |
565 | - return FALSE; |
566 | - } |
567 | + manager->priv->rr_screen = gnome_rr_screen_new_finish (result, NULL); |
568 | + |
569 | + /* set up the screens */ |
570 | + if (manager->priv->lid_is_present) { |
571 | + g_signal_connect (manager->priv->rr_screen, "changed", G_CALLBACK (on_randr_event), manager); |
572 | + watch_external_monitor (manager->priv->rr_screen); |
573 | + on_randr_event (manager->priv->rr_screen, manager); |
574 | + } |
575 | + |
576 | + /* check whether a backlight is available */ |
577 | + manager->priv->backlight_available = backlight_available (manager->priv->rr_screen); |
578 | + |
579 | + /* ensure the default dpms timeouts are cleared */ |
580 | + backlight_enable (manager); |
581 | + |
582 | g_signal_connect (manager->priv->logind_proxy, "g-signal", |
583 | G_CALLBACK (logind_proxy_signal_cb), |
584 | manager); |
585 | + |
586 | /* Set up a delay inhibitor to be informed about suspend attempts */ |
587 | inhibit_suspend (manager); |
588 | |
589 | @@ -3473,8 +3461,6 @@ |
590 | g_signal_connect (manager->priv->settings_session, "changed", |
591 | G_CALLBACK (engine_settings_key_changed_cb), manager); |
592 | manager->priv->settings_xrandr = g_settings_new (GSD_XRANDR_SETTINGS_SCHEMA); |
593 | - manager->priv->up_client = up_client_new (); |
594 | - manager->priv->lid_is_closed = up_client_get_lid_is_closed (manager->priv->up_client); |
595 | g_signal_connect (manager->priv->up_client, "device-added", |
596 | G_CALLBACK (engine_device_added_cb), manager); |
597 | g_signal_connect (manager->priv->up_client, "device-removed", |
598 | @@ -3552,20 +3538,6 @@ |
599 | /* create IDLETIME watcher */ |
600 | manager->priv->idle_monitor = gnome_idle_monitor_new (); |
601 | |
602 | - /* set up the screens */ |
603 | - g_signal_connect (manager->priv->rr_screen, "changed", G_CALLBACK (on_randr_event), manager); |
604 | - on_randr_event (manager->priv->rr_screen, manager); |
605 | - |
606 | -#ifdef GSD_MOCK |
607 | - g_unix_signal_add (SIGUSR2, (GSourceFunc) received_sigusr2, manager); |
608 | -#endif /* GSD_MOCK */ |
609 | - |
610 | - /* check whether a backlight is available */ |
611 | - manager->priv->backlight_available = backlight_available (manager->priv->rr_screen); |
612 | - |
613 | - /* ensure the default dpms timeouts are cleared */ |
614 | - backlight_enable (manager); |
615 | - |
616 | /* coldplug the engine */ |
617 | engine_coldplug (manager); |
618 | idle_configure (manager); |
619 | @@ -3577,6 +3549,47 @@ |
620 | |
621 | setup_lid_closed_action (manager); |
622 | gnome_settings_profile_end (NULL); |
623 | +} |
624 | + |
625 | +gboolean |
626 | +gsd_power_manager_start (GsdPowerManager *manager, |
627 | + GError **error) |
628 | +{ |
629 | + g_debug ("Starting power manager"); |
630 | + gnome_settings_profile_start (NULL); |
631 | + |
632 | + /* Check whether we have a lid first */ |
633 | + manager->priv->up_client = up_client_new (); |
634 | + manager->priv->lid_is_present = up_client_get_lid_is_present (manager->priv->up_client); |
635 | + if (manager->priv->lid_is_present) |
636 | + manager->priv->lid_is_closed = up_client_get_lid_is_closed (manager->priv->up_client); |
637 | + |
638 | + /* Set up the logind proxy */ |
639 | + manager->priv->logind_proxy = |
640 | + g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, |
641 | + 0, |
642 | + NULL, |
643 | + SYSTEMD_DBUS_NAME, |
644 | + SYSTEMD_DBUS_PATH, |
645 | + SYSTEMD_DBUS_INTERFACE, |
646 | + NULL, |
647 | + error); |
648 | + if (manager->priv->logind_proxy == NULL) { |
649 | + g_debug ("No systemd (logind) support, disabling plugin"); |
650 | + return FALSE; |
651 | + } |
652 | + |
653 | + /* Check for XTEST support */ |
654 | + if (supports_xtest () == FALSE) { |
655 | + g_debug ("XTEST extension required, disabling plugin"); |
656 | + return FALSE; |
657 | + } |
658 | + |
659 | + /* coldplug the list of screens */ |
660 | + gnome_rr_screen_new_async (gdk_screen_get_default (), |
661 | + on_rr_screen_acquired, manager); |
662 | + |
663 | + gnome_settings_profile_end (NULL); |
664 | return TRUE; |
665 | } |
666 | |
667 | |
668 | === modified file 'plugins/wacom/gsd-wacom-device.c' |
669 | --- plugins/wacom/gsd-wacom-device.c 2012-12-20 10:20:29 +0000 |
670 | +++ plugins/wacom/gsd-wacom-device.c 2014-03-01 03:37:38 +0000 |
671 | @@ -521,35 +521,26 @@ |
672 | rr_outputs = gnome_rr_screen_list_outputs (rr_screen); |
673 | |
674 | for (i = 0; rr_outputs[i] != NULL; i++) { |
675 | - gchar *o_vendor_s; |
676 | - gchar *o_product_s; |
677 | - int o_product; |
678 | - gchar *o_serial_s; |
679 | - int o_serial; |
680 | + gchar *o_vendor; |
681 | + gchar *o_product; |
682 | + gchar *o_serial; |
683 | gboolean match; |
684 | |
685 | - if (!gnome_rr_output_is_connected (rr_outputs[i])) |
686 | - continue; |
687 | - |
688 | - if (!gnome_rr_output_get_ids_from_edid (rr_outputs[i], |
689 | - &o_vendor_s, |
690 | - &o_product, |
691 | - &o_serial)) |
692 | - continue; |
693 | - |
694 | - o_product_s = g_strdup_printf ("%d", o_product); |
695 | - o_serial_s = g_strdup_printf ("%d", o_serial); |
696 | + gnome_rr_output_get_ids_from_edid (rr_outputs[i], |
697 | + &o_vendor, |
698 | + &o_product, |
699 | + &o_serial); |
700 | |
701 | g_debug ("Checking for match between '%s','%s','%s' and '%s','%s','%s'", \ |
702 | - vendor, product, serial, o_vendor_s, o_product_s, o_serial_s); |
703 | - |
704 | - match = (vendor == NULL || g_strcmp0 (vendor, o_vendor_s) == 0) && \ |
705 | - (product == NULL || g_strcmp0 (product, o_product_s) == 0) && \ |
706 | - (serial == NULL || g_strcmp0 (serial, o_serial_s) == 0); |
707 | - |
708 | - g_free (o_vendor_s); |
709 | - g_free (o_product_s); |
710 | - g_free (o_serial_s); |
711 | + vendor, product, serial, o_vendor, o_product, o_serial); |
712 | + |
713 | + match = (vendor == NULL || g_strcmp0 (vendor, o_vendor) == 0) && \ |
714 | + (product == NULL || g_strcmp0 (product, o_product) == 0) && \ |
715 | + (serial == NULL || g_strcmp0 (serial, o_serial) == 0); |
716 | + |
717 | + g_free (o_vendor); |
718 | + g_free (o_product); |
719 | + g_free (o_serial); |
720 | |
721 | if (match) { |
722 | retval = rr_outputs[i]; |
723 | @@ -573,10 +564,7 @@ |
724 | |
725 | rr_outputs = gnome_rr_screen_list_outputs (rr_screen); |
726 | for (i = 0; rr_outputs[i] != NULL; i++) { |
727 | - if (!gnome_rr_output_is_connected (rr_outputs[i])) |
728 | - continue; |
729 | - |
730 | - if (gnome_rr_output_is_laptop(rr_outputs[i])) { |
731 | + if (gnome_rr_output_is_builtin_display(rr_outputs[i])) { |
732 | retval = rr_outputs[i]; |
733 | break; |
734 | } |
735 | @@ -699,8 +687,7 @@ |
736 | GVariant *c_array; |
737 | GVariant *n_array; |
738 | gsize nvalues; |
739 | - gchar *o_vendor_s, *o_product_s, *o_serial_s; |
740 | - int o_product, o_serial; |
741 | + gchar *o_vendor, *o_product, *o_serial; |
742 | const gchar *values[3]; |
743 | |
744 | tablet = gsd_wacom_device_get_settings (device); |
745 | @@ -711,28 +698,26 @@ |
746 | return; |
747 | } |
748 | |
749 | - if (rr_output == NULL || |
750 | - !gnome_rr_output_get_ids_from_edid (rr_output, |
751 | - &o_vendor_s, |
752 | - &o_product, |
753 | - &o_serial)) { |
754 | - o_vendor_s = g_strdup (""); |
755 | - o_product_s = g_strdup (""); |
756 | - o_serial_s = g_strdup (""); |
757 | + if (rr_output == NULL) { |
758 | + o_vendor = g_strdup (""); |
759 | + o_product = g_strdup (""); |
760 | + o_serial = g_strdup (""); |
761 | } else { |
762 | - o_product_s = g_strdup_printf ("%d", o_product); |
763 | - o_serial_s = g_strdup_printf ("%d", o_serial); |
764 | + gnome_rr_output_get_ids_from_edid (rr_output, |
765 | + &o_vendor, |
766 | + &o_product, |
767 | + &o_serial); |
768 | } |
769 | |
770 | - values[0] = o_vendor_s; |
771 | - values[1] = o_product_s; |
772 | - values[2] = o_serial_s; |
773 | + values[0] = o_vendor; |
774 | + values[1] = o_product; |
775 | + values[2] = o_serial; |
776 | n_array = g_variant_new_strv ((const gchar * const *) &values, 3); |
777 | g_settings_set_value (tablet, "display", n_array); |
778 | |
779 | - g_free (o_vendor_s); |
780 | - g_free (o_product_s); |
781 | - g_free (o_serial_s); |
782 | + g_free (o_vendor); |
783 | + g_free (o_product); |
784 | + g_free (o_serial); |
785 | } |
786 | |
787 | static GsdWacomRotation |
788 | |
789 | === modified file 'plugins/wacom/gsd-wacom-manager.c' |
790 | --- plugins/wacom/gsd-wacom-manager.c 2013-12-04 23:55:26 +0000 |
791 | +++ plugins/wacom/gsd-wacom-manager.c 2014-03-01 03:37:38 +0000 |
792 | @@ -79,10 +79,10 @@ |
793 | guint device_added_id; |
794 | guint device_removed_id; |
795 | GHashTable *devices; /* key = GdkDevice, value = GsdWacomDevice */ |
796 | - GList *rr_screens; |
797 | + GnomeRRScreen *rr_screen; |
798 | |
799 | /* button capture */ |
800 | - GSList *screens; |
801 | + GdkScreen *screen; |
802 | int opcode; |
803 | |
804 | /* Help OSD window */ |
805 | @@ -745,7 +745,7 @@ |
806 | |
807 | id = get_device_id (device); |
808 | reset_pad_buttons (device); |
809 | - grab_button (id, TRUE, manager->priv->screens); |
810 | + grab_button (id, TRUE, manager->priv->screen); |
811 | return; |
812 | } |
813 | |
814 | @@ -1339,7 +1339,6 @@ |
815 | gsd_wacom_manager_idle_cb (GsdWacomManager *manager) |
816 | { |
817 | GList *devices, *l; |
818 | - GSList *ls; |
819 | |
820 | gnome_settings_profile_start (NULL); |
821 | |
822 | @@ -1353,11 +1352,9 @@ |
823 | g_list_free (devices); |
824 | |
825 | /* Start filtering the button events */ |
826 | - for (ls = manager->priv->screens; ls != NULL; ls = ls->next) { |
827 | - gdk_window_add_filter (gdk_screen_get_root_window (ls->data), |
828 | - (GdkFilterFunc) filter_button_events, |
829 | - manager); |
830 | - } |
831 | + gdk_window_add_filter (gdk_screen_get_root_window (manager->priv->screen), |
832 | + (GdkFilterFunc) filter_button_events, |
833 | + manager); |
834 | |
835 | gnome_settings_profile_end (NULL); |
836 | |
837 | @@ -1406,41 +1403,45 @@ |
838 | } |
839 | g_list_free (devices); |
840 | } |
841 | - |
842 | -static void |
843 | -init_screens (GsdWacomManager *manager) |
844 | -{ |
845 | - GdkDisplay *display; |
846 | - int i; |
847 | - |
848 | - display = gdk_display_get_default (); |
849 | - for (i = 0; i < gdk_display_get_n_screens (display); i++) { |
850 | - GError *error = NULL; |
851 | - GdkScreen *screen; |
852 | - GnomeRRScreen *rr_screen; |
853 | - |
854 | - screen = gdk_display_get_screen (display, i); |
855 | - if (screen == NULL) { |
856 | - continue; |
857 | - } |
858 | - manager->priv->screens = g_slist_append (manager->priv->screens, screen); |
859 | - |
860 | - /* |
861 | - * We also keep a list of GnomeRRScreen to monitor changes such as rotation |
862 | - * which are not reported by Gdk's "monitors-changed" callback |
863 | - */ |
864 | - rr_screen = gnome_rr_screen_new (screen, &error); |
865 | - if (rr_screen == NULL) { |
866 | - g_warning ("Failed to create GnomeRRScreen: %s", error->message); |
867 | - g_error_free (error); |
868 | - continue; |
869 | - } |
870 | - manager->priv->rr_screens = g_list_prepend (manager->priv->rr_screens, rr_screen); |
871 | - g_signal_connect (rr_screen, |
872 | - "changed", |
873 | - G_CALLBACK (on_screen_changed_cb), |
874 | - manager); |
875 | - } |
876 | +static void |
877 | +on_rr_screen_acquired (GObject *object, |
878 | + GAsyncResult *result, |
879 | + gpointer user_data) |
880 | +{ |
881 | + GsdWacomManager *manager = user_data; |
882 | + GError *error = NULL; |
883 | + |
884 | + manager->priv->rr_screen = gnome_rr_screen_new_finish (result, NULL); |
885 | + if (manager->priv->rr_screen == NULL) { |
886 | + g_warning ("Failed to create GnomeRRScreen: %s", error->message); |
887 | + g_error_free (error); |
888 | + return; |
889 | + } |
890 | + |
891 | + g_signal_connect (manager->priv->rr_screen, |
892 | + "changed", |
893 | + G_CALLBACK (on_screen_changed_cb), |
894 | + manager); |
895 | +} |
896 | + |
897 | +static void |
898 | +init_screen (GsdWacomManager *manager) |
899 | +{ |
900 | + GError *error = NULL; |
901 | + GdkScreen *screen; |
902 | + GnomeRRScreen *rr_screen; |
903 | + |
904 | + screen = gdk_screen_get_default (); |
905 | + if (screen == NULL) { |
906 | + return; |
907 | + } |
908 | + manager->priv->screen = screen; |
909 | + |
910 | + /* |
911 | + * We keep GnomeRRScreen to monitor changes such as rotation |
912 | + * which are not reported by Gdk's "monitors-changed" callback |
913 | + */ |
914 | + gnome_rr_screen_new_async (screen, on_rr_screen_acquired, manager); |
915 | } |
916 | |
917 | gboolean |
918 | @@ -1459,7 +1460,7 @@ |
919 | return TRUE; |
920 | } |
921 | |
922 | - init_screens (manager); |
923 | + init_screen (manager); |
924 | |
925 | manager->priv->start_idle_id = g_idle_add ((GSourceFunc) gsd_wacom_manager_idle_cb, manager); |
926 | |
927 | @@ -1472,7 +1473,6 @@ |
928 | gsd_wacom_manager_stop (GsdWacomManager *manager) |
929 | { |
930 | GsdWacomManagerPrivate *p = manager->priv; |
931 | - GSList *ls; |
932 | GList *l; |
933 | |
934 | g_debug ("Stopping wacom manager"); |
935 | @@ -1492,7 +1492,7 @@ |
936 | int id; |
937 | |
938 | id = get_device_id (l->data); |
939 | - grab_button (id, FALSE, manager->priv->screens); |
940 | + grab_button (id, FALSE, manager->priv->screen); |
941 | } |
942 | } |
943 | g_list_free (devices); |
944 | @@ -1500,14 +1500,11 @@ |
945 | p->device_manager = NULL; |
946 | } |
947 | |
948 | - for (ls = p->screens; ls != NULL; ls = ls->next) { |
949 | - gdk_window_remove_filter (gdk_screen_get_root_window (ls->data), |
950 | - (GdkFilterFunc) filter_button_events, |
951 | - manager); |
952 | - } |
953 | + gdk_window_remove_filter (gdk_screen_get_root_window (p->screen), |
954 | + (GdkFilterFunc) filter_button_events, |
955 | + manager); |
956 | |
957 | - for (l = p->rr_screens; l != NULL; l = l->next) |
958 | - g_signal_handlers_disconnect_by_func (l->data, on_screen_changed_cb, manager); |
959 | + g_signal_handlers_disconnect_by_func (p->rr_screen, on_screen_changed_cb, manager); |
960 | |
961 | g_clear_pointer (&p->osd_window, gtk_widget_destroy); |
962 | } |
963 | @@ -1529,14 +1526,9 @@ |
964 | wacom_manager->priv->devices = NULL; |
965 | } |
966 | |
967 | - if (wacom_manager->priv->screens != NULL) { |
968 | - g_slist_free (wacom_manager->priv->screens); |
969 | - wacom_manager->priv->screens = NULL; |
970 | - } |
971 | - |
972 | - if (wacom_manager->priv->rr_screens != NULL) { |
973 | - g_list_free_full (wacom_manager->priv->rr_screens, g_object_unref); |
974 | - wacom_manager->priv->rr_screens = NULL; |
975 | + if (wacom_manager->priv->rr_screen != NULL) { |
976 | + g_clear_object (&wacom_manager->priv->rr_screen); |
977 | + wacom_manager->priv->rr_screen = NULL; |
978 | } |
979 | |
980 | if (wacom_manager->priv->start_idle_id != 0) |
981 | |
982 | === modified file 'plugins/xrandr/gsd-xrandr-manager.c' |
983 | --- plugins/xrandr/gsd-xrandr-manager.c 2013-12-04 23:55:26 +0000 |
984 | +++ plugins/xrandr/gsd-xrandr-manager.c 2014-03-01 03:37:38 +0000 |
985 | @@ -62,7 +62,6 @@ |
986 | |
987 | #define CONF_SCHEMA "org.gnome.settings-daemon.plugins.xrandr" |
988 | #define CONF_KEY_DEFAULT_MONITORS_SETUP "default-monitors-setup" |
989 | -#define CONF_KEY_DEFAULT_CONFIGURATION_FILE "default-configuration-file" |
990 | |
991 | /* Number of seconds that the confirmation dialog will last before it resets the |
992 | * RANDR configuration to its old state. |
993 | @@ -79,15 +78,6 @@ |
994 | "<node name='/org/gnome/SettingsDaemon/XRANDR'>" |
995 | " <interface name='org.gnome.SettingsDaemon.XRANDR_2'>" |
996 | " <annotation name='org.freedesktop.DBus.GLib.CSymbol' value='gsd_xrandr_manager_2'/>" |
997 | -" <method name='ApplyConfiguration'>" |
998 | -" <!-- transient-parent window for the confirmation dialog; use 0" |
999 | -" for no parent -->" |
1000 | -" <arg name='parent_window_id' type='x' direction='in'/>" |
1001 | -"" |
1002 | -" <!-- Timestamp used to present the confirmation dialog and (in" |
1003 | -" the future) for the RANDR calls themselves -->" |
1004 | -" <arg name='timestamp' type='x' direction='in'/>" |
1005 | -" </method>" |
1006 | " <method name='VideoModeSwitch'>" |
1007 | " <!-- Timestamp for the RANDR call itself -->" |
1008 | " <arg name='timestamp' type='x' direction='in'/>" |
1009 | @@ -109,7 +99,6 @@ |
1010 | gboolean running; |
1011 | |
1012 | UpClient *upower_client; |
1013 | - gboolean laptop_lid_is_closed; |
1014 | |
1015 | GSettings *settings; |
1016 | GDBusNodeInfo *introspection_data; |
1017 | @@ -121,9 +110,6 @@ |
1018 | int current_fn_f7_config; /* -1 if no configs */ |
1019 | GnomeRRConfig **fn_f7_configs; /* NULL terminated, NULL if there are no configs */ |
1020 | |
1021 | - /* Last time at which we got a "screen got reconfigured" event; see on_randr_event() */ |
1022 | - guint32 last_config_timestamp; |
1023 | - |
1024 | #ifdef HAVE_WACOM |
1025 | WacomDeviceDatabase *wacom_db; |
1026 | #endif /* HAVE_WACOM */ |
1027 | @@ -251,23 +237,11 @@ |
1028 | log_msg (" no outputs!\n"); |
1029 | } |
1030 | |
1031 | -static char |
1032 | -timestamp_relationship (guint32 a, guint32 b) |
1033 | -{ |
1034 | - if (a < b) |
1035 | - return '<'; |
1036 | - else if (a > b) |
1037 | - return '>'; |
1038 | - else |
1039 | - return '='; |
1040 | -} |
1041 | - |
1042 | static void |
1043 | log_screen (GnomeRRScreen *screen) |
1044 | { |
1045 | GnomeRRConfig *config; |
1046 | int min_w, min_h, max_w, max_h; |
1047 | - guint32 change_timestamp, config_timestamp; |
1048 | |
1049 | if (!log_file) |
1050 | return; |
1051 | @@ -275,14 +249,10 @@ |
1052 | config = gnome_rr_config_new_current (screen, NULL); |
1053 | |
1054 | gnome_rr_screen_get_ranges (screen, &min_w, &max_w, &min_h, &max_h); |
1055 | - gnome_rr_screen_get_timestamps (screen, &change_timestamp, &config_timestamp); |
1056 | |
1057 | - log_msg (" Screen min(%d, %d), max(%d, %d), change=%u %c config=%u\n", |
1058 | + log_msg (" Screen min(%d, %d), max(%d, %d)\n", |
1059 | min_w, min_h, |
1060 | - max_w, max_h, |
1061 | - change_timestamp, |
1062 | - timestamp_relationship (change_timestamp, config_timestamp), |
1063 | - config_timestamp); |
1064 | + max_w, max_h); |
1065 | |
1066 | log_configuration (config); |
1067 | g_object_unref (config); |
1068 | @@ -305,34 +275,6 @@ |
1069 | } |
1070 | |
1071 | static void |
1072 | -show_timestamps_dialog (GsdXrandrManager *manager, const char *msg) |
1073 | -{ |
1074 | -#if 1 |
1075 | - return; |
1076 | -#else |
1077 | - struct GsdXrandrManagerPrivate *priv = manager->priv; |
1078 | - GtkWidget *dialog; |
1079 | - guint32 change_timestamp, config_timestamp; |
1080 | - static int serial; |
1081 | - |
1082 | - gnome_rr_screen_get_timestamps (priv->rw_screen, &change_timestamp, &config_timestamp); |
1083 | - |
1084 | - dialog = gtk_message_dialog_new (NULL, |
1085 | - 0, |
1086 | - GTK_MESSAGE_INFO, |
1087 | - GTK_BUTTONS_CLOSE, |
1088 | - "RANDR timestamps (%d):\n%s\nchange: %u\nconfig: %u", |
1089 | - serial++, |
1090 | - msg, |
1091 | - change_timestamp, |
1092 | - config_timestamp); |
1093 | - g_signal_connect (dialog, "response", |
1094 | - G_CALLBACK (gtk_widget_destroy), NULL); |
1095 | - gtk_widget_show (dialog); |
1096 | -#endif |
1097 | -} |
1098 | - |
1099 | -static void |
1100 | print_output (GnomeRROutputInfo *info) |
1101 | { |
1102 | int x, y, width, height; |
1103 | @@ -374,7 +316,7 @@ |
1104 | |
1105 | rr_output = gnome_rr_screen_get_output_by_name (screen, gnome_rr_output_info_get_name (output)); |
1106 | |
1107 | - return gnome_rr_output_is_laptop (rr_output); |
1108 | + return gnome_rr_output_is_builtin_display (rr_output); |
1109 | } |
1110 | |
1111 | static GnomeRROutputInfo * |
1112 | @@ -391,96 +333,6 @@ |
1113 | return NULL; |
1114 | } |
1115 | |
1116 | -static gboolean |
1117 | -non_laptop_outputs_are_active (GnomeRRConfig *config, GnomeRROutputInfo *laptop_info) |
1118 | -{ |
1119 | - GnomeRROutputInfo **outputs; |
1120 | - int i; |
1121 | - |
1122 | - outputs = gnome_rr_config_get_outputs (config); |
1123 | - for (i = 0; outputs[i] != NULL; i++) { |
1124 | - if (outputs[i] == laptop_info) |
1125 | - continue; |
1126 | - |
1127 | - if (gnome_rr_output_info_is_active (outputs[i])) |
1128 | - return TRUE; |
1129 | - } |
1130 | - |
1131 | - return FALSE; |
1132 | -} |
1133 | - |
1134 | -static void |
1135 | -turn_off_laptop_display_in_configuration (GnomeRRScreen *screen, GnomeRRConfig *config) |
1136 | -{ |
1137 | - GnomeRROutputInfo *laptop_info; |
1138 | - |
1139 | - laptop_info = get_laptop_output_info (screen, config); |
1140 | - if (laptop_info) { |
1141 | - /* Turn off the laptop's screen only if other displays are on. This is to avoid an all-black-screens scenario. */ |
1142 | - if (non_laptop_outputs_are_active (config, laptop_info)) |
1143 | - gnome_rr_output_info_set_active (laptop_info, FALSE); |
1144 | - } |
1145 | - |
1146 | - /* Adjust the offsets of outputs so they start at (0, 0) */ |
1147 | - gnome_rr_config_sanitize (config); |
1148 | -} |
1149 | - |
1150 | -/* This function effectively centralizes the use of gnome_rr_config_apply_from_filename_with_time(). |
1151 | - * |
1152 | - * Optionally filters out GNOME_RR_ERROR_NO_MATCHING_CONFIG from the matching |
1153 | - * process(), since that is not usually an error. |
1154 | - */ |
1155 | -static gboolean |
1156 | -apply_configuration_from_filename (GsdXrandrManager *manager, |
1157 | - const char *filename, |
1158 | - gboolean no_matching_config_is_an_error, |
1159 | - guint32 timestamp, |
1160 | - GError **error) |
1161 | -{ |
1162 | - struct GsdXrandrManagerPrivate *priv = manager->priv; |
1163 | - GnomeRRConfig *config; |
1164 | - GError *my_error; |
1165 | - gboolean success; |
1166 | - char *str; |
1167 | - |
1168 | - str = g_strdup_printf ("Applying %s with timestamp %d", filename, timestamp); |
1169 | - show_timestamps_dialog (manager, str); |
1170 | - g_free (str); |
1171 | - |
1172 | - my_error = NULL; |
1173 | - |
1174 | - config = g_object_new (GNOME_TYPE_RR_CONFIG, "screen", priv->rw_screen, NULL); |
1175 | - if (!gnome_rr_config_load_filename (config, filename, &my_error)) { |
1176 | - g_object_unref (config); |
1177 | - |
1178 | - if (g_error_matches (my_error, GNOME_RR_ERROR, GNOME_RR_ERROR_NO_MATCHING_CONFIG)) { |
1179 | - if (no_matching_config_is_an_error) { |
1180 | - g_propagate_error (error, my_error); |
1181 | - return FALSE; |
1182 | - } else { |
1183 | - /* This is not an error; the user probably changed his monitors |
1184 | - * and so they don't match any of the stored configurations. |
1185 | - */ |
1186 | - g_error_free (my_error); |
1187 | - return TRUE; |
1188 | - } |
1189 | - } else { |
1190 | - g_propagate_error (error, my_error); |
1191 | - return FALSE; |
1192 | - } |
1193 | - } |
1194 | - |
1195 | - if (up_client_get_lid_is_closed (priv->upower_client)) |
1196 | - turn_off_laptop_display_in_configuration (priv->rw_screen, config); |
1197 | - |
1198 | - gnome_rr_config_ensure_primary (config); |
1199 | - success = gnome_rr_config_apply_with_time (config, priv->rw_screen, timestamp, error); |
1200 | - |
1201 | - g_object_unref (config); |
1202 | - |
1203 | - return success; |
1204 | -} |
1205 | - |
1206 | /* This function centralizes the use of gnome_rr_config_apply_with_time(). |
1207 | * |
1208 | * Applies a configuration and displays an error message if an error happens. |
1209 | @@ -498,11 +350,12 @@ |
1210 | print_configuration (config, "Applying Configuration"); |
1211 | |
1212 | error = NULL; |
1213 | - success = gnome_rr_config_apply_with_time (config, priv->rw_screen, timestamp, &error); |
1214 | - if (success) { |
1215 | - if (save_configuration) |
1216 | - gnome_rr_config_save (config, NULL); /* NULL-GError - there's not much we can do if this fails */ |
1217 | - } else { |
1218 | + if (save_configuration) |
1219 | + success = gnome_rr_config_apply_persistent (config, priv->rw_screen, &error); |
1220 | + else |
1221 | + success = gnome_rr_config_apply (config, priv->rw_screen, &error); |
1222 | + |
1223 | + if (!success) { |
1224 | log_msg ("Could not switch to the following configuration (timestamp %u): %s\n", timestamp, error->message); |
1225 | log_configuration (config); |
1226 | if (show_error) |
1227 | @@ -513,250 +366,6 @@ |
1228 | return success; |
1229 | } |
1230 | |
1231 | -static void |
1232 | -restore_backup_configuration_without_messages (const char *backup_filename, const char *intended_filename) |
1233 | -{ |
1234 | - backup_filename = gnome_rr_config_get_backup_filename (); |
1235 | - rename (backup_filename, intended_filename); |
1236 | -} |
1237 | - |
1238 | -static void |
1239 | -restore_backup_configuration (GsdXrandrManager *manager, const char *backup_filename, const char *intended_filename, guint32 timestamp) |
1240 | -{ |
1241 | - int saved_errno; |
1242 | - |
1243 | - if (rename (backup_filename, intended_filename) == 0) { |
1244 | - GError *error; |
1245 | - |
1246 | - error = NULL; |
1247 | - if (!apply_configuration_from_filename (manager, intended_filename, FALSE, timestamp, &error)) { |
1248 | - error_message (manager, _("Could not restore the display's configuration"), error, NULL); |
1249 | - |
1250 | - if (error) |
1251 | - g_error_free (error); |
1252 | - } |
1253 | - |
1254 | - return; |
1255 | - } |
1256 | - |
1257 | - saved_errno = errno; |
1258 | - |
1259 | - /* ENOENT means the original file didn't exist. That is *not* an error; |
1260 | - * the backup was not created because there wasn't even an original |
1261 | - * monitors.xml (such as on a first-time login). Note that *here* there |
1262 | - * is a "didn't work" monitors.xml, so we must delete that one. |
1263 | - */ |
1264 | - if (saved_errno == ENOENT) |
1265 | - unlink (intended_filename); |
1266 | - else { |
1267 | - char *msg; |
1268 | - |
1269 | - msg = g_strdup_printf ("Could not rename %s to %s: %s", |
1270 | - backup_filename, intended_filename, |
1271 | - g_strerror (saved_errno)); |
1272 | - error_message (manager, |
1273 | - _("Could not restore the display's configuration from a backup"), |
1274 | - NULL, |
1275 | - msg); |
1276 | - g_free (msg); |
1277 | - } |
1278 | - |
1279 | - unlink (backup_filename); |
1280 | -} |
1281 | - |
1282 | -typedef struct { |
1283 | - GsdXrandrManager *manager; |
1284 | - GtkWidget *dialog; |
1285 | - |
1286 | - int countdown; |
1287 | - int response_id; |
1288 | -} TimeoutDialog; |
1289 | - |
1290 | -static void |
1291 | -print_countdown_text (TimeoutDialog *timeout) |
1292 | -{ |
1293 | - gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (timeout->dialog), |
1294 | - ngettext ("The display will be reset to its previous configuration in %d second", |
1295 | - "The display will be reset to its previous configuration in %d seconds", |
1296 | - timeout->countdown), |
1297 | - timeout->countdown); |
1298 | -} |
1299 | - |
1300 | -static gboolean |
1301 | -timeout_cb (gpointer data) |
1302 | -{ |
1303 | - TimeoutDialog *timeout = data; |
1304 | - |
1305 | - timeout->countdown--; |
1306 | - |
1307 | - if (timeout->countdown == 0) { |
1308 | - timeout->response_id = GTK_RESPONSE_CANCEL; |
1309 | - gtk_main_quit (); |
1310 | - } else { |
1311 | - print_countdown_text (timeout); |
1312 | - } |
1313 | - |
1314 | - return TRUE; |
1315 | -} |
1316 | - |
1317 | -static void |
1318 | -timeout_response_cb (GtkDialog *dialog, int response_id, gpointer data) |
1319 | -{ |
1320 | - TimeoutDialog *timeout = data; |
1321 | - |
1322 | - if (response_id == GTK_RESPONSE_DELETE_EVENT) { |
1323 | - /* The user closed the dialog or pressed ESC, revert */ |
1324 | - timeout->response_id = GTK_RESPONSE_CANCEL; |
1325 | - } else |
1326 | - timeout->response_id = response_id; |
1327 | - |
1328 | - gtk_main_quit (); |
1329 | -} |
1330 | - |
1331 | -static gboolean |
1332 | -user_says_things_are_ok (GsdXrandrManager *manager, GdkWindow *parent_window) |
1333 | -{ |
1334 | - TimeoutDialog timeout; |
1335 | - guint timeout_id; |
1336 | - |
1337 | - timeout.manager = manager; |
1338 | - |
1339 | - timeout.dialog = gtk_message_dialog_new (NULL, |
1340 | - GTK_DIALOG_MODAL, |
1341 | - GTK_MESSAGE_QUESTION, |
1342 | - GTK_BUTTONS_NONE, |
1343 | - _("Does the display look OK?")); |
1344 | - |
1345 | - timeout.countdown = CONFIRMATION_DIALOG_SECONDS; |
1346 | - |
1347 | - print_countdown_text (&timeout); |
1348 | - |
1349 | - gtk_window_set_icon_name (GTK_WINDOW (timeout.dialog), "preferences-desktop-display"); |
1350 | - gtk_dialog_add_button (GTK_DIALOG (timeout.dialog), _("_Restore Previous Configuration"), GTK_RESPONSE_CANCEL); |
1351 | - gtk_dialog_add_button (GTK_DIALOG (timeout.dialog), _("_Keep This Configuration"), GTK_RESPONSE_ACCEPT); |
1352 | - gtk_dialog_set_default_response (GTK_DIALOG (timeout.dialog), GTK_RESPONSE_ACCEPT); /* ah, the optimism */ |
1353 | - |
1354 | - g_signal_connect (timeout.dialog, "response", |
1355 | - G_CALLBACK (timeout_response_cb), |
1356 | - &timeout); |
1357 | - |
1358 | - gtk_widget_realize (timeout.dialog); |
1359 | - |
1360 | - if (parent_window) |
1361 | - gdk_window_set_transient_for (gtk_widget_get_window (timeout.dialog), parent_window); |
1362 | - |
1363 | - gtk_widget_show_all (timeout.dialog); |
1364 | - /* We don't use g_timeout_add_seconds() since we actually care that the user sees "real" second ticks in the dialog */ |
1365 | - timeout_id = g_timeout_add (1000, |
1366 | - timeout_cb, |
1367 | - &timeout); |
1368 | - gtk_main (); |
1369 | - |
1370 | - gtk_widget_destroy (timeout.dialog); |
1371 | - g_source_remove (timeout_id); |
1372 | - |
1373 | - if (timeout.response_id == GTK_RESPONSE_ACCEPT) |
1374 | - return TRUE; |
1375 | - else |
1376 | - return FALSE; |
1377 | -} |
1378 | - |
1379 | -struct confirmation { |
1380 | - GsdXrandrManager *manager; |
1381 | - GdkWindow *parent_window; |
1382 | - guint32 timestamp; |
1383 | -}; |
1384 | - |
1385 | -static gboolean |
1386 | -confirm_with_user_idle_cb (gpointer data) |
1387 | -{ |
1388 | - struct confirmation *confirmation = data; |
1389 | - char *backup_filename; |
1390 | - char *intended_filename; |
1391 | - |
1392 | - backup_filename = gnome_rr_config_get_backup_filename (); |
1393 | - intended_filename = gnome_rr_config_get_intended_filename (); |
1394 | - |
1395 | - if (user_says_things_are_ok (confirmation->manager, confirmation->parent_window)) |
1396 | - unlink (backup_filename); |
1397 | - else |
1398 | - restore_backup_configuration (confirmation->manager, backup_filename, intended_filename, confirmation->timestamp); |
1399 | - |
1400 | - g_free (confirmation); |
1401 | - |
1402 | - return FALSE; |
1403 | -} |
1404 | - |
1405 | -static void |
1406 | -queue_confirmation_by_user (GsdXrandrManager *manager, GdkWindow *parent_window, guint32 timestamp) |
1407 | -{ |
1408 | - struct confirmation *confirmation; |
1409 | - |
1410 | - confirmation = g_new (struct confirmation, 1); |
1411 | - confirmation->manager = manager; |
1412 | - confirmation->parent_window = parent_window; |
1413 | - confirmation->timestamp = timestamp; |
1414 | - |
1415 | - g_idle_add (confirm_with_user_idle_cb, confirmation); |
1416 | -} |
1417 | - |
1418 | -static gboolean |
1419 | -try_to_apply_intended_configuration (GsdXrandrManager *manager, GdkWindow *parent_window, guint32 timestamp, GError **error) |
1420 | -{ |
1421 | - char *backup_filename; |
1422 | - char *intended_filename; |
1423 | - gboolean result; |
1424 | - |
1425 | - /* Try to apply the intended configuration */ |
1426 | - |
1427 | - backup_filename = gnome_rr_config_get_backup_filename (); |
1428 | - intended_filename = gnome_rr_config_get_intended_filename (); |
1429 | - |
1430 | - result = apply_configuration_from_filename (manager, intended_filename, FALSE, timestamp, error); |
1431 | - if (!result) { |
1432 | - error_message (manager, _("The selected configuration for displays could not be applied"), error ? *error : NULL, NULL); |
1433 | - restore_backup_configuration_without_messages (backup_filename, intended_filename); |
1434 | - goto out; |
1435 | - } else { |
1436 | - /* We need to return as quickly as possible, so instead of |
1437 | - * confirming with the user right here, we do it in an idle |
1438 | - * handler. The caller only expects a status for "could you |
1439 | - * change the RANDR configuration?", not "is the user OK with it |
1440 | - * as well?". |
1441 | - */ |
1442 | - queue_confirmation_by_user (manager, parent_window, timestamp); |
1443 | - } |
1444 | - |
1445 | -out: |
1446 | - g_free (backup_filename); |
1447 | - g_free (intended_filename); |
1448 | - |
1449 | - return result; |
1450 | -} |
1451 | - |
1452 | -/* DBus method for org.gnome.SettingsDaemon.XRANDR_2 ApplyConfiguration; see gsd-xrandr-manager.xml for the interface definition */ |
1453 | -static gboolean |
1454 | -gsd_xrandr_manager_2_apply_configuration (GsdXrandrManager *manager, |
1455 | - gint64 parent_window_id, |
1456 | - gint64 timestamp, |
1457 | - GError **error) |
1458 | -{ |
1459 | - GdkWindow *parent_window; |
1460 | - gboolean result; |
1461 | - |
1462 | - if (parent_window_id != 0) |
1463 | - parent_window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), (Window) parent_window_id); |
1464 | - else |
1465 | - parent_window = NULL; |
1466 | - |
1467 | - result = try_to_apply_intended_configuration (manager, parent_window, (guint32) timestamp, error); |
1468 | - |
1469 | - if (parent_window) |
1470 | - g_object_unref (parent_window); |
1471 | - |
1472 | - return result; |
1473 | -} |
1474 | - |
1475 | /* DBus method for org.gnome.SettingsDaemon.XRANDR_2 VideoModeSwitch; see gsd-xrandr-manager.xml for the interface definition */ |
1476 | static gboolean |
1477 | gsd_xrandr_manager_2_video_mode_switch (GsdXrandrManager *manager, |
1478 | @@ -1402,7 +1011,6 @@ |
1479 | g_object_unref (current); |
1480 | |
1481 | if (priv->fn_f7_configs) { |
1482 | - guint32 server_timestamp; |
1483 | gboolean success; |
1484 | |
1485 | mgr->priv->current_fn_f7_config++; |
1486 | @@ -1416,22 +1024,6 @@ |
1487 | |
1488 | g_debug ("applying"); |
1489 | |
1490 | - /* See https://bugzilla.gnome.org/show_bug.cgi?id=610482 |
1491 | - * |
1492 | - * Sometimes we'll get two rapid XF86Display keypress events, |
1493 | - * but their timestamps will be out of order with respect to the |
1494 | - * RANDR timestamps. This *may* be due to stupid BIOSes sending |
1495 | - * out display-switch keystrokes "to make Windows work". |
1496 | - * |
1497 | - * The X server will error out if the timestamp provided is |
1498 | - * older than a previous change configuration timestamp. We |
1499 | - * assume here that we do want this event to go through still, |
1500 | - * since kernel timestamps may be skewed wrt the X server. |
1501 | - */ |
1502 | - gnome_rr_screen_get_timestamps (screen, NULL, &server_timestamp); |
1503 | - if (timestamp < server_timestamp) |
1504 | - timestamp = server_timestamp; |
1505 | - |
1506 | success = apply_configuration (mgr, priv->fn_f7_configs[mgr->priv->current_fn_f7_config], timestamp, TRUE, TRUE); |
1507 | |
1508 | if (success) { |
1509 | @@ -1674,153 +1266,6 @@ |
1510 | g_object_unref (current); |
1511 | } |
1512 | |
1513 | -static GnomeRRConfig * |
1514 | -make_default_setup (GsdXrandrManager *manager) |
1515 | -{ |
1516 | - GsdXrandrManagerPrivate *priv = manager->priv; |
1517 | - GnomeRRConfig *config; |
1518 | - GsdXrandrBootBehaviour boot; |
1519 | - |
1520 | - boot = g_settings_get_enum (priv->settings, CONF_KEY_DEFAULT_MONITORS_SETUP); |
1521 | - g_debug ("xrandr default monitors setup: %d\n", boot); |
1522 | - |
1523 | - switch (boot) { |
1524 | - case GSD_XRANDR_BOOT_BEHAVIOUR_DO_NOTHING: |
1525 | - config = make_xinerama_setup (manager, priv->rw_screen); |
1526 | - break; |
1527 | - case GSD_XRANDR_BOOT_BEHAVIOUR_FOLLOW_LID: |
1528 | - if (laptop_lid_is_closed (manager)) |
1529 | - config = make_other_setup (priv->rw_screen); |
1530 | - else |
1531 | - config = make_xinerama_setup (manager, priv->rw_screen); |
1532 | - break; |
1533 | - case GSD_XRANDR_BOOT_BEHAVIOUR_CLONE: |
1534 | - config = make_clone_setup (manager, priv->rw_screen); |
1535 | - break; |
1536 | - case GSD_XRANDR_BOOT_BEHAVIOUR_DOCK: |
1537 | - config = make_other_setup (priv->rw_screen); |
1538 | - break; |
1539 | - default: |
1540 | - g_assert_not_reached (); |
1541 | - } |
1542 | - |
1543 | - return config; |
1544 | -} |
1545 | - |
1546 | -static void |
1547 | -auto_configure_outputs (GsdXrandrManager *manager, guint32 timestamp) |
1548 | -{ |
1549 | - GnomeRRConfig *config; |
1550 | - |
1551 | - g_debug ("xrandr auto-configure"); |
1552 | - config = make_default_setup (manager); |
1553 | - if (config) { |
1554 | - apply_configuration (manager, config, timestamp, TRUE, FALSE); |
1555 | - g_object_unref (config); |
1556 | - } else { |
1557 | - g_debug ("No applicable configuration found during auto-configure"); |
1558 | - } |
1559 | -} |
1560 | - |
1561 | -static void |
1562 | -use_stored_configuration_or_auto_configure_outputs (GsdXrandrManager *manager, guint32 timestamp) |
1563 | -{ |
1564 | - GsdXrandrManagerPrivate *priv = manager->priv; |
1565 | - char *intended_filename; |
1566 | - GError *error; |
1567 | - gboolean success; |
1568 | - |
1569 | - intended_filename = gnome_rr_config_get_intended_filename (); |
1570 | - |
1571 | - error = NULL; |
1572 | - success = apply_configuration_from_filename (manager, intended_filename, TRUE, timestamp, &error); |
1573 | - g_free (intended_filename); |
1574 | - |
1575 | - if (!success) { |
1576 | - /* We don't bother checking the error type. |
1577 | - * |
1578 | - * Both G_FILE_ERROR_NOENT and |
1579 | - * GNOME_RR_ERROR_NO_MATCHING_CONFIG would mean, "there |
1580 | - * was no configuration to apply, or none that matched |
1581 | - * the current outputs", and in that case we need to run |
1582 | - * our fallback. |
1583 | - * |
1584 | - * Any other error means "we couldn't do the smart thing |
1585 | - * of using a previously- saved configuration, anyway, |
1586 | - * for some other reason. In that case, we also need to |
1587 | - * run our fallback to avoid leaving the user with a |
1588 | - * bogus configuration. |
1589 | - */ |
1590 | - |
1591 | - if (error) |
1592 | - g_error_free (error); |
1593 | - |
1594 | - if (timestamp != priv->last_config_timestamp || timestamp == GDK_CURRENT_TIME) { |
1595 | - priv->last_config_timestamp = timestamp; |
1596 | - auto_configure_outputs (manager, timestamp); |
1597 | - log_msg (" Automatically configured outputs\n"); |
1598 | - } else |
1599 | - log_msg (" Ignored autoconfiguration as old and new config timestamps are the same\n"); |
1600 | - } else |
1601 | - log_msg ("Applied stored configuration\n"); |
1602 | -} |
1603 | - |
1604 | -static void |
1605 | -on_randr_event (GnomeRRScreen *screen, gpointer data) |
1606 | -{ |
1607 | - GsdXrandrManager *manager = GSD_XRANDR_MANAGER (data); |
1608 | - GsdXrandrManagerPrivate *priv = manager->priv; |
1609 | - guint32 change_timestamp, config_timestamp; |
1610 | - |
1611 | - if (!priv->running) |
1612 | - return; |
1613 | - |
1614 | - gnome_rr_screen_get_timestamps (screen, &change_timestamp, &config_timestamp); |
1615 | - |
1616 | - log_open (); |
1617 | - log_msg ("Got RANDR event with timestamps change=%u %c config=%u\n", |
1618 | - change_timestamp, |
1619 | - timestamp_relationship (change_timestamp, config_timestamp), |
1620 | - config_timestamp); |
1621 | - |
1622 | - if (change_timestamp >= config_timestamp) { |
1623 | - GnomeRRConfig *rr_config; |
1624 | - |
1625 | - /* The event is due to an explicit configuration change. |
1626 | - * |
1627 | - * If the change was performed by us, then we need to do nothing. |
1628 | - * |
1629 | - * If the change was done by some other X client, we don't need |
1630 | - * to do anything, either; the screen is already configured. |
1631 | - */ |
1632 | - |
1633 | - /* Check if we need to update the primary */ |
1634 | - rr_config = gnome_rr_config_new_current (priv->rw_screen, NULL); |
1635 | - if (gnome_rr_config_ensure_primary (rr_config)) { |
1636 | - if (gnome_rr_config_applicable (rr_config, priv->rw_screen, NULL)) { |
1637 | - print_configuration (rr_config, "Updating for primary"); |
1638 | - priv->last_config_timestamp = config_timestamp; |
1639 | - gnome_rr_config_apply_with_time (rr_config, priv->rw_screen, config_timestamp, NULL); |
1640 | - } |
1641 | - } |
1642 | - g_object_unref (rr_config); |
1643 | - |
1644 | - show_timestamps_dialog (manager, "ignoring since change > config"); |
1645 | - log_msg (" Ignoring event since change >= config\n"); |
1646 | - } else { |
1647 | - /* Here, config_timestamp > change_timestamp. This means that |
1648 | - * the screen got reconfigured because of hotplug/unplug; the X |
1649 | - * server is just notifying us, and we need to configure the |
1650 | - * outputs in a sane way. |
1651 | - */ |
1652 | - |
1653 | - show_timestamps_dialog (manager, "need to deal with reconfiguration, as config > change"); |
1654 | - use_stored_configuration_or_auto_configure_outputs (manager, config_timestamp); |
1655 | - } |
1656 | - |
1657 | - log_close (); |
1658 | -} |
1659 | - |
1660 | static void |
1661 | get_allowed_rotations_for_output (GnomeRRConfig *config, |
1662 | GnomeRRScreen *rr_screen, |
1663 | @@ -1860,177 +1305,34 @@ |
1664 | } |
1665 | } |
1666 | |
1667 | -static gboolean |
1668 | -apply_intended_configuration (GsdXrandrManager *manager, const char *intended_filename, guint32 timestamp) |
1669 | -{ |
1670 | - GError *my_error; |
1671 | - gboolean result; |
1672 | - |
1673 | - my_error = NULL; |
1674 | - result = apply_configuration_from_filename (manager, intended_filename, TRUE, timestamp, &my_error); |
1675 | - if (!result) { |
1676 | - if (my_error) { |
1677 | - if (!g_error_matches (my_error, G_FILE_ERROR, G_FILE_ERROR_NOENT) && |
1678 | - !g_error_matches (my_error, GNOME_RR_ERROR, GNOME_RR_ERROR_NO_MATCHING_CONFIG)) |
1679 | - error_message (manager, _("Could not apply the stored configuration for monitors"), my_error, NULL); |
1680 | - |
1681 | - g_error_free (my_error); |
1682 | - } |
1683 | - } |
1684 | - |
1685 | - return result; |
1686 | -} |
1687 | - |
1688 | static void |
1689 | -apply_default_boot_configuration (GsdXrandrManager *mgr, guint32 timestamp) |
1690 | +on_rr_screen_acquired (GObject *object, |
1691 | + GAsyncResult *result, |
1692 | + gpointer user_data) |
1693 | { |
1694 | - GsdXrandrManagerPrivate *priv = mgr->priv; |
1695 | - GnomeRRConfig *config; |
1696 | - GsdXrandrBootBehaviour boot; |
1697 | - |
1698 | - boot = g_settings_get_enum (priv->settings, CONF_KEY_DEFAULT_MONITORS_SETUP); |
1699 | - |
1700 | - if (boot == GSD_XRANDR_BOOT_BEHAVIOUR_DO_NOTHING) |
1701 | + GsdXrandrManager *manager = user_data; |
1702 | + GError *error = NULL; |
1703 | + |
1704 | + manager->priv->rw_screen = gnome_rr_screen_new_finish (result, NULL); |
1705 | + |
1706 | + if (manager->priv->rw_screen == NULL) { |
1707 | + log_msg ("Could not initialize the RANDR plugin: %s\n", |
1708 | + error->message); |
1709 | + g_error_free (error); |
1710 | + log_close (); |
1711 | return; |
1712 | - |
1713 | - config = make_default_setup (mgr); |
1714 | - if (config) { |
1715 | - /* We don't save the configuration (the "false" parameter to the following function) because we don't want to |
1716 | - * install a user-side setting when *here* we are using a system-default setting. |
1717 | - */ |
1718 | - apply_configuration (mgr, config, timestamp, TRUE, FALSE); |
1719 | - g_object_unref (config); |
1720 | - } |
1721 | -} |
1722 | - |
1723 | -static gboolean |
1724 | -apply_stored_configuration_at_startup (GsdXrandrManager *manager, guint32 timestamp) |
1725 | -{ |
1726 | - GError *my_error; |
1727 | - gboolean success; |
1728 | - char *backup_filename; |
1729 | - char *intended_filename; |
1730 | - GnomePnpIds *pnp_ids; |
1731 | - |
1732 | - /* This avoids the GnomePnpIds object being created multiple times. |
1733 | - * See c9240e8b69c5833074508b46bc56307aac12ec19 */ |
1734 | - pnp_ids = gnome_pnp_ids_new (); |
1735 | - backup_filename = gnome_rr_config_get_backup_filename (); |
1736 | - intended_filename = gnome_rr_config_get_intended_filename (); |
1737 | - |
1738 | - /* 1. See if there was a "saved" configuration. If there is one, it means |
1739 | - * that the user had selected to change the display configuration, but the |
1740 | - * machine crashed. In that case, we'll apply *that* configuration and save it on top of the |
1741 | - * "intended" one. |
1742 | - */ |
1743 | - |
1744 | - my_error = NULL; |
1745 | - |
1746 | - success = apply_configuration_from_filename (manager, backup_filename, FALSE, timestamp, &my_error); |
1747 | - if (success) { |
1748 | - /* The backup configuration existed, and could be applied |
1749 | - * successfully, so we must restore it on top of the |
1750 | - * failed/intended one. |
1751 | - */ |
1752 | - restore_backup_configuration (manager, backup_filename, intended_filename, timestamp); |
1753 | - goto out; |
1754 | - } |
1755 | - |
1756 | - if (!g_error_matches (my_error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) { |
1757 | - /* Epic fail: there (probably) was a backup configuration, but |
1758 | - * we could not apply it. The only thing we can do is delete |
1759 | - * the backup configuration. Let's hope that the user doesn't |
1760 | - * get left with an unusable display... |
1761 | - */ |
1762 | - |
1763 | - unlink (backup_filename); |
1764 | - goto out; |
1765 | - } |
1766 | - |
1767 | - /* 2. There was no backup configuration! This means we are |
1768 | - * good. Apply the intended configuration instead. |
1769 | - */ |
1770 | - |
1771 | - success = apply_intended_configuration (manager, intended_filename, timestamp); |
1772 | - |
1773 | -out: |
1774 | - g_object_unref (pnp_ids); |
1775 | - |
1776 | - if (my_error) |
1777 | - g_error_free (my_error); |
1778 | - |
1779 | - g_free (backup_filename); |
1780 | - g_free (intended_filename); |
1781 | - |
1782 | - return success; |
1783 | -} |
1784 | - |
1785 | -static gboolean |
1786 | -apply_default_configuration_from_file (GsdXrandrManager *manager, guint32 timestamp) |
1787 | -{ |
1788 | - GsdXrandrManagerPrivate *priv = manager->priv; |
1789 | - char *default_config_filename; |
1790 | - gboolean result; |
1791 | - |
1792 | - default_config_filename = g_settings_get_string (priv->settings, CONF_KEY_DEFAULT_CONFIGURATION_FILE); |
1793 | - if (!default_config_filename) |
1794 | - return FALSE; |
1795 | - |
1796 | - result = apply_configuration_from_filename (manager, default_config_filename, TRUE, timestamp, NULL); |
1797 | - |
1798 | - g_free (default_config_filename); |
1799 | - return result; |
1800 | -} |
1801 | - |
1802 | -static void |
1803 | -turn_off_laptop_display (GsdXrandrManager *manager, guint32 timestamp) |
1804 | -{ |
1805 | - GsdXrandrManagerPrivate *priv = manager->priv; |
1806 | - GnomeRRConfig *config; |
1807 | - |
1808 | - config = gnome_rr_config_new_current (priv->rw_screen, NULL); |
1809 | - |
1810 | - turn_off_laptop_display_in_configuration (priv->rw_screen, config); |
1811 | - |
1812 | - /* We don't turn the laptop's display off if it is the only display present. */ |
1813 | - if (!config_is_all_off (config)) { |
1814 | - /* We don't save the configuration (the "false" parameter to the following function) because we |
1815 | - * wouldn't want to restore a configuration with the laptop's display turned off, if at some |
1816 | - * point later the user booted his laptop with the lid open. |
1817 | - */ |
1818 | - apply_configuration (manager, config, timestamp, FALSE, FALSE); |
1819 | - } |
1820 | - |
1821 | - g_object_unref (config); |
1822 | -} |
1823 | - |
1824 | -static void |
1825 | -power_client_changed_cb (UpClient *client, gpointer data) |
1826 | -{ |
1827 | - GsdXrandrManager *manager = data; |
1828 | - GsdXrandrManagerPrivate *priv = manager->priv; |
1829 | - gboolean is_closed; |
1830 | - |
1831 | - is_closed = up_client_get_lid_is_closed (priv->upower_client); |
1832 | - |
1833 | - if (is_closed != priv->laptop_lid_is_closed) { |
1834 | - priv->laptop_lid_is_closed = is_closed; |
1835 | - if (!follow_laptop_lid(manager)) |
1836 | - return; |
1837 | - |
1838 | - /* Refresh the RANDR state. The lid just got opened/closed, so we can afford to |
1839 | - * probe the outputs right now. It will also help the case where we can't detect |
1840 | - * hotplug/unplug, but the fact that the lid's state changed lets us know that the |
1841 | - * user probably did something interesting. |
1842 | - */ |
1843 | - |
1844 | - gnome_rr_screen_refresh (priv->rw_screen, NULL); /* NULL-GError */ |
1845 | - |
1846 | - if (is_closed) |
1847 | - turn_off_laptop_display (manager, GDK_CURRENT_TIME); /* sucks not to have a timestamp for the notification */ |
1848 | - else |
1849 | - use_stored_configuration_or_auto_configure_outputs (manager, GDK_CURRENT_TIME); |
1850 | - } |
1851 | + |
1852 | + } |
1853 | + |
1854 | + manager->priv->upower_client = up_client_new (); |
1855 | + |
1856 | + log_msg ("State of screen at startup:\n"); |
1857 | + log_screen (manager->priv->rw_screen); |
1858 | + |
1859 | + manager->priv->running = TRUE; |
1860 | + manager->priv->settings = g_settings_new (CONF_SCHEMA); |
1861 | + |
1862 | + log_close (); |
1863 | } |
1864 | |
1865 | gboolean |
1866 | @@ -2043,38 +1345,8 @@ |
1867 | log_open (); |
1868 | log_msg ("------------------------------------------------------------\nSTARTING XRANDR PLUGIN\n"); |
1869 | |
1870 | - manager->priv->rw_screen = gnome_rr_screen_new (gdk_screen_get_default (), error); |
1871 | - |
1872 | - if (manager->priv->rw_screen == NULL) { |
1873 | - log_msg ("Could not initialize the RANDR plugin%s%s\n", |
1874 | - (error && *error) ? ": " : "", |
1875 | - (error && *error) ? (*error)->message : ""); |
1876 | - log_close (); |
1877 | - return FALSE; |
1878 | - } |
1879 | - |
1880 | - g_signal_connect (manager->priv->rw_screen, "changed", G_CALLBACK (on_randr_event), manager); |
1881 | - |
1882 | - manager->priv->upower_client = up_client_new (); |
1883 | - manager->priv->laptop_lid_is_closed = up_client_get_lid_is_closed (manager->priv->upower_client); |
1884 | - g_signal_connect (manager->priv->upower_client, "changed", |
1885 | - G_CALLBACK (power_client_changed_cb), manager); |
1886 | - |
1887 | - log_msg ("State of screen at startup:\n"); |
1888 | - log_screen (manager->priv->rw_screen); |
1889 | - |
1890 | - manager->priv->running = TRUE; |
1891 | - manager->priv->settings = g_settings_new (CONF_SCHEMA); |
1892 | - |
1893 | - show_timestamps_dialog (manager, "Startup"); |
1894 | - if (!apply_stored_configuration_at_startup (manager, GDK_CURRENT_TIME)) /* we don't have a real timestamp at startup anyway */ |
1895 | - if (!apply_default_configuration_from_file (manager, GDK_CURRENT_TIME)) |
1896 | - apply_default_boot_configuration (manager, GDK_CURRENT_TIME); |
1897 | - |
1898 | - log_msg ("State of screen after initial configuration:\n"); |
1899 | - log_screen (manager->priv->rw_screen); |
1900 | - |
1901 | - log_close (); |
1902 | + gnome_rr_screen_new_async (gdk_screen_get_default (), |
1903 | + on_rr_screen_acquired, manager); |
1904 | |
1905 | gnome_settings_profile_end (NULL); |
1906 | |
1907 | @@ -2186,21 +1458,10 @@ |
1908 | GDBusMethodInvocation *invocation) |
1909 | { |
1910 | gint64 timestamp; |
1911 | - GError *error = NULL; |
1912 | |
1913 | g_debug ("Calling method '%s' for org.gnome.SettingsDaemon.XRANDR_2", method_name); |
1914 | |
1915 | - if (g_strcmp0 (method_name, "ApplyConfiguration") == 0) { |
1916 | - gint64 parent_window_id; |
1917 | - |
1918 | - g_variant_get (parameters, "(xx)", &parent_window_id, ×tamp); |
1919 | - if (gsd_xrandr_manager_2_apply_configuration (manager, parent_window_id, |
1920 | - clamp_timestamp(timestamp), &error) == FALSE) { |
1921 | - g_dbus_method_invocation_return_gerror (invocation, error); |
1922 | - } else { |
1923 | - g_dbus_method_invocation_return_value (invocation, NULL); |
1924 | - } |
1925 | - } else if (g_strcmp0 (method_name, "VideoModeSwitch") == 0) { |
1926 | + if (g_strcmp0 (method_name, "VideoModeSwitch") == 0) { |
1927 | g_variant_get (parameters, "(x)", ×tamp); |
1928 | gsd_xrandr_manager_2_video_mode_switch (manager, clamp_timestamp(timestamp), NULL); |
1929 | g_dbus_method_invocation_return_value (invocation, NULL); |
Thank you for your work but trusty has gnome-desktop 3.8 /launchpad. net/distros/ ubuntu/ +source/ gnome-desktop3
https:/