2 #define I3__FILE__ "match.c"
19 # define _i3_timercmp(a, b, CMP) \
20 (((a).tv_sec == (b).tv_sec) ? \
21 ((a).tv_usec CMP (b).tv_usec) : \
22 ((a).tv_sec CMP (b).tv_sec))
31 memset(match, 0,
sizeof(
Match));
33 match->
urgent = U_DONTCHECK;
45 return (match->
title == NULL &&
46 match->
mark == NULL &&
48 match->
class == NULL &&
50 match->
role == NULL &&
51 match->
urgent == U_DONTCHECK &&
52 match->
id == XCB_NONE &&
63 memcpy(dest, src,
sizeof(
Match));
68 #define DUPLICATE_REGEX(field) do { \
69 if (src->field != NULL) \
70 dest->field = regex_new(src->field->pattern); \
88 if (match->
class != NULL) {
106 if (match->
id != XCB_NONE) {
107 if (window->
id == match->
id) {
108 LOG(
"match made by window id (%d)\n", window->
id);
110 LOG(
"window id does not match\n");
115 if (match->
title != NULL) {
116 if (window->
name != NULL &&
124 if (match->
role != NULL) {
125 if (window->
role != NULL &&
127 LOG(
"window_role matches (%s)\n", window->
role);
134 if (match->
urgent == U_LATEST) {
136 if (window->
urgent.tv_sec == 0) {
141 if ((con->
window != NULL) &&
146 LOG(
"urgent matches latest\n");
149 if (match->
urgent == U_OLDEST) {
151 if (window->
urgent.tv_sec == 0) {
156 if ((con->
window != NULL) &&
162 LOG(
"urgent matches oldest\n");
165 if (match->
dock != -1) {
166 if ((window->
dock == W_DOCK_TOP && match->
dock == M_DOCK_TOP) ||
167 (window->
dock == W_DOCK_BOTTOM && match->
dock == M_DOCK_BOTTOM) ||
168 ((window->
dock == W_DOCK_TOP || window->
dock == W_DOCK_BOTTOM) &&
169 match->
dock == M_DOCK_ANY) ||
170 (window->
dock == W_NODOCK && match->
dock == M_NODOCK)) {
171 LOG(
"dock status matches\n");
173 LOG(
"dock status does not match\n");
180 if (match->
mark != NULL) {
181 LOG(
"mark does not match\n");
A 'Con' represents everything from the X11 root window down to a single X11 window.
bool match_matches_window(Match *match, i3Window *window)
Check if a match data structure matches the given window.
struct all_cons_head all_cons
char * role
The WM_WINDOW_ROLE of this window (for example, the pidgin buddy window sets "buddy list")...
#define _i3_timercmp(a, b, CMP)
i3String * name
The name of the window.
bool match_is_empty(Match *match)
Check if a match is empty.
A "match" is a data structure which acts like a mask or expression to match certain windows or not...
void regex_free(struct regex *regex)
Frees the given regular expression.
const char * i3string_as_utf8(i3String *str)
Returns the UTF-8 encoded version of the i3String.
void match_init(Match *match)
void match_free(Match *match)
Frees the given match.
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
#define DUPLICATE_REGEX(field)
struct timeval urgent
When this window was marked urgent.
struct regex * application
#define TAILQ_FOREACH(var, head, field)
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...
enum Window::@11 dock
Whether the window says it is a dock window.