refactor some places to use con_descend_focused instead of duplicating code
This commit is contained in:
parent
f462a9a215
commit
3383437705
@ -483,12 +483,8 @@ void con_move_to_workspace(Con *con, Con *workspace) {
|
|||||||
* container is moved away */
|
* container is moved away */
|
||||||
Con *focus_next = con_next_focused(con);
|
Con *focus_next = con_next_focused(con);
|
||||||
|
|
||||||
/* 2: get the focused container of this workspace by going down as far as
|
/* 2: get the focused container of this workspace */
|
||||||
* possible */
|
Con *next = con_descend_focused(workspace);
|
||||||
Con *next = workspace;
|
|
||||||
|
|
||||||
while (!TAILQ_EMPTY(&(next->focus_head)))
|
|
||||||
next = TAILQ_FIRST(&(next->focus_head));
|
|
||||||
|
|
||||||
/* 3: we go up one level, but only when next is a normal container */
|
/* 3: we go up one level, but only when next is a normal container */
|
||||||
if (next->type != CT_WORKSPACE)
|
if (next->type != CT_WORKSPACE)
|
||||||
|
@ -210,11 +210,8 @@ int handle_enter_notify(void *ignored, xcb_connection_t *conn,
|
|||||||
|
|
||||||
if (config.disable_focus_follows_mouse)
|
if (config.disable_focus_follows_mouse)
|
||||||
return 1;
|
return 1;
|
||||||
Con *next = con;
|
|
||||||
while (!TAILQ_EMPTY(&(next->focus_head)))
|
|
||||||
next = TAILQ_FIRST(&(next->focus_head));
|
|
||||||
|
|
||||||
con_focus(next);
|
con_focus(con_descend_focused(con));
|
||||||
x_push_changes(croot);
|
x_push_changes(croot);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -621,12 +621,7 @@ void randr_query_outputs() {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
DLOG("Focusing primary output %s\n", output->name);
|
DLOG("Focusing primary output %s\n", output->name);
|
||||||
Con *next = output->con;
|
con_focus(con_descend_focused(output->con));
|
||||||
while (!TAILQ_EMPTY(&(next->focus_head)))
|
|
||||||
next = TAILQ_FIRST(&(next->focus_head));
|
|
||||||
|
|
||||||
DLOG("focusing %p\n", next);
|
|
||||||
con_focus(next);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* render_layout flushes */
|
/* render_layout flushes */
|
||||||
|
16
src/tree.c
16
src/tree.c
@ -155,11 +155,8 @@ void tree_close(Con *con, bool kill_window, bool dont_kill_parent) {
|
|||||||
DLOG("parent container killed\n");
|
DLOG("parent container killed\n");
|
||||||
if (con == focused) {
|
if (con == focused) {
|
||||||
DLOG("This is the focused container, i need to find another one to focus. I start looking at ws = %p\n", ws);
|
DLOG("This is the focused container, i need to find another one to focus. I start looking at ws = %p\n", ws);
|
||||||
next = ws;
|
/* go down the focus stack as far as possible */
|
||||||
/* now go down the focus stack as far as
|
next = con_descend_focused(ws);
|
||||||
* possible, excluding the current container */
|
|
||||||
while (!TAILQ_EMPTY(&(next->focus_head)))
|
|
||||||
next = TAILQ_FIRST(&(next->focus_head));
|
|
||||||
|
|
||||||
dont_kill_parent = true;
|
dont_kill_parent = true;
|
||||||
DLOG("Alright, focusing %p\n", next);
|
DLOG("Alright, focusing %p\n", next);
|
||||||
@ -361,11 +358,7 @@ void tree_next(char way, orientation_t orientation) {
|
|||||||
/* 3: focus choice comes in here. at the moment we will go down
|
/* 3: focus choice comes in here. at the moment we will go down
|
||||||
* until we find a window */
|
* until we find a window */
|
||||||
/* TODO: check for window, atm we only go down as far as possible */
|
/* TODO: check for window, atm we only go down as far as possible */
|
||||||
while (!TAILQ_EMPTY(&(next->focus_head)))
|
con_focus(con_descend_focused(next));
|
||||||
next = TAILQ_FIRST(&(next->focus_head));
|
|
||||||
|
|
||||||
DLOG("focusing %p\n", next);
|
|
||||||
con_focus(next);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -450,8 +443,7 @@ void tree_move(char way, orientation_t orientation) {
|
|||||||
next = current;
|
next = current;
|
||||||
} else {
|
} else {
|
||||||
/* if this is a split container, we need to go down */
|
/* if this is a split container, we need to go down */
|
||||||
while (!TAILQ_EMPTY(&(next->focus_head)))
|
next = con_descend_focused(next);
|
||||||
next = TAILQ_FIRST(&(next->focus_head));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,11 +226,7 @@ void workspace_show(const char *num) {
|
|||||||
workspace_reassign_sticky(workspace);
|
workspace_reassign_sticky(workspace);
|
||||||
|
|
||||||
LOG("switching to %p\n", workspace);
|
LOG("switching to %p\n", workspace);
|
||||||
Con *next = workspace;
|
Con *next = con_descend_focused(workspace);
|
||||||
|
|
||||||
while (!TAILQ_EMPTY(&(next->focus_head)))
|
|
||||||
next = TAILQ_FIRST(&(next->focus_head));
|
|
||||||
|
|
||||||
|
|
||||||
if (TAILQ_EMPTY(&(old->nodes_head)) && TAILQ_EMPTY(&(old->floating_head))) {
|
if (TAILQ_EMPTY(&(old->nodes_head)) && TAILQ_EMPTY(&(old->floating_head))) {
|
||||||
/* check if this workspace is currently visible */
|
/* check if this workspace is currently visible */
|
||||||
|
Loading…
Reference in New Issue
Block a user