Refactor tree_next
- Makes `tree_next` not recursive. - Adds `focus next|prev [sibling]` command. See (1.) and (2.) in https://github.com/i3/i3/issues/2587#issuecomment-378505551 (Issue also requests move command, not implemented here). - Directional focus command now supports command criteria. Wrapping is not implemented inside a floating container. This was also true before the refactor so I am not changing it here.
This commit is contained in:
committed by
Orestis Floros
parent
f402f45702
commit
bbc4c99c72
18
src/click.c
18
src/click.c
@ -212,21 +212,13 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod
|
||||
event->detail == XCB_BUTTON_SCROLL_LEFT ||
|
||||
event->detail == XCB_BUTTON_SCROLL_RIGHT)) {
|
||||
DLOG("Scrolling on a window decoration\n");
|
||||
orientation_t orientation = con_orientation(con->parent);
|
||||
/* Use the focused child of the tabbed / stacked container, not the
|
||||
* container the user scrolled on. */
|
||||
Con *focused = con->parent;
|
||||
focused = TAILQ_FIRST(&(focused->focus_head));
|
||||
con_activate(con_descend_focused(focused));
|
||||
/* To prevent scrolling from going outside the container (see ticket
|
||||
* #557), we first check if scrolling is possible at all. */
|
||||
bool scroll_prev_possible = (TAILQ_PREV(focused, nodes_head, nodes) != NULL);
|
||||
bool scroll_next_possible = (TAILQ_NEXT(focused, nodes) != NULL);
|
||||
if ((event->detail == XCB_BUTTON_SCROLL_UP || event->detail == XCB_BUTTON_SCROLL_LEFT) && scroll_prev_possible) {
|
||||
tree_next('p', orientation);
|
||||
} else if ((event->detail == XCB_BUTTON_SCROLL_DOWN || event->detail == XCB_BUTTON_SCROLL_RIGHT) && scroll_next_possible) {
|
||||
tree_next('n', orientation);
|
||||
}
|
||||
Con *current = TAILQ_FIRST(&(con->parent->focus_head));
|
||||
const position_t direction =
|
||||
(event->detail == XCB_BUTTON_SCROLL_UP || event->detail == XCB_BUTTON_SCROLL_LEFT) ? BEFORE : AFTER;
|
||||
Con *next = get_tree_next_sibling(current, direction);
|
||||
con_activate(con_descend_focused(next ? next : current));
|
||||
|
||||
goto done;
|
||||
}
|
||||
|
Reference in New Issue
Block a user