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 if (match->
class != NULL) {
95 LOG(
"window class matches focused window\n");
108 LOG(
"window instance matches focused window\n");
116 if (match->
id != XCB_NONE) {
117 if (window->
id == match->
id) {
118 LOG(
"match made by window id (%d)\n", window->
id);
120 LOG(
"window id does not match\n");
125 if (match->
title != NULL) {
126 if (window->
name == NULL)
130 if (strcmp(match->
title->
pattern,
"__focused__") == 0 &&
132 LOG(
"window title matches focused window\n");
134 LOG(
"title matches (%s)\n", title);
141 if (window->
role == NULL)
145 LOG(
"window role matches focused window\n");
147 LOG(
"window_role matches (%s)\n", window->
role);
162 if (match->
urgent == U_LATEST) {
164 if (window->
urgent.tv_sec == 0) {
169 if ((con->
window != NULL) &&
174 LOG(
"urgent matches latest\n");
177 if (match->
urgent == U_OLDEST) {
179 if (window->
urgent.tv_sec == 0) {
184 if ((con->
window != NULL) &&
190 LOG(
"urgent matches oldest\n");
203 LOG(
"workspace matches focused workspace\n");
205 LOG(
"workspace matches (%s)\n", ws->
name);
211 if (match->
dock != M_DONTCHECK) {
212 if ((window->
dock == W_DOCK_TOP && match->
dock == M_DOCK_TOP) ||
213 (window->
dock == W_DOCK_BOTTOM && match->
dock == M_DOCK_BOTTOM) ||
214 ((window->
dock == W_DOCK_TOP || window->
dock == W_DOCK_BOTTOM) &&
215 match->
dock == M_DOCK_ANY) ||
216 (window->
dock == W_NODOCK && match->
dock == M_NODOCK)) {
217 LOG(
"dock status matches\n");
219 LOG(
"dock status does not match\n");
224 if (match->
mark != NULL) {
228 bool matched =
false;
238 LOG(
"mark matches\n");
240 LOG(
"mark does not match\n");
251 if ((match->
window_mode == WM_TILING && floating) ||
252 (match->
window_mode == WM_FLOATING && !floating)) {
253 LOG(
"window_mode does not match\n");
257 LOG(
"window_mode matches\n");
283 assert(match != NULL);
284 DLOG(
"ctype=*%s*, cvalue=*%s*\n", ctype, cvalue);
286 if (strcmp(ctype,
"class") == 0) {
292 if (strcmp(ctype,
"instance") == 0) {
298 if (strcmp(ctype,
"window_role") == 0) {
304 if (strcmp(ctype,
"con_id") == 0) {
305 if (strcmp(cvalue,
"__focused__") == 0) {
312 ELOG(
"Could not parse con id \"%s\"\n", cvalue);
321 if (strcmp(ctype,
"id") == 0) {
324 ELOG(
"Could not parse window id \"%s\"\n", cvalue);
328 DLOG(
"window id as int = %d\n", match->
id);
333 if (strcmp(ctype,
"window_type") == 0) {
334 if (strcasecmp(cvalue,
"normal") == 0) {
336 }
else if (strcasecmp(cvalue,
"dialog") == 0) {
338 }
else if (strcasecmp(cvalue,
"utility") == 0) {
339 match->
window_type = A__NET_WM_WINDOW_TYPE_UTILITY;
340 }
else if (strcasecmp(cvalue,
"toolbar") == 0) {
341 match->
window_type = A__NET_WM_WINDOW_TYPE_TOOLBAR;
342 }
else if (strcasecmp(cvalue,
"splash") == 0) {
344 }
else if (strcasecmp(cvalue,
"menu") == 0) {
346 }
else if (strcasecmp(cvalue,
"dropdown_menu") == 0) {
347 match->
window_type = A__NET_WM_WINDOW_TYPE_DROPDOWN_MENU;
348 }
else if (strcasecmp(cvalue,
"popup_menu") == 0) {
349 match->
window_type = A__NET_WM_WINDOW_TYPE_POPUP_MENU;
350 }
else if (strcasecmp(cvalue,
"tooltip") == 0) {
351 match->
window_type = A__NET_WM_WINDOW_TYPE_TOOLTIP;
352 }
else if (strcasecmp(cvalue,
"notification") == 0) {
353 match->
window_type = A__NET_WM_WINDOW_TYPE_NOTIFICATION;
355 ELOG(
"unknown window_type value \"%s\"\n", cvalue);
362 if (strcmp(ctype,
"con_mark") == 0) {
368 if (strcmp(ctype,
"title") == 0) {
374 if (strcmp(ctype,
"urgent") == 0) {
375 if (strcasecmp(cvalue,
"latest") == 0 ||
376 strcasecmp(cvalue,
"newest") == 0 ||
377 strcasecmp(cvalue,
"recent") == 0 ||
378 strcasecmp(cvalue,
"last") == 0) {
380 }
else if (strcasecmp(cvalue,
"oldest") == 0 ||
381 strcasecmp(cvalue,
"first") == 0) {
387 if (strcmp(ctype,
"workspace") == 0) {
393 if (strcmp(ctype,
"tiling") == 0) {
398 if (strcmp(ctype,
"floating") == 0) {
403 ELOG(
"Unknown criterion: %s\n", ctype);
char * role
The WM_WINDOW_ROLE of this window (for example, the pidgin buddy window sets "buddy list")...
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
const char * i3string_as_utf8(i3String *str)
Returns the UTF-8 encoded version of the i3String.
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
A 'Con' represents everything from the X11 root window down to a single X11 window.
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...
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)
bool parse_long(const char *str, long *out, int base)
Converts a string into a long using strtol().
Con * con_get_workspace(Con *con)
Gets the workspace container this node is on.
#define TAILQ_FOREACH(var, head, field)
bool match_is_empty(Match *match)
Check if a match is empty.
bool match_matches_window(Match *match, i3Window *window)
Check if a match data structure matches the given window.
struct all_cons_head all_cons
i3String * name
The name of the window.
struct regex * window_role
void regex_free(struct regex *regex)
Frees the given regular expression.
struct timeval urgent
When this window was marked urgent.
A "match" is a data structure which acts like a mask or expression to match certain windows or not...
enum Window::@13 dock
Whether the window says it is a dock window.
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...
struct regex * application
void match_init(Match *match)
struct regex * regex_new(const char *pattern)
Creates a new 'regex' struct containing the given pattern and a PCRE compiled regular expression...
xcb_atom_t window_type
The _NET_WM_WINDOW_TYPE for this window.
#define DUPLICATE_REGEX(field)
enum Match::@16 window_mode