Compares the X11 window ID, which you can get via +xwininfo+ for example.
title::
Compares the X11 window title (_NET_WM_NAME or WM_NAME as fallback).
+urgent::
+ Compares the urgent state of the window. Can be "latest" or "oldest".
+ Matches the latest or oldest urgent window, respectively.
+ (The following aliases are also available: newest, last, recent, first)
con_mark::
Compares the mark set for this container, see <<vim_like_marks>>.
con_id::
/** Whether the application needs to receive WM_TAKE_FOCUS */
bool needs_take_focus;
+ /** When this window was marked urgent. 0 means not urgent */
+ time_t urgent;
+
/** Whether this window accepts focus. We store this inverted so that the
* default will be 'accepts focus'. */
bool doesnt_accept_focus;
struct regex *instance;
struct regex *mark;
struct regex *role;
+ enum {
+ U_DONTCHECK = -1,
+ U_LATEST = 0,
+ U_OLDEST = 1
+ } urgent;
enum {
M_DONTCHECK = -1,
M_NODOCK = 0,
ctype = 'id' -> CRITERION
ctype = 'con_mark' -> CRITERION
ctype = 'title' -> CRITERION
+ ctype = 'urgent' -> CRITERION
']' -> call cmd_criteria_match_windows(); INITIAL
state CRITERION:
con_id { yy_push_state(WANT_QSTRING); return TOK_CON_ID; }
con_mark { yy_push_state(WANT_QSTRING); return TOK_MARK; }
title { yy_push_state(WANT_QSTRING); return TOK_TITLE; }
+urgent { yy_push_state(WANT_QSTRING); return TOK_URGENT; }
<*>{EOL} {
FREE(context->line_copy);
%token TOK_ID "id"
%token TOK_CON_ID "con_id"
%token TOK_TITLE "title"
+%token TOK_URGENT "urgent"
%type <binding> binding
%type <binding> bindcode
current_match.title = regex_new($3);
free($3);
}
+ | TOK_URGENT '=' STR
+ {
+ printf("criteria: urgent = %s\n", $3);
+ if (strcasecmp($3, "latest") == 0 ||
+ strcasecmp($3, "newest") == 0 ||
+ strcasecmp($3, "recent") == 0 ||
+ strcasecmp($3, "last") == 0) {
+ current_match.urgent = U_LATEST;
+ } else if (strcasecmp($3, "oldest") == 0 ||
+ strcasecmp($3, "first") == 0) {
+ current_match.urgent = U_OLDEST;
+ }
+ free($3);
+ }
;
qstring_or_number:
return NULL;
}
+ if (strcmp(ctype, "urgent") == 0) {
+ if (strcasecmp(cvalue, "latest") == 0 ||
+ strcasecmp(cvalue, "newest") == 0 ||
+ strcasecmp(cvalue, "recent") == 0 ||
+ strcasecmp(cvalue, "last") == 0) {
+ current_match->urgent = U_LATEST;
+ } else if (strcasecmp(cvalue, "oldest") == 0 ||
+ strcasecmp(cvalue, "first") == 0) {
+ current_match->urgent = U_OLDEST;
+ }
+ return NULL;
+ }
+
ELOG("Unknown criterion: %s\n", ctype);
/* This command is internal and does not generate a JSON reply. */
if (!con->urgent && focused == con) {
DLOG("Ignoring urgency flag for current client\n");
+ con->window->urgent = 0;
goto end;
}
/* Update the flag on the client directly */
con->urgent = (xcb_icccm_wm_hints_get_urgency(&hints) != 0);
//CLIENT_LOG(con);
+ if (con->window) {
+ if (con->urgent) {
+ con->window->urgent = time(NULL);
+ } else {
+ con->window->urgent = 0;
+ }
+ }
LOG("Urgency flag changed to %d\n", con->urgent);
Con *ws;
void match_init(Match *match) {
memset(match, 0, sizeof(Match));
match->dock = -1;
+ match->urgent = U_DONTCHECK;
}
/*
match->class == NULL &&
match->instance == NULL &&
match->role == NULL &&
+ match->urgent == U_DONTCHECK &&
match->id == XCB_NONE &&
match->con_id == NULL &&
match->dock == -1 &&
}
}
+ 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) ||