Implement urgency flag matcher
Currently it supports the following options: "oldest": match the first window that triggered an urgent event "latest": match the last window that triggered an urgent event
This commit is contained in:
committed by
Michael Stapelberg
parent
23abfcf7f2
commit
53541817ef
34
src/match.c
34
src/match.c
@ -22,6 +22,7 @@
|
||||
void match_init(Match *match) {
|
||||
memset(match, 0, sizeof(Match));
|
||||
match->dock = -1;
|
||||
match->urgent = U_DONTCHECK;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -39,6 +40,7 @@ bool match_is_empty(Match *match) {
|
||||
match->class == NULL &&
|
||||
match->instance == NULL &&
|
||||
match->role == NULL &&
|
||||
match->urgent == U_DONTCHECK &&
|
||||
match->id == XCB_NONE &&
|
||||
match->con_id == NULL &&
|
||||
match->dock == -1 &&
|
||||
@ -120,6 +122,38 @@ bool match_matches_window(Match *match, i3Window *window) {
|
||||
}
|
||||
}
|
||||
|
||||
Con *con = NULL;
|
||||
if (match->urgent == U_LATEST) {
|
||||
/* if the window isn't urgent, no sense in searching */
|
||||
if (window->urgent == 0) {
|
||||
return false;
|
||||
}
|
||||
/* if we find a window that is newer than this one, bail */
|
||||
TAILQ_FOREACH(con, &all_cons, all_cons) {
|
||||
if ((con->window != NULL) &&
|
||||
(con->window->urgent > window->urgent)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
LOG("urgent matches latest\n");
|
||||
}
|
||||
|
||||
if (match->urgent == U_OLDEST) {
|
||||
/* if the window isn't urgent, no sense in searching */
|
||||
if (window->urgent == 0) {
|
||||
return false;
|
||||
}
|
||||
/* if we find a window that is older than this one (and not 0), bail */
|
||||
TAILQ_FOREACH(con, &all_cons, all_cons) {
|
||||
if ((con->window != NULL) &&
|
||||
(con->window->urgent != 0) &&
|
||||
(con->window->urgent < window->urgent)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
LOG("urgent matches oldest\n");
|
||||
}
|
||||
|
||||
if (match->dock != -1) {
|
||||
if ((window->dock == W_DOCK_TOP && match->dock == M_DOCK_TOP) ||
|
||||
(window->dock == W_DOCK_BOTTOM && match->dock == M_DOCK_BOTTOM) ||
|
||||
|
Reference in New Issue
Block a user