17 #define _i3_timercmp(a, b, CMP) \ 18 (((a).tv_sec == (b).tv_sec) ? ((a).tv_usec CMP(b).tv_usec) : ((a).tv_sec CMP(b).tv_sec)) 27 memset(match, 0,
sizeof(
Match));
28 match->
urgent = U_DONTCHECK;
43 return (match->
title == NULL &&
44 match->
mark == NULL &&
46 match->
class == NULL &&
50 match->
urgent == U_DONTCHECK &&
51 match->
id == XCB_NONE &&
54 match->
dock == M_NODOCK &&
63 memcpy(dest, src,
sizeof(
Match));
68 #define DUPLICATE_REGEX(field) \ 70 if (src->field != NULL) \ 71 dest->field = regex_new(src->field->pattern); \ 90 #define GET_FIELD_str(field) (field) 91 #define GET_FIELD_i3string(field) (i3string_as_utf8(field)) 92 #define CHECK_WINDOW_FIELD(match_field, window_field, type) \ 94 if (match->match_field != NULL) { \ 95 if (window->window_field == NULL) { \ 99 const char *window_field_str = GET_FIELD_##type(window->window_field); \ 100 if (strcmp(match->match_field->pattern, "__focused__") == 0 && \ 101 focused && focused->window && focused->window->window_field && \ 102 strcmp(window_field_str, GET_FIELD_##type(focused->window->window_field)) == 0) { \ 103 LOG("window " #match_field " matches focused window\n"); \ 104 } else if (regex_matches(match->match_field, window_field_str)) { \ 105 LOG("window " #match_field " matches (%s)\n", window_field_str); \ 115 if (match->
id != XCB_NONE) {
116 if (window->
id == match->
id) {
117 LOG(
"match made by window id (%d)\n", window->
id);
119 LOG(
"window id does not match\n");
136 if (match->
urgent == U_LATEST) {
138 if (window->
urgent.tv_sec == 0) {
143 if ((con->
window != NULL) &&
148 LOG(
"urgent matches latest\n");
151 if (match->
urgent == U_OLDEST) {
153 if (window->
urgent.tv_sec == 0) {
158 if ((con->
window != NULL) &&
164 LOG(
"urgent matches oldest\n");
177 LOG(
"workspace matches focused workspace\n");
179 LOG(
"workspace matches (%s)\n", ws->
name);
185 if (match->
dock != M_DONTCHECK) {
186 if ((window->
dock == W_DOCK_TOP && match->
dock == M_DOCK_TOP) ||
187 (window->
dock == W_DOCK_BOTTOM && match->
dock == M_DOCK_BOTTOM) ||
188 ((window->
dock == W_DOCK_TOP || window->
dock == W_DOCK_BOTTOM) &&
189 match->
dock == M_DOCK_ANY) ||
190 (window->
dock == W_NODOCK && match->
dock == M_NODOCK)) {
191 LOG(
"dock status matches\n");
193 LOG(
"dock status does not match\n");
198 if (match->
mark != NULL) {
202 bool matched =
false;
212 LOG(
"mark matches\n");
214 LOG(
"mark does not match\n");
225 if ((match->
window_mode == WM_TILING && floating) ||
226 (match->
window_mode == WM_FLOATING && !floating)) {
227 LOG(
"window_mode does not match\n");
231 LOG(
"window_mode matches\n");
257 assert(match != NULL);
258 DLOG(
"ctype=*%s*, cvalue=*%s*\n", ctype, cvalue);
260 if (strcmp(ctype,
"class") == 0) {
266 if (strcmp(ctype,
"instance") == 0) {
272 if (strcmp(ctype,
"window_role") == 0) {
278 if (strcmp(ctype,
"con_id") == 0) {
279 if (strcmp(cvalue,
"__focused__") == 0) {
286 ELOG(
"Could not parse con id \"%s\"\n", cvalue);
295 if (strcmp(ctype,
"id") == 0) {
298 ELOG(
"Could not parse window id \"%s\"\n", cvalue);
302 DLOG(
"window id as int = %d\n", match->
id);
307 if (strcmp(ctype,
"window_type") == 0) {
308 if (strcasecmp(cvalue,
"normal") == 0) {
310 }
else if (strcasecmp(cvalue,
"dialog") == 0) {
312 }
else if (strcasecmp(cvalue,
"utility") == 0) {
313 match->
window_type = A__NET_WM_WINDOW_TYPE_UTILITY;
314 }
else if (strcasecmp(cvalue,
"toolbar") == 0) {
315 match->
window_type = A__NET_WM_WINDOW_TYPE_TOOLBAR;
316 }
else if (strcasecmp(cvalue,
"splash") == 0) {
318 }
else if (strcasecmp(cvalue,
"menu") == 0) {
320 }
else if (strcasecmp(cvalue,
"dropdown_menu") == 0) {
321 match->
window_type = A__NET_WM_WINDOW_TYPE_DROPDOWN_MENU;
322 }
else if (strcasecmp(cvalue,
"popup_menu") == 0) {
323 match->
window_type = A__NET_WM_WINDOW_TYPE_POPUP_MENU;
324 }
else if (strcasecmp(cvalue,
"tooltip") == 0) {
325 match->
window_type = A__NET_WM_WINDOW_TYPE_TOOLTIP;
326 }
else if (strcasecmp(cvalue,
"notification") == 0) {
327 match->
window_type = A__NET_WM_WINDOW_TYPE_NOTIFICATION;
329 ELOG(
"unknown window_type value \"%s\"\n", cvalue);
336 if (strcmp(ctype,
"con_mark") == 0) {
342 if (strcmp(ctype,
"title") == 0) {
348 if (strcmp(ctype,
"urgent") == 0) {
349 if (strcasecmp(cvalue,
"latest") == 0 ||
350 strcasecmp(cvalue,
"newest") == 0 ||
351 strcasecmp(cvalue,
"recent") == 0 ||
352 strcasecmp(cvalue,
"last") == 0) {
354 }
else if (strcasecmp(cvalue,
"oldest") == 0 ||
355 strcasecmp(cvalue,
"first") == 0) {
361 if (strcmp(ctype,
"workspace") == 0) {
367 if (strcmp(ctype,
"tiling") == 0) {
372 if (strcmp(ctype,
"floating") == 0) {
377 ELOG(
"Unknown criterion: %s\n", ctype);
#define CHECK_WINDOW_FIELD(match_field, window_field, type)
struct regex * window_role
xcb_atom_t window_type
The _NET_WM_WINDOW_TYPE for this window.
bool parse_long(const char *str, long *out, int base)
Converts a string into a long using strtol().
struct timeval urgent
When this window was marked urgent.
void match_free(Match *match)
Frees the given match.
Con * con_inside_floating(Con *con)
Checks if the given container is either floating or inside some floating container.
Con * con_by_window_id(xcb_window_t window)
Returns the container with the given client window ID or NULL if no such container exists...
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
void match_parse_property(Match *match, const char *ctype, const char *cvalue)
Interprets a ctype=cvalue pair and adds it to the given match specification.
#define _i3_timercmp(a, b, CMP)
struct regex * application
A 'Con' represents everything from the X11 root window down to a single X11 window.
Con * con_get_workspace(Con *con)
Gets the workspace container this node is on.
bool match_is_empty(Match *match)
Check if a match is empty.
struct pending_marks * marks
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
bool match_matches_window(Match *match, i3Window *window)
Check if a match data structure matches the given window.
struct all_cons_head all_cons
enum Match::@16 window_mode
void regex_free(struct regex *regex)
Frees the given regular expression.
A "match" is a data structure which acts like a mask or expression to match certain windows or not...
void match_copy(Match *dest, Match *src)
Copies the data of a match from src to dest.
bool regex_matches(struct regex *regex, const char *input)
Checks if the given regular expression matches the given input and returns true if it does...
void match_init(Match *match)
Initializes the Match data structure.
struct regex * regex_new(const char *pattern)
Creates a new 'regex' struct containing the given pattern and a PCRE compiled regular expression...
#define TAILQ_FOREACH(var, head, field)
#define DUPLICATE_REGEX(field)
enum Window::@13 dock
Whether the window says it is a dock window.