summaryrefslogtreecommitdiffstats
path: root/sway/container.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/container.c')
-rw-r--r--sway/container.c26
1 files changed, 26 insertions, 0 deletions
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) {
398 return container; 398 return container;
399} 399}
400 400
401swayc_t *swayc_focus_by_type(swayc_t *container, enum swayc_types type) {
402 if (!ASSERT_NONNULL(container)) {
403 return NULL;
404 }
405 if (!sway_assert(type < C_TYPES && type >= C_ROOT, "%s: invalid type", __func__)) {
406 return NULL;
407 }
408 do {
409 container = container->focused;
410 } while (container && container->type != type);
411 return container;
412}
413swayc_t *swayc_focus_by_layout(swayc_t *container, enum swayc_layouts layout) {
414 if (!ASSERT_NONNULL(container)) {
415 return NULL;
416 }
417 if (!sway_assert(layout < L_LAYOUTS && layout >= L_NONE, "%s: invalid layout", __func__)) {
418 return NULL;
419 }
420 do {
421 container = container->focused;
422 } while (container && container->layout != layout);
423 return container;
424}
425
426
401static swayc_t *_swayc_by_handle_helper(wlc_handle handle, swayc_t *parent) { 427static swayc_t *_swayc_by_handle_helper(wlc_handle handle, swayc_t *parent) {
402 if (!parent || !parent->children) { 428 if (!parent || !parent->children) {
403 return NULL; 429 return NULL;