[digesting_libdecor] collapse new/free states and just pass W,H to frame_commit

main
Allen Webster 2026-02-27 09:18:29 -08:00
parent 4d9d8d1081
commit 3ba29693f4
2 changed files with 20 additions and 76 deletions

View File

@ -545,9 +545,7 @@ int main(){
if (ctx.has_cached_config){
ctx.has_cached_config = 0;
struct libdecor_state *state = libdecor_state_new(ctx.w, ctx.h);
libdecor_frame_commit(ctx.frame, state, &ctx.cached_config);
libdecor_state_free(state);
libdecor_frame_commit(ctx.frame, ctx.w, ctx.h, &ctx.cached_config);
}
/* (nodocs-wl_egl) */
@ -622,16 +620,12 @@ LIBDECOR_WINDOW_STATE_TILED_TOP | LIBDECOR_WINDOW_STATE_TILED_BOTTOM;
static bool
state_is_floating(enum libdecor_window_state window_state)
{
state_is_floating(enum libdecor_window_state window_state){
return !(window_state & states_non_floating);
}
static void
constrain_content_size(const struct libdecor_frame *frame,
int *width,
int *height)
{
constrain_content_size(const struct libdecor_frame *frame, int *width, int *height){
const struct libdecor_limits lim = frame->content_limits;
if (lim.min_width > 0)
@ -646,8 +640,7 @@ constrain_content_size(const struct libdecor_frame *frame,
}
static bool
frame_has_visible_client_side_decoration(struct libdecor_frame *frame)
{
frame_has_visible_client_side_decoration(struct libdecor_frame *frame){
/* visibility by client configuration */
const bool vis_client = frame->visible;
/* visibility by compositor configuration */
@ -657,43 +650,6 @@ frame_has_visible_client_side_decoration(struct libdecor_frame *frame)
return vis_client && vis_server;
}
int
libdecor_state_get_content_width(struct libdecor_state *state)
{
return state->content_width;
}
int
libdecor_state_get_content_height(struct libdecor_state *state)
{
return state->content_height;
}
enum libdecor_window_state
libdecor_state_get_window_state(struct libdecor_state *state)
{
return state->window_state;
}
struct libdecor_state *
libdecor_state_new(int width,
int height)
{
struct libdecor_state *state;
state = calloc(1, sizeof *state);
state->content_width = width;
state->content_height = height;
return state;
}
void
libdecor_state_free(struct libdecor_state *state)
{
free(state);
}
static struct libdecor_configuration *
libdecor_configuration_new(void)
{
@ -825,9 +781,7 @@ xdg_surface_configure(void *user_data, struct xdg_surface *xdg_surface, uint32_t
}
if (!ctx.configured){
ctx.configured = 1;
struct libdecor_state *state = libdecor_state_new(w, h);
libdecor_frame_commit(frame, state, configuration);
libdecor_state_free(state);
libdecor_frame_commit(frame, w, h, configuration);
}
else{
ctx.has_cached_config = 1;
@ -1135,9 +1089,7 @@ set_capabilities(struct libdecor_frame *frame, const enum libdecor_capabilities
frame->content_limits = frame->interactive_limits;
}
state = libdecor_state_new(frame->frame_content_width, frame->frame_content_height);
libdecor_frame_commit(frame, state, 0);
libdecor_state_free(state);
libdecor_frame_commit(frame, frame->frame_content_width, frame->frame_content_height, 0);
wl_surface_commit(ctx.wl_surface);
}
@ -1341,22 +1293,25 @@ libdecor_frame_apply_state(struct libdecor_frame *frame, struct libdecor_state *
}
void
libdecor_frame_commit(struct libdecor_frame *frame, struct libdecor_state *state,
libdecor_frame_commit(struct libdecor_frame *frame, int w, int h,
struct libdecor_configuration *configuration){
if (configuration && configuration->has_window_state){
struct libdecor_state state = {0};
state.content_width = w;
state.content_height = h;
if (configuration != 0 && configuration->has_window_state){
frame->frame_window_state = configuration->window_state;
state->window_state = configuration->window_state;
state.window_state = configuration->window_state;
}
else{
state->window_state = frame->frame_window_state;
state.window_state = frame->frame_window_state;
}
libdecor_frame_apply_state(frame, state);
libdecor_frame_apply_state(frame, &state);
/* switch between decoration modes */
if (frame_has_visible_client_side_decoration(frame)){
libdecor_plugin_gtk_frame_commit(frame, state,
configuration);
libdecor_plugin_gtk_frame_commit(frame, &state, configuration);
}
else{
libdecor_plugin_gtk_frame_free(frame);
@ -1364,7 +1319,7 @@ libdecor_frame_commit(struct libdecor_frame *frame, struct libdecor_state *state
frame_set_window_geometry(frame, frame->frame_content_width, frame->frame_content_height);
if (configuration){
if (configuration != 0){
xdg_surface_ack_configure(frame->xdg_surface, configuration->serial);
}
}
@ -2795,11 +2750,10 @@ draw_title_bar(struct libdecor_frame *frame)
H = frame->frame_content_height;
if (W < frame->content_limits.min_width) {
W = frame->content_limits.min_width;
struct libdecor_state *libdecor_state = libdecor_state_new(W, H);
libdecor_frame_commit(frame, libdecor_state, NULL);
libdecor_state_free(libdecor_state);
libdecor_frame_commit(frame, W, H, NULL);
return;
}
/* set default height */
gtk_widget_get_preferred_height(frame->header, NULL, &allocation.height);

View File

@ -387,7 +387,7 @@ void libdecor_frame_move(struct libdecor_frame *frame,
struct wl_seat *wl_seat,
uint32_t serial);
void libdecor_frame_commit(struct libdecor_frame *frame,
struct libdecor_state *state,
int w, int h,
struct libdecor_configuration *configuration);
void libdecor_frame_set_minimized(struct libdecor_frame *frame);
void libdecor_frame_set_maximized(struct libdecor_frame *frame);
@ -399,8 +399,6 @@ bool libdecor_frame_is_floating(struct libdecor_frame *frame);
void libdecor_frame_close(struct libdecor_frame *frame);
void libdecor_frame_map(struct libdecor_frame *frame);
struct libdecor_state * libdecor_state_new(int width, int height);
void libdecor_state_free(struct libdecor_state *state);
bool libdecor_configuration_get_content_size(struct libdecor_configuration *configuration,
struct libdecor_frame *frame,
int *width,
@ -410,14 +408,6 @@ bool libdecor_configuration_get_window_state(struct libdecor_configuration *conf
int libdecor_dispatch(int timeout);
// libdecor-plugin.h
int libdecor_state_get_content_width(struct libdecor_state *state);
int libdecor_state_get_content_height(struct libdecor_state *state);
enum libdecor_window_state libdecor_state_get_window_state(struct libdecor_state *state);
// #include "libdecor-cairo-blur.h"
int blur_surface(cairo_surface_t *surface, int margin);