2 * vim:ts=4:sw=4:expandtab
4 * i3 - an improved dynamic tiling window manager
5 * © 2009-2010 Michael Stapelberg and contributors (see also: LICENSE)
7 * A "match" is a data structure which acts like a mask or expression to match
8 * certain windows or not. For example, when using commands, you can specify a
9 * command like this: [title="*Firefox*"] kill. The title member of the match
10 * data structure will then be filled and i3 will check each window using
11 * match_matches_window() to find the windows affected by this command.
18 * Check if a match is empty. This is necessary while parsing commands to see
19 * whether the user specified a match at all.
22 bool match_is_empty(Match *match) {
23 /* we cannot simply use memcmp() because the structure is part of a
24 * TAILQ and I don’t want to start with things like assuming that the
25 * last member of a struct really is at the end in memory… */
26 return (match->title == NULL &&
27 match->mark == NULL &&
28 match->application == NULL &&
29 match->class == NULL &&
30 match->instance == NULL &&
31 match->id == XCB_NONE &&
32 match->con_id == NULL &&
33 match->floating == M_ANY);
37 * Check if a match data structure matches the given window.
40 bool match_matches_window(Match *match, i3Window *window) {
41 /* TODO: pcre, full matching, … */
42 if (match->class != NULL && window->class_class != NULL && strcasecmp(match->class, window->class_class) == 0) {
43 LOG("match made by window class (%s)\n", window->class_class);
47 if (match->instance != NULL && window->class_instance != NULL && strcasecmp(match->instance, window->class_instance) == 0) {
48 LOG("match made by window instance (%s)\n", window->class_instance);
52 if (match->id != XCB_NONE && window->id == match->id) {
53 LOG("match made by window id (%d)\n", window->id);
57 LOG("window %d (%s) could not be matched\n", window->id, window->class_class);