Skip to content

Commit

Permalink
remanage_window: Refactor to make clearer when a swallowing happens
Browse files Browse the repository at this point in the history
  • Loading branch information
orestisfl authored and stapelberg committed Sep 6, 2023
1 parent 82b9821 commit 908c865
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -678,27 +678,34 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
free(attr);
}

/*
* Remanages a window: performs a swallow check and runs assignments.
* Returns con for the window regardless if it updated.
*
*/
Con *remanage_window(Con *con) {
static Con *placeholder_for_con(Con *con) {
/* Make sure this windows hasn't already been swallowed. */
if (con->window->swallowed) {
run_assignments(con->window);
return con;
return NULL;
}
Match *match;
Con *nc = con_for_window(croot, con->window, &match);
if (nc == NULL || nc->window == NULL || nc->window == con->window) {
run_assignments(con->window);
return con;
return NULL;
}
/* Make sure the placeholder that wants to swallow this window didn't spawn
* after the window to follow current behavior: adding a placeholder won't
* swallow windows currently managed. */
if (nc->window->managed_since > con->window->managed_since) {
return NULL;
}
return nc;
}

/*
* Remanages a window: performs a swallow check and runs assignments.
* Returns con for the window regardless if it updated.
*
*/
Con *remanage_window(Con *con) {
Con *nc = placeholder_for_con(con);
if (!nc) {
/* The con is not updated, just run assignments */
run_assignments(con->window);
return con;
}
Expand Down

0 comments on commit 908c865

Please sign in to comment.