diff options
| author | Iain Lane <iain.lane@canonical.com> | 2016-09-29 16:12:07 +0000 |
|---|---|---|
| committer | Bileto Bot <ci-train-bot@canonical.com> | 2016-09-29 16:12:07 +0000 |
| commit | 64cd012a36dd200fa938682ad0550814c898be15 (patch) | |
| tree | 6353d443e1b7e4d267c1b5404edd033052775da6 | |
| parent | 3a675b44dd96fd9f5a3554b2707ee21a20e1977c (diff) | |
| parent | c4d4d8759ff25db5f332c3aa2c0fe5e0ad7c317c (diff) | |
Adjust for XDG_CURRENT_DESKTOP containing multiple colon-separated values
Approved by: Marco Trevisan (TreviƱo) (bzr r649)
| -rw-r--r-- | src/bamf-application.c | 8 | ||||
| -rw-r--r-- | src/bamf-legacy-screen.c | 11 | ||||
| -rw-r--r-- | src/bamf-matcher.c | 23 |
3 files changed, 27 insertions, 15 deletions
diff --git a/src/bamf-application.c b/src/bamf-application.c index 81f30295..139f420f 100644 --- a/src/bamf-application.c +++ b/src/bamf-application.c @@ -673,13 +673,15 @@ bamf_application_create_local_desktop_file (BamfApplication *self) if (curdesktop) { - const gchar* show_in_list[] = { curdesktop, NULL }; + gchar** show_in_list = g_strsplit (curdesktop, ":", 0); g_key_file_set_string_list (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN, - show_in_list, 1); + (const gchar * const *) show_in_list, 1); + g_strfreev (show_in_list); } - gchar *generator = g_strdup_printf ("X-%sGenerated", curdesktop ? curdesktop : "BAMF"); + gchar *generator = g_strdup_printf ("X-%sGenerated", curdesktop && !g_strstr_len(curdesktop, -1, ":") ? + curdesktop : "BAMF"); g_key_file_set_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, generator, TRUE); g_free (generator); diff --git a/src/bamf-legacy-screen.c b/src/bamf-legacy-screen.c index 00b3ebac..f50f4854 100644 --- a/src/bamf-legacy-screen.c +++ b/src/bamf-legacy-screen.c @@ -580,6 +580,8 @@ bamf_legacy_screen_get_default () { BamfLegacyScreen *self; Display *dpy; + gchar **current_desktops = NULL; + const gchar *xdg_current_desktop; if (static_screen) return static_screen; @@ -613,13 +615,20 @@ bamf_legacy_screen_get_default () g_signal_connect (G_OBJECT (self->priv->legacy_screen), "active-window-changed", (GCallback) handle_active_window_changed, self); - if (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0) + xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP"); + + if (xdg_current_desktop) + current_desktops = g_strsplit (xdg_current_desktop, ":", 0); + + if (current_desktops && g_strv_contains ((const gchar * const *) current_desktops, "Unity")) { _COMPIZ_TOOLKIT_ACTION = XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION", False); _COMPIZ_TOOLKIT_ACTION_WINDOW_MENU = XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION_WINDOW_MENU", False); gdk_window_add_filter (NULL, filter_compiz_messages, self); } + g_strfreev (current_desktops); + return static_screen; } diff --git a/src/bamf-matcher.c b/src/bamf-matcher.c index 7f9c487d..e686ec56 100644 --- a/src/bamf-matcher.c +++ b/src/bamf-matcher.c @@ -827,7 +827,6 @@ load_desktop_file_to_table (BamfMatcher * self, { GDesktopAppInfo *desktop_file; gboolean no_display; - const char *current_desktop; char *exec; char *path; GString *desktop_id; /* is ok... really */ @@ -841,9 +840,7 @@ load_desktop_file_to_table (BamfMatcher * self, return; } - current_desktop = g_getenv ("XDG_CURRENT_DESKTOP"); - - if (current_desktop && !g_desktop_app_info_get_show_in (desktop_file, current_desktop)) + if (!g_desktop_app_info_get_show_in (desktop_file, NULL)) { g_object_unref (desktop_file); return; @@ -945,7 +942,8 @@ load_index_file_to_table (BamfMatcher * self, GDataInputStream *input; char *line; char *directory; - const char *current_desktop; + gchar **current_desktops = NULL; + const gchar *xdg_current_desktop; gsize length; file = g_file_new_for_path (index_file); @@ -961,13 +959,15 @@ load_index_file_to_table (BamfMatcher * self, } length = 0; - current_desktop = g_getenv ("XDG_CURRENT_DESKTOP"); + + xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP"); + + if (xdg_current_desktop) + current_desktops = g_strsplit (xdg_current_desktop, ":", 0); + directory = g_path_get_dirname (index_file); input = g_data_input_stream_new (G_INPUT_STREAM (stream)); - if (current_desktop && current_desktop[0] == '\0') - current_desktop = NULL; - while ((line = g_data_input_stream_read_line (input, &length, NULL, NULL))) { char *exec; @@ -982,7 +982,7 @@ load_index_file_to_table (BamfMatcher * self, show_in = parts[3]; - if (current_desktop && show_in && show_in[0] != '\0') + if (current_desktops && show_in && show_in[0] != '\0') { gchar **sub_parts = g_strsplit (show_in, ";", -1); gboolean found_current = FALSE; @@ -990,7 +990,7 @@ load_index_file_to_table (BamfMatcher * self, for (i = 0; sub_parts[i]; ++i) { - if (g_ascii_strcasecmp (sub_parts[i], current_desktop) == 0) + if (g_strv_contains ((const gchar * const *) current_desktops, sub_parts[i]) == 0) { found_current = TRUE; break; @@ -1041,6 +1041,7 @@ load_index_file_to_table (BamfMatcher * self, g_object_unref (input); g_object_unref (stream); g_object_unref (file); + g_strfreev (current_desktops); g_free (directory); } |
