From b54c91967061d03a7bd93003fec270eb57a2f3e0 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sat, 28 Feb 2026 17:49:11 -0800 Subject: [PATCH] [digesting_libdecor] untangle return spaghetti in then in-line the code --- digesting_libdecor.c | 83 ++++++++++++++++++++------------------------ digesting_libdecor.h | 3 -- 2 files changed, 37 insertions(+), 49 deletions(-) diff --git a/digesting_libdecor.c b/digesting_libdecor.c index a171396..750f44b 100755 --- a/digesting_libdecor.c +++ b/digesting_libdecor.c @@ -574,7 +574,43 @@ xdg_surface_configure(void *user_data, struct xdg_surface *xdg_surface, uint32_t { int w = ctx.w; int h = ctx.h; - if (libdecor_configuration_get_content_size(configuration, &w, &h)){ + + bool got_size = false; + if (configuration->has_window_state && + configuration->has_size && + configuration->window_width != 0 && + configuration->window_height != 0){ + + w = configuration->window_width; + h = configuration->window_height; + + if (ctx.visible && ctx.decoration_mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE){ + ctx.frame_window_state = configuration->window_state; + Sides2D border_size = border_size_from_window_state(configuration->window_state); + w -= border_size.x[0] + border_size.x[1]; + h -= border_size.y[0] + border_size.y[1]; + } + + /* constrain content dimensions manually */ + if (!(configuration->window_state & LIBDECOR_WINDOW_STATE_NON_FLOATING)) { + // TODO(allen): + if (ctx.size_bounds.x[0] > 0){ + w = MAX(ctx.size_bounds.x[0], w); + } + if (ctx.size_bounds.x[1] > 0){ + w = MIN(w, ctx.size_bounds.x[1]); + } + if (ctx.size_bounds.y[0] > 0){ + h = MAX(ctx.size_bounds.y[0], h); + } + if (ctx.size_bounds.y[1] > 0){ + h = MIN(h, ctx.size_bounds.y[1]); + } + } + + got_size = true; + } + if (got_size){ ctx.w = w; ctx.h = h; } @@ -1129,51 +1165,6 @@ int main(){ //#include "libdecor.c" -bool -libdecor_configuration_get_content_size(struct libdecor_configuration *configuration, int *width, int *height){ - /* get configured toplevel dimensions */ - if (!configuration->has_size) - return false; - - if (configuration->window_width == 0 || configuration->window_height == 0) - return false; - - *width = configuration->window_width; - *height = configuration->window_height; - - if (ctx.visible != 0 && - ctx.decoration_mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE){ - ctx.frame_window_state = configuration->window_state; - if (configuration->has_window_state){ - Sides2D border_size = border_size_from_window_state(configuration->window_state); - *width -= border_size.x[0] + border_size.x[1]; - *height -= border_size.y[0] + border_size.y[1]; - } - else{ - return false; - } - } - - /* constrain content dimensions manually */ - if (!(configuration->window_state & LIBDECOR_WINDOW_STATE_NON_FLOATING)) { - // TODO(allen): - if (ctx.size_bounds.x[0] > 0){ - *width = MAX(ctx.size_bounds.x[0], *width); - } - if (ctx.size_bounds.x[1] > 0){ - *width = MIN(*width, ctx.size_bounds.x[1]); - } - if (ctx.size_bounds.y[0] > 0){ - *height = MAX(ctx.size_bounds.y[0], *height); - } - if (ctx.size_bounds.y[1] > 0){ - *height = MIN(*height, ctx.size_bounds.y[1]); - } - } - - return true; -} - static enum decoration_type decoration_type_from_window_state(enum libdecor_window_state window_state){ enum decoration_type result = DECORATION_TYPE_ALL; diff --git a/digesting_libdecor.h b/digesting_libdecor.h index 8671137..214fa23 100644 --- a/digesting_libdecor.h +++ b/digesting_libdecor.h @@ -257,9 +257,6 @@ void libdecor_frame_commit(int w, int h, struct libdecor_configuration *configur void libdecor_frame_set_fullscreen(struct wl_output *output); void libdecor_frame_unset_fullscreen(void); - -bool libdecor_configuration_get_content_size(struct libdecor_configuration *configuration, int *width, int *height); - // #include "libdecor-cairo-blur.h" int blur_surface(cairo_surface_t *surface, int margin);