From c4a84385d68373ef19d82441a0e1615c0109f0c0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ingo=20B=C3=BCrk?= Date: Tue, 14 Apr 2015 17:51:28 +0200 Subject: [PATCH] added function 'con_by_mark' to look up a con holding the given mark --- include/con.h | 7 +++++++ src/con.c | 15 +++++++++++++++ 2 files changed, 22 insertions(+) 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 -- 2.39.5