From dbad30a409b83d2e327e5eb2a53b46f12e462258 Mon Sep 17 00:00:00 2001 From: taiyu Date: Mon, 24 Aug 2015 01:11:21 -0700 Subject: add limit to swayc_in_direction --- sway/container.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'sway/container.c') diff --git a/sway/container.c b/sway/container.c index d4f7c693..d23cef8f 100644 --- a/sway/container.c +++ b/sway/container.c @@ -398,6 +398,32 @@ swayc_t *swayc_parent_by_layout(swayc_t *container, enum swayc_layouts layout) { return container; } +swayc_t *swayc_focus_by_type(swayc_t *container, enum swayc_types type) { + if (!ASSERT_NONNULL(container)) { + return NULL; + } + if (!sway_assert(type < C_TYPES && type >= C_ROOT, "%s: invalid type", __func__)) { + return NULL; + } + do { + container = container->focused; + } while (container && container->type != type); + return container; +} +swayc_t *swayc_focus_by_layout(swayc_t *container, enum swayc_layouts layout) { + if (!ASSERT_NONNULL(container)) { + return NULL; + } + if (!sway_assert(layout < L_LAYOUTS && layout >= L_NONE, "%s: invalid layout", __func__)) { + return NULL; + } + do { + container = container->focused; + } while (container && container->layout != layout); + return container; +} + + static swayc_t *_swayc_by_handle_helper(wlc_handle handle, swayc_t *parent) { if (!parent || !parent->children) { return NULL; -- cgit v1.2.3