Merge lp:~3v1n0/bamf/better-wmclass-filter into lp:bamf/0.4
- better-wmclass-filter
- Merge into 0.4
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Marco Trevisan (Treviño) | ||||
Approved revision: | 479 | ||||
Merged at revision: | 466 | ||||
Proposed branch: | lp:~3v1n0/bamf/better-wmclass-filter | ||||
Merge into: | lp:bamf/0.4 | ||||
Prerequisite: | lp:~3v1n0/bamf/desktopless-webapps-fix | ||||
Diff against target: |
434 lines (+140/-75) 3 files modified
src/bamf-application.c (+29/-19) src/bamf-matcher.c (+108/-56) src/bamf-matcher.h (+3/-0) |
||||
To merge this branch: | bzr merge lp:~3v1n0/bamf/better-wmclass-filter | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jason Smith (community) | Approve | ||
Review via email: mp+104036@code.launchpad.net |
Commit message
BamfMatcher: use both instance and class names for matching WMClass
Also, filter out the .desktop files that have a defined StartupWMClass
that doesn't match with our .desktop file.
Description of the change
We use both WMClass instance and class name to match proper .desktop files, also we filter out from possible_desktop list the .desktop files that have defined a wmclass that does not match with the one of the target window.
This allow to make both the custom applications .desktop files to work correctly and the web applications to be matched as new ones.
Plus, favorites are used only if their class matches.
Unity Merger (unity-merger) wrote : | # |
The prerequisite lp:~3v1n0/bamf/desktopless-webapps-fix has not yet been merged into lp:bamf.
Unity Merger (unity-merger) wrote : | # |
Attempt to merge into lp:bamf failed due to conflicts:
text conflict in src/bamf-matcher.c
- 479. By Marco Trevisan (Treviño)
-
Merging with trunk
Preview Diff
1 | === modified file 'src/bamf-application.c' | |||
2 | --- src/bamf-application.c 2012-04-26 06:16:01 +0000 | |||
3 | +++ src/bamf-application.c 2012-05-22 16:24:22 +0000 | |||
4 | @@ -120,17 +120,20 @@ | |||
5 | 120 | if (self->priv->desktop_file) | 120 | if (self->priv->desktop_file) |
6 | 121 | { | 121 | { |
7 | 122 | keyfile = g_key_file_new(); | 122 | keyfile = g_key_file_new(); |
9 | 123 | if (!g_key_file_load_from_file(keyfile, self->priv->desktop_file, G_KEY_FILE_NONE, NULL)) { | 123 | |
10 | 124 | if (!g_key_file_load_from_file(keyfile, self->priv->desktop_file, G_KEY_FILE_NONE, NULL)) | ||
11 | 125 | { | ||
12 | 124 | g_key_file_free(keyfile); | 126 | g_key_file_free(keyfile); |
15 | 125 | return; | 127 | return; |
16 | 126 | } | 128 | } |
17 | 127 | 129 | ||
18 | 128 | desktop = g_desktop_app_info_new_from_keyfile (keyfile); | 130 | desktop = g_desktop_app_info_new_from_keyfile (keyfile); |
19 | 129 | 131 | ||
24 | 130 | if (!G_IS_APP_INFO (desktop)) { | 132 | if (!G_IS_APP_INFO (desktop)) |
25 | 131 | g_key_file_free(keyfile); | 133 | { |
26 | 132 | return; | 134 | g_key_file_free(keyfile); |
27 | 133 | } | 135 | return; |
28 | 136 | } | ||
29 | 134 | 137 | ||
30 | 135 | gicon = g_app_info_get_icon (G_APP_INFO (desktop)); | 138 | gicon = g_app_info_get_icon (G_APP_INFO (desktop)); |
31 | 136 | 139 | ||
32 | @@ -139,14 +142,15 @@ | |||
33 | 139 | if (gicon) | 142 | if (gicon) |
34 | 140 | icon = g_icon_to_string (gicon); | 143 | icon = g_icon_to_string (gicon); |
35 | 141 | 144 | ||
44 | 142 | if (g_key_file_has_key(keyfile, G_KEY_FILE_DESKTOP_GROUP, STUB_KEY, NULL)) { | 145 | if (g_key_file_has_key(keyfile, G_KEY_FILE_DESKTOP_GROUP, STUB_KEY, NULL)) |
45 | 143 | /* This will error to return false, which is okay as it seems | 146 | { |
46 | 144 | unlikely anyone will want to set this flag except to turn | 147 | /* This will error to return false, which is okay as it seems |
47 | 145 | off the stub menus. */ | 148 | unlikely anyone will want to set this flag except to turn |
48 | 146 | self->priv->show_stubs = g_key_file_get_boolean (keyfile, | 149 | off the stub menus. */ |
49 | 147 | G_KEY_FILE_DESKTOP_GROUP, | 150 | self->priv->show_stubs = g_key_file_get_boolean (keyfile, |
50 | 148 | STUB_KEY, NULL); | 151 | G_KEY_FILE_DESKTOP_GROUP, |
51 | 149 | } | 152 | STUB_KEY, NULL); |
52 | 153 | } | ||
53 | 150 | 154 | ||
54 | 151 | if (g_key_file_has_key (keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-FullName", NULL)) | 155 | if (g_key_file_has_key (keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-FullName", NULL)) |
55 | 152 | { | 156 | { |
56 | @@ -489,11 +493,12 @@ | |||
57 | 489 | } | 493 | } |
58 | 490 | 494 | ||
59 | 491 | static char * | 495 | static char * |
61 | 492 | bamf_application_favorite_from_list (BamfApplication *self, GList *list) | 496 | bamf_application_favorite_from_list (BamfApplication *self, GList *desktop_list) |
62 | 493 | { | 497 | { |
63 | 494 | BamfMatcher *matcher; | 498 | BamfMatcher *matcher; |
64 | 495 | GList *favs, *l; | 499 | GList *favs, *l; |
65 | 496 | char *result = NULL; | 500 | char *result = NULL; |
66 | 501 | const char *desktop_class; | ||
67 | 497 | 502 | ||
68 | 498 | g_return_val_if_fail (BAMF_IS_APPLICATION (self), NULL); | 503 | g_return_val_if_fail (BAMF_IS_APPLICATION (self), NULL); |
69 | 499 | 504 | ||
70 | @@ -504,10 +509,15 @@ | |||
71 | 504 | { | 509 | { |
72 | 505 | for (l = favs; l; l = l->next) | 510 | for (l = favs; l; l = l->next) |
73 | 506 | { | 511 | { |
75 | 507 | if (g_list_find_custom (list, l->data, (GCompareFunc) g_strcmp0)) | 512 | if (g_list_find_custom (desktop_list, l->data, (GCompareFunc) g_strcmp0)) |
76 | 508 | { | 513 | { |
79 | 509 | result = l->data; | 514 | desktop_class = bamf_matcher_get_desktop_file_class (matcher, l->data); |
80 | 510 | break; | 515 | |
81 | 516 | if (!desktop_class || g_strcmp0 (self->priv->wmclass, desktop_class) == 0) | ||
82 | 517 | { | ||
83 | 518 | result = l->data; | ||
84 | 519 | break; | ||
85 | 520 | } | ||
86 | 511 | } | 521 | } |
87 | 512 | } | 522 | } |
88 | 513 | } | 523 | } |
89 | 514 | 524 | ||
90 | === modified file 'src/bamf-matcher.c' | |||
91 | --- src/bamf-matcher.c 2012-05-22 15:10:26 +0000 | |||
92 | +++ src/bamf-matcher.c 2012-05-22 16:24:22 +0000 | |||
93 | @@ -659,9 +659,11 @@ | |||
94 | 659 | } | 659 | } |
95 | 660 | 660 | ||
96 | 661 | static gboolean | 661 | static gboolean |
99 | 662 | exec_string_should_be_processed (BamfMatcher *self, | 662 | exec_string_should_be_processed (const char *exec) |
98 | 663 | char *exec) | ||
100 | 664 | { | 663 | { |
101 | 664 | if (!exec) | ||
102 | 665 | return TRUE; | ||
103 | 666 | |||
104 | 665 | return !g_str_has_prefix (exec, "ooffice") && !g_str_has_prefix (exec, "libreoffice"); | 667 | return !g_str_has_prefix (exec, "ooffice") && !g_str_has_prefix (exec, "libreoffice"); |
105 | 666 | } | 668 | } |
106 | 667 | 669 | ||
107 | @@ -829,7 +831,7 @@ | |||
108 | 829 | return; | 831 | return; |
109 | 830 | } | 832 | } |
110 | 831 | 833 | ||
112 | 832 | if (exec_string_should_be_processed (self, exec)) | 834 | if (exec_string_should_be_processed (exec)) |
113 | 833 | { | 835 | { |
114 | 834 | /** | 836 | /** |
115 | 835 | * Set of nasty hacks which should be removed some day. We wish to keep the full exec | 837 | * Set of nasty hacks which should be removed some day. We wish to keep the full exec |
116 | @@ -939,7 +941,7 @@ | |||
117 | 939 | gchar **parts = g_strsplit (line, "\t", 3); | 941 | gchar **parts = g_strsplit (line, "\t", 3); |
118 | 940 | exec = parts[1]; | 942 | exec = parts[1]; |
119 | 941 | 943 | ||
121 | 942 | if (exec_string_should_be_processed (self, exec)) | 944 | if (exec_string_should_be_processed (exec)) |
122 | 943 | { | 945 | { |
123 | 944 | char *tmp = trim_exec_string (self, exec); | 946 | char *tmp = trim_exec_string (self, exec); |
124 | 945 | g_free (parts[1]); | 947 | g_free (parts[1]); |
125 | @@ -1377,6 +1379,9 @@ | |||
126 | 1377 | { | 1379 | { |
127 | 1378 | const char *class_name = bamf_legacy_window_get_class_name (window); | 1380 | const char *class_name = bamf_legacy_window_get_class_name (window); |
128 | 1379 | 1381 | ||
129 | 1382 | if (!class_name) | ||
130 | 1383 | return FALSE; | ||
131 | 1384 | |||
132 | 1380 | return (g_str_has_prefix (class_name, "LibreOffice") || | 1385 | return (g_str_has_prefix (class_name, "LibreOffice") || |
133 | 1381 | g_str_has_prefix (class_name, "libreoffice") || | 1386 | g_str_has_prefix (class_name, "libreoffice") || |
134 | 1382 | g_str_has_prefix (class_name, "OpenOffice") || | 1387 | g_str_has_prefix (class_name, "OpenOffice") || |
135 | @@ -1543,17 +1548,20 @@ | |||
136 | 1543 | 1548 | ||
137 | 1544 | gboolean valid_app = FALSE; | 1549 | gboolean valid_app = FALSE; |
138 | 1545 | 1550 | ||
150 | 1546 | if (g_strcmp0 (window_class, "Google-chrome") == 0 && | 1551 | if (instance_name && window_class) |
151 | 1547 | g_strcmp0 (instance_name, "google-chrome") != 0 && | 1552 | { |
152 | 1548 | !g_str_has_prefix (instance_name, "Google-chrome")) | 1553 | if (g_strcmp0 (window_class, "Google-chrome") == 0 && |
153 | 1549 | { | 1554 | g_strcmp0 (instance_name, "google-chrome") != 0 && |
154 | 1550 | valid_app = TRUE; | 1555 | !g_str_has_prefix (instance_name, "Google-chrome")) |
155 | 1551 | } | 1556 | { |
156 | 1552 | else if (g_strcmp0 (window_class, "Chromium-browser") == 0 && | 1557 | valid_app = TRUE; |
157 | 1553 | g_strcmp0 (instance_name, "chromium-browser") != 0 && | 1558 | } |
158 | 1554 | !g_str_has_prefix (instance_name, "Chromium-browser")) | 1559 | else if (g_strcmp0 (window_class, "Chromium-browser") == 0 && |
159 | 1555 | { | 1560 | g_strcmp0 (instance_name, "chromium-browser") != 0 && |
160 | 1556 | valid_app = TRUE; | 1561 | !g_str_has_prefix (instance_name, "Chromium-browser")) |
161 | 1562 | { | ||
162 | 1563 | valid_app = TRUE; | ||
163 | 1564 | } | ||
164 | 1557 | } | 1565 | } |
165 | 1558 | 1566 | ||
166 | 1559 | return valid_app; | 1567 | return valid_app; |
167 | @@ -1620,36 +1628,50 @@ | |||
168 | 1620 | 1628 | ||
169 | 1621 | static GList * | 1629 | static GList * |
170 | 1622 | bamf_matcher_possible_applications_for_window (BamfMatcher *self, | 1630 | bamf_matcher_possible_applications_for_window (BamfMatcher *self, |
172 | 1623 | BamfWindow *bamf_window) | 1631 | BamfWindow *bamf_window, |
173 | 1632 | const char **target_class_out) | ||
174 | 1624 | { | 1633 | { |
175 | 1625 | BamfMatcherPrivate *priv; | 1634 | BamfMatcherPrivate *priv; |
176 | 1626 | BamfLegacyWindow *window; | 1635 | BamfLegacyWindow *window; |
177 | 1627 | GList *desktop_files = NULL, *l; | 1636 | GList *desktop_files = NULL, *l; |
178 | 1628 | char *desktop_file = NULL; | 1637 | char *desktop_file = NULL; |
180 | 1629 | char *desktop_class = NULL; | 1638 | const char *desktop_class = NULL; |
181 | 1639 | const char *class_name = NULL; | ||
182 | 1640 | const char *instance_name = NULL; | ||
183 | 1641 | const char *target_class = NULL; | ||
184 | 1642 | gboolean filter_by_wmclass = FALSE; | ||
185 | 1630 | 1643 | ||
186 | 1631 | g_return_val_if_fail (BAMF_IS_WINDOW (bamf_window), NULL); | 1644 | g_return_val_if_fail (BAMF_IS_WINDOW (bamf_window), NULL); |
187 | 1632 | g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); | 1645 | g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); |
188 | 1633 | 1646 | ||
189 | 1634 | priv = self->priv; | 1647 | priv = self->priv; |
190 | 1635 | window = bamf_window_get_window (bamf_window); | 1648 | window = bamf_window_get_window (bamf_window); |
191 | 1636 | |||
192 | 1637 | desktop_file = get_window_hint (window, _NET_WM_DESKTOP_FILE); | 1649 | desktop_file = get_window_hint (window, _NET_WM_DESKTOP_FILE); |
199 | 1638 | 1650 | class_name = bamf_legacy_window_get_class_name (window); | |
200 | 1639 | const char *class_name = bamf_legacy_window_get_class_name (window); | 1651 | instance_name = bamf_legacy_window_get_class_instance_name (window); |
201 | 1640 | const char *instance_name = bamf_legacy_window_get_class_instance_name (window); | 1652 | |
202 | 1641 | gboolean known_desktop_class = bamf_matcher_has_instance_class_desktop_file (self, instance_name); | 1653 | target_class = instance_name; |
203 | 1642 | 1654 | filter_by_wmclass = bamf_matcher_has_instance_class_desktop_file (self, target_class); | |
204 | 1643 | if (!known_desktop_class) | 1655 | |
205 | 1656 | if (!filter_by_wmclass) | ||
206 | 1644 | { | 1657 | { |
208 | 1645 | known_desktop_class = is_web_app_window (self, window); | 1658 | if (is_web_app_window (self, window)) |
209 | 1659 | { | ||
210 | 1660 | // This ensures that a new application is created even for unknown webapps | ||
211 | 1661 | filter_by_wmclass = TRUE; | ||
212 | 1662 | } | ||
213 | 1663 | else | ||
214 | 1664 | { | ||
215 | 1665 | target_class = class_name; | ||
216 | 1666 | filter_by_wmclass = bamf_matcher_has_instance_class_desktop_file (self, target_class); | ||
217 | 1667 | } | ||
218 | 1646 | } | 1668 | } |
219 | 1647 | 1669 | ||
220 | 1648 | if (desktop_file) | 1670 | if (desktop_file) |
221 | 1649 | { | 1671 | { |
223 | 1650 | desktop_class = g_hash_table_lookup (priv->desktop_class_table, desktop_file); | 1672 | desktop_class = bamf_matcher_get_desktop_file_class (self, desktop_file); |
224 | 1651 | 1673 | ||
226 | 1652 | if (!known_desktop_class || g_strcmp0 (desktop_class, instance_name) == 0) | 1674 | if ((!filter_by_wmclass && !desktop_class) || g_strcmp0 (desktop_class, target_class) == 0) |
227 | 1653 | { | 1675 | { |
228 | 1654 | desktop_files = g_list_prepend (desktop_files, desktop_file); | 1676 | desktop_files = g_list_prepend (desktop_files, desktop_file); |
229 | 1655 | } | 1677 | } |
230 | @@ -1675,9 +1697,9 @@ | |||
231 | 1675 | 1697 | ||
232 | 1676 | if (desktop_file) | 1698 | if (desktop_file) |
233 | 1677 | { | 1699 | { |
235 | 1678 | desktop_class = g_hash_table_lookup (priv->desktop_class_table, desktop_file); | 1700 | desktop_class = bamf_matcher_get_desktop_file_class (self, desktop_file); |
236 | 1679 | 1701 | ||
238 | 1680 | if (!known_desktop_class || g_strcmp0 (desktop_class, instance_name) == 0) | 1702 | if ((!filter_by_wmclass && !desktop_class) || g_strcmp0 (desktop_class, target_class) == 0) |
239 | 1681 | { | 1703 | { |
240 | 1682 | if (!g_list_find_custom (desktop_files, desktop_file, | 1704 | if (!g_list_find_custom (desktop_files, desktop_file, |
241 | 1683 | (GCompareFunc) g_strcmp0)) | 1705 | (GCompareFunc) g_strcmp0)) |
242 | @@ -1708,10 +1730,10 @@ | |||
243 | 1708 | { | 1730 | { |
244 | 1709 | gboolean append = FALSE; | 1731 | gboolean append = FALSE; |
245 | 1710 | 1732 | ||
247 | 1711 | if (instance_name) | 1733 | if (target_class) |
248 | 1712 | { | 1734 | { |
251 | 1713 | desktop_class = g_hash_table_lookup (priv->desktop_class_table, desktop_file); | 1735 | desktop_class = bamf_matcher_get_desktop_file_class (self, desktop_file); |
252 | 1714 | if (!known_desktop_class || g_strcmp0 (desktop_class, instance_name) == 0) | 1736 | if ((!filter_by_wmclass && !desktop_class) || g_strcmp0 (desktop_class, target_class) == 0) |
253 | 1715 | { | 1737 | { |
254 | 1716 | append = TRUE; | 1738 | append = TRUE; |
255 | 1717 | } | 1739 | } |
256 | @@ -1753,34 +1775,40 @@ | |||
257 | 1753 | g_list_free (pid_list); | 1775 | g_list_free (pid_list); |
258 | 1754 | } | 1776 | } |
259 | 1755 | 1777 | ||
263 | 1756 | if (!desktop_files && known_desktop_class) | 1778 | if (!desktop_files && filter_by_wmclass) |
264 | 1757 | { | 1779 | { |
265 | 1758 | desktop_files = bamf_matcher_get_class_matching_desktop_files (self, instance_name); | 1780 | desktop_files = bamf_matcher_get_class_matching_desktop_files (self, target_class); |
266 | 1781 | } | ||
267 | 1782 | |||
268 | 1783 | if (target_class_out) | ||
269 | 1784 | { | ||
270 | 1785 | *target_class_out = target_class; | ||
271 | 1759 | } | 1786 | } |
272 | 1760 | 1787 | ||
273 | 1761 | return desktop_files; | 1788 | return desktop_files; |
274 | 1762 | } | 1789 | } |
275 | 1763 | 1790 | ||
279 | 1764 | static void | 1791 | static BamfApplication * |
280 | 1765 | bamf_matcher_setup_window_state (BamfMatcher *self, | 1792 | bamf_matcher_get_application_for_window (BamfMatcher *self, |
281 | 1766 | BamfWindow *bamf_window) | 1793 | BamfWindow *bamf_window, |
282 | 1794 | gboolean *new_application) | ||
283 | 1767 | { | 1795 | { |
284 | 1768 | GList *possible_apps, *l; | 1796 | GList *possible_apps, *l; |
285 | 1769 | BamfLegacyWindow *window; | 1797 | BamfLegacyWindow *window; |
287 | 1770 | const gchar *app_class; | 1798 | const gchar *win_class_name; |
288 | 1799 | const gchar *target_class = NULL; | ||
289 | 1800 | const gchar *app_class = NULL; | ||
290 | 1771 | const gchar *app_desktop = NULL; | 1801 | const gchar *app_desktop = NULL; |
291 | 1772 | BamfApplication *app = NULL, *best = NULL; | 1802 | BamfApplication *app = NULL, *best = NULL; |
292 | 1773 | 1803 | ||
295 | 1774 | g_return_if_fail (BAMF_IS_MATCHER (self)); | 1804 | g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); |
296 | 1775 | g_return_if_fail (BAMF_IS_WINDOW (bamf_window)); | 1805 | g_return_val_if_fail (BAMF_IS_WINDOW (bamf_window), NULL); |
297 | 1776 | 1806 | ||
298 | 1777 | window = bamf_window_get_window (bamf_window); | 1807 | window = bamf_window_get_window (bamf_window); |
305 | 1778 | 1808 | win_class_name = bamf_legacy_window_get_class_name (window); | |
306 | 1779 | possible_apps = bamf_matcher_possible_applications_for_window (self, bamf_window); | 1809 | |
307 | 1780 | const char *win_instance = bamf_legacy_window_get_class_instance_name (window); | 1810 | possible_apps = bamf_matcher_possible_applications_for_window (self, bamf_window, &target_class); |
308 | 1781 | const char *win_class_name = bamf_legacy_window_get_class_name (window); | 1811 | app_class = target_class; |
303 | 1782 | |||
304 | 1783 | app_class = win_instance; | ||
309 | 1784 | 1812 | ||
310 | 1785 | /* Loop over every possible desktop file that could match the window, and try | 1813 | /* Loop over every possible desktop file that could match the window, and try |
311 | 1786 | * to reuse an already-opened window that uses it. | 1814 | * to reuse an already-opened window that uses it. |
312 | @@ -1799,7 +1827,7 @@ | |||
313 | 1799 | const gchar *app_desktop_class; | 1827 | const gchar *app_desktop_class; |
314 | 1800 | app_desktop_class = bamf_application_get_wmclass (app); | 1828 | app_desktop_class = bamf_application_get_wmclass (app); |
315 | 1801 | 1829 | ||
317 | 1802 | if (win_instance && app_desktop_class && strcasecmp (win_instance, app_desktop_class) == 0) | 1830 | if (target_class && app_desktop_class && strcasecmp (target_class, app_desktop_class) == 0) |
318 | 1803 | { | 1831 | { |
319 | 1804 | best = app; | 1832 | best = app; |
320 | 1805 | break; | 1833 | break; |
321 | @@ -1829,7 +1857,7 @@ | |||
322 | 1829 | const gchar *best_desktop_class; | 1857 | const gchar *best_desktop_class; |
323 | 1830 | 1858 | ||
324 | 1831 | best_app_class = bamf_application_get_wmclass (best); | 1859 | best_app_class = bamf_application_get_wmclass (best); |
326 | 1832 | best_desktop_class = g_hash_table_lookup (self->priv->desktop_class_table, best_desktop); | 1860 | best_desktop_class = bamf_matcher_get_desktop_file_class (self, best_desktop); |
327 | 1833 | 1861 | ||
328 | 1834 | /* We compare the two classes using their "distance" from the | 1862 | /* We compare the two classes using their "distance" from the |
329 | 1835 | * desidered class value */ | 1863 | * desidered class value */ |
330 | @@ -1867,7 +1895,7 @@ | |||
331 | 1867 | 1895 | ||
332 | 1868 | if (bamf_application_contains_similar_to_window (app, bamf_window)) | 1896 | if (bamf_application_contains_similar_to_window (app, bamf_window)) |
333 | 1869 | { | 1897 | { |
335 | 1870 | if (win_instance && g_strcmp0 (win_instance, app_desktop_class) == 0) | 1898 | if (target_class && g_strcmp0 (target_class, app_desktop_class) == 0) |
336 | 1871 | { | 1899 | { |
337 | 1872 | best = app; | 1900 | best = app; |
338 | 1873 | break; | 1901 | break; |
339 | @@ -1896,12 +1924,19 @@ | |||
340 | 1896 | } | 1924 | } |
341 | 1897 | 1925 | ||
342 | 1898 | bamf_application_set_wmclass (best, app_class); | 1926 | bamf_application_set_wmclass (best, app_class); |
343 | 1899 | bamf_matcher_register_view_stealing_ref (self, BAMF_VIEW (best)); | ||
344 | 1900 | } | ||
345 | 1901 | 1927 | ||
347 | 1902 | bamf_view_add_child (BAMF_VIEW (best), BAMF_VIEW (bamf_window)); | 1928 | if (new_application) |
348 | 1929 | *new_application = TRUE; | ||
349 | 1930 | } | ||
350 | 1931 | else | ||
351 | 1932 | { | ||
352 | 1933 | if (new_application) | ||
353 | 1934 | *new_application = FALSE; | ||
354 | 1935 | } | ||
355 | 1903 | 1936 | ||
356 | 1904 | g_list_free_full (possible_apps, g_free); | 1937 | g_list_free_full (possible_apps, g_free); |
357 | 1938 | |||
358 | 1939 | return best; | ||
359 | 1905 | } | 1940 | } |
360 | 1906 | 1941 | ||
361 | 1907 | /* Ensures that the window hint is set if a registered pid matches, and that set window hints | 1942 | /* Ensures that the window hint is set if a registered pid matches, and that set window hints |
362 | @@ -1972,6 +2007,7 @@ | |||
363 | 1972 | handle_raw_window (BamfMatcher *self, BamfLegacyWindow *window) | 2007 | handle_raw_window (BamfMatcher *self, BamfLegacyWindow *window) |
364 | 1973 | { | 2008 | { |
365 | 1974 | BamfWindow *bamfwindow; | 2009 | BamfWindow *bamfwindow; |
366 | 2010 | BamfApplication *bamfapplication; | ||
367 | 1975 | 2011 | ||
368 | 1976 | g_return_if_fail (BAMF_IS_MATCHER (self)); | 2012 | g_return_if_fail (BAMF_IS_MATCHER (self)); |
369 | 1977 | g_return_if_fail (BAMF_IS_LEGACY_WINDOW (window)); | 2013 | g_return_if_fail (BAMF_IS_LEGACY_WINDOW (window)); |
370 | @@ -1989,7 +2025,15 @@ | |||
371 | 1989 | bamfwindow = bamf_window_new (window); | 2025 | bamfwindow = bamf_window_new (window); |
372 | 1990 | bamf_matcher_register_view_stealing_ref (self, BAMF_VIEW (bamfwindow)); | 2026 | bamf_matcher_register_view_stealing_ref (self, BAMF_VIEW (bamfwindow)); |
373 | 1991 | 2027 | ||
375 | 1992 | bamf_matcher_setup_window_state (self, bamfwindow); | 2028 | gboolean new_app = FALSE; |
376 | 2029 | bamfapplication = bamf_matcher_get_application_for_window (self, bamfwindow, &new_app); | ||
377 | 2030 | |||
378 | 2031 | if (new_app) | ||
379 | 2032 | { | ||
380 | 2033 | bamf_matcher_register_view_stealing_ref (self, BAMF_VIEW (bamfapplication)); | ||
381 | 2034 | } | ||
382 | 2035 | |||
383 | 2036 | bamf_view_add_child (BAMF_VIEW (bamfapplication), BAMF_VIEW (bamfwindow)); | ||
384 | 1993 | } | 2037 | } |
385 | 1994 | 2038 | ||
386 | 1995 | static void | 2039 | static void |
387 | @@ -2243,6 +2287,15 @@ | |||
388 | 2243 | } | 2287 | } |
389 | 2244 | } | 2288 | } |
390 | 2245 | 2289 | ||
391 | 2290 | const char * | ||
392 | 2291 | bamf_matcher_get_desktop_file_class (BamfMatcher * self, const char * desktop_file) | ||
393 | 2292 | { | ||
394 | 2293 | g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); | ||
395 | 2294 | g_return_val_if_fail (desktop_file, NULL); | ||
396 | 2295 | |||
397 | 2296 | return g_hash_table_lookup (self->priv->desktop_class_table, desktop_file); | ||
398 | 2297 | } | ||
399 | 2298 | |||
400 | 2246 | static int | 2299 | static int |
401 | 2247 | x_error_handler (Display *display, XErrorEvent *event) | 2300 | x_error_handler (Display *display, XErrorEvent *event) |
402 | 2248 | { | 2301 | { |
403 | @@ -2347,7 +2400,6 @@ | |||
404 | 2347 | return (idx_a < idx_b) ? -1 : 1; | 2400 | return (idx_a < idx_b) ? -1 : 1; |
405 | 2348 | } | 2401 | } |
406 | 2349 | 2402 | ||
407 | 2350 | |||
408 | 2351 | GVariant * | 2403 | GVariant * |
409 | 2352 | bamf_matcher_get_window_stack_for_monitor (BamfMatcher *matcher, gint monitor) | 2404 | bamf_matcher_get_window_stack_for_monitor (BamfMatcher *matcher, gint monitor) |
410 | 2353 | { | 2405 | { |
411 | @@ -2515,8 +2567,8 @@ | |||
412 | 2515 | if (g_list_find_custom (priv->favorites, fav, (GCompareFunc) g_strcmp0)) | 2567 | if (g_list_find_custom (priv->favorites, fav, (GCompareFunc) g_strcmp0)) |
413 | 2516 | continue; | 2568 | continue; |
414 | 2517 | 2569 | ||
415 | 2570 | bamf_matcher_load_desktop_file (matcher, fav); | ||
416 | 2518 | priv->favorites = g_list_prepend (priv->favorites, g_strdup (fav)); | 2571 | priv->favorites = g_list_prepend (priv->favorites, g_strdup (fav)); |
417 | 2519 | bamf_matcher_load_desktop_file (matcher, fav); | ||
418 | 2520 | } | 2572 | } |
419 | 2521 | 2573 | ||
420 | 2522 | g_signal_emit (matcher, matcher_signals[FAVORITES_CHANGED], 0); | 2574 | g_signal_emit (matcher, matcher_signals[FAVORITES_CHANGED], 0); |
421 | 2523 | 2575 | ||
422 | === modified file 'src/bamf-matcher.h' | |||
423 | --- src/bamf-matcher.h 2012-01-21 00:29:55 +0000 | |||
424 | +++ src/bamf-matcher.h 2012-05-22 16:24:22 +0000 | |||
425 | @@ -74,6 +74,9 @@ | |||
426 | 74 | const char *application, | 74 | const char *application, |
427 | 75 | gint pid); | 75 | gint pid); |
428 | 76 | 76 | ||
429 | 77 | const char * bamf_matcher_get_desktop_file_class (BamfMatcher * self, | ||
430 | 78 | const char * desktop_file); | ||
431 | 79 | |||
432 | 77 | const char * bamf_matcher_get_active_application (BamfMatcher *matcher); | 80 | const char * bamf_matcher_get_active_application (BamfMatcher *matcher); |
433 | 78 | 81 | ||
434 | 79 | const char * bamf_matcher_get_active_window (BamfMatcher *matcher); | 82 | const char * bamf_matcher_get_active_window (BamfMatcher *matcher); |
Looks good, nothing too scary.