diff options
author | taiyu <taiyu.len@gmail.com> | 2015-08-24 01:11:21 -0700 |
---|---|---|
committer | taiyu <taiyu.len@gmail.com> | 2015-08-24 01:11:21 -0700 |
commit | dbad30a409b83d2e327e5eb2a53b46f12e462258 (patch) | |
tree | beedc915a86c4a1109fd0cf4de7961642ccd8354 /sway | |
parent | Merge branch 'master' of https://github.com/SirCmpwn/sway (diff) | |
download | sway-dbad30a409b83d2e327e5eb2a53b46f12e462258.tar.gz sway-dbad30a409b83d2e327e5eb2a53b46f12e462258.tar.zst sway-dbad30a409b83d2e327e5eb2a53b46f12e462258.zip |
add limit to swayc_in_direction
Diffstat (limited to 'sway')
-rw-r--r-- | sway/container.c | 26 | ||||
-rw-r--r-- | sway/input_state.c | 13 | ||||
-rw-r--r-- | sway/layout.c | 9 |
3 files changed, 41 insertions, 7 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 | ||
401 | swayc_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 | } | ||
413 | swayc_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 | |||
401 | static swayc_t *_swayc_by_handle_helper(wlc_handle handle, swayc_t *parent) { | 427 | static 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; |
diff --git a/sway/input_state.c b/sway/input_state.c index e911d9cf..10425c57 100644 --- a/sway/input_state.c +++ b/sway/input_state.c | |||
@@ -119,15 +119,20 @@ static void set_initial_view(swayc_t *view) { | |||
119 | 119 | ||
120 | static void set_initial_sibling(void) { | 120 | static void set_initial_sibling(void) { |
121 | bool reset = true; | 121 | bool reset = true; |
122 | if ((initial.horiz.ptr = get_swayc_in_direction(initial.ptr, lock.left ? MOVE_RIGHT: MOVE_LEFT))) { | 122 | swayc_t *ws = swayc_active_workspace_for(initial.ptr); |
123 | if ((initial.horiz.ptr = get_swayc_in_direction_under(initial.ptr, | ||
124 | lock.left ? MOVE_RIGHT: MOVE_LEFT, ws))) { | ||
123 | initial.horiz.w = initial.horiz.ptr->width; | 125 | initial.horiz.w = initial.horiz.ptr->width; |
124 | initial.horiz.parent.ptr = get_swayc_in_direction(initial.horiz.ptr, lock.left ? MOVE_LEFT : MOVE_RIGHT); | 126 | initial.horiz.parent.ptr = get_swayc_in_direction_under(initial.horiz.ptr, |
127 | lock.left ? MOVE_LEFT : MOVE_RIGHT, ws); | ||
125 | initial.horiz.parent.w = initial.horiz.parent.ptr->width; | 128 | initial.horiz.parent.w = initial.horiz.parent.ptr->width; |
126 | reset = false; | 129 | reset = false; |
127 | } | 130 | } |
128 | if ((initial.vert.ptr = get_swayc_in_direction(initial.ptr, lock.top ? MOVE_DOWN: MOVE_UP))) { | 131 | if ((initial.vert.ptr = get_swayc_in_direction_under(initial.ptr, |
132 | lock.top ? MOVE_DOWN: MOVE_UP, ws))) { | ||
129 | initial.vert.h = initial.vert.ptr->height; | 133 | initial.vert.h = initial.vert.ptr->height; |
130 | initial.vert.parent.ptr = get_swayc_in_direction(initial.vert.ptr, lock.top ? MOVE_UP : MOVE_DOWN); | 134 | initial.vert.parent.ptr = get_swayc_in_direction_under(initial.vert.ptr, |
135 | lock.top ? MOVE_UP : MOVE_DOWN, ws); | ||
131 | initial.vert.parent.h = initial.vert.parent.ptr->height; | 136 | initial.vert.parent.h = initial.vert.parent.ptr->height; |
132 | reset = false; | 137 | reset = false; |
133 | } | 138 | } |
diff --git a/sway/layout.c b/sway/layout.c index bc12b9b1..a37e137c 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -353,8 +353,7 @@ void arrange_windows(swayc_t *container, double width, double height) { | |||
353 | layout_log(&root_container, 0); | 353 | layout_log(&root_container, 0); |
354 | } | 354 | } |
355 | 355 | ||
356 | 356 | swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_direction dir, swayc_t *limit) { | |
357 | swayc_t *get_swayc_in_direction(swayc_t *container, enum movement_direction dir) { | ||
358 | swayc_t *parent = container->parent; | 357 | swayc_t *parent = container->parent; |
359 | 358 | ||
360 | if (dir == MOVE_PARENT) { | 359 | if (dir == MOVE_PARENT) { |
@@ -453,7 +452,7 @@ swayc_t *get_swayc_in_direction(swayc_t *container, enum movement_direction dir) | |||
453 | if (!can_move) { | 452 | if (!can_move) { |
454 | container = parent; | 453 | container = parent; |
455 | parent = parent->parent; | 454 | parent = parent->parent; |
456 | if (!parent) { | 455 | if (!parent || container == limit) { |
457 | // Nothing we can do | 456 | // Nothing we can do |
458 | return NULL; | 457 | return NULL; |
459 | } | 458 | } |
@@ -461,6 +460,10 @@ swayc_t *get_swayc_in_direction(swayc_t *container, enum movement_direction dir) | |||
461 | } | 460 | } |
462 | } | 461 | } |
463 | 462 | ||
463 | swayc_t *get_swayc_in_direction(swayc_t *container, enum movement_direction dir) { | ||
464 | return get_swayc_in_direction_under(container, dir, NULL); | ||
465 | } | ||
466 | |||
464 | void recursive_resize(swayc_t *container, double amount, enum wlc_resize_edge edge) { | 467 | void recursive_resize(swayc_t *container, double amount, enum wlc_resize_edge edge) { |
465 | int i; | 468 | int i; |
466 | bool layout_match = true; | 469 | bool layout_match = true; |