Bugfix: Insert the new client after the currently active one, not always at the end

next
Michael Stapelberg 2009-02-28 02:24:38 +01:00
parent cdb92e6a49
commit 74c973e8c6
1 changed files with 9 additions and 3 deletions

View File

@ -119,7 +119,7 @@ out:
* reparent_window() gets called when a new window was opened and becomes a child of the root * reparent_window() gets called when a new window was opened and becomes a child of the root
* window, or it gets called by us when we manage the already existing windows at startup. * window, or it gets called by us when we manage the already existing windows at startup.
* *
* Essentially, this is the point, where we take over control. * Essentially, this is the point where we take over control.
* *
*/ */
void reparent_window(xcb_connection_t *conn, xcb_window_t child, void reparent_window(xcb_connection_t *conn, xcb_window_t child,
@ -143,6 +143,7 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
uint32_t values[3]; uint32_t values[3];
/* Update the data structures */ /* Update the data structures */
Client *old_focused = CUR_CELL->currently_focused;
CUR_CELL->currently_focused = new; CUR_CELL->currently_focused = new;
new->container = CUR_CELL; new->container = CUR_CELL;
@ -238,8 +239,13 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
} }
/* Insert into the currently active container, if its not a dock window */ /* Insert into the currently active container, if its not a dock window */
if (!new->dock) if (!new->dock) {
CIRCLEQ_INSERT_TAIL(&(CUR_CELL->clients), new, clients); /* Insert after the old active client, if existing. If it does not exist, the
container is empty and it does not matter, where we insert it */
if (old_focused != NULL)
CIRCLEQ_INSERT_AFTER(&(CUR_CELL->clients), old_focused, new, clients);
else CIRCLEQ_INSERT_TAIL(&(CUR_CELL->clients), new, clients);
}
render_layout(conn); render_layout(conn);
} }