aboutsummaryrefslogtreecommitdiff
path: root/sway/container.c
diff options
context:
space:
mode:
authortaiyu <taiyu.len@gmail.com>2015-08-24 01:11:21 -0700
committertaiyu <taiyu.len@gmail.com>2015-08-24 01:11:21 -0700
commitdbad30a409b83d2e327e5eb2a53b46f12e462258 (patch)
treebeedc915a86c4a1109fd0cf4de7961642ccd8354 /sway/container.c
parentb054ac9d4973c8803ff8981eb1f1a754434efe4d (diff)
add limit to swayc_in_direction
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) {
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;