Merge pull request #3816 from sandsmark/martin/empty-matches
Match empty window properties (e. g. no title set) #3308
Orestis Floros authored 4 years ago
GitHub committed 4 years ago
91 | 91 |
#define CHECK_WINDOW_FIELD(match_field, window_field, type) \
|
92 | 92 |
do { \
|
93 | 93 |
if (match->match_field != NULL) { \
|
94 | |
if (window->window_field == NULL) { \
|
95 | |
return false; \
|
96 | |
} \
|
97 | |
\
|
98 | |
const char *window_field_str = GET_FIELD_##type(window->window_field); \
|
|
94 |
const char *window_field_str = window->window_field == NULL \
|
|
95 |
? "" \
|
|
96 |
: GET_FIELD_##type(window->window_field); \
|
99 | 97 |
if (strcmp(match->match_field->pattern, "__focused__") == 0 && \
|
100 | 98 |
focused && focused->window && focused->window->window_field && \
|
101 | 99 |
strcmp(window_field_str, GET_FIELD_##type(focused->window->window_field)) == 0) { \
|
32 | 32 |
# not match it
|
33 | 33 |
######################################################################
|
34 | 34 |
# TODO: specify more match types
|
35 | |
# we can match on any (non-empty) class here since that window does not have
|
36 | |
# WM_CLASS set
|
37 | |
cmd q|[class=".*"] kill|;
|
|
35 |
# Try matching with an empty pattern since there isn't a WM_CLASS set.
|
38 | 36 |
cmd q|[con_id="99999"] kill|;
|
39 | 37 |
|
40 | 38 |
is_num_children($tmp, 1, 'window still there');
|
|
102 | 100 |
wait_for_unmap $left;
|
103 | 101 |
is_num_children($tmp, 0, 'window killed');
|
104 | 102 |
|
|
103 |
######################################################################
|
|
104 |
# check that we can match empty properties
|
|
105 |
######################################################################
|
|
106 |
|
|
107 |
$tmp = fresh_workspace;
|
|
108 |
|
|
109 |
$left = open_window(name => 'class is empty', wm_class => '');
|
|
110 |
ok($left->mapped, 'left window mapped');
|
|
111 |
is_num_children($tmp, 1, 'window opened');
|
|
112 |
|
|
113 |
cmd '[class="^$"] kill';
|
|
114 |
wait_for_unmap $left;
|
|
115 |
is_num_children($tmp, 0, 'window killed');
|
|
116 |
|
105 | 117 |
done_testing;
|