From c9893592be2e141a86e32824d824d2d1f84ecd91 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Wed, 6 Sep 2023 10:56:25 +0200 Subject: remanage_window: Refactor to make clearer when a swallowing happens --- src/manage.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/manage.c b/src/manage.c index a7de243e..aeef703f 100644 --- a/src/manage.c +++ b/src/manage.c @@ -678,27 +678,34 @@ out: 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; } -- cgit v1.2.3-54-g00ecf