Merge lp:~3v1n0/bamf/safe-win-reopen-on-new-desktop into lp:bamf/0.4
- safe-win-reopen-on-new-desktop
- Merge into 0.4
Proposed by
Marco Trevisan (Treviño)
Status: | Merged |
---|---|
Approved by: | Michal Hruby |
Approved revision: | 502 |
Merged at revision: | 476 |
Proposed branch: | lp:~3v1n0/bamf/safe-win-reopen-on-new-desktop |
Merge into: | lp:bamf/0.4 |
Diff against target: |
1107 lines (+634/-109) 13 files modified
src/bamf-application.c (+1/-1) src/bamf-legacy-screen-private.h (+29/-0) src/bamf-legacy-screen.c (+69/-18) src/bamf-legacy-window-test.c (+95/-14) src/bamf-legacy-window-test.h (+8/-2) src/bamf-legacy-window.c (+15/-5) src/bamf-legacy-window.h (+6/-4) src/bamf-matcher-private.h (+50/-0) src/bamf-matcher.c (+59/-53) src/bamf-window.c (+1/-1) tests/bamfdaemon/data/test-bamf-app.desktop (+7/-0) tests/bamfdaemon/test-bamf.c (+2/-2) tests/bamfdaemon/test-matcher.c (+292/-9) |
To merge this branch: | bzr merge lp:~3v1n0/bamf/safe-win-reopen-on-new-desktop |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michal Hruby (community) | Approve | ||
Review via email: mp+117177@code.launchpad.net |
Commit message
BamfMatcher: don't reopen windows when iterating on view's list, add tests
Description of the change
Fixed a crash that happened on reopening bamf windows when a new desktop file is added to a monitored folder, LegacyWindow and LegacyScreen slightly refactored and improved to allow matcher testing.
Added first real unit tests for the matcher.
To post a comment you must log in.
- 500. By Marco Trevisan (Treviño)
-
test-matcher: fix data_dir path
- 501. By Marco Trevisan (Treviño)
-
BamfLegacyScreen: avoid close event duplication
Revision history for this message
Michal Hruby (mhr3) wrote : | # |
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Yes, true.
- 502. By Marco Trevisan (Treviño)
-
BamfLegacyWindo
wTest: set the window as closed before emitting the signal
Revision history for this message
Michal Hruby (mhr3) wrote : | # |
Looks fine, tests pass here...
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 2012-07-17 19:03:36 +0000 | |||
3 | +++ src/bamf-application.c 2012-07-31 15:13:24 +0000 | |||
4 | @@ -322,7 +322,7 @@ | |||
5 | 322 | const char *window_class = bamf_legacy_window_get_class_name (window); | 322 | const char *window_class = bamf_legacy_window_get_class_name (window); |
6 | 323 | const char *instance_name = bamf_legacy_window_get_class_instance_name (window); | 323 | const char *instance_name = bamf_legacy_window_get_class_instance_name (window); |
7 | 324 | 324 | ||
9 | 325 | if (!window_class || !instance_name) | 325 | if (!window_class && !instance_name) |
10 | 326 | return FALSE; | 326 | return FALSE; |
11 | 327 | 327 | ||
12 | 328 | children = bamf_view_get_children (BAMF_VIEW (self)); | 328 | children = bamf_view_get_children (BAMF_VIEW (self)); |
13 | 329 | 329 | ||
14 | === added file 'src/bamf-legacy-screen-private.h' | |||
15 | --- src/bamf-legacy-screen-private.h 1970-01-01 00:00:00 +0000 | |||
16 | +++ src/bamf-legacy-screen-private.h 2012-07-31 15:13:24 +0000 | |||
17 | @@ -0,0 +1,29 @@ | |||
18 | 1 | /* | ||
19 | 2 | * Copyright (C) 2012 Canonical Ltd | ||
20 | 3 | * | ||
21 | 4 | * This program is free software: you can redistribute it and/or modify | ||
22 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
23 | 6 | * published by the Free Software Foundation. | ||
24 | 7 | * | ||
25 | 8 | * This program is distributed in the hope that it will be useful, | ||
26 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
27 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
28 | 11 | * GNU General Public License for more details. | ||
29 | 12 | * | ||
30 | 13 | * You should have received a copy of the GNU General Public License | ||
31 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
32 | 15 | * | ||
33 | 16 | * Authored by: Marco Trevisan (Treviño) <marco.trevisan@canonical.com> | ||
34 | 17 | * | ||
35 | 18 | */ | ||
36 | 19 | |||
37 | 20 | #ifndef __BAMF_LEGACY_SCREEN_PRIVATE_H__ | ||
38 | 21 | #define __BAMF_LEGACY_SCREEN_PRIVATE_H__ | ||
39 | 22 | |||
40 | 23 | #include "bamf-legacy-screen.h" | ||
41 | 24 | #include "bamf-legacy-window-test.h" | ||
42 | 25 | |||
43 | 26 | void _bamf_legacy_screen_open_test_window (BamfLegacyScreen *self, BamfLegacyWindowTest *window); | ||
44 | 27 | void _bamf_legacy_screen_close_test_window (BamfLegacyScreen *self, BamfLegacyWindowTest *window); | ||
45 | 28 | |||
46 | 29 | #endif | ||
47 | 0 | 30 | ||
48 | === modified file 'src/bamf-legacy-screen.c' | |||
49 | --- src/bamf-legacy-screen.c 2012-01-10 17:48:03 +0000 | |||
50 | +++ src/bamf-legacy-screen.c 2012-07-31 15:13:24 +0000 | |||
51 | @@ -18,13 +18,15 @@ | |||
52 | 18 | */ | 18 | */ |
53 | 19 | 19 | ||
54 | 20 | #include "bamf-legacy-screen.h" | 20 | #include "bamf-legacy-screen.h" |
56 | 21 | #include "bamf-legacy-window-test.h" | 21 | #include "bamf-legacy-screen-private.h" |
57 | 22 | #include <gio/gio.h> | 22 | #include <gio/gio.h> |
58 | 23 | 23 | ||
59 | 24 | G_DEFINE_TYPE (BamfLegacyScreen, bamf_legacy_screen, G_TYPE_OBJECT); | 24 | G_DEFINE_TYPE (BamfLegacyScreen, bamf_legacy_screen, G_TYPE_OBJECT); |
60 | 25 | #define BAMF_LEGACY_SCREEN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ | 25 | #define BAMF_LEGACY_SCREEN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ |
61 | 26 | BAMF_TYPE_LEGACY_SCREEN, BamfLegacyScreenPrivate)) | 26 | BAMF_TYPE_LEGACY_SCREEN, BamfLegacyScreenPrivate)) |
62 | 27 | 27 | ||
63 | 28 | static BamfLegacyScreen *static_screen = NULL; | ||
64 | 29 | |||
65 | 28 | enum | 30 | enum |
66 | 29 | { | 31 | { |
67 | 30 | WINDOW_OPENED, | 32 | WINDOW_OPENED, |
68 | @@ -100,14 +102,8 @@ | |||
69 | 100 | class = parts[3]; | 102 | class = parts[3]; |
70 | 101 | exec = parts[4]; | 103 | exec = parts[4]; |
71 | 102 | 104 | ||
80 | 103 | window = BAMF_LEGACY_WINDOW (bamf_legacy_window_test_new (xid, name, class, exec)); | 105 | BamfLegacyWindowTest *test_win = bamf_legacy_window_test_new (xid, name, class, exec); |
81 | 104 | self->priv->windows = g_list_append (self->priv->windows, window); | 106 | _bamf_legacy_screen_open_test_window (self, test_win); |
74 | 105 | g_signal_emit (window, legacy_screen_signals[STACKING_CHANGED], 0); | ||
75 | 106 | |||
76 | 107 | g_signal_connect (G_OBJECT (window), "closed", | ||
77 | 108 | (GCallback) handle_window_closed, self); | ||
78 | 109 | |||
79 | 110 | g_signal_emit (self, legacy_screen_signals[WINDOW_OPENED], 0, window); | ||
82 | 111 | } | 107 | } |
83 | 112 | else if (g_strcmp0 (parts[0], "close") == 0 && parts_size == 2) | 108 | else if (g_strcmp0 (parts[0], "close") == 0 && parts_size == 2) |
84 | 113 | { | 109 | { |
85 | @@ -116,7 +112,7 @@ | |||
86 | 116 | window = l->data; | 112 | window = l->data; |
87 | 117 | if (bamf_legacy_window_get_xid (window) == xid) | 113 | if (bamf_legacy_window_get_xid (window) == xid) |
88 | 118 | { | 114 | { |
90 | 119 | bamf_legacy_window_test_close (BAMF_LEGACY_WINDOW_TEST (window)); | 115 | _bamf_legacy_screen_close_test_window (self, BAMF_LEGACY_WINDOW_TEST (window)); |
91 | 120 | break; | 116 | break; |
92 | 121 | } | 117 | } |
93 | 122 | } | 118 | } |
94 | @@ -382,9 +378,22 @@ | |||
95 | 382 | } | 378 | } |
96 | 383 | 379 | ||
97 | 384 | static void | 380 | static void |
99 | 385 | bamf_legacy_screen_dispose (GObject *object) | 381 | bamf_legacy_screen_finalize (GObject *object) |
100 | 386 | { | 382 | { |
102 | 387 | G_OBJECT_CLASS (bamf_legacy_screen_parent_class)->dispose (object); | 383 | BamfLegacyScreen *self = BAMF_LEGACY_SCREEN (object); |
103 | 384 | |||
104 | 385 | if (self->priv->windows) | ||
105 | 386 | g_list_free_full (self->priv->windows, g_object_unref); | ||
106 | 387 | |||
107 | 388 | if (self->priv->file) | ||
108 | 389 | g_object_unref (self->priv->file); | ||
109 | 390 | |||
110 | 391 | if (self->priv->stream) | ||
111 | 392 | g_object_unref (self->priv->stream); | ||
112 | 393 | |||
113 | 394 | static_screen = NULL; | ||
114 | 395 | |||
115 | 396 | G_OBJECT_CLASS (bamf_legacy_screen_parent_class)->finalize (object); | ||
116 | 388 | } | 397 | } |
117 | 389 | 398 | ||
118 | 390 | static void | 399 | static void |
119 | @@ -398,7 +407,7 @@ | |||
120 | 398 | { | 407 | { |
121 | 399 | GObjectClass *object_class = G_OBJECT_CLASS (klass); | 408 | GObjectClass *object_class = G_OBJECT_CLASS (klass); |
122 | 400 | 409 | ||
124 | 401 | object_class->dispose = bamf_legacy_screen_dispose; | 410 | object_class->finalize = bamf_legacy_screen_finalize; |
125 | 402 | 411 | ||
126 | 403 | g_type_class_add_private (klass, sizeof (BamfLegacyScreenPrivate)); | 412 | g_type_class_add_private (klass, sizeof (BamfLegacyScreenPrivate)); |
127 | 404 | 413 | ||
128 | @@ -441,15 +450,16 @@ | |||
129 | 441 | G_TYPE_NONE, 0); | 450 | G_TYPE_NONE, 0); |
130 | 442 | } | 451 | } |
131 | 443 | 452 | ||
132 | 444 | static BamfLegacyScreen *self = NULL; | ||
133 | 445 | |||
134 | 446 | BamfLegacyScreen * | 453 | BamfLegacyScreen * |
135 | 447 | bamf_legacy_screen_get_default () | 454 | bamf_legacy_screen_get_default () |
136 | 448 | { | 455 | { |
139 | 449 | if (self) | 456 | BamfLegacyScreen *self; |
140 | 450 | return self; | 457 | |
141 | 458 | if (static_screen) | ||
142 | 459 | return static_screen; | ||
143 | 451 | 460 | ||
144 | 452 | self = (BamfLegacyScreen *) g_object_new (BAMF_TYPE_LEGACY_SCREEN, NULL); | 461 | self = (BamfLegacyScreen *) g_object_new (BAMF_TYPE_LEGACY_SCREEN, NULL); |
145 | 462 | static_screen = self; | ||
146 | 453 | 463 | ||
147 | 454 | self->priv->legacy_screen = wnck_screen_get_default (); | 464 | self->priv->legacy_screen = wnck_screen_get_default (); |
148 | 455 | 465 | ||
149 | @@ -462,5 +472,46 @@ | |||
150 | 462 | g_signal_connect (G_OBJECT (self->priv->legacy_screen), "active-window-changed", | 472 | g_signal_connect (G_OBJECT (self->priv->legacy_screen), "active-window-changed", |
151 | 463 | (GCallback) handle_active_window_changed, self); | 473 | (GCallback) handle_active_window_changed, self); |
152 | 464 | 474 | ||
154 | 465 | return self; | 475 | return static_screen; |
155 | 476 | } | ||
156 | 477 | |||
157 | 478 | |||
158 | 479 | // Private functions for testing purposes | ||
159 | 480 | |||
160 | 481 | void _bamf_legacy_screen_open_test_window (BamfLegacyScreen *self, BamfLegacyWindowTest *test_window) | ||
161 | 482 | { | ||
162 | 483 | GList *l; | ||
163 | 484 | BamfLegacyWindow *window; | ||
164 | 485 | guint xid; | ||
165 | 486 | |||
166 | 487 | g_return_if_fail (BAMF_IS_LEGACY_SCREEN (self)); | ||
167 | 488 | g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (test_window)); | ||
168 | 489 | |||
169 | 490 | window = BAMF_LEGACY_WINDOW (test_window); | ||
170 | 491 | xid = bamf_legacy_window_get_xid (window); | ||
171 | 492 | |||
172 | 493 | for (l = self->priv->windows; l; l = l->next) | ||
173 | 494 | { | ||
174 | 495 | if (bamf_legacy_window_get_xid (BAMF_LEGACY_WINDOW (l->data)) == xid) | ||
175 | 496 | { | ||
176 | 497 | return; | ||
177 | 498 | } | ||
178 | 499 | } | ||
179 | 500 | |||
180 | 501 | self->priv->windows = g_list_append (self->priv->windows, window); | ||
181 | 502 | g_signal_emit (self, legacy_screen_signals[STACKING_CHANGED], 0); | ||
182 | 503 | |||
183 | 504 | g_signal_connect (G_OBJECT (window), "closed", | ||
184 | 505 | (GCallback) handle_window_closed, self); | ||
185 | 506 | |||
186 | 507 | g_signal_emit (self, legacy_screen_signals[WINDOW_OPENED], 0, window); | ||
187 | 508 | } | ||
188 | 509 | |||
189 | 510 | void _bamf_legacy_screen_close_test_window (BamfLegacyScreen *self, BamfLegacyWindowTest *test_window) | ||
190 | 511 | { | ||
191 | 512 | g_return_if_fail (BAMF_IS_LEGACY_SCREEN (self)); | ||
192 | 513 | g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (test_window)); | ||
193 | 514 | |||
194 | 515 | // This will cause handle_window_closed to be called | ||
195 | 516 | bamf_legacy_window_test_close (BAMF_LEGACY_WINDOW_TEST (test_window)); | ||
196 | 466 | } | 517 | } |
197 | 467 | 518 | ||
198 | === modified file 'src/bamf-legacy-window-test.c' | |||
199 | --- src/bamf-legacy-window-test.c 2012-01-10 18:01:52 +0000 | |||
200 | +++ src/bamf-legacy-window-test.c 2012-07-31 15:13:24 +0000 | |||
201 | @@ -18,6 +18,7 @@ | |||
202 | 18 | */ | 18 | */ |
203 | 19 | 19 | ||
204 | 20 | #include "bamf-legacy-window-test.h" | 20 | #include "bamf-legacy-window-test.h" |
205 | 21 | #include "bamf-legacy-screen-private.h" | ||
206 | 21 | 22 | ||
207 | 22 | G_DEFINE_TYPE (BamfLegacyWindowTest, bamf_legacy_window_test, BAMF_TYPE_LEGACY_WINDOW); | 23 | G_DEFINE_TYPE (BamfLegacyWindowTest, bamf_legacy_window_test, BAMF_TYPE_LEGACY_WINDOW); |
208 | 23 | 24 | ||
209 | @@ -147,13 +148,23 @@ | |||
210 | 147 | } | 148 | } |
211 | 148 | 149 | ||
212 | 149 | static const char * | 150 | static const char * |
220 | 150 | bamf_legacy_window_test_get_class (BamfLegacyWindow *legacy_window) | 151 | bamf_legacy_window_test_get_class_name (BamfLegacyWindow *legacy_window) |
221 | 151 | { | 152 | { |
222 | 152 | BamfLegacyWindowTest *self; | 153 | BamfLegacyWindowTest *self; |
223 | 153 | 154 | ||
224 | 154 | self = BAMF_LEGACY_WINDOW_TEST (legacy_window); | 155 | self = BAMF_LEGACY_WINDOW_TEST (legacy_window); |
225 | 155 | 156 | ||
226 | 156 | return self->klass; | 157 | return self->wm_class_name; |
227 | 158 | } | ||
228 | 159 | |||
229 | 160 | static const char * | ||
230 | 161 | bamf_legacy_window_test_get_class_instance_name (BamfLegacyWindow *legacy_window) | ||
231 | 162 | { | ||
232 | 163 | BamfLegacyWindowTest *self; | ||
233 | 164 | |||
234 | 165 | self = BAMF_LEGACY_WINDOW_TEST (legacy_window); | ||
235 | 166 | |||
236 | 167 | return self->wm_class_instance; | ||
237 | 157 | } | 168 | } |
238 | 158 | 169 | ||
239 | 159 | char * | 170 | char * |
240 | @@ -229,6 +240,7 @@ | |||
241 | 229 | void | 240 | void |
242 | 230 | bamf_legacy_window_test_close (BamfLegacyWindowTest *self) | 241 | bamf_legacy_window_test_close (BamfLegacyWindowTest *self) |
243 | 231 | { | 242 | { |
244 | 243 | self->is_closed = TRUE; | ||
245 | 232 | g_signal_emit_by_name (self, "closed"); | 244 | g_signal_emit_by_name (self, "closed"); |
246 | 233 | } | 245 | } |
247 | 234 | 246 | ||
248 | @@ -280,6 +292,42 @@ | |||
249 | 280 | self->dbus_menu_object_path = g_strdup (object_path); | 292 | self->dbus_menu_object_path = g_strdup (object_path); |
250 | 281 | } | 293 | } |
251 | 282 | 294 | ||
252 | 295 | gboolean | ||
253 | 296 | bamf_legacy_window_test_is_closed (BamfLegacyWindow *window) | ||
254 | 297 | { | ||
255 | 298 | g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (window), TRUE); | ||
256 | 299 | |||
257 | 300 | BamfLegacyWindowTest *self = BAMF_LEGACY_WINDOW_TEST (window); | ||
258 | 301 | return self->is_closed; | ||
259 | 302 | } | ||
260 | 303 | |||
261 | 304 | static void | ||
262 | 305 | handle_destroy_notify (BamfLegacyWindowTest *copy, BamfLegacyWindowTest *self_was_here) | ||
263 | 306 | { | ||
264 | 307 | BamfLegacyScreen *screen = bamf_legacy_screen_get_default (); | ||
265 | 308 | _bamf_legacy_screen_open_test_window (screen, copy); | ||
266 | 309 | } | ||
267 | 310 | |||
268 | 311 | void | ||
269 | 312 | bamf_legacy_window_test_reopen (BamfLegacyWindow *window) | ||
270 | 313 | { | ||
271 | 314 | g_return_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (window)); | ||
272 | 315 | |||
273 | 316 | BamfLegacyWindowTest *self = BAMF_LEGACY_WINDOW_TEST (window); | ||
274 | 317 | BamfLegacyWindowTest *copy = bamf_legacy_window_copy (self); | ||
275 | 318 | g_object_weak_ref (G_OBJECT (self), (GWeakNotify) handle_destroy_notify, copy); | ||
276 | 319 | bamf_legacy_window_test_close (self); | ||
277 | 320 | } | ||
278 | 321 | |||
279 | 322 | BamfWindowType | ||
280 | 323 | bamf_legacy_window_test_get_window_type (BamfLegacyWindow *window) | ||
281 | 324 | { | ||
282 | 325 | g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW_TEST (window), TRUE); | ||
283 | 326 | |||
284 | 327 | BamfLegacyWindowTest *self = BAMF_LEGACY_WINDOW_TEST (window); | ||
285 | 328 | return self->window_type; | ||
286 | 329 | } | ||
287 | 330 | |||
288 | 283 | void | 331 | void |
289 | 284 | bamf_legacy_window_test_dispose (GObject *object) | 332 | bamf_legacy_window_test_dispose (GObject *object) |
290 | 285 | { | 333 | { |
291 | @@ -294,7 +342,8 @@ | |||
292 | 294 | 342 | ||
293 | 295 | obj_class->dispose = bamf_legacy_window_test_dispose; | 343 | obj_class->dispose = bamf_legacy_window_test_dispose; |
294 | 296 | win_class->get_name = bamf_legacy_window_test_get_name; | 344 | win_class->get_name = bamf_legacy_window_test_get_name; |
296 | 297 | win_class->get_class_name = bamf_legacy_window_test_get_class; | 345 | win_class->get_class_name = bamf_legacy_window_test_get_class_name; |
297 | 346 | win_class->get_class_instance_name = bamf_legacy_window_test_get_class_instance_name; | ||
298 | 298 | win_class->get_exec_string = bamf_legacy_window_test_get_exec_string; | 347 | win_class->get_exec_string = bamf_legacy_window_test_get_exec_string; |
299 | 299 | win_class->get_xid = bamf_legacy_window_test_get_xid; | 348 | win_class->get_xid = bamf_legacy_window_test_get_xid; |
300 | 300 | win_class->get_pid = bamf_legacy_window_test_get_pid; | 349 | win_class->get_pid = bamf_legacy_window_test_get_pid; |
301 | @@ -306,7 +355,10 @@ | |||
302 | 306 | win_class->get_unique_bus_name = bamf_legacy_window_test_get_unique_bus_name; | 355 | win_class->get_unique_bus_name = bamf_legacy_window_test_get_unique_bus_name; |
303 | 307 | win_class->get_menu_object_path = bamf_legacy_window_test_get_menu_object_path; | 356 | win_class->get_menu_object_path = bamf_legacy_window_test_get_menu_object_path; |
304 | 308 | win_class->get_geometry = bamf_legacy_window_test_get_geometry; | 357 | win_class->get_geometry = bamf_legacy_window_test_get_geometry; |
305 | 358 | win_class->get_window_type = bamf_legacy_window_test_get_window_type; | ||
306 | 309 | win_class->maximized = bamf_legacy_window_test_maximized; | 359 | win_class->maximized = bamf_legacy_window_test_maximized; |
307 | 360 | win_class->is_closed = bamf_legacy_window_test_is_closed; | ||
308 | 361 | win_class->reopen = bamf_legacy_window_test_reopen; | ||
309 | 310 | } | 362 | } |
310 | 311 | 363 | ||
311 | 312 | 364 | ||
312 | @@ -315,18 +367,47 @@ | |||
313 | 315 | { | 367 | { |
314 | 316 | self->pid = g_random_int_range (1, 100000); | 368 | self->pid = g_random_int_range (1, 100000); |
315 | 317 | self->maximized = BAMF_WINDOW_FLOATING; | 369 | self->maximized = BAMF_WINDOW_FLOATING; |
321 | 318 | } | 370 | self->is_closed = FALSE; |
322 | 319 | 371 | } | |
323 | 320 | 372 | ||
324 | 321 | BamfLegacyWindowTest * | 373 | |
325 | 322 | bamf_legacy_window_test_new (guint32 xid, gchar *name, gchar *klass, gchar *exec) | 374 | BamfLegacyWindowTest * |
326 | 375 | bamf_legacy_window_copy (BamfLegacyWindowTest *self) | ||
327 | 376 | { | ||
328 | 377 | BamfLegacyWindowTest *copy; | ||
329 | 378 | |||
330 | 379 | copy = g_object_new (BAMF_TYPE_LEGACY_WINDOW_TEST, NULL); | ||
331 | 380 | copy->xid = self->xid; | ||
332 | 381 | copy->pid = self->pid; | ||
333 | 382 | copy->name = g_strdup (self->name); | ||
334 | 383 | copy->wm_class_name = g_strdup (self->wm_class_name); | ||
335 | 384 | copy->wm_class_instance = g_strdup (self->wm_class_instance); | ||
336 | 385 | copy->exec = g_strdup (self->exec); | ||
337 | 386 | copy->application_id = g_strdup (self->application_id); | ||
338 | 387 | copy->unique_bus_name = g_strdup (self->unique_bus_name); | ||
339 | 388 | copy->dbus_menu_object_path = g_strdup (self->dbus_menu_object_path); | ||
340 | 389 | copy->needs_attention = self->needs_attention; | ||
341 | 390 | copy->is_desktop = self->is_desktop; | ||
342 | 391 | copy->is_skip = self->is_skip; | ||
343 | 392 | copy->is_active = self->is_active; | ||
344 | 393 | copy->is_closed = self->is_closed; | ||
345 | 394 | copy->geometry = self->geometry; | ||
346 | 395 | copy->maximized = self->maximized; | ||
347 | 396 | copy->window_type = self->window_type; | ||
348 | 397 | |||
349 | 398 | return copy; | ||
350 | 399 | } | ||
351 | 400 | |||
352 | 401 | BamfLegacyWindowTest * | ||
353 | 402 | bamf_legacy_window_test_new (guint32 xid, gchar *name, gchar *wmclass_name, gchar *exec) | ||
354 | 323 | { | 403 | { |
355 | 324 | BamfLegacyWindowTest *self; | 404 | BamfLegacyWindowTest *self; |
356 | 325 | 405 | ||
357 | 326 | self = g_object_new (BAMF_TYPE_LEGACY_WINDOW_TEST, NULL); | 406 | self = g_object_new (BAMF_TYPE_LEGACY_WINDOW_TEST, NULL); |
358 | 407 | self->window_type = BAMF_WINDOW_NORMAL; | ||
359 | 327 | self->xid = xid; | 408 | self->xid = xid; |
360 | 328 | self->name = g_strdup (name); | 409 | self->name = g_strdup (name); |
362 | 329 | self->klass = g_strdup (klass); | 410 | self->wm_class_name = g_strdup (wmclass_name); |
363 | 330 | self->exec = g_strdup (exec); | 411 | self->exec = g_strdup (exec); |
364 | 331 | 412 | ||
365 | 332 | return self; | 413 | return self; |
366 | 333 | 414 | ||
367 | === modified file 'src/bamf-legacy-window-test.h' | |||
368 | --- src/bamf-legacy-window-test.h 2012-01-10 18:01:52 +0000 | |||
369 | +++ src/bamf-legacy-window-test.h 2012-07-31 15:13:24 +0000 | |||
370 | @@ -54,7 +54,8 @@ | |||
371 | 54 | guint32 xid; | 54 | guint32 xid; |
372 | 55 | gint pid; | 55 | gint pid; |
373 | 56 | char * name; | 56 | char * name; |
375 | 57 | char * klass; | 57 | char * wm_class_name; |
376 | 58 | char * wm_class_instance; | ||
377 | 58 | char * exec; | 59 | char * exec; |
378 | 59 | char * application_id; | 60 | char * application_id; |
379 | 60 | char * unique_bus_name; | 61 | char * unique_bus_name; |
380 | @@ -63,8 +64,10 @@ | |||
381 | 63 | gboolean is_desktop; | 64 | gboolean is_desktop; |
382 | 64 | gboolean is_skip; | 65 | gboolean is_skip; |
383 | 65 | gboolean is_active; | 66 | gboolean is_active; |
384 | 67 | gboolean is_closed; | ||
385 | 66 | GdkRectangle geometry; | 68 | GdkRectangle geometry; |
386 | 67 | BamfWindowMaximizationType maximized; | 69 | BamfWindowMaximizationType maximized; |
387 | 70 | BamfWindowType window_type; | ||
388 | 68 | }; | 71 | }; |
389 | 69 | 72 | ||
390 | 70 | struct _BamfLegacyWindowTestClass | 73 | struct _BamfLegacyWindowTestClass |
391 | @@ -136,6 +139,9 @@ | |||
392 | 136 | bamf_legacy_window_test_close (BamfLegacyWindowTest *self); | 139 | bamf_legacy_window_test_close (BamfLegacyWindowTest *self); |
393 | 137 | 140 | ||
394 | 138 | BamfLegacyWindowTest * | 141 | BamfLegacyWindowTest * |
396 | 139 | bamf_legacy_window_test_new (guint32 xid, gchar *name, gchar *klass, gchar *exec); | 142 | bamf_legacy_window_test_new (guint32 xid, gchar *name, gchar *wmclass_name, gchar *exec); |
397 | 143 | |||
398 | 144 | BamfLegacyWindowTest * | ||
399 | 145 | bamf_legacy_window_copy (BamfLegacyWindowTest *self); | ||
400 | 140 | 146 | ||
401 | 141 | #endif | 147 | #endif |
402 | 142 | 148 | ||
403 | === modified file 'src/bamf-legacy-window.c' | |||
404 | --- src/bamf-legacy-window.c 2012-04-19 18:00:19 +0000 | |||
405 | +++ src/bamf-legacy-window.c 2012-07-31 15:13:24 +0000 | |||
406 | @@ -78,6 +78,10 @@ | |||
407 | 78 | bamf_legacy_window_get_window_type (BamfLegacyWindow *self) | 78 | bamf_legacy_window_get_window_type (BamfLegacyWindow *self) |
408 | 79 | { | 79 | { |
409 | 80 | g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), 0); | 80 | g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), 0); |
410 | 81 | |||
411 | 82 | if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_window_type) | ||
412 | 83 | return BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_window_type (self); | ||
413 | 84 | |||
414 | 81 | g_return_val_if_fail (self->priv->legacy_window, 0); | 85 | g_return_val_if_fail (self->priv->legacy_window, 0); |
415 | 82 | 86 | ||
416 | 83 | return (BamfWindowType) wnck_window_get_window_type (self->priv->legacy_window); | 87 | return (BamfWindowType) wnck_window_get_window_type (self->priv->legacy_window); |
417 | @@ -88,7 +92,6 @@ | |||
418 | 88 | { | 92 | { |
419 | 89 | g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), FALSE); | 93 | g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), FALSE); |
420 | 90 | 94 | ||
421 | 91 | |||
422 | 92 | if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->needs_attention) | 95 | if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->needs_attention) |
423 | 93 | return BAMF_LEGACY_WINDOW_GET_CLASS (self)->needs_attention (self); | 96 | return BAMF_LEGACY_WINDOW_GET_CLASS (self)->needs_attention (self); |
424 | 94 | 97 | ||
425 | @@ -356,11 +359,14 @@ | |||
426 | 356 | g_signal_emit (self, legacy_window_signals[GEOMETRY_CHANGED], 0); | 359 | g_signal_emit (self, legacy_window_signals[GEOMETRY_CHANGED], 0); |
427 | 357 | } | 360 | } |
428 | 358 | 361 | ||
430 | 359 | gboolean | 362 | gboolean |
431 | 360 | bamf_legacy_window_is_closed (BamfLegacyWindow *self) | 363 | bamf_legacy_window_is_closed (BamfLegacyWindow *self) |
432 | 361 | { | 364 | { |
433 | 362 | g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), TRUE); | 365 | g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), TRUE); |
435 | 363 | 366 | ||
436 | 367 | if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->is_closed) | ||
437 | 368 | return BAMF_LEGACY_WINDOW_GET_CLASS (self)->is_closed (self); | ||
438 | 369 | |||
439 | 364 | return self->priv->is_closed; | 370 | return self->priv->is_closed; |
440 | 365 | } | 371 | } |
441 | 366 | 372 | ||
442 | @@ -463,6 +469,10 @@ | |||
443 | 463 | bamf_legacy_window_reopen (BamfLegacyWindow *self) | 469 | bamf_legacy_window_reopen (BamfLegacyWindow *self) |
444 | 464 | { | 470 | { |
445 | 465 | g_return_if_fail (BAMF_IS_LEGACY_WINDOW (self)); | 471 | g_return_if_fail (BAMF_IS_LEGACY_WINDOW (self)); |
446 | 472 | |||
447 | 473 | if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->reopen) | ||
448 | 474 | return BAMF_LEGACY_WINDOW_GET_CLASS (self)->reopen (self); | ||
449 | 475 | |||
450 | 466 | g_return_if_fail (WNCK_IS_WINDOW (self->priv->legacy_window)); | 476 | g_return_if_fail (WNCK_IS_WINDOW (self->priv->legacy_window)); |
451 | 467 | 477 | ||
452 | 468 | guint xid = bamf_legacy_window_get_xid (self); | 478 | guint xid = bamf_legacy_window_get_xid (self); |
453 | @@ -488,13 +498,13 @@ | |||
454 | 488 | 498 | ||
455 | 489 | g_signal_handler_disconnect (wnck_screen_get_default (), | 499 | g_signal_handler_disconnect (wnck_screen_get_default (), |
456 | 490 | self->priv->closed_id); | 500 | self->priv->closed_id); |
458 | 491 | 501 | ||
459 | 492 | if (self->priv->mini_icon_path) | 502 | if (self->priv->mini_icon_path) |
460 | 493 | { | 503 | { |
461 | 494 | file = g_file_new_for_path (self->priv->mini_icon_path); | 504 | file = g_file_new_for_path (self->priv->mini_icon_path); |
462 | 495 | g_file_delete (file, NULL, NULL); | 505 | g_file_delete (file, NULL, NULL); |
463 | 496 | g_object_unref (file); | 506 | g_object_unref (file); |
465 | 497 | 507 | ||
466 | 498 | g_free (self->priv->mini_icon_path); | 508 | g_free (self->priv->mini_icon_path); |
467 | 499 | self->priv->mini_icon_path = NULL; | 509 | self->priv->mini_icon_path = NULL; |
468 | 500 | } | 510 | } |
469 | 501 | 511 | ||
470 | === modified file 'src/bamf-legacy-window.h' | |||
471 | --- src/bamf-legacy-window.h 2012-04-18 20:12:33 +0000 | |||
472 | +++ src/bamf-legacy-window.h 2012-07-31 15:13:24 +0000 | |||
473 | @@ -84,11 +84,13 @@ | |||
474 | 84 | gboolean (*is_skip_tasklist) (BamfLegacyWindow *legacy_window); | 84 | gboolean (*is_skip_tasklist) (BamfLegacyWindow *legacy_window); |
475 | 85 | gboolean (*is_desktop) (BamfLegacyWindow *legacy_window); | 85 | gboolean (*is_desktop) (BamfLegacyWindow *legacy_window); |
476 | 86 | gboolean (*is_dialog) (BamfLegacyWindow *legacy_window); | 86 | gboolean (*is_dialog) (BamfLegacyWindow *legacy_window); |
477 | 87 | gboolean (*is_closed) (BamfLegacyWindow *legacy_window); | ||
478 | 87 | BamfWindowMaximizationType (*maximized) (BamfLegacyWindow *legacy_window); | 88 | BamfWindowMaximizationType (*maximized) (BamfLegacyWindow *legacy_window); |
483 | 88 | 89 | BamfWindowType (*get_window_type) (BamfLegacyWindow *legacy_window); | |
484 | 89 | void (*get_geometry) (BamfLegacyWindow *self, | 90 | void (*get_geometry) (BamfLegacyWindow *legacy_window, |
485 | 90 | gint *x, gint *y, | 91 | gint *x, gint *y, |
486 | 91 | gint *width, gint *height); | 92 | gint *width, gint *height); |
487 | 93 | void (*reopen) (BamfLegacyWindow *legacy_window); | ||
488 | 92 | 94 | ||
489 | 93 | /*< signals >*/ | 95 | /*< signals >*/ |
490 | 94 | void (*name_changed) (BamfLegacyWindow *legacy_window); | 96 | void (*name_changed) (BamfLegacyWindow *legacy_window); |
491 | 95 | 97 | ||
492 | === added file 'src/bamf-matcher-private.h' | |||
493 | --- src/bamf-matcher-private.h 1970-01-01 00:00:00 +0000 | |||
494 | +++ src/bamf-matcher-private.h 2012-07-31 15:13:24 +0000 | |||
495 | @@ -0,0 +1,50 @@ | |||
496 | 1 | /* | ||
497 | 2 | * Copyright (C) 2012 Canonical Ltd | ||
498 | 3 | * | ||
499 | 4 | * This program is free software: you can redistribute it and/or modify | ||
500 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
501 | 6 | * published by the Free Software Foundation. | ||
502 | 7 | * | ||
503 | 8 | * This program is distributed in the hope that it will be useful, | ||
504 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
505 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
506 | 11 | * GNU General Public License for more details. | ||
507 | 12 | * | ||
508 | 13 | * You should have received a copy of the GNU General Public License | ||
509 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
510 | 15 | * | ||
511 | 16 | * Authored by: Marco Trevisan (Treviño) <marco.trevisan@canonical.com> | ||
512 | 17 | * | ||
513 | 18 | */ | ||
514 | 19 | |||
515 | 20 | #ifndef __BAMF_MATCHER_PRIVATE_H__ | ||
516 | 21 | #define __BAMF_MATCHER_PRIVATE_H__ | ||
517 | 22 | |||
518 | 23 | #include "bamf-view.h" | ||
519 | 24 | #include "bamf-matcher.h" | ||
520 | 25 | #include "bamf-application.h" | ||
521 | 26 | #include "bamf-window.h" | ||
522 | 27 | #include "bamf-legacy-window.h" | ||
523 | 28 | |||
524 | 29 | struct _BamfMatcherPrivate | ||
525 | 30 | { | ||
526 | 31 | GArray * bad_prefixes; | ||
527 | 32 | GArray * good_prefixes; | ||
528 | 33 | GArray * known_pids; | ||
529 | 34 | GHashTable * desktop_id_table; | ||
530 | 35 | GHashTable * desktop_file_table; | ||
531 | 36 | GHashTable * desktop_class_table; | ||
532 | 37 | GHashTable * registered_pids; | ||
533 | 38 | GHashTable * opened_closed_paths_table; | ||
534 | 39 | GList * views; | ||
535 | 40 | GList * monitors; | ||
536 | 41 | GList * favorites; | ||
537 | 42 | BamfView * active_app; | ||
538 | 43 | BamfView * active_win; | ||
539 | 44 | guint dispatch_changes_id; | ||
540 | 45 | }; | ||
541 | 46 | |||
542 | 47 | BamfApplication * bamf_matcher_get_application_by_desktop_file (BamfMatcher *self, const char *desktop_file); | ||
543 | 48 | BamfApplication * bamf_matcher_get_application_by_xid (BamfMatcher *self, guint xid); | ||
544 | 49 | |||
545 | 50 | #endif | ||
546 | 0 | 51 | ||
547 | === modified file 'src/bamf-matcher.c' | |||
548 | --- src/bamf-matcher.c 2012-05-22 17:02:28 +0000 | |||
549 | +++ src/bamf-matcher.c 2012-07-31 15:13:24 +0000 | |||
550 | @@ -21,10 +21,9 @@ | |||
551 | 21 | #include "config.h" | 21 | #include "config.h" |
552 | 22 | 22 | ||
553 | 23 | #include "bamf-matcher.h" | 23 | #include "bamf-matcher.h" |
554 | 24 | #include "bamf-matcher-private.h" | ||
555 | 24 | #include "bamf-application.h" | 25 | #include "bamf-application.h" |
556 | 25 | #include "bamf-window.h" | 26 | #include "bamf-window.h" |
557 | 26 | #include "bamf-legacy-window.h" | ||
558 | 27 | #include "bamf-legacy-window-test.h" | ||
559 | 28 | #include "bamf-legacy-screen.h" | 27 | #include "bamf-legacy-screen.h" |
560 | 29 | #include "bamf-indicator-source.h" | 28 | #include "bamf-indicator-source.h" |
561 | 30 | #include "bamf-xutils.h" | 29 | #include "bamf-xutils.h" |
562 | @@ -50,24 +49,6 @@ | |||
563 | 50 | static BamfMatcher *static_matcher; | 49 | static BamfMatcher *static_matcher; |
564 | 51 | static guint matcher_signals[LAST_SIGNAL] = { 0 }; | 50 | static guint matcher_signals[LAST_SIGNAL] = { 0 }; |
565 | 52 | 51 | ||
566 | 53 | struct _BamfMatcherPrivate | ||
567 | 54 | { | ||
568 | 55 | GArray * bad_prefixes; | ||
569 | 56 | GArray * good_prefixes; | ||
570 | 57 | GArray * known_pids; | ||
571 | 58 | GHashTable * desktop_id_table; | ||
572 | 59 | GHashTable * desktop_file_table; | ||
573 | 60 | GHashTable * desktop_class_table; | ||
574 | 61 | GHashTable * registered_pids; | ||
575 | 62 | GHashTable * opened_closed_paths_table; | ||
576 | 63 | GList * views; | ||
577 | 64 | GList * monitors; | ||
578 | 65 | GList * favorites; | ||
579 | 66 | BamfView * active_app; | ||
580 | 67 | BamfView * active_win; | ||
581 | 68 | guint dispatch_changes_id; | ||
582 | 69 | }; | ||
583 | 70 | |||
584 | 71 | static void | 52 | static void |
585 | 72 | on_view_active_changed (BamfView *view, gboolean active, BamfMatcher *matcher) | 53 | on_view_active_changed (BamfView *view, gboolean active, BamfMatcher *matcher) |
586 | 73 | { | 54 | { |
587 | @@ -127,7 +108,7 @@ | |||
588 | 127 | 108 | ||
589 | 128 | static void bamf_matcher_unregister_view (BamfMatcher *self, BamfView *view); | 109 | static void bamf_matcher_unregister_view (BamfMatcher *self, BamfView *view); |
590 | 129 | 110 | ||
592 | 130 | static BamfApplication * | 111 | BamfApplication * |
593 | 131 | bamf_matcher_get_application_by_desktop_file (BamfMatcher *self, const char *desktop_file) | 112 | bamf_matcher_get_application_by_desktop_file (BamfMatcher *self, const char *desktop_file) |
594 | 132 | { | 113 | { |
595 | 133 | GList *l; | 114 | GList *l; |
596 | @@ -158,6 +139,30 @@ | |||
597 | 158 | return NULL; | 139 | return NULL; |
598 | 159 | } | 140 | } |
599 | 160 | 141 | ||
600 | 142 | BamfApplication * | ||
601 | 143 | bamf_matcher_get_application_by_xid (BamfMatcher *self, guint xid) | ||
602 | 144 | { | ||
603 | 145 | GList *l; | ||
604 | 146 | BamfView *view; | ||
605 | 147 | |||
606 | 148 | g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); | ||
607 | 149 | |||
608 | 150 | for (l = self->priv->views; l; l = l->next) | ||
609 | 151 | { | ||
610 | 152 | view = l->data; | ||
611 | 153 | |||
612 | 154 | if (!BAMF_IS_APPLICATION (view)) | ||
613 | 155 | continue; | ||
614 | 156 | |||
615 | 157 | if (bamf_application_manages_xid (BAMF_APPLICATION (view), xid)) | ||
616 | 158 | { | ||
617 | 159 | return BAMF_APPLICATION (view); | ||
618 | 160 | } | ||
619 | 161 | } | ||
620 | 162 | |||
621 | 163 | return NULL; | ||
622 | 164 | } | ||
623 | 165 | |||
624 | 161 | static gboolean | 166 | static gboolean |
625 | 162 | emit_paths_changed (gpointer user_data) | 167 | emit_paths_changed (gpointer user_data) |
626 | 163 | { | 168 | { |
627 | @@ -2238,7 +2243,7 @@ | |||
628 | 2238 | { | 2243 | { |
629 | 2239 | g_return_if_fail (BAMF_IS_MATCHER (self)); | 2244 | g_return_if_fail (BAMF_IS_MATCHER (self)); |
630 | 2240 | g_return_if_fail (BAMF_IS_INDICATOR (indicator)); | 2245 | g_return_if_fail (BAMF_IS_INDICATOR (indicator)); |
632 | 2241 | 2246 | ||
633 | 2242 | bamf_matcher_register_view_stealing_ref (self, BAMF_VIEW (indicator)); | 2247 | bamf_matcher_register_view_stealing_ref (self, BAMF_VIEW (indicator)); |
634 | 2243 | bamf_matcher_setup_indicator_state (self, indicator); | 2248 | bamf_matcher_setup_indicator_state (self, indicator); |
635 | 2244 | } | 2249 | } |
636 | @@ -2258,7 +2263,12 @@ | |||
637 | 2258 | self->priv->desktop_class_table); | 2263 | self->priv->desktop_class_table); |
638 | 2259 | 2264 | ||
639 | 2260 | /* If an application with no .desktop file has windows that matches | 2265 | /* If an application with no .desktop file has windows that matches |
641 | 2261 | * the new added .desktop file, then we try to re-match them. */ | 2266 | * the new added .desktop file, then we try to re-match them. |
642 | 2267 | * We use another list to save the windows that should be re-matched to avoid | ||
643 | 2268 | * that the list that we're iterating is changed, since reopening a window | ||
644 | 2269 | * makes it to be removed from the views. */ | ||
645 | 2270 | GList *to_rematch = NULL; | ||
646 | 2271 | |||
647 | 2262 | for (vl = self->priv->views; vl; vl = vl->next) | 2272 | for (vl = self->priv->views; vl; vl = vl->next) |
648 | 2263 | { | 2273 | { |
649 | 2264 | if (!BAMF_IS_APPLICATION (vl->data)) | 2274 | if (!BAMF_IS_APPLICATION (vl->data)) |
650 | @@ -2271,21 +2281,29 @@ | |||
651 | 2271 | GList *children = bamf_view_get_children (BAMF_VIEW (app)); | 2281 | GList *children = bamf_view_get_children (BAMF_VIEW (app)); |
652 | 2272 | 2282 | ||
653 | 2273 | for (wl = children; wl; wl = wl->next) | 2283 | for (wl = children; wl; wl = wl->next) |
667 | 2274 | { | 2284 | { |
668 | 2275 | if (!BAMF_IS_WINDOW (wl->data)) | 2285 | if (!BAMF_IS_WINDOW (wl->data)) |
669 | 2276 | continue; | 2286 | continue; |
670 | 2277 | 2287 | ||
671 | 2278 | BamfWindow *win = BAMF_WINDOW (wl->data); | 2288 | BamfWindow *win = BAMF_WINDOW (wl->data); |
672 | 2279 | GList *desktops = bamf_matcher_possible_applications_for_window (self, win, NULL); | 2289 | GList *desktops = bamf_matcher_possible_applications_for_window (self, win, NULL); |
673 | 2280 | 2290 | ||
674 | 2281 | if (g_list_find_custom (desktops, desktop_file, (GCompareFunc) g_strcmp0)) | 2291 | if (g_list_find_custom (desktops, desktop_file, (GCompareFunc) g_strcmp0)) |
675 | 2282 | { | 2292 | { |
676 | 2283 | BamfLegacyWindow *legacy_window = bamf_window_get_window (win); | 2293 | BamfLegacyWindow *legacy_window = bamf_window_get_window (win); |
677 | 2284 | bamf_legacy_window_reopen (legacy_window); | 2294 | to_rematch = g_list_prepend (to_rematch, legacy_window); |
678 | 2285 | } | 2295 | } |
679 | 2286 | } | 2296 | } |
680 | 2287 | } | 2297 | } |
681 | 2288 | } | 2298 | } |
682 | 2299 | |||
683 | 2300 | for (wl = to_rematch; wl; wl = wl->next) | ||
684 | 2301 | { | ||
685 | 2302 | BamfLegacyWindow *legacy_window = BAMF_LEGACY_WINDOW (wl->data); | ||
686 | 2303 | bamf_legacy_window_reopen (legacy_window); | ||
687 | 2304 | } | ||
688 | 2305 | |||
689 | 2306 | g_list_free (to_rematch); | ||
690 | 2289 | } | 2307 | } |
691 | 2290 | 2308 | ||
692 | 2291 | void | 2309 | void |
693 | @@ -2396,26 +2414,14 @@ | |||
694 | 2396 | bamf_matcher_application_for_xid (BamfMatcher *matcher, | 2414 | bamf_matcher_application_for_xid (BamfMatcher *matcher, |
695 | 2397 | guint32 xid) | 2415 | guint32 xid) |
696 | 2398 | { | 2416 | { |
700 | 2399 | GList *l; | 2417 | BamfApplication *app; |
698 | 2400 | BamfView *view; | ||
699 | 2401 | BamfMatcherPrivate *priv; | ||
701 | 2402 | 2418 | ||
702 | 2403 | g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); | 2419 | g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL); |
703 | 2404 | 2420 | ||
718 | 2405 | priv = matcher->priv; | 2421 | app = bamf_matcher_get_application_by_xid (matcher, xid); |
719 | 2406 | 2422 | ||
720 | 2407 | for (l = priv->views; l; l = l->next) | 2423 | if (BAMF_IS_APPLICATION (app)) |
721 | 2408 | { | 2424 | return bamf_view_get_path (BAMF_VIEW (app)); |
708 | 2409 | view = l->data; | ||
709 | 2410 | |||
710 | 2411 | if (!BAMF_IS_APPLICATION (view)) | ||
711 | 2412 | continue; | ||
712 | 2413 | |||
713 | 2414 | if (bamf_application_manages_xid (BAMF_APPLICATION (view), xid)) | ||
714 | 2415 | { | ||
715 | 2416 | return bamf_view_get_path (view); | ||
716 | 2417 | } | ||
717 | 2418 | } | ||
722 | 2419 | 2425 | ||
723 | 2420 | return ""; | 2426 | return ""; |
724 | 2421 | } | 2427 | } |
725 | 2422 | 2428 | ||
726 | === modified file 'src/bamf-window.c' | |||
727 | --- src/bamf-window.c 2012-02-15 05:45:13 +0000 | |||
728 | +++ src/bamf-window.c 2012-07-31 15:13:24 +0000 | |||
729 | @@ -265,7 +265,7 @@ | |||
730 | 265 | g_return_val_if_fail (BAMF_IS_WINDOW (view), NULL); | 265 | g_return_val_if_fail (BAMF_IS_WINDOW (view), NULL); |
731 | 266 | self = BAMF_WINDOW (view); | 266 | self = BAMF_WINDOW (view); |
732 | 267 | 267 | ||
734 | 268 | return g_strdup_printf ("window%i", bamf_legacy_window_get_xid (self->priv->legacy_window)); | 268 | return g_strdup_printf ("window%u", bamf_legacy_window_get_xid (self->priv->legacy_window)); |
735 | 269 | } | 269 | } |
736 | 270 | 270 | ||
737 | 271 | gint | 271 | gint |
738 | 272 | 272 | ||
739 | === added file 'tests/bamfdaemon/data/test-bamf-app.desktop' | |||
740 | --- tests/bamfdaemon/data/test-bamf-app.desktop 1970-01-01 00:00:00 +0000 | |||
741 | +++ tests/bamfdaemon/data/test-bamf-app.desktop 2012-07-31 15:13:24 +0000 | |||
742 | @@ -0,0 +1,7 @@ | |||
743 | 1 | [Desktop Entry] | ||
744 | 2 | Name=TestBamfApp | ||
745 | 3 | Type=Application | ||
746 | 4 | Exec=testbamfapp | ||
747 | 5 | Icon=bamf | ||
748 | 6 | StartupWMClass=test_bamf_app | ||
749 | 7 | |||
750 | 0 | 8 | ||
751 | === modified file 'tests/bamfdaemon/test-bamf.c' | |||
752 | --- tests/bamfdaemon/test-bamf.c 2012-01-19 16:22:52 +0000 | |||
753 | +++ tests/bamfdaemon/test-bamf.c 2012-07-31 15:13:24 +0000 | |||
754 | @@ -28,7 +28,7 @@ | |||
755 | 28 | #include "bamf.h" | 28 | #include "bamf.h" |
756 | 29 | 29 | ||
757 | 30 | void test_application_create_suite (GDBusConnection *connection); | 30 | void test_application_create_suite (GDBusConnection *connection); |
759 | 31 | void test_matcher_create_suite (void); | 31 | void test_matcher_create_suite (GDBusConnection *connection); |
760 | 32 | void test_view_create_suite (GDBusConnection *connection); | 32 | void test_view_create_suite (GDBusConnection *connection); |
761 | 33 | void test_window_create_suite (void); | 33 | void test_window_create_suite (void); |
762 | 34 | 34 | ||
763 | @@ -39,7 +39,7 @@ | |||
764 | 39 | { | 39 | { |
765 | 40 | GMainLoop *loop = data; | 40 | GMainLoop *loop = data; |
766 | 41 | 41 | ||
768 | 42 | test_matcher_create_suite (); | 42 | test_matcher_create_suite (connection); |
769 | 43 | test_view_create_suite (connection); | 43 | test_view_create_suite (connection); |
770 | 44 | test_window_create_suite (); | 44 | test_window_create_suite (); |
771 | 45 | test_application_create_suite (connection); | 45 | test_application_create_suite (connection); |
772 | 46 | 46 | ||
773 | === modified file 'tests/bamfdaemon/test-matcher.c' | |||
774 | --- tests/bamfdaemon/test-matcher.c 2010-05-05 10:07:48 +0000 | |||
775 | +++ tests/bamfdaemon/test-matcher.c 2012-07-31 15:13:24 +0000 | |||
776 | @@ -1,8 +1,8 @@ | |||
777 | 1 | /* | 1 | /* |
779 | 2 | * Copyright (C) 2009 Canonical Ltd | 2 | * Copyright (C) 2009-2012 Canonical Ltd |
780 | 3 | * | 3 | * |
781 | 4 | * This program is free software: you can redistribute it and/or modify | 4 | * This program is free software: you can redistribute it and/or modify |
783 | 5 | * it under the terms of the GNU General Public License version 3 as | 5 | * it under the terms of the GNU General Public License version 3 as |
784 | 6 | * published by the Free Software Foundation. | 6 | * published by the Free Software Foundation. |
785 | 7 | * | 7 | * |
786 | 8 | * This program is distributed in the hope that it will be useful, | 8 | * This program is distributed in the hope that it will be useful, |
787 | @@ -13,30 +13,313 @@ | |||
788 | 13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
789 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
790 | 15 | * | 15 | * |
792 | 16 | * Authored by Neil Jagdish Patel <neil.patel@canonical.com> | 16 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> |
793 | 17 | * Marco Trevisan (Treviño) <marco.trevisan@canonical.com> | ||
794 | 17 | * | 18 | * |
795 | 18 | */ | 19 | */ |
796 | 19 | 20 | ||
797 | 20 | #include <glib.h> | 21 | #include <glib.h> |
798 | 21 | #include <stdlib.h> | 22 | #include <stdlib.h> |
799 | 22 | #include "bamf-matcher.h" | 23 | #include "bamf-matcher.h" |
802 | 23 | 24 | #include "bamf-matcher-private.h" | |
803 | 24 | static void test_allocation (void); | 25 | #include "bamf-legacy-screen-private.h" |
804 | 26 | #include "bamf-legacy-window.h" | ||
805 | 27 | #include "bamf-legacy-window-test.h" | ||
806 | 28 | |||
807 | 29 | static void test_allocation (void); | ||
808 | 30 | static void test_load_desktop_file (void); | ||
809 | 31 | static void test_open_windows (void); | ||
810 | 32 | static void test_match_desktopless_application (void); | ||
811 | 33 | static void test_match_desktop_application (void); | ||
812 | 34 | static void test_new_desktop_matches_unmatched_windows (void); | ||
813 | 35 | |||
814 | 36 | static GDBusConnection *gdbus_connection = NULL; | ||
815 | 37 | |||
816 | 38 | #define DOMAIN "/Matcher" | ||
817 | 39 | #define DATA_DIR TESTDIR "/bamfdaemon/data" | ||
818 | 40 | #define TEST_BAMF_APP_DESKTOP DATA_DIR "/test-bamf-app.desktop" | ||
819 | 25 | 41 | ||
820 | 26 | void | 42 | void |
822 | 27 | test_matcher_create_suite (void) | 43 | test_matcher_create_suite (GDBusConnection *connection) |
823 | 28 | { | 44 | { |
825 | 29 | #define DOMAIN "/Matcher" | 45 | gdbus_connection = connection; |
826 | 30 | 46 | ||
827 | 31 | g_test_add_func (DOMAIN"/Allocation", test_allocation); | 47 | g_test_add_func (DOMAIN"/Allocation", test_allocation); |
828 | 48 | g_test_add_func (DOMAIN"/LoadDesktopFile", test_load_desktop_file); | ||
829 | 49 | g_test_add_func (DOMAIN"/OpenWindows", test_open_windows); | ||
830 | 50 | g_test_add_func (DOMAIN"/MatchDesktopLessApplication", test_match_desktopless_application); | ||
831 | 51 | g_test_add_func (DOMAIN"/MatchDesktopApplication", test_match_desktop_application); | ||
832 | 52 | g_test_add_func (DOMAIN"/NewMatchesUnmatchedWindows", test_new_desktop_matches_unmatched_windows); | ||
833 | 53 | } | ||
834 | 54 | |||
835 | 55 | static void | ||
836 | 56 | export_matcher_on_bus (BamfMatcher *matcher) | ||
837 | 57 | { | ||
838 | 58 | GError *error = NULL; | ||
839 | 59 | g_return_if_fail (BAMF_IS_MATCHER (matcher)); | ||
840 | 60 | |||
841 | 61 | g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (matcher), | ||
842 | 62 | gdbus_connection, BAMF_MATCHER_PATH"/Test", | ||
843 | 63 | &error); | ||
844 | 64 | |||
845 | 65 | g_assert (!error); | ||
846 | 66 | g_clear_error (&error); | ||
847 | 67 | } | ||
848 | 68 | |||
849 | 69 | static BamfWindow * | ||
850 | 70 | find_window_in_matcher (BamfMatcher *matcher, BamfLegacyWindow *legacy) | ||
851 | 71 | { | ||
852 | 72 | GList *l; | ||
853 | 73 | BamfWindow *found_window = NULL; | ||
854 | 74 | |||
855 | 75 | for (l = matcher->priv->views; l; l = l->next) | ||
856 | 76 | { | ||
857 | 77 | if (!BAMF_IS_WINDOW (l->data)) | ||
858 | 78 | continue; | ||
859 | 79 | |||
860 | 80 | if (bamf_window_get_window (BAMF_WINDOW (l->data)) == legacy) | ||
861 | 81 | { | ||
862 | 82 | g_assert (!found_window); | ||
863 | 83 | found_window = l->data; | ||
864 | 84 | } | ||
865 | 85 | } | ||
866 | 86 | |||
867 | 87 | return found_window; | ||
868 | 88 | } | ||
869 | 89 | |||
870 | 90 | static BamfWindow * | ||
871 | 91 | find_window_in_app (BamfApplication *app, BamfLegacyWindow *legacy) | ||
872 | 92 | { | ||
873 | 93 | GList *l; | ||
874 | 94 | BamfWindow *found_window = NULL; | ||
875 | 95 | |||
876 | 96 | for (l = bamf_view_get_children (BAMF_VIEW (app)); l; l = l->next) | ||
877 | 97 | { | ||
878 | 98 | if (!BAMF_IS_WINDOW (l->data)) | ||
879 | 99 | continue; | ||
880 | 100 | |||
881 | 101 | if (bamf_window_get_window (BAMF_WINDOW (l->data)) == legacy) | ||
882 | 102 | { | ||
883 | 103 | g_assert (!found_window); | ||
884 | 104 | found_window = l->data; | ||
885 | 105 | } | ||
886 | 106 | } | ||
887 | 107 | |||
888 | 108 | return found_window; | ||
889 | 32 | } | 109 | } |
890 | 33 | 110 | ||
891 | 34 | static void | 111 | static void |
892 | 35 | test_allocation (void) | 112 | test_allocation (void) |
893 | 36 | { | 113 | { |
895 | 37 | BamfMatcher *matcher; | 114 | BamfMatcher *matcher; |
896 | 38 | 115 | ||
897 | 39 | /* Check it allocates */ | 116 | /* Check it allocates */ |
898 | 40 | matcher = bamf_matcher_get_default (); | 117 | matcher = bamf_matcher_get_default (); |
899 | 41 | g_assert (BAMF_IS_MATCHER (matcher)); | 118 | g_assert (BAMF_IS_MATCHER (matcher)); |
901 | 42 | } | 119 | g_object_unref (matcher); |
902 | 120 | } | ||
903 | 121 | |||
904 | 122 | static void | ||
905 | 123 | test_load_desktop_file (void) | ||
906 | 124 | { | ||
907 | 125 | BamfMatcher *matcher = bamf_matcher_get_default (); | ||
908 | 126 | BamfMatcherPrivate *priv = matcher->priv; | ||
909 | 127 | |||
910 | 128 | bamf_matcher_load_desktop_file (matcher, TEST_BAMF_APP_DESKTOP); | ||
911 | 129 | |||
912 | 130 | GList *l = g_hash_table_lookup (priv->desktop_file_table, "testbamfapp"); | ||
913 | 131 | g_assert_cmpstr (l->data, ==, TEST_BAMF_APP_DESKTOP); | ||
914 | 132 | |||
915 | 133 | l = g_hash_table_lookup (priv->desktop_id_table, "test-bamf-app"); | ||
916 | 134 | g_assert_cmpstr (l->data, ==, TEST_BAMF_APP_DESKTOP); | ||
917 | 135 | |||
918 | 136 | const char *desktop = g_hash_table_lookup (priv->desktop_class_table, TEST_BAMF_APP_DESKTOP); | ||
919 | 137 | g_assert_cmpstr (desktop, ==, "test_bamf_app"); | ||
920 | 138 | } | ||
921 | 139 | |||
922 | 140 | static void | ||
923 | 141 | test_open_windows (void) | ||
924 | 142 | { | ||
925 | 143 | BamfMatcher *matcher; | ||
926 | 144 | BamfLegacyScreen *screen; | ||
927 | 145 | BamfLegacyWindow *window; | ||
928 | 146 | BamfLegacyWindowTest *test_win; | ||
929 | 147 | guint xid; | ||
930 | 148 | const int window_count = 500; | ||
931 | 149 | |||
932 | 150 | screen = bamf_legacy_screen_get_default(); | ||
933 | 151 | matcher = bamf_matcher_get_default (); | ||
934 | 152 | |||
935 | 153 | export_matcher_on_bus (matcher); | ||
936 | 154 | |||
937 | 155 | for (xid = G_MAXUINT; xid > G_MAXUINT-window_count; xid--) | ||
938 | 156 | { | ||
939 | 157 | gchar *name = g_strdup_printf ("Test Window %u", xid); | ||
940 | 158 | gchar *class = g_strdup_printf ("test-class-%u", xid); | ||
941 | 159 | gchar *exec = g_strdup_printf ("test-class-%u", xid); | ||
942 | 160 | |||
943 | 161 | test_win = bamf_legacy_window_test_new (xid, name, class, exec); | ||
944 | 162 | window = BAMF_LEGACY_WINDOW (test_win); | ||
945 | 163 | |||
946 | 164 | _bamf_legacy_screen_open_test_window (screen, test_win); | ||
947 | 165 | g_assert (g_list_find (bamf_legacy_screen_get_windows (screen), test_win)); | ||
948 | 166 | g_assert (find_window_in_matcher (matcher, window)); | ||
949 | 167 | g_assert (bamf_matcher_get_application_by_xid (matcher, xid)); | ||
950 | 168 | |||
951 | 169 | _bamf_legacy_screen_close_test_window (screen, test_win); | ||
952 | 170 | g_assert (!g_list_find (bamf_legacy_screen_get_windows (screen), test_win)); | ||
953 | 171 | g_assert (!find_window_in_matcher (matcher, window)); | ||
954 | 172 | g_assert (!bamf_matcher_get_application_by_xid (matcher, xid)); | ||
955 | 173 | |||
956 | 174 | g_free (name); | ||
957 | 175 | g_free (class); | ||
958 | 176 | g_free (exec); | ||
959 | 177 | } | ||
960 | 178 | |||
961 | 179 | g_object_unref (matcher); | ||
962 | 180 | g_object_unref (screen); | ||
963 | 181 | } | ||
964 | 182 | |||
965 | 183 | static void | ||
966 | 184 | test_match_desktopless_application (void) | ||
967 | 185 | { | ||
968 | 186 | BamfMatcher *matcher; | ||
969 | 187 | BamfLegacyScreen *screen; | ||
970 | 188 | BamfLegacyWindow *window; | ||
971 | 189 | BamfLegacyWindowTest *test_win; | ||
972 | 190 | BamfApplication *app; | ||
973 | 191 | GList *test_windows = NULL, *l, *app_children; | ||
974 | 192 | guint xid; | ||
975 | 193 | const int window_count = 5; | ||
976 | 194 | |||
977 | 195 | screen = bamf_legacy_screen_get_default(); | ||
978 | 196 | matcher = bamf_matcher_get_default (); | ||
979 | 197 | char *exec = "test-bamf-app"; | ||
980 | 198 | char *class = "test-bamf-app"; | ||
981 | 199 | |||
982 | 200 | export_matcher_on_bus (matcher); | ||
983 | 201 | |||
984 | 202 | for (xid = G_MAXUINT; xid > G_MAXUINT-window_count; xid--) | ||
985 | 203 | { | ||
986 | 204 | gchar *name = g_strdup_printf ("Test Window %u", xid); | ||
987 | 205 | |||
988 | 206 | test_win = bamf_legacy_window_test_new (xid, name, class, exec); | ||
989 | 207 | window = BAMF_LEGACY_WINDOW (test_win); | ||
990 | 208 | test_windows = g_list_prepend (test_windows, window); | ||
991 | 209 | |||
992 | 210 | _bamf_legacy_screen_open_test_window (screen, test_win); | ||
993 | 211 | g_free (name); | ||
994 | 212 | } | ||
995 | 213 | |||
996 | 214 | app = bamf_matcher_get_application_by_xid (matcher, G_MAXUINT); | ||
997 | 215 | g_assert (app); | ||
998 | 216 | |||
999 | 217 | app_children = bamf_view_get_children (BAMF_VIEW (app)); | ||
1000 | 218 | g_assert_cmpuint (g_list_length (app_children), ==, window_count); | ||
1001 | 219 | |||
1002 | 220 | for (l = test_windows; l; l = l->next) | ||
1003 | 221 | { | ||
1004 | 222 | g_assert (find_window_in_app (app, BAMF_LEGACY_WINDOW (l->data))); | ||
1005 | 223 | } | ||
1006 | 224 | |||
1007 | 225 | g_list_free (test_windows); | ||
1008 | 226 | g_object_unref (matcher); | ||
1009 | 227 | g_object_unref (screen); | ||
1010 | 228 | } | ||
1011 | 229 | |||
1012 | 230 | static void | ||
1013 | 231 | test_match_desktop_application (void) | ||
1014 | 232 | { | ||
1015 | 233 | BamfMatcher *matcher; | ||
1016 | 234 | BamfLegacyScreen *screen; | ||
1017 | 235 | BamfLegacyWindow *window; | ||
1018 | 236 | BamfLegacyWindowTest *test_win; | ||
1019 | 237 | BamfApplication *app; | ||
1020 | 238 | GList *test_windows = NULL, *l, *app_children; | ||
1021 | 239 | guint xid; | ||
1022 | 240 | const int window_count = 5; | ||
1023 | 241 | |||
1024 | 242 | screen = bamf_legacy_screen_get_default(); | ||
1025 | 243 | matcher = bamf_matcher_get_default (); | ||
1026 | 244 | char *exec = "testbamfapp"; | ||
1027 | 245 | char *class = "test_bamf_app"; | ||
1028 | 246 | |||
1029 | 247 | export_matcher_on_bus (matcher); | ||
1030 | 248 | bamf_matcher_load_desktop_file (matcher, TEST_BAMF_APP_DESKTOP); | ||
1031 | 249 | |||
1032 | 250 | for (xid = G_MAXUINT; xid > G_MAXUINT-window_count; xid--) | ||
1033 | 251 | { | ||
1034 | 252 | gchar *name = g_strdup_printf ("Test Window %u", xid); | ||
1035 | 253 | |||
1036 | 254 | test_win = bamf_legacy_window_test_new (xid, name, class, exec); | ||
1037 | 255 | window = BAMF_LEGACY_WINDOW (test_win); | ||
1038 | 256 | test_windows = g_list_prepend (test_windows, window); | ||
1039 | 257 | |||
1040 | 258 | _bamf_legacy_screen_open_test_window (screen, test_win); | ||
1041 | 259 | g_free (name); | ||
1042 | 260 | } | ||
1043 | 261 | |||
1044 | 262 | app = bamf_matcher_get_application_by_desktop_file (matcher, TEST_BAMF_APP_DESKTOP); | ||
1045 | 263 | g_assert (app); | ||
1046 | 264 | |||
1047 | 265 | g_assert (bamf_matcher_get_application_by_xid (matcher, G_MAXUINT) == app); | ||
1048 | 266 | |||
1049 | 267 | app_children = bamf_view_get_children (BAMF_VIEW (app)); | ||
1050 | 268 | g_assert_cmpuint (g_list_length (app_children), ==, window_count); | ||
1051 | 269 | |||
1052 | 270 | for (l = test_windows; l; l = l->next) | ||
1053 | 271 | { | ||
1054 | 272 | g_assert (find_window_in_app (app, BAMF_LEGACY_WINDOW (l->data))); | ||
1055 | 273 | } | ||
1056 | 274 | |||
1057 | 275 | g_list_free (test_windows); | ||
1058 | 276 | g_object_unref (matcher); | ||
1059 | 277 | g_object_unref (screen); | ||
1060 | 278 | } | ||
1061 | 279 | |||
1062 | 280 | static void | ||
1063 | 281 | test_new_desktop_matches_unmatched_windows (void) | ||
1064 | 282 | { | ||
1065 | 283 | BamfMatcher *matcher; | ||
1066 | 284 | BamfLegacyScreen *screen; | ||
1067 | 285 | BamfLegacyWindowTest *test_win; | ||
1068 | 286 | BamfApplication *app; | ||
1069 | 287 | GList *app_children; | ||
1070 | 288 | guint xid = 0; | ||
1071 | 289 | const int window_count = 5; | ||
1072 | 290 | |||
1073 | 291 | screen = bamf_legacy_screen_get_default(); | ||
1074 | 292 | matcher = bamf_matcher_get_default (); | ||
1075 | 293 | char *exec = "testbamfapp"; | ||
1076 | 294 | char *class = "test_bamf_app"; | ||
1077 | 295 | |||
1078 | 296 | export_matcher_on_bus (matcher); | ||
1079 | 297 | g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, TEST_BAMF_APP_DESKTOP)); | ||
1080 | 298 | |||
1081 | 299 | for (xid = G_MAXUINT; xid > G_MAXUINT-window_count; xid--) | ||
1082 | 300 | { | ||
1083 | 301 | gchar *name = g_strdup_printf ("Test Window %u", xid); | ||
1084 | 302 | |||
1085 | 303 | test_win = bamf_legacy_window_test_new (xid, name, class, exec); | ||
1086 | 304 | _bamf_legacy_screen_open_test_window (screen, test_win); | ||
1087 | 305 | |||
1088 | 306 | g_free (name); | ||
1089 | 307 | } | ||
1090 | 308 | |||
1091 | 309 | bamf_matcher_load_desktop_file (matcher, TEST_BAMF_APP_DESKTOP); | ||
1092 | 310 | |||
1093 | 311 | app = bamf_matcher_get_application_by_desktop_file (matcher, TEST_BAMF_APP_DESKTOP); | ||
1094 | 312 | g_assert (app); | ||
1095 | 313 | |||
1096 | 314 | app_children = bamf_view_get_children (BAMF_VIEW (app)); | ||
1097 | 315 | g_assert_cmpuint (g_list_length (app_children), ==, window_count); | ||
1098 | 316 | |||
1099 | 317 | for (xid = G_MAXUINT; xid > G_MAXUINT-window_count; xid--) | ||
1100 | 318 | { | ||
1101 | 319 | g_assert (bamf_matcher_get_application_by_xid (matcher, xid) == app); | ||
1102 | 320 | } | ||
1103 | 321 | |||
1104 | 322 | g_object_unref (matcher); | ||
1105 | 323 | g_object_unref (screen); | ||
1106 | 324 | } | ||
1107 | 325 |
243 g_signal_ emit_by_ name (self, "closed");
244 + self->is_closed = TRUE;
Shouldn't the is_closed be set before emitting the signal? That way calling the .is_closed method will return proper value even inside the handler.