Merge lp:~laney/bamf/multiple-xdg-current-desktop-values into lp:bamf

Proposed by Iain Lane
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: 650
Merged at revision: 649
Proposed branch: lp:~laney/bamf/multiple-xdg-current-desktop-values
Merge into: lp:bamf
Diff against target: 135 lines (+27/-15)
3 files modified
src/bamf-application.c (+5/-3)
src/bamf-legacy-screen.c (+10/-1)
src/bamf-matcher.c (+12/-11)
To merge this branch: bzr merge lp:~laney/bamf/multiple-xdg-current-desktop-values
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Unity Team Pending
Review via email: mp+307189@code.launchpad.net

Commit message

Adjust for XDG_CURRENT_DESKTOP containing multiple colon-separated values

Description of the change

XDG_CURRENT_DESKTOP for Unity 7 now contains multiple values.

bamf needs to get along with this.

To post a comment you must log in.
Revision history for this message
Iain Lane (laney) wrote :

This bug makes new nautilus windows not match the launcher icon in Yakkety currently

650. By Iain Lane on 2016-09-29

Don't leak current_desktops

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Looks good, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/bamf-application.c'
2--- src/bamf-application.c 2016-04-08 21:54:32 +0000
3+++ src/bamf-application.c 2016-09-29 15:41:58 +0000
4@@ -673,13 +673,15 @@
5
6 if (curdesktop)
7 {
8- const gchar* show_in_list[] = { curdesktop, NULL };
9+ gchar** show_in_list = g_strsplit (curdesktop, ":", 0);
10 g_key_file_set_string_list (key_file, G_KEY_FILE_DESKTOP_GROUP,
11 G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN,
12- show_in_list, 1);
13+ (const gchar * const *) show_in_list, 1);
14+ g_strfreev (show_in_list);
15 }
16
17- gchar *generator = g_strdup_printf ("X-%sGenerated", curdesktop ? curdesktop : "BAMF");
18+ gchar *generator = g_strdup_printf ("X-%sGenerated", curdesktop && !g_strstr_len(curdesktop, -1, ":") ?
19+ curdesktop : "BAMF");
20 g_key_file_set_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, generator, TRUE);
21 g_free (generator);
22
23
24=== modified file 'src/bamf-legacy-screen.c'
25--- src/bamf-legacy-screen.c 2016-06-13 22:27:18 +0000
26+++ src/bamf-legacy-screen.c 2016-09-29 15:41:58 +0000
27@@ -580,6 +580,8 @@
28 {
29 BamfLegacyScreen *self;
30 Display *dpy;
31+ gchar **current_desktops = NULL;
32+ const gchar *xdg_current_desktop;
33
34 if (static_screen)
35 return static_screen;
36@@ -613,13 +615,20 @@
37 g_signal_connect (G_OBJECT (self->priv->legacy_screen), "active-window-changed",
38 (GCallback) handle_active_window_changed, self);
39
40- if (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0)
41+ xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
42+
43+ if (xdg_current_desktop)
44+ current_desktops = g_strsplit (xdg_current_desktop, ":", 0);
45+
46+ if (current_desktops && g_strv_contains ((const gchar * const *) current_desktops, "Unity"))
47 {
48 _COMPIZ_TOOLKIT_ACTION = XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION", False);
49 _COMPIZ_TOOLKIT_ACTION_WINDOW_MENU = XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION_WINDOW_MENU", False);
50 gdk_window_add_filter (NULL, filter_compiz_messages, self);
51 }
52
53+ g_strfreev (current_desktops);
54+
55 return static_screen;
56 }
57
58
59=== modified file 'src/bamf-matcher.c'
60--- src/bamf-matcher.c 2016-06-13 22:27:18 +0000
61+++ src/bamf-matcher.c 2016-09-29 15:41:58 +0000
62@@ -827,7 +827,6 @@
63 {
64 GDesktopAppInfo *desktop_file;
65 gboolean no_display;
66- const char *current_desktop;
67 char *exec;
68 char *path;
69 GString *desktop_id; /* is ok... really */
70@@ -841,9 +840,7 @@
71 return;
72 }
73
74- current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
75-
76- if (current_desktop && !g_desktop_app_info_get_show_in (desktop_file, current_desktop))
77+ if (!g_desktop_app_info_get_show_in (desktop_file, NULL))
78 {
79 g_object_unref (desktop_file);
80 return;
81@@ -945,7 +942,8 @@
82 GDataInputStream *input;
83 char *line;
84 char *directory;
85- const char *current_desktop;
86+ gchar **current_desktops = NULL;
87+ const gchar *xdg_current_desktop;
88 gsize length;
89
90 file = g_file_new_for_path (index_file);
91@@ -961,13 +959,15 @@
92 }
93
94 length = 0;
95- current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
96+
97+ xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP");
98+
99+ if (xdg_current_desktop)
100+ current_desktops = g_strsplit (xdg_current_desktop, ":", 0);
101+
102 directory = g_path_get_dirname (index_file);
103 input = g_data_input_stream_new (G_INPUT_STREAM (stream));
104
105- if (current_desktop && current_desktop[0] == '\0')
106- current_desktop = NULL;
107-
108 while ((line = g_data_input_stream_read_line (input, &length, NULL, NULL)))
109 {
110 char *exec;
111@@ -982,7 +982,7 @@
112
113 show_in = parts[3];
114
115- if (current_desktop && show_in && show_in[0] != '\0')
116+ if (current_desktops && show_in && show_in[0] != '\0')
117 {
118 gchar **sub_parts = g_strsplit (show_in, ";", -1);
119 gboolean found_current = FALSE;
120@@ -990,7 +990,7 @@
121
122 for (i = 0; sub_parts[i]; ++i)
123 {
124- if (g_ascii_strcasecmp (sub_parts[i], current_desktop) == 0)
125+ if (g_strv_contains ((const gchar * const *) current_desktops, sub_parts[i]) == 0)
126 {
127 found_current = TRUE;
128 break;
129@@ -1041,6 +1041,7 @@
130 g_object_unref (input);
131 g_object_unref (stream);
132 g_object_unref (file);
133+ g_strfreev (current_desktops);
134 g_free (directory);
135 }
136

Subscribers

People subscribed via source and target branches

to all changes: