2 #define I3__FILE__ "match.c"
19 #define _i3_timercmp(a, b, CMP) \
20 (((a).tv_sec == (b).tv_sec) ? ((a).tv_usec CMP(b).tv_usec) : ((a).tv_sec CMP(b).tv_sec))
29 memset(match, 0,
sizeof(
Match));
31 match->
urgent = U_DONTCHECK;
43 return (match->
title == NULL &&
44 match->
mark == NULL &&
46 match->
class == NULL &&
49 match->
urgent == U_DONTCHECK &&
50 match->
id == XCB_NONE &&
61 memcpy(dest, src,
sizeof(
Match));
66 #define DUPLICATE_REGEX(field) \
68 if (src->field != NULL) \
69 dest->field = regex_new(src->field->pattern); \
87 if (match->
class != NULL) {
105 if (match->
id != XCB_NONE) {
106 if (window->
id == match->
id) {
107 LOG(
"match made by window id (%d)\n", window->
id);
109 LOG(
"window id does not match\n");
114 if (match->
title != NULL) {
115 if (window->
name != NULL &&
124 if (window->
role != NULL &&
126 LOG(
"window_role matches (%s)\n", window->
role);
133 if (match->
urgent == U_LATEST) {
135 if (window->
urgent.tv_sec == 0) {
140 if ((con->
window != NULL) &&
145 LOG(
"urgent matches latest\n");
148 if (match->
urgent == U_OLDEST) {
150 if (window->
urgent.tv_sec == 0) {
155 if ((con->
window != NULL) &&
161 LOG(
"urgent matches oldest\n");
164 if (match->
dock != -1) {
165 if ((window->
dock == W_DOCK_TOP && match->
dock == M_DOCK_TOP) ||
166 (window->
dock == W_DOCK_BOTTOM && match->
dock == M_DOCK_BOTTOM) ||
167 ((window->
dock == W_DOCK_TOP || window->
dock == W_DOCK_BOTTOM) &&
168 match->
dock == M_DOCK_ANY) ||
169 (window->
dock == W_NODOCK && match->
dock == M_NODOCK)) {
170 LOG(
"dock status matches\n");
172 LOG(
"dock status does not match\n");
179 if (match->
mark != NULL) {
180 LOG(
"mark does not match\n");
const char * i3string_as_utf8(i3String *str)
Returns the UTF-8 encoded version of the i3String.
#define DUPLICATE_REGEX(field)
struct all_cons_head all_cons
struct regex * window_role
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
void match_copy(Match *dest, Match *src)
Copies the data of a match from src to dest.
struct regex * application
bool match_matches_window(Match *match, i3Window *window)
Check if a match data structure matches the given window.
void regex_free(struct regex *regex)
Frees the given regular expression.
struct timeval urgent
When this window was marked urgent.
enum Window::@11 dock
Whether the window says it is a dock window.
A "match" is a data structure which acts like a mask or expression to match certain windows or not...
char * role
The WM_WINDOW_ROLE of this window (for example, the pidgin buddy window sets "buddy list")...
A 'Con' represents everything from the X11 root window down to a single X11 window.
#define _i3_timercmp(a, b, CMP)
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...
bool match_is_empty(Match *match)
Check if a match is empty.
i3String * name
The name of the window.
#define TAILQ_FOREACH(var, head, field)
void match_init(Match *match)
void match_free(Match *match)
Frees the given match.