From: Ingo Bürk Date: Tue, 14 Apr 2015 15:51:28 +0000 (+0200) Subject: added function 'con_by_mark' to look up a con holding the given mark X-Git-Tag: 4.11~129^2~8 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c4a84385d68373ef19d82441a0e1615c0109f0c0;p=i3%2Fi3 added function 'con_by_mark' to look up a con holding the given mark --- diff --git a/include/con.h b/include/con.h index b025adab..c760643d 100644 --- a/include/con.h +++ b/include/con.h @@ -126,6 +126,13 @@ Con *con_by_window_id(xcb_window_t window); */ Con *con_by_frame_id(xcb_window_t frame); +/** + * Returns the container with the given mark or NULL if no such container + * exists. + * + */ +Con *con_by_mark(const char *mark); + /** * Returns the first container below 'con' which wants to swallow this window * TODO: priority diff --git a/src/con.c b/src/con.c index dab8d29d..066ba1c4 100644 --- a/src/con.c +++ b/src/con.c @@ -460,6 +460,21 @@ Con *con_by_frame_id(xcb_window_t frame) { return NULL; } +/* + * Returns the container with the given mark or NULL if no such container + * exists. + * + */ +Con *con_by_mark(const char *mark) { + Con *con; + TAILQ_FOREACH(con, &all_cons, all_cons) { + if (con->mark != NULL && strcmp(con->mark, mark) == 0) + return con; + } + + return NULL; +} + /* * Returns the first container below 'con' which wants to swallow this window * TODO: priority