Merge lp:~khurshid-alam/unity-settings-daemon/media-keys-fix into lp:unity-settings-daemon

Proposed by Khurshid Alam
Status: Merged
Merged at revision: 4189
Proposed branch: lp:~khurshid-alam/unity-settings-daemon/media-keys-fix
Merge into: lp:unity-settings-daemon
Diff against target: 217 lines (+53/-27)
1 file modified
plugins/media-keys/gsd-media-keys-manager.c (+53/-27)
To merge this branch: bzr merge lp:~khurshid-alam/unity-settings-daemon/media-keys-fix
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
Review via email: mp+359935@code.launchpad.net

Commit message

* media-keys: Add more debug info

  This backports commits dc13b2d, 5f01643 & a09ae56 from gnome-settings-daemon.

* media-keys: Fix cancelled async calls usage

  This backports commits 86cbfda + 5147e6b & 214145c from gnome-settings-daemon.

* DESKTOP_SESSION is now unity

  Unity uses legacy key-grabber code. But since artful unity isn't the default session anymore and DESKTOP_SESSION changed from ubuntu to unity. Fixes LP: #1755106 LP: #1188569 LP: #1727842

Description of the change

It may seem unnecessary to add debug info for each dbus method call (revno: 4187), but I noticed session name change only after I added the debug info in the first place. Beside I don't want to partially backport commit for no reason. They do no harm.

And since I have other fixes just for media-keys plugin, this will keep size of each MR & no of MRs short.

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks, that looks fine to me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/media-keys/gsd-media-keys-manager.c'
2--- plugins/media-keys/gsd-media-keys-manager.c 2017-10-03 05:07:39 +0000
3+++ plugins/media-keys/gsd-media-keys-manager.c 2018-11-30 16:30:16 +0000
4@@ -223,7 +223,7 @@
5 GDBusConnection *connection;
6 GCancellable *bus_cancellable;
7 GDBusProxy *xrandr_proxy;
8- GCancellable *cancellable;
9+ GCancellable *cancellable; /* Only used for XRandR operations */
10
11 guint start_idle_id;
12
13@@ -699,6 +699,7 @@
14 {
15 GsdMediaKeysManager *manager = data;
16
17+ g_debug ("Retrying to grab accelerators");
18 grab_media_keys (manager);
19 return FALSE;
20 }
21@@ -718,8 +719,10 @@
22
23 if (error) {
24 retry = (error->code == G_DBUS_ERROR_UNKNOWN_METHOD);
25- if (!retry)
26- g_warning ("%d: %s", error->code, error->message);
27+ if (!retry && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
28+ g_warning ("Failed to grab accelerators: %s (%d)", error->message, error->code);
29+ else if (retry)
30+ g_debug ("Failed to grab accelerators, will retry: %s (%d)", error->message, error->code);
31 g_error_free (error);
32 } else {
33 int i;
34@@ -768,9 +771,14 @@
35 {
36 GrabData *data = user_data;
37 MediaKey *key = data->key;
38+ GError *error = NULL;
39
40- shell_key_grabber_call_grab_accelerator_finish (SHELL_KEY_GRABBER (object),
41- &key->accel_id, result, NULL);
42+ if (!shell_key_grabber_call_grab_accelerator_finish (SHELL_KEY_GRABBER (object),
43+ &key->accel_id, result, &error)) {
44+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
45+ g_warning ("Failed to grab accelerator: %s", error->message);
46+ g_error_free (error);
47+ }
48
49 g_slice_free (GrabData, data);
50 }
51@@ -838,8 +846,14 @@
52 gpointer user_data)
53 {
54 GsdMediaKeysManager *manager = user_data;
55- shell_key_grabber_call_ungrab_accelerator_finish (SHELL_KEY_GRABBER (object),
56- NULL, result, NULL);
57+
58+ GError *error = NULL;
59+ if (!shell_key_grabber_call_ungrab_accelerator_finish (SHELL_KEY_GRABBER (object),
60+ NULL, result, &error)) {
61+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
62+ g_warning ("Failed to ungrab accelerator: %s", error->message);
63+ g_error_free (error);
64+ }
65 }
66
67 static void
68@@ -1390,7 +1404,7 @@
69 priv->screen_saver_proxy = gnome_settings_bus_get_screen_saver_proxy ();
70
71 gsd_screen_saver_call_lock (priv->screen_saver_proxy,
72- priv->cancellable,
73+ priv->bus_cancellable,
74 (GAsyncReadyCallback) on_screen_locked,
75 manager);
76 }
77@@ -2005,7 +2019,8 @@
78 manager->priv->cancellable = NULL;
79
80 if (error != NULL) {
81- g_warning ("Unable to call '%s': %s", action, error->message);
82+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
83+ g_warning ("Failed to complete XRandR action: %s", error->message);
84 g_error_free (error);
85 } else {
86 g_variant_unref (variant);
87@@ -2275,7 +2290,7 @@
88 guint first;
89 gint i, n;
90
91- if (g_strcmp0 (g_getenv ("DESKTOP_SESSION"), "ubuntu") != 0)
92+ if (g_strcmp0 (g_getenv ("DESKTOP_SESSION"), "unity") != 0)
93 if (!priv->have_legacy_keygrabber)
94 return;
95
96@@ -2817,6 +2832,9 @@
97 {
98 guint i;
99
100+ g_debug ("Received accel id %u (device-id: %u, timestamp: %u",
101+ accel_id, deviceid, timestamp);
102+
103 for (i = 0; i < manager->priv->keys->len; i++) {
104 MediaKey *key;
105
106@@ -2831,6 +2849,8 @@
107 do_action (manager, deviceid, key->key_type, timestamp);
108 return;
109 }
110+
111+ g_warning ("Could not find accelerator for accel id %u", accel_id);
112 }
113
114 static void
115@@ -2962,12 +2982,17 @@
116 gpointer data)
117 {
118 GsdMediaKeysManager *manager = data;
119+ GError *error = NULL;
120
121 manager->priv->key_grabber =
122- shell_key_grabber_proxy_new_for_bus_finish (result, NULL);
123+ shell_key_grabber_proxy_new_for_bus_finish (result, &error);
124
125- if (!manager->priv->key_grabber)
126+ if (!manager->priv->key_grabber) {
127+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
128+ g_warning ("Failed to create proxy for key grabber: %s", error->message);
129+ g_error_free (error);
130 return;
131+ }
132
133 g_signal_connect (manager->priv->key_grabber, "accelerator-activated",
134 G_CALLBACK (on_accelerator_activated), manager);
135@@ -2979,7 +3004,7 @@
136 session_has_key_grabber (void)
137 {
138 const gchar *session = g_getenv ("DESKTOP_SESSION");
139- return g_strcmp0 (session, "gnome") == 0 || g_strcmp0 (session, "ubuntu") == 0;
140+ return g_strcmp0 (session, "gnome") == 0 || g_strcmp0 (session, "unity") == 0;
141 }
142
143 static void
144@@ -3379,7 +3404,8 @@
145
146 res = g_dbus_proxy_call_with_unix_fd_list_finish (proxy, &fd_list, result, &error);
147 if (res == NULL) {
148- g_warning ("Unable to inhibit keypresses: %s", error->message);
149+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
150+ g_warning ("Unable to inhibit keypresses: %s", error->message);
151 g_error_free (error);
152 } else {
153 g_variant_get (res, "(h)", &idx);
154@@ -3478,7 +3504,8 @@
155
156 manager->priv->xrandr_proxy = g_dbus_proxy_new_finish (res, &error);
157 if (manager->priv->xrandr_proxy == NULL) {
158- g_warning ("Failed to get proxy for XRandR operations: %s", error->message);
159+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
160+ g_warning ("Failed to get proxy for XRandR operations: %s", error->message);
161 g_error_free (error);
162 }
163 }
164@@ -3492,8 +3519,9 @@
165
166 manager->priv->power_proxy = g_dbus_proxy_new_finish (res, &error);
167 if (manager->priv->power_proxy == NULL) {
168- g_warning ("Failed to get proxy for power: %s",
169- error->message);
170+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
171+ g_warning ("Failed to get proxy for power: %s",
172+ error->message);
173 g_error_free (error);
174 }
175 }
176@@ -3507,8 +3535,9 @@
177
178 manager->priv->power_screen_proxy = g_dbus_proxy_new_finish (res, &error);
179 if (manager->priv->power_screen_proxy == NULL) {
180- g_warning ("Failed to get proxy for power (screen): %s",
181- error->message);
182+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
183+ g_warning ("Failed to get proxy for power (screen): %s",
184+ error->message);
185 g_error_free (error);
186 }
187 }
188@@ -3522,8 +3551,9 @@
189
190 manager->priv->power_keyboard_proxy = g_dbus_proxy_new_finish (res, &error);
191 if (manager->priv->power_keyboard_proxy == NULL) {
192- g_warning ("Failed to get proxy for power (keyboard): %s",
193- error->message);
194+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
195+ g_warning ("Failed to get proxy for power (keyboard): %s",
196+ error->message);
197 g_error_free (error);
198 }
199 }
200@@ -3536,15 +3566,11 @@
201 GDBusConnection *connection;
202 GError *error = NULL;
203
204- if (manager->priv->bus_cancellable == NULL ||
205- g_cancellable_is_cancelled (manager->priv->bus_cancellable)) {
206- g_warning ("Operation has been cancelled, so not retrieving session bus");
207- return;
208- }
209
210 connection = g_bus_get_finish (res, &error);
211 if (connection == NULL) {
212- g_warning ("Could not get session bus: %s", error->message);
213+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
214+ g_warning ("Could not get session bus: %s", error->message);
215 g_error_free (error);
216 return;
217 }

Subscribers

People subscribed via source and target branches