From 37065cd0c4faa6757f1f53bfd5c2bf8b521edc7c Mon Sep 17 00:00:00 2001 From: Nicolas Cornu Date: Thu, 6 Oct 2016 20:23:46 +0200 Subject: add click on title_bar to focus a container --- sway/container.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'sway/container.c') diff --git a/sway/container.c b/sway/container.c index 73b627ec..9d5e2690 100644 --- a/sway/container.c +++ b/sway/container.c @@ -722,6 +722,25 @@ swayc_t *container_under_pointer(void) { return lookup; } +swayc_t *container_find(swayc_t *container, bool (*f)(swayc_t *, const void *), const void *data) { + if (container->children == NULL || container->children->length == 0) { + return NULL; + } + + for (int i = 0; i < container->children->length; ++i) { + if (f(container->children->items[i], data)) { + return container->children->items[i]; + } + + swayc_t *find = container_find(container->children->items[i], f, data); + if (find != NULL) { + return find; + } + } + + return NULL; +} + // Container information bool swayc_is_fullscreen(swayc_t *view) { -- cgit v1.2.3