Merge lp:~kalgasnik/lightdm-gtk-greeter/lp-1377743-indicator-services-restart-after-every-resume into lp:~lightdm-gtk-greeter-team/lightdm-gtk-greeter/trunk

Proposed by Andrew P.
Status: Merged
Merged at revision: 313
Proposed branch: lp:~kalgasnik/lightdm-gtk-greeter/lp-1377743-indicator-services-restart-after-every-resume
Merge into: lp:~lightdm-gtk-greeter-team/lightdm-gtk-greeter/trunk
Diff against target: 211 lines (+62/-45)
1 file modified
src/lightdm-gtk-greeter.c (+62/-45)
To merge this branch: bzr merge lp:~kalgasnik/lightdm-gtk-greeter/lp-1377743-indicator-services-restart-after-every-resume
Reviewer Review Type Date Requested Status
Sean Davis Approve
Review via email: mp+243145@code.launchpad.net

Description of the change

#1377743: indicator services restart after every resume

#1366534: lightdm lefts a11y (at-spi*) process behind
This solution is better than one used in debian, but I don't like it too.
It's still possible to see lightdm's at-spi processes after login in some cases.
Needs testing.

To post a comment you must log in.
Revision history for this message
Sean Davis (bluesabre) wrote :

Verified with Xubuntu 14.10. Merging into trunk for a wider testing audience.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/lightdm-gtk-greeter.c'
2--- src/lightdm-gtk-greeter.c 2014-09-01 07:58:56 +0000
3+++ src/lightdm-gtk-greeter.c 2014-11-28 12:04:27 +0000
4@@ -61,6 +61,11 @@
5 static gchar *state_filename;
6 static void save_state_file (void);
7
8+/* Terminating */
9+GSList *pids_to_close = NULL;
10+static void sigterm_cb (gpointer user_data);
11+static void close_pid (GPid *pid, gboolean remove);
12+
13 /* Screen window */
14 static GtkOverlay *screen_overlay;
15
16@@ -254,11 +259,7 @@
17 /* Maybe unnecessary (in future) trick to enable accelerators for hidden/detached menu items */
18 static void reassign_menu_item_accel (GtkWidget *item);
19
20-#ifdef START_INDICATOR_SERVICES
21-static void init_indicators (GKeyFile* config, GPid* indicator_pid, GPid* spi_pid);
22-#else
23 static void init_indicators (GKeyFile* config);
24-#endif
25
26 static void layout_selected_cb (GtkCheckMenuItem *menuitem, gpointer user_data);
27 static void update_layouts_menu (void);
28@@ -312,6 +313,31 @@
29 }
30 }
31
32+/* Terminating */
33+
34+static void
35+sigterm_cb (gpointer user_data)
36+{
37+ g_slist_foreach (pids_to_close, (GFunc)close_pid, GINT_TO_POINTER (FALSE));
38+ g_slist_free (pids_to_close);
39+ pids_to_close = NULL;
40+ gtk_main_quit ();
41+}
42+
43+static void
44+close_pid (GPid *ppid, gboolean remove)
45+{
46+ if (!ppid || !*ppid)
47+ return;
48+
49+ if (remove)
50+ pids_to_close = g_slist_remove (pids_to_close, GINT_TO_POINTER (*ppid));
51+
52+ kill (*ppid, SIGTERM);
53+ waitpid (*ppid, NULL, 0);
54+ *ppid = 0;
55+}
56+
57 /* Power window */
58
59 static gboolean
60@@ -755,7 +781,11 @@
61 g_child_watch_add (command->pid, (GChildWatchFunc)menu_command_terminated_cb, command);
62 }
63
64- if (!spawned)
65+ if (spawned)
66+ {
67+ pids_to_close = g_slist_prepend (pids_to_close, GINT_TO_POINTER (command->pid));
68+ }
69+ else
70 {
71 if (error)
72 g_warning ("Command spawning error: '%s'", error->message);
73@@ -773,9 +803,7 @@
74
75 if (command->pid)
76 {
77- kill (command->pid, SIGTERM);
78- g_spawn_close_pid (command->pid);
79- command->pid = 0;
80+ close_pid (&command->pid, TRUE);
81 if (command->menu_item)
82 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (command->menu_item), FALSE);
83 if (command->widget)
84@@ -1293,11 +1321,7 @@
85 }
86
87 static void
88-#ifdef START_INDICATOR_SERVICES
89-init_indicators (GKeyFile* config, GPid* indicator_pid, GPid* spi_pid)
90-#else
91 init_indicators (GKeyFile* config)
92-#endif
93 {
94 gchar **names = NULL;
95 gsize length = 0;
96@@ -1313,12 +1337,6 @@
97 const gchar *DEFAULT_LAYOUT[] = {"~host", "~spacer", "~clock", "~spacer",
98 "~session", "~language", "~a11y", "~power", NULL};
99
100-#ifdef START_INDICATOR_SERVICES
101- GError *error = NULL;
102- gchar *AT_SPI_CMD[] = {"/usr/lib/at-spi2-core/at-spi-bus-launcher", "--launch-immediately", NULL};
103- gchar *INDICATORS_CMD[] = {"init", "--user", "--startup-event", "indicator-services-start", NULL};
104-#endif
105-
106 if (g_key_file_has_key (config, "greeter", "indicators", NULL))
107 { /* no option = default list, empty value = empty list */
108 names = g_key_file_get_string_list (config, "greeter", "indicators", &length, NULL);
109@@ -1399,12 +1417,14 @@
110 greeter_set_env ("GVFS_DISABLE_FUSE", "1");
111
112 #ifdef START_INDICATOR_SERVICES
113- if (!g_spawn_async (NULL, AT_SPI_CMD, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, spi_pid, &error))
114- g_warning ("Failed to run \"at-spi-bus-launcher\": %s", error->message);
115- g_clear_error (&error);
116+ gchar *INDICATORS_CMD[] = {"init", "--user", "--startup-event", "indicator-services-start", NULL};
117+ GError *error = NULL;
118+ GPid pid = 0;
119
120- if (!g_spawn_async (NULL, INDICATORS_CMD, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, indicator_pid, &error))
121- g_warning ("Failed to run \"indicator-services\": %s", error->message);
122+ if (g_spawn_async (NULL, INDICATORS_CMD, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &pid, &error))
123+ pids_to_close = g_slist_prepend (pids_to_close, GINT_TO_POINTER (pid));
124+ else
125+ g_warning ("[Greeter] Failed to run 'init --startup-event indicator-services-start': %s", error->message);
126 g_clear_error (&error);
127 #endif
128 inited = TRUE;
129@@ -2457,10 +2477,6 @@
130 GError *error = NULL;
131 Display *display;
132
133- #ifdef START_INDICATOR_SERVICES
134- GPid indicator_pid = 0, spi_pid = 0;
135- #endif
136-
137 /* Prevent memory from being swapped out, as we are dealing with passwords */
138 mlockall (MCL_CURRENT | MCL_FUTURE);
139
140@@ -2470,13 +2486,16 @@
141 /* LP: #1024482 */
142 g_setenv ("GDK_CORE_DEVICE_EVENTS", "1", TRUE);
143
144+ /* LP: #1366534 */
145+ g_setenv ("NO_AT_BRIDGE", "1", TRUE);
146+
147 /* Initialize i18n */
148 setlocale (LC_ALL, "");
149 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
150 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
151 textdomain (GETTEXT_PACKAGE);
152
153- g_unix_signal_add (SIGTERM, (GSourceFunc)gtk_main_quit, NULL);
154+ g_unix_signal_add (SIGTERM, (GSourceFunc)sigterm_cb, pids_to_close);
155
156 /* init gtk */
157 gtk_init (&argc, &argv);
158@@ -2638,11 +2657,7 @@
159 gtk_accel_map_add_entry ("<Login>/a11y/reader", GDK_KEY_F4, 0);
160 gtk_accel_map_add_entry ("<Login>/power/shutdown", GDK_KEY_F4, GDK_MOD1_MASK);
161
162-#ifdef START_INDICATOR_SERVICES
163- init_indicators (config, &indicator_pid, &spi_pid);
164-#else
165 init_indicators (config);
166-#endif
167
168 /* Hide empty panel */
169 GList *menubar_items = gtk_container_get_children (GTK_CONTAINER (menubar));
170@@ -2765,6 +2780,20 @@
171 gtk_widget_set_visible (reader_menuitem, a11y_reader_command != NULL);
172 g_free (value);
173
174+ if (a11y_keyboard_command || a11y_reader_command)
175+ {
176+ gchar *AT_SPI_CMD[] = {"/usr/lib/at-spi2-core/at-spi-bus-launcher", "--launch-immediately", NULL};
177+ GPid pid = 0;
178+ if (g_spawn_async (NULL, AT_SPI_CMD, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &pid, &error))
179+ {
180+ g_debug ("[Greeter] AT-SPI launched");
181+ pids_to_close = g_slist_prepend (pids_to_close, GINT_TO_POINTER (pid));
182+ }
183+ else
184+ g_warning ("[Greeter] Failed to launch AT-SPI: %s", error->message);
185+ g_clear_error (&error);
186+ }
187+
188 /* Power menu */
189 if (gtk_widget_get_visible (power_menuitem))
190 {
191@@ -2965,19 +2994,7 @@
192
193 gtk_main ();
194
195-#ifdef START_INDICATOR_SERVICES
196- if (indicator_pid)
197- {
198- kill (indicator_pid, SIGTERM);
199- waitpid (indicator_pid, NULL, 0);
200- }
201-
202- if (spi_pid)
203- {
204- kill (spi_pid, SIGTERM);
205- waitpid (spi_pid, NULL, 0);
206- }
207-#endif
208+ g_slist_foreach (pids_to_close, (GFunc)close_pid, NULL);
209
210 return EXIT_SUCCESS;
211 }

Subscribers

People subscribed via source and target branches