Merge lp:~3v1n0/bamf/libreoffice-base-and-tests into lp:bamf/0.4
- libreoffice-base-and-tests
- Merge into 0.4
Proposed by
Marco Trevisan (Treviño)
Status: | Merged |
---|---|
Approved by: | Marco Trevisan (Treviño) |
Approved revision: | 497 |
Merged at revision: | 492 |
Proposed branch: | lp:~3v1n0/bamf/libreoffice-base-and-tests |
Merge into: | lp:bamf/0.4 |
Diff against target: |
1051 lines (+429/-112) 19 files modified
src/bamf-legacy-window-test.c (+62/-13) src/bamf-legacy-window-test.h (+6/-2) src/bamf-legacy-window.c (+27/-7) src/bamf-legacy-window.h (+11/-3) src/bamf-matcher.c (+25/-29) src/bamf-unity-webapps-tab.c (+0/-1) src/bamf-window.c (+5/-5) src/bamf-window.h (+1/-1) src/bamf-xutils.c (+55/-40) src/bamf-xutils.h (+2/-2) tests/bamfdaemon/data/libreoffice-base.desktop (+7/-0) tests/bamfdaemon/data/libreoffice-calc.desktop (+7/-0) tests/bamfdaemon/data/libreoffice-draw.desktop (+7/-0) tests/bamfdaemon/data/libreoffice-impress.desktop (+7/-0) tests/bamfdaemon/data/libreoffice-math.desktop (+7/-0) tests/bamfdaemon/data/libreoffice-startcenter.desktop (+7/-0) tests/bamfdaemon/data/libreoffice-writer.desktop (+7/-0) tests/bamfdaemon/test-matcher.c (+166/-9) tests/bamfdaemon/test-window.c (+20/-0) |
To merge this branch: | bzr merge lp:~3v1n0/bamf/libreoffice-base-and-tests |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Brandon Schaefer (community) | Approve | ||
jenkins | continuous-integration | Pending | |
Review via email:
|
Commit message
BamfMatcher: add support for libreoffice Base, and libreoffice matching tests
Description of the change
Added libreoffice base support to BAMF, at this point I've decided to add tests for the libreoffice matching in bamfdaemon; this required some refactoring in BamfLegacyWindow, adding an overridable setter/getter for the window hint (and that BamfLegacyWindo
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/bamf-legacy-window-test.c' |
2 | --- src/bamf-legacy-window-test.c 2012-07-31 15:11:20 +0000 |
3 | +++ src/bamf-legacy-window-test.c 2012-10-10 17:32:43 +0000 |
4 | @@ -127,16 +127,32 @@ |
5 | } |
6 | |
7 | void |
8 | -bamf_legacy_window_test_set_name (BamfLegacyWindowTest *self, char *val) |
9 | +bamf_legacy_window_test_set_name (BamfLegacyWindowTest *self, const char *val) |
10 | { |
11 | if (g_strcmp0 (self->name, val) == 0) |
12 | return; |
13 | |
14 | - self->name = val; |
15 | + self->name = g_strdup (val); |
16 | |
17 | g_signal_emit_by_name (self, "name-changed"); |
18 | } |
19 | |
20 | +void |
21 | +bamf_legacy_window_test_set_wmclass (BamfLegacyWindowTest *self, const char *class_name, const char *instance_name) |
22 | +{ |
23 | + if (g_strcmp0 (self->wm_class_name, class_name) != 0) |
24 | + { |
25 | + g_free (self->wm_class_name); |
26 | + self->wm_class_name = g_strdup (class_name); |
27 | + } |
28 | + |
29 | + if (g_strcmp0 (self->wm_class_instance, instance_name) != 0) |
30 | + { |
31 | + g_free (self->wm_class_instance); |
32 | + self->wm_class_instance = g_strdup (instance_name); |
33 | + } |
34 | +} |
35 | + |
36 | static const char * |
37 | bamf_legacy_window_test_get_name (BamfLegacyWindow *legacy_window) |
38 | { |
39 | @@ -154,7 +170,7 @@ |
40 | |
41 | self = BAMF_LEGACY_WINDOW_TEST (legacy_window); |
42 | |
43 | - return self->wm_class_name; |
44 | + return self->wm_class_name; |
45 | } |
46 | |
47 | static const char * |
48 | @@ -164,7 +180,7 @@ |
49 | |
50 | self = BAMF_LEGACY_WINDOW_TEST (legacy_window); |
51 | |
52 | - return self->wm_class_instance; |
53 | + return self->wm_class_instance; |
54 | } |
55 | |
56 | char * |
57 | @@ -174,7 +190,7 @@ |
58 | |
59 | self = BAMF_LEGACY_WINDOW_TEST (legacy_window); |
60 | |
61 | - return self->exec; |
62 | + return g_strdup (self->exec); |
63 | } |
64 | |
65 | char * |
66 | @@ -185,7 +201,7 @@ |
67 | |
68 | self = BAMF_LEGACY_WINDOW_TEST (legacy_window); |
69 | |
70 | - return self->application_id; |
71 | + return g_strdup (self->application_id); |
72 | } |
73 | |
74 | char * |
75 | @@ -196,7 +212,7 @@ |
76 | |
77 | self = BAMF_LEGACY_WINDOW_TEST (legacy_window); |
78 | |
79 | - return self->unique_bus_name; |
80 | + return g_strdup (self->unique_bus_name); |
81 | } |
82 | |
83 | char * |
84 | @@ -207,7 +223,7 @@ |
85 | |
86 | self = BAMF_LEGACY_WINDOW_TEST (legacy_window); |
87 | |
88 | - return self->dbus_menu_object_path; |
89 | + return g_strdup (self->dbus_menu_object_path); |
90 | } |
91 | |
92 | void |
93 | @@ -328,10 +344,39 @@ |
94 | return self->window_type; |
95 | } |
96 | |
97 | +char * |
98 | +bamf_legacy_window_test_get_hint (BamfLegacyWindow *window, const char *name) |
99 | +{ |
100 | + g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (window), NULL); |
101 | + BamfLegacyWindowTest *self = BAMF_LEGACY_WINDOW_TEST (window); |
102 | + |
103 | + return g_strdup (g_hash_table_lookup (self->hints, name)); |
104 | +} |
105 | + |
106 | void |
107 | -bamf_legacy_window_test_dispose (GObject *object) |
108 | -{ |
109 | - G_OBJECT_CLASS (bamf_legacy_window_test_parent_class)->dispose (object); |
110 | +bamf_legacy_window_test_set_hint (BamfLegacyWindow *window, const char *name, const char *value) |
111 | +{ |
112 | + g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (window)); |
113 | + BamfLegacyWindowTest *self = BAMF_LEGACY_WINDOW_TEST (window); |
114 | + |
115 | + return g_hash_table_insert (self->hints, g_strdup (name), g_strdup (value)); |
116 | +} |
117 | + |
118 | +static void |
119 | +bamf_legacy_window_test_finalize (GObject *object) |
120 | +{ |
121 | + BamfLegacyWindowTest *self = BAMF_LEGACY_WINDOW_TEST (object); |
122 | + |
123 | + g_free (self->name); |
124 | + g_free (self->wm_class_name); |
125 | + g_free (self->wm_class_instance); |
126 | + g_free (self->exec); |
127 | + g_free (self->application_id); |
128 | + g_free (self->unique_bus_name); |
129 | + g_free (self->dbus_menu_object_path); |
130 | + g_hash_table_unref (self->hints); |
131 | + |
132 | + G_OBJECT_CLASS (bamf_legacy_window_test_parent_class)->finalize (object); |
133 | } |
134 | |
135 | void |
136 | @@ -340,7 +385,7 @@ |
137 | BamfLegacyWindowClass *win_class = BAMF_LEGACY_WINDOW_CLASS (klass); |
138 | GObjectClass *obj_class = G_OBJECT_CLASS (klass); |
139 | |
140 | - obj_class->dispose = bamf_legacy_window_test_dispose; |
141 | + obj_class->finalize = bamf_legacy_window_test_finalize; |
142 | win_class->get_name = bamf_legacy_window_test_get_name; |
143 | win_class->get_class_name = bamf_legacy_window_test_get_class_name; |
144 | win_class->get_class_instance_name = bamf_legacy_window_test_get_class_instance_name; |
145 | @@ -358,6 +403,8 @@ |
146 | win_class->get_window_type = bamf_legacy_window_test_get_window_type; |
147 | win_class->maximized = bamf_legacy_window_test_maximized; |
148 | win_class->is_closed = bamf_legacy_window_test_is_closed; |
149 | + win_class->get_hint = bamf_legacy_window_test_get_hint; |
150 | + win_class->set_hint = bamf_legacy_window_test_set_hint; |
151 | win_class->reopen = bamf_legacy_window_test_reopen; |
152 | } |
153 | |
154 | @@ -368,6 +415,7 @@ |
155 | self->pid = g_random_int_range (1, 100000); |
156 | self->maximized = BAMF_WINDOW_FLOATING; |
157 | self->is_closed = FALSE; |
158 | + self->hints = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); |
159 | } |
160 | |
161 | |
162 | @@ -394,12 +442,13 @@ |
163 | copy->geometry = self->geometry; |
164 | copy->maximized = self->maximized; |
165 | copy->window_type = self->window_type; |
166 | + copy->hints = g_hash_table_ref (self->hints); |
167 | |
168 | return copy; |
169 | } |
170 | |
171 | BamfLegacyWindowTest * |
172 | -bamf_legacy_window_test_new (guint32 xid, gchar *name, gchar *wmclass_name, gchar *exec) |
173 | +bamf_legacy_window_test_new (guint32 xid, const gchar *name, const gchar *wmclass_name, const gchar *exec) |
174 | { |
175 | BamfLegacyWindowTest *self; |
176 | |
177 | |
178 | === modified file 'src/bamf-legacy-window-test.h' |
179 | --- src/bamf-legacy-window-test.h 2012-08-21 22:01:48 +0000 |
180 | +++ src/bamf-legacy-window-test.h 2012-10-10 17:32:43 +0000 |
181 | @@ -68,6 +68,7 @@ |
182 | GdkRectangle geometry; |
183 | BamfWindowMaximizationType maximized; |
184 | BamfWindowType window_type; |
185 | + GHashTable * hints; |
186 | }; |
187 | |
188 | struct _BamfLegacyWindowTestClass |
189 | @@ -116,7 +117,7 @@ |
190 | bamf_legacy_window_test_is_skip_tasklist (BamfLegacyWindow *legacy_window); |
191 | |
192 | void |
193 | -bamf_legacy_window_test_set_name (BamfLegacyWindowTest *self, char *val); |
194 | +bamf_legacy_window_test_set_name (BamfLegacyWindowTest *self, const char *val); |
195 | |
196 | void |
197 | bamf_legacy_window_test_set_geometry (BamfLegacyWindowTest *self, int x, int y, |
198 | @@ -136,10 +137,13 @@ |
199 | bamf_legacy_window_test_set_dbus_menu_object_path (BamfLegacyWindowTest *self, const char *object_path); |
200 | |
201 | void |
202 | +bamf_legacy_window_test_set_wmclass (BamfLegacyWindowTest *self, const char *class_name, const char *instance_name); |
203 | + |
204 | +void |
205 | bamf_legacy_window_test_close (BamfLegacyWindowTest *self); |
206 | |
207 | BamfLegacyWindowTest * |
208 | -bamf_legacy_window_test_new (guint32 xid, gchar *name, gchar *wmclass_name, gchar *exec); |
209 | +bamf_legacy_window_test_new (guint32 xid, const gchar *name, const gchar *wmclass_name, const gchar *exec); |
210 | |
211 | BamfLegacyWindowTest * |
212 | bamf_legacy_window_copy (BamfLegacyWindowTest *self); |
213 | |
214 | === modified file 'src/bamf-legacy-window.c' |
215 | --- src/bamf-legacy-window.c 2012-07-27 17:46:22 +0000 |
216 | +++ src/bamf-legacy-window.c 2012-10-10 17:32:43 +0000 |
217 | @@ -429,15 +429,35 @@ |
218 | } |
219 | |
220 | char * |
221 | -bamf_legacy_window_get_utf8_xprop (BamfLegacyWindow *self, const char* prop) |
222 | +bamf_legacy_window_get_hint (BamfLegacyWindow *self, const char *name) |
223 | { |
224 | g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), NULL); |
225 | - |
226 | - if (!self->priv->legacy_window) |
227 | - return NULL; |
228 | - |
229 | - guint xid = bamf_legacy_window_get_xid (self); |
230 | - return bamf_xutils_get_window_hint (xid, prop, XInternAtom(gdk_x11_get_default_xdisplay (), "UTF8_STRING", False)); |
231 | + g_return_val_if_fail (name, NULL); |
232 | + |
233 | + if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_hint) |
234 | + return BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_hint (self, name); |
235 | + |
236 | + g_return_val_if_fail (WNCK_IS_WINDOW (self->priv->legacy_window), NULL); |
237 | + |
238 | + guint xid = bamf_legacy_window_get_xid (self); |
239 | + |
240 | + return bamf_xutils_get_string_window_hint (xid, name); |
241 | +} |
242 | + |
243 | +void |
244 | +bamf_legacy_window_set_hint (BamfLegacyWindow *self, const char *name, const char *value) |
245 | +{ |
246 | + g_return_if_fail (BAMF_IS_LEGACY_WINDOW (self)); |
247 | + g_return_if_fail (name); |
248 | + |
249 | + if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->set_hint) |
250 | + return BAMF_LEGACY_WINDOW_GET_CLASS (self)->set_hint (self, name, value); |
251 | + |
252 | + g_return_if_fail (WNCK_IS_WINDOW (self->priv->legacy_window)); |
253 | + |
254 | + guint xid = bamf_legacy_window_get_xid (self); |
255 | + |
256 | + bamf_xutils_set_string_window_hint (xid, name, value); |
257 | } |
258 | |
259 | static void |
260 | |
261 | === modified file 'src/bamf-legacy-window.h' |
262 | --- src/bamf-legacy-window.h 2012-08-21 22:01:48 +0000 |
263 | +++ src/bamf-legacy-window.h 2012-10-10 17:32:43 +0000 |
264 | @@ -77,6 +77,8 @@ |
265 | char * (*get_app_id) (BamfLegacyWindow *legacy_window); |
266 | char * (*get_unique_bus_name) (BamfLegacyWindow *legacy_window); |
267 | char * (*get_menu_object_path) (BamfLegacyWindow *legacy_window); |
268 | + char * (*get_hint) (BamfLegacyWindow *legacy_window, |
269 | + const gchar *name); |
270 | gint (*get_pid) (BamfLegacyWindow *legacy_window); |
271 | guint32 (*get_xid) (BamfLegacyWindow *legacy_window); |
272 | gboolean (*needs_attention) (BamfLegacyWindow *legacy_window); |
273 | @@ -88,8 +90,9 @@ |
274 | BamfWindowMaximizationType (*maximized) (BamfLegacyWindow *legacy_window); |
275 | BamfWindowType (*get_window_type) (BamfLegacyWindow *legacy_window); |
276 | void (*get_geometry) (BamfLegacyWindow *legacy_window, |
277 | - gint *x, gint *y, |
278 | - gint *width, gint *height); |
279 | + gint *x, gint *y, gint *w, gint *h); |
280 | + void (*set_hint) (BamfLegacyWindow *legacy_window, |
281 | + const gchar *name, const gchar *value); |
282 | void (*reopen) (BamfLegacyWindow *legacy_window); |
283 | |
284 | /*< signals >*/ |
285 | @@ -141,7 +144,12 @@ |
286 | |
287 | BamfLegacyWindow * bamf_legacy_window_get_transient (BamfLegacyWindow *self); |
288 | |
289 | -char * bamf_legacy_window_get_utf8_xprop (BamfLegacyWindow *self, const char* prop); |
290 | +char * bamf_legacy_window_get_hint (BamfLegacyWindow *self, |
291 | + const char *name); |
292 | + |
293 | +void bamf_legacy_window_set_hint (BamfLegacyWindow *self, |
294 | + const char *name, |
295 | + const char *value); |
296 | |
297 | gint bamf_legacy_window_get_stacking_position (BamfLegacyWindow *self); |
298 | |
299 | |
300 | === modified file 'src/bamf-matcher.c' |
301 | --- src/bamf-matcher.c 2012-10-08 10:24:47 +0000 |
302 | +++ src/bamf-matcher.c 2012-10-10 17:32:43 +0000 |
303 | @@ -26,7 +26,6 @@ |
304 | #include "bamf-window.h" |
305 | #include "bamf-legacy-screen.h" |
306 | #include "bamf-indicator-source.h" |
307 | -#include "bamf-xutils.h" |
308 | |
309 | #ifdef HAVE_WEBAPPS |
310 | #include "bamf-unity-webapps-application.h" |
311 | @@ -370,6 +369,11 @@ |
312 | binary = "libreoffice"; |
313 | parameter = "draw"; |
314 | } |
315 | + else if (g_str_has_suffix (name, "LibreOffice Base")) |
316 | + { |
317 | + binary = "libreoffice"; |
318 | + parameter = "base"; |
319 | + } |
320 | else if (g_strcmp0 (class, "libreoffice-startcenter") == 0) |
321 | { |
322 | binary = "libreoffice"; |
323 | @@ -403,6 +407,11 @@ |
324 | binary = "ooffice"; |
325 | parameter = "draw"; |
326 | } |
327 | + else if (g_str_has_suffix (name, "OpenOffice.org Base")) |
328 | + { |
329 | + binary = "ooffice"; |
330 | + parameter = "base"; |
331 | + } |
332 | else if (g_strcmp0 (name, "OpenOffice.org") == 0 && type == BAMF_WINDOW_NORMAL) |
333 | { |
334 | binary = "ooffice"; |
335 | @@ -437,6 +446,11 @@ |
336 | binary = "libreoffice"; |
337 | parameter = "draw"; |
338 | } |
339 | + else if (g_strcmp0 (class, "libreoffice-base") == 0) |
340 | + { |
341 | + binary = "libreoffice"; |
342 | + parameter = "base"; |
343 | + } |
344 | } |
345 | |
346 | if (!binary) |
347 | @@ -1398,24 +1412,6 @@ |
348 | } |
349 | |
350 | static char * |
351 | -get_window_hint (BamfLegacyWindow *window, const char *atom_name) |
352 | -{ |
353 | - g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (window), NULL); |
354 | - |
355 | - Window xid = bamf_legacy_window_get_xid (window); |
356 | - return bamf_xutils_get_window_hint (xid, atom_name, XA_STRING); |
357 | -} |
358 | - |
359 | -static void |
360 | -set_window_hint (BamfLegacyWindow * window, const char *atom_name, const char *data) |
361 | -{ |
362 | - g_return_if_fail (BAMF_LEGACY_WINDOW (window)); |
363 | - |
364 | - Window xid = bamf_legacy_window_get_xid (window); |
365 | - bamf_xutils_set_window_hint (xid, atom_name, XA_STRING, data); |
366 | -} |
367 | - |
368 | -static char * |
369 | process_exec_string (gint pid) |
370 | { |
371 | gchar *result = NULL; |
372 | @@ -1655,7 +1651,7 @@ |
373 | |
374 | priv = self->priv; |
375 | window = bamf_window_get_window (bamf_window); |
376 | - desktop_file = get_window_hint (window, _NET_WM_DESKTOP_FILE); |
377 | + desktop_file = bamf_legacy_window_get_hint (window, _NET_WM_DESKTOP_FILE); |
378 | class_name = bamf_legacy_window_get_class_name (window); |
379 | instance_name = bamf_legacy_window_get_class_instance_name (window); |
380 | |
381 | @@ -1972,7 +1968,7 @@ |
382 | return; |
383 | } |
384 | |
385 | - desktop_file_hint = get_window_hint (window, _NET_WM_DESKTOP_FILE); |
386 | + desktop_file_hint = bamf_legacy_window_get_hint (window, _NET_WM_DESKTOP_FILE); |
387 | |
388 | if (desktop_file_hint) |
389 | { |
390 | @@ -2009,7 +2005,7 @@ |
391 | g_array_free (pids, TRUE); |
392 | |
393 | if (desktop_file_hint) |
394 | - set_window_hint (window, _NET_WM_DESKTOP_FILE, desktop_file_hint); |
395 | + bamf_legacy_window_set_hint (window, _NET_WM_DESKTOP_FILE, desktop_file_hint); |
396 | } |
397 | |
398 | static void |
399 | @@ -2054,7 +2050,7 @@ |
400 | char *old_hint; |
401 | const char *new_hint; |
402 | |
403 | - old_hint = get_window_hint (window, _NET_WM_DESKTOP_FILE); |
404 | + old_hint = bamf_legacy_window_get_hint (window, _NET_WM_DESKTOP_FILE); |
405 | new_hint = get_open_office_window_hint (self, window); |
406 | |
407 | if (new_hint && g_strcmp0 (new_hint, old_hint) != 0) |
408 | @@ -2083,7 +2079,7 @@ |
409 | g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); |
410 | g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (window), NULL); |
411 | |
412 | - role = get_window_hint (window, WM_WINDOW_ROLE); |
413 | + role = bamf_legacy_window_get_hint (window, WM_WINDOW_ROLE); |
414 | exec = g_strconcat ("gnome-control-center", (role ? " " : NULL), role, NULL); |
415 | |
416 | desktopFileTable = self->priv->desktop_file_table; |
417 | @@ -2109,7 +2105,7 @@ |
418 | char *old_hint; |
419 | const char *new_hint; |
420 | |
421 | - old_hint = get_window_hint (window, _NET_WM_DESKTOP_FILE); |
422 | + old_hint = bamf_legacy_window_get_hint (window, _NET_WM_DESKTOP_FILE); |
423 | new_hint = get_gnome_control_center_window_hint (self, window); |
424 | |
425 | if (new_hint && g_strcmp0 (new_hint, old_hint) != 0) |
426 | @@ -2150,12 +2146,12 @@ |
427 | return; |
428 | } |
429 | |
430 | - char *old_hint = get_window_hint (window, _NET_WM_DESKTOP_FILE); |
431 | + char *old_hint = bamf_legacy_window_get_hint (window, _NET_WM_DESKTOP_FILE); |
432 | const char *new_hint = get_open_office_window_hint (self, window); |
433 | |
434 | if (new_hint && g_strcmp0 (old_hint, new_hint) != 0) |
435 | { |
436 | - set_window_hint (window, _NET_WM_DESKTOP_FILE, new_hint); |
437 | + bamf_legacy_window_set_hint (window, _NET_WM_DESKTOP_FILE, new_hint); |
438 | } |
439 | |
440 | g_object_ref (window); |
441 | @@ -2166,12 +2162,12 @@ |
442 | } |
443 | else if (g_strcmp0 (bamf_legacy_window_get_class_name (window), "Gnome-control-center") == 0) |
444 | { |
445 | - char *old_hint = get_window_hint (window, _NET_WM_DESKTOP_FILE); |
446 | + char *old_hint = bamf_legacy_window_get_hint (window, _NET_WM_DESKTOP_FILE); |
447 | const char *new_hint = get_gnome_control_center_window_hint (self, window); |
448 | |
449 | if (new_hint && g_strcmp0 (old_hint, new_hint) != 0) |
450 | { |
451 | - set_window_hint (window, _NET_WM_DESKTOP_FILE, new_hint); |
452 | + bamf_legacy_window_set_hint (window, _NET_WM_DESKTOP_FILE, new_hint); |
453 | } |
454 | |
455 | g_object_ref (window); |
456 | |
457 | === modified file 'src/bamf-unity-webapps-tab.c' |
458 | --- src/bamf-unity-webapps-tab.c 2012-08-21 22:01:48 +0000 |
459 | +++ src/bamf-unity-webapps-tab.c 2012-10-10 17:32:43 +0000 |
460 | @@ -21,7 +21,6 @@ |
461 | #include "bamf-unity-webapps-tab.h" |
462 | #include "bamf-matcher.h" |
463 | |
464 | -#include "bamf-xutils.h" |
465 | #include "bamf-legacy-window.h" |
466 | #include "bamf-legacy-screen.h" |
467 | |
468 | |
469 | === modified file 'src/bamf-window.c' |
470 | --- src/bamf-window.c 2012-07-28 12:58:30 +0000 |
471 | +++ src/bamf-window.c 2012-10-10 17:32:43 +0000 |
472 | @@ -232,10 +232,10 @@ |
473 | } |
474 | |
475 | char * |
476 | -bamf_window_get_xprop (BamfWindow *self, const char* prop) |
477 | +bamf_window_get_string_hint (BamfWindow *self, const char* prop) |
478 | { |
479 | g_return_val_if_fail (BAMF_IS_WINDOW (self), NULL); |
480 | - return bamf_legacy_window_get_utf8_xprop(self->priv->legacy_window, prop); |
481 | + return bamf_legacy_window_get_hint (self->priv->legacy_window, prop); |
482 | } |
483 | |
484 | BamfWindowMaximizationType |
485 | @@ -334,11 +334,11 @@ |
486 | const gchar *prop, |
487 | BamfWindow *self) |
488 | { |
489 | - char *bus_name = bamf_window_get_xprop (self, prop); |
490 | + char *hint = bamf_window_get_string_hint (self, prop); |
491 | g_dbus_method_invocation_return_value (invocation, |
492 | - g_variant_new ("(s)", bus_name ? bus_name : "")); |
493 | + g_variant_new ("(s)", hint ? hint : "")); |
494 | |
495 | - g_free (bus_name); |
496 | + g_free (hint); |
497 | |
498 | return TRUE; |
499 | } |
500 | |
501 | === modified file 'src/bamf-window.h' |
502 | --- src/bamf-window.h 2012-08-21 22:01:48 +0000 |
503 | +++ src/bamf-window.h 2012-10-10 17:32:43 +0000 |
504 | @@ -76,7 +76,7 @@ |
505 | |
506 | gint bamf_window_get_stack_position (BamfWindow *window); |
507 | |
508 | -char * bamf_window_get_xprop (BamfWindow *self, const char* prop); |
509 | +char * bamf_window_get_string_hint (BamfWindow *self, const char* prop); |
510 | |
511 | BamfWindowMaximizationType bamf_window_maximized (BamfWindow *self); |
512 | |
513 | |
514 | === modified file 'src/bamf-xutils.c' |
515 | --- src/bamf-xutils.c 2012-04-19 18:58:57 +0000 |
516 | +++ src/bamf-xutils.c 2012-10-10 17:32:43 +0000 |
517 | @@ -44,69 +44,80 @@ |
518 | return xdisplay; |
519 | } |
520 | |
521 | -char * |
522 | -bamf_xutils_get_window_hint (Window xid, const char *atom_name, Atom type) |
523 | +static void |
524 | +bamf_xutils_get_string_window_hint_and_type (Window xid, const char *atom_name, |
525 | + gchar** return_hint, Atom* return_type) |
526 | { |
527 | Display *XDisplay; |
528 | - Atom atom; |
529 | - char *hint = NULL; |
530 | - Atom result_type; |
531 | gint format; |
532 | gulong numItems; |
533 | gulong bytesAfter; |
534 | + Atom type; |
535 | unsigned char *buffer; |
536 | - gboolean close_display = FALSE; |
537 | - |
538 | - g_return_val_if_fail ((xid != 0), NULL); |
539 | - g_return_val_if_fail (atom_name, NULL); |
540 | - |
541 | + gboolean close_display; |
542 | + |
543 | + if (return_hint) |
544 | + *return_hint = NULL; |
545 | + |
546 | + if (return_type) |
547 | + *return_type = AnyPropertyType; |
548 | + |
549 | + g_return_if_fail (xid != 0); |
550 | + g_return_if_fail (return_hint || return_type); |
551 | + |
552 | + close_display = FALSE; |
553 | XDisplay = get_xdisplay (&close_display); |
554 | |
555 | if (!XDisplay) |
556 | { |
557 | g_warning ("%s: Unable to get a valid XDisplay", G_STRFUNC); |
558 | - return NULL; |
559 | + return; |
560 | } |
561 | |
562 | - atom = XInternAtom (XDisplay, atom_name, FALSE); |
563 | - |
564 | - int result = XGetWindowProperty (XDisplay, |
565 | - xid, |
566 | - atom, |
567 | - 0, |
568 | - G_MAXINT, |
569 | - FALSE, |
570 | - type, |
571 | - &result_type, |
572 | - &format, |
573 | - &numItems, |
574 | - &bytesAfter, |
575 | - &buffer); |
576 | + int result = XGetWindowProperty (XDisplay, xid, |
577 | + gdk_x11_get_xatom_by_name (atom_name), |
578 | + 0, G_MAXINT, False, AnyPropertyType, |
579 | + &type, &format, &numItems, |
580 | + &bytesAfter, &buffer); |
581 | |
582 | if (close_display) |
583 | XCloseDisplay (XDisplay); |
584 | |
585 | if (result == Success && numItems > 0) |
586 | { |
587 | - if (buffer && buffer[0] != '\0') |
588 | - hint = g_strdup ((char*) buffer); |
589 | + if (return_type) |
590 | + *return_type = type; |
591 | + |
592 | + if (return_hint && buffer && buffer[0] != '\0') |
593 | + { |
594 | + if (type == XA_STRING || type == gdk_x11_get_xatom_by_name("UTF8_STRING")) |
595 | + *return_hint = g_strdup ((char*) buffer); |
596 | + } |
597 | |
598 | XFree (buffer); |
599 | } |
600 | +} |
601 | + |
602 | +char * |
603 | +bamf_xutils_get_string_window_hint (Window xid, const char *atom_name) |
604 | +{ |
605 | + gchar *hint = NULL; |
606 | + bamf_xutils_get_string_window_hint_and_type (xid, atom_name, &hint, NULL); |
607 | |
608 | return hint; |
609 | } |
610 | |
611 | void |
612 | -bamf_xutils_set_window_hint (Window xid, const char *atom_name, Atom type, const char *data) |
613 | +bamf_xutils_set_string_window_hint (Window xid, const char *atom_name, const char *value) |
614 | { |
615 | Display *XDisplay; |
616 | + Atom type; |
617 | gboolean close_display = FALSE; |
618 | |
619 | g_return_if_fail (xid != 0); |
620 | g_return_if_fail (atom_name); |
621 | - g_return_if_fail (data); |
622 | - |
623 | + g_return_if_fail (value); |
624 | + |
625 | XDisplay = get_xdisplay (&close_display); |
626 | |
627 | if (!XDisplay) |
628 | @@ -115,16 +126,20 @@ |
629 | return; |
630 | } |
631 | |
632 | - XChangeProperty (XDisplay, |
633 | - xid, |
634 | - XInternAtom (XDisplay, |
635 | - atom_name, |
636 | - FALSE), |
637 | - type, |
638 | - 8, |
639 | - PropModeReplace, |
640 | - (unsigned char *) data, |
641 | - strlen (data)); |
642 | + bamf_xutils_get_string_window_hint_and_type (xid, atom_name, NULL, &type); |
643 | + |
644 | + if (type == AnyPropertyType) |
645 | + { |
646 | + type = XA_STRING; |
647 | + } |
648 | + else if (type != XA_STRING && type != gdk_x11_get_xatom_by_name("UTF8_STRING")) |
649 | + { |
650 | + g_error ("Impossible to set the atom %s on Window %lu", atom_name, xid); |
651 | + return; |
652 | + } |
653 | + |
654 | + XChangeProperty (XDisplay, xid, gdk_x11_get_xatom_by_name (atom_name), |
655 | + type, 8, PropModeReplace, (unsigned char *) value, strlen (value)); |
656 | |
657 | if (close_display) |
658 | XCloseDisplay (XDisplay); |
659 | |
660 | === modified file 'src/bamf-xutils.h' |
661 | --- src/bamf-xutils.h 2012-04-18 20:12:33 +0000 |
662 | +++ src/bamf-xutils.h 2012-10-10 17:32:43 +0000 |
663 | @@ -26,8 +26,8 @@ |
664 | #include <X11/Xlib.h> |
665 | #include <gdk/gdkx.h> |
666 | |
667 | -void bamf_xutils_set_window_hint (Window xid, const char *atom_name, Atom type, const char *data); |
668 | -char* bamf_xutils_get_window_hint (Window xid, const char *atom_name, Atom type); |
669 | +void bamf_xutils_set_string_window_hint (Window xid, const char *atom_name, const char *value); |
670 | +char* bamf_xutils_get_string_window_hint (Window xid, const char *atom_name); |
671 | |
672 | void bamf_xutils_get_window_class_hints (Window xid, char **class_instance_name, char **class_name); |
673 | |
674 | |
675 | === added file 'tests/bamfdaemon/data/libreoffice-base.desktop' |
676 | --- tests/bamfdaemon/data/libreoffice-base.desktop 1970-01-01 00:00:00 +0000 |
677 | +++ tests/bamfdaemon/data/libreoffice-base.desktop 2012-10-10 17:32:43 +0000 |
678 | @@ -0,0 +1,7 @@ |
679 | +[Desktop Entry] |
680 | +Version=1.0 |
681 | +Terminal=false |
682 | +Icon=libreoffice-base |
683 | +Type=Application |
684 | +Exec=libreoffice --base %U |
685 | +Name=LibreOffice Base |
686 | |
687 | === added file 'tests/bamfdaemon/data/libreoffice-calc.desktop' |
688 | --- tests/bamfdaemon/data/libreoffice-calc.desktop 1970-01-01 00:00:00 +0000 |
689 | +++ tests/bamfdaemon/data/libreoffice-calc.desktop 2012-10-10 17:32:43 +0000 |
690 | @@ -0,0 +1,7 @@ |
691 | +[Desktop Entry] |
692 | +Version=1.0 |
693 | +Terminal=false |
694 | +Icon=libreoffice-calc |
695 | +Type=Application |
696 | +Exec=libreoffice --calc %U |
697 | +Name=LibreOffice Calc |
698 | |
699 | === added file 'tests/bamfdaemon/data/libreoffice-draw.desktop' |
700 | --- tests/bamfdaemon/data/libreoffice-draw.desktop 1970-01-01 00:00:00 +0000 |
701 | +++ tests/bamfdaemon/data/libreoffice-draw.desktop 2012-10-10 17:32:43 +0000 |
702 | @@ -0,0 +1,7 @@ |
703 | +[Desktop Entry] |
704 | +Version=1.0 |
705 | +Terminal=false |
706 | +Icon=libreoffice-draw |
707 | +Type=Application |
708 | +Exec=libreoffice --draw %U |
709 | +Name=LibreOffice Draw |
710 | |
711 | === added file 'tests/bamfdaemon/data/libreoffice-impress.desktop' |
712 | --- tests/bamfdaemon/data/libreoffice-impress.desktop 1970-01-01 00:00:00 +0000 |
713 | +++ tests/bamfdaemon/data/libreoffice-impress.desktop 2012-10-10 17:32:43 +0000 |
714 | @@ -0,0 +1,7 @@ |
715 | +[Desktop Entry] |
716 | +Version=1.0 |
717 | +Terminal=false |
718 | +Icon=libreoffice-impress |
719 | +Type=Application |
720 | +Exec=libreoffice --impress %U |
721 | +Name=LibreOffice Impress |
722 | |
723 | === added file 'tests/bamfdaemon/data/libreoffice-math.desktop' |
724 | --- tests/bamfdaemon/data/libreoffice-math.desktop 1970-01-01 00:00:00 +0000 |
725 | +++ tests/bamfdaemon/data/libreoffice-math.desktop 2012-10-10 17:32:43 +0000 |
726 | @@ -0,0 +1,7 @@ |
727 | +[Desktop Entry] |
728 | +Version=1.0 |
729 | +Terminal=false |
730 | +Icon=libreoffice-math |
731 | +Type=Application |
732 | +Exec=libreoffice --math %U |
733 | +Name=LibreOffice Math |
734 | |
735 | === added file 'tests/bamfdaemon/data/libreoffice-startcenter.desktop' |
736 | --- tests/bamfdaemon/data/libreoffice-startcenter.desktop 1970-01-01 00:00:00 +0000 |
737 | +++ tests/bamfdaemon/data/libreoffice-startcenter.desktop 2012-10-10 17:32:43 +0000 |
738 | @@ -0,0 +1,7 @@ |
739 | +[Desktop Entry] |
740 | +Version=1.0 |
741 | +Terminal=false |
742 | +Icon=libreoffice-startcenter |
743 | +Type=Application |
744 | +Exec=libreoffice %U |
745 | +Name=LibreOffice |
746 | |
747 | === added file 'tests/bamfdaemon/data/libreoffice-writer.desktop' |
748 | --- tests/bamfdaemon/data/libreoffice-writer.desktop 1970-01-01 00:00:00 +0000 |
749 | +++ tests/bamfdaemon/data/libreoffice-writer.desktop 2012-10-10 17:32:43 +0000 |
750 | @@ -0,0 +1,7 @@ |
751 | +[Desktop Entry] |
752 | +Version=1.0 |
753 | +Terminal=false |
754 | +Icon=libreoffice-writer |
755 | +Type=Application |
756 | +Exec=libreoffice --writer %U |
757 | +Name=LibreOffice Writer |
758 | |
759 | === modified file 'tests/bamfdaemon/test-matcher.c' |
760 | --- tests/bamfdaemon/test-matcher.c 2012-07-30 03:00:23 +0000 |
761 | +++ tests/bamfdaemon/test-matcher.c 2012-10-10 17:32:43 +0000 |
762 | @@ -31,6 +31,7 @@ |
763 | static void test_open_windows (void); |
764 | static void test_match_desktopless_application (void); |
765 | static void test_match_desktop_application (void); |
766 | +static void test_match_libreoffice_windows (void); |
767 | static void test_new_desktop_matches_unmatched_windows (void); |
768 | |
769 | static GDBusConnection *gdbus_connection = NULL; |
770 | @@ -47,9 +48,10 @@ |
771 | g_test_add_func (DOMAIN"/Allocation", test_allocation); |
772 | g_test_add_func (DOMAIN"/LoadDesktopFile", test_load_desktop_file); |
773 | g_test_add_func (DOMAIN"/OpenWindows", test_open_windows); |
774 | - g_test_add_func (DOMAIN"/MatchDesktopLessApplication", test_match_desktopless_application); |
775 | - g_test_add_func (DOMAIN"/MatchDesktopApplication", test_match_desktop_application); |
776 | - g_test_add_func (DOMAIN"/NewMatchesUnmatchedWindows", test_new_desktop_matches_unmatched_windows); |
777 | + g_test_add_func (DOMAIN"/Matching/Application/DesktopLess", test_match_desktopless_application); |
778 | + g_test_add_func (DOMAIN"/Matching/Application/Desktop", test_match_desktop_application); |
779 | + g_test_add_func (DOMAIN"/Matching/Application/LibreOffice", test_match_libreoffice_windows); |
780 | + g_test_add_func (DOMAIN"/Matching/Windows/UnmatchedOnNewDesktop", test_new_desktop_matches_unmatched_windows); |
781 | } |
782 | |
783 | static void |
784 | @@ -66,6 +68,34 @@ |
785 | g_clear_error (&error); |
786 | } |
787 | |
788 | +static void |
789 | +cleanup_matcher_tables (BamfMatcher *matcher) |
790 | +{ |
791 | + g_return_if_fail (BAMF_IS_MATCHER (matcher)); |
792 | + |
793 | + g_hash_table_destroy (matcher->priv->desktop_file_table); |
794 | + g_hash_table_destroy (matcher->priv->desktop_id_table); |
795 | + g_hash_table_destroy (matcher->priv->desktop_class_table); |
796 | + |
797 | + matcher->priv->desktop_file_table = |
798 | + g_hash_table_new_full ((GHashFunc) g_str_hash, |
799 | + (GEqualFunc) g_str_equal, |
800 | + (GDestroyNotify) g_free, |
801 | + NULL); |
802 | + |
803 | + matcher->priv->desktop_id_table = |
804 | + g_hash_table_new_full ((GHashFunc) g_str_hash, |
805 | + (GEqualFunc) g_str_equal, |
806 | + (GDestroyNotify) g_free, |
807 | + NULL); |
808 | + |
809 | + matcher->priv->desktop_class_table = |
810 | + g_hash_table_new_full ((GHashFunc) g_str_hash, |
811 | + (GEqualFunc) g_str_equal, |
812 | + (GDestroyNotify) g_free, |
813 | + (GDestroyNotify) g_free); |
814 | +} |
815 | + |
816 | static BamfWindow * |
817 | find_window_in_matcher (BamfMatcher *matcher, BamfLegacyWindow *legacy) |
818 | { |
819 | @@ -93,6 +123,8 @@ |
820 | GList *l; |
821 | BamfWindow *found_window = NULL; |
822 | |
823 | + g_return_val_if_fail (BAMF_IS_APPLICATION (app), NULL); |
824 | + |
825 | for (l = bamf_view_get_children (BAMF_VIEW (app)); l; l = l->next) |
826 | { |
827 | if (!BAMF_IS_WINDOW (l->data)) |
828 | @@ -125,6 +157,7 @@ |
829 | BamfMatcher *matcher = bamf_matcher_get_default (); |
830 | BamfMatcherPrivate *priv = matcher->priv; |
831 | |
832 | + cleanup_matcher_tables (matcher); |
833 | bamf_matcher_load_desktop_file (matcher, TEST_BAMF_APP_DESKTOP); |
834 | |
835 | GList *l = g_hash_table_lookup (priv->desktop_file_table, "testbamfapp"); |
836 | @@ -150,6 +183,7 @@ |
837 | screen = bamf_legacy_screen_get_default(); |
838 | matcher = bamf_matcher_get_default (); |
839 | |
840 | + cleanup_matcher_tables (matcher); |
841 | export_matcher_on_bus (matcher); |
842 | |
843 | for (xid = G_MAXUINT; xid > G_MAXUINT-window_count; xid--) |
844 | @@ -194,9 +228,10 @@ |
845 | |
846 | screen = bamf_legacy_screen_get_default(); |
847 | matcher = bamf_matcher_get_default (); |
848 | - char *exec = "test-bamf-app"; |
849 | - char *class = "test-bamf-app"; |
850 | + const char *exec = "test-bamf-app"; |
851 | + const char *class = "test-bamf-app"; |
852 | |
853 | + cleanup_matcher_tables (matcher); |
854 | export_matcher_on_bus (matcher); |
855 | |
856 | for (xid = G_MAXUINT; xid > G_MAXUINT-window_count; xid--) |
857 | @@ -241,9 +276,10 @@ |
858 | |
859 | screen = bamf_legacy_screen_get_default(); |
860 | matcher = bamf_matcher_get_default (); |
861 | - char *exec = "testbamfapp"; |
862 | - char *class = "test_bamf_app"; |
863 | + const char *exec = "testbamfapp"; |
864 | + const char *class = "test_bamf_app"; |
865 | |
866 | + cleanup_matcher_tables (matcher); |
867 | export_matcher_on_bus (matcher); |
868 | bamf_matcher_load_desktop_file (matcher, TEST_BAMF_APP_DESKTOP); |
869 | |
870 | @@ -290,9 +326,10 @@ |
871 | |
872 | screen = bamf_legacy_screen_get_default(); |
873 | matcher = bamf_matcher_get_default (); |
874 | - char *exec = "testbamfapp"; |
875 | - char *class = "test_bamf_app"; |
876 | + const char *exec = "testbamfapp"; |
877 | + const char *class = "test_bamf_app"; |
878 | |
879 | + cleanup_matcher_tables (matcher); |
880 | export_matcher_on_bus (matcher); |
881 | g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, TEST_BAMF_APP_DESKTOP)); |
882 | |
883 | @@ -323,3 +360,123 @@ |
884 | g_object_unref (screen); |
885 | } |
886 | |
887 | +static void |
888 | +test_match_libreoffice_windows (void) |
889 | +{ |
890 | + BamfMatcher *matcher; |
891 | + BamfWindow *window; |
892 | + BamfLegacyScreen *screen; |
893 | + BamfLegacyWindowTest *test_win; |
894 | + BamfApplication *app; |
895 | + char *hint; |
896 | + |
897 | + screen = bamf_legacy_screen_get_default (); |
898 | + matcher = bamf_matcher_get_default (); |
899 | + guint xid = g_random_int (); |
900 | + const char *exec = "soffice.bin"; |
901 | + const char *class_instance = "VCLSalFrame.DocumentWindow"; |
902 | + |
903 | + cleanup_matcher_tables (matcher); |
904 | + export_matcher_on_bus (matcher); |
905 | + |
906 | + bamf_matcher_load_desktop_file (matcher, DATA_DIR"/libreoffice-startcenter.desktop"); |
907 | + bamf_matcher_load_desktop_file (matcher, DATA_DIR"/libreoffice-base.desktop"); |
908 | + bamf_matcher_load_desktop_file (matcher, DATA_DIR"/libreoffice-calc.desktop"); |
909 | + bamf_matcher_load_desktop_file (matcher, DATA_DIR"/libreoffice-draw.desktop"); |
910 | + bamf_matcher_load_desktop_file (matcher, DATA_DIR"/libreoffice-impress.desktop"); |
911 | + bamf_matcher_load_desktop_file (matcher, DATA_DIR"/libreoffice-math.desktop"); |
912 | + bamf_matcher_load_desktop_file (matcher, DATA_DIR"/libreoffice-writer.desktop"); |
913 | + |
914 | + test_win = bamf_legacy_window_test_new (xid, "LibreOffice", "libreoffice-startcenter", exec); |
915 | + bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-startcenter", class_instance); |
916 | + _bamf_legacy_screen_open_test_window (screen, test_win); |
917 | + |
918 | + hint = bamf_legacy_window_get_hint (BAMF_LEGACY_WINDOW (test_win), _NET_WM_DESKTOP_FILE); |
919 | + g_assert_cmpstr (hint, ==, DATA_DIR"/libreoffice-startcenter.desktop"); |
920 | + g_free (hint); |
921 | + app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-startcenter.desktop"); |
922 | + g_assert (find_window_in_app (app, BAMF_LEGACY_WINDOW (test_win))); |
923 | + |
924 | + bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-base", class_instance); |
925 | + bamf_legacy_window_test_set_name (test_win, "FooDoc.odb - LibreOffice Base"); |
926 | + g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-startcenter.desktop")); |
927 | + app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-base.desktop"); |
928 | + g_assert (app); |
929 | + window = BAMF_WINDOW (bamf_view_get_children (BAMF_VIEW (app))->data); |
930 | + test_win = BAMF_LEGACY_WINDOW_TEST (bamf_window_get_window (window)); |
931 | + hint = bamf_legacy_window_get_hint (BAMF_LEGACY_WINDOW (test_win), _NET_WM_DESKTOP_FILE); |
932 | + g_assert_cmpstr (hint, ==, DATA_DIR"/libreoffice-base.desktop"); |
933 | + g_free (hint); |
934 | + |
935 | + bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-calc", class_instance); |
936 | + bamf_legacy_window_test_set_name (test_win, "FooDoc.ods - LibreOffice Calc"); |
937 | + g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-base.desktop")); |
938 | + app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-calc.desktop"); |
939 | + g_assert (app); |
940 | + window = BAMF_WINDOW (bamf_view_get_children (BAMF_VIEW (app))->data); |
941 | + test_win = BAMF_LEGACY_WINDOW_TEST (bamf_window_get_window (window)); |
942 | + hint = bamf_legacy_window_get_hint (BAMF_LEGACY_WINDOW (test_win), _NET_WM_DESKTOP_FILE); |
943 | + g_assert_cmpstr (hint, ==, DATA_DIR"/libreoffice-calc.desktop"); |
944 | + g_free (hint); |
945 | + |
946 | + bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-draw", class_instance); |
947 | + bamf_legacy_window_test_set_name (test_win, "FooDoc.odg - LibreOffice Draw"); |
948 | + g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-calc.desktop")); |
949 | + app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-draw.desktop"); |
950 | + g_assert (app); |
951 | + window = BAMF_WINDOW (bamf_view_get_children (BAMF_VIEW (app))->data); |
952 | + test_win = BAMF_LEGACY_WINDOW_TEST (bamf_window_get_window (window)); |
953 | + hint = bamf_legacy_window_get_hint (BAMF_LEGACY_WINDOW (test_win), _NET_WM_DESKTOP_FILE); |
954 | + g_assert_cmpstr (hint, ==, DATA_DIR"/libreoffice-draw.desktop"); |
955 | + g_free (hint); |
956 | + |
957 | + bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-impress", class_instance); |
958 | + bamf_legacy_window_test_set_name (test_win, "FooDoc.odp - LibreOffice Impress"); |
959 | + g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-draw.desktop")); |
960 | + app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-impress.desktop"); |
961 | + g_assert (app); |
962 | + window = BAMF_WINDOW (bamf_view_get_children (BAMF_VIEW (app))->data); |
963 | + test_win = BAMF_LEGACY_WINDOW_TEST (bamf_window_get_window (window)); |
964 | + hint = bamf_legacy_window_get_hint (BAMF_LEGACY_WINDOW (test_win), _NET_WM_DESKTOP_FILE); |
965 | + g_assert_cmpstr (hint, ==, DATA_DIR"/libreoffice-impress.desktop"); |
966 | + g_free (hint); |
967 | + |
968 | + bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-math", class_instance); |
969 | + bamf_legacy_window_test_set_name (test_win, "FooDoc.odf - LibreOffice Math"); |
970 | + g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-impress.desktop")); |
971 | + app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-math.desktop"); |
972 | + g_assert (app); |
973 | + window = BAMF_WINDOW (bamf_view_get_children (BAMF_VIEW (app))->data); |
974 | + test_win = BAMF_LEGACY_WINDOW_TEST (bamf_window_get_window (window)); |
975 | + hint = bamf_legacy_window_get_hint (BAMF_LEGACY_WINDOW (test_win), _NET_WM_DESKTOP_FILE); |
976 | + g_assert_cmpstr (hint, ==, DATA_DIR"/libreoffice-math.desktop"); |
977 | + g_free (hint); |
978 | + |
979 | + bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-writer", class_instance); |
980 | + bamf_legacy_window_test_set_name (test_win, "FooDoc.odt - LibreOffice Writer"); |
981 | + g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-math.desktop")); |
982 | + app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-writer.desktop"); |
983 | + g_assert (app); |
984 | + window = BAMF_WINDOW (bamf_view_get_children (BAMF_VIEW (app))->data); |
985 | + test_win = BAMF_LEGACY_WINDOW_TEST (bamf_window_get_window (window)); |
986 | + hint = bamf_legacy_window_get_hint (BAMF_LEGACY_WINDOW (test_win), _NET_WM_DESKTOP_FILE); |
987 | + g_assert_cmpstr (hint, ==, DATA_DIR"/libreoffice-writer.desktop"); |
988 | + g_free (hint); |
989 | + |
990 | + xid = g_random_int (); |
991 | + test_win = bamf_legacy_window_test_new (xid, "BarDoc.odt - LibreOffice Writer", "libreoffice-writer", exec); |
992 | + bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-writer", class_instance); |
993 | + _bamf_legacy_screen_open_test_window (screen, test_win); |
994 | + |
995 | + g_assert_cmpuint (g_list_length (bamf_view_get_children (BAMF_VIEW (app))), ==, 2); |
996 | + |
997 | + xid = g_random_int (); |
998 | + test_win = bamf_legacy_window_test_new (xid, "BarDoc.ods - LibreOffice Calc", "libreoffice-calc", exec); |
999 | + bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-calc", class_instance); |
1000 | + _bamf_legacy_screen_open_test_window (screen, test_win); |
1001 | + g_assert (bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-calc.desktop")); |
1002 | + |
1003 | + g_object_unref (matcher); |
1004 | + g_object_unref (screen); |
1005 | +} |
1006 | + |
1007 | |
1008 | === modified file 'tests/bamfdaemon/test-window.c' |
1009 | --- tests/bamfdaemon/test-window.c 2012-02-10 18:30:25 +0000 |
1010 | +++ tests/bamfdaemon/test-window.c 2012-10-10 17:32:43 +0000 |
1011 | @@ -25,6 +25,7 @@ |
1012 | |
1013 | static void test_allocation (void); |
1014 | static void test_xid (void); |
1015 | +static void test_hints (void); |
1016 | static void test_active (void); |
1017 | static void test_urgent (void); |
1018 | static void test_user_visible (void); |
1019 | @@ -43,6 +44,7 @@ |
1020 | |
1021 | g_test_add_func (DOMAIN"/Allocation", test_allocation); |
1022 | g_test_add_func (DOMAIN"/Xid", test_xid); |
1023 | + g_test_add_func (DOMAIN"/Hints", test_hints); |
1024 | g_test_add_func (DOMAIN"/Events/Active", test_active); |
1025 | g_test_add_func (DOMAIN"/Events/Urgent", test_urgent); |
1026 | g_test_add_func (DOMAIN"/Events/UserVisible", test_user_visible); |
1027 | @@ -71,6 +73,24 @@ |
1028 | } |
1029 | |
1030 | void |
1031 | +test_hints (void) |
1032 | +{ |
1033 | + BamfWindow *window; |
1034 | + BamfLegacyWindowTest *test; |
1035 | + |
1036 | + test = bamf_legacy_window_test_new (20,"Window X", "class", "exec"); |
1037 | + window = bamf_window_new (BAMF_LEGACY_WINDOW (test)); |
1038 | + |
1039 | + bamf_legacy_window_set_hint (BAMF_LEGACY_WINDOW (test), "HINT_NAME", "HINT_VALUE"); |
1040 | + |
1041 | + g_assert_cmpstr (bamf_window_get_string_hint (window, "HINT_NAME"), ==, "HINT_VALUE"); |
1042 | + g_assert_cmpstr (bamf_window_get_string_hint (window, "INVALID_HINT_NAME"), ==, NULL); |
1043 | + |
1044 | + g_object_unref (window); |
1045 | + g_object_unref (test); |
1046 | +} |
1047 | + |
1048 | +void |
1049 | test_xid (void) |
1050 | { |
1051 | BamfWindow *window; |
Confirmed works, tests pass and code looks good! +1