From babb2ccb594f16eac944eeca4449c087248a924d Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Thu, 26 Feb 2026 16:27:42 -0800 Subject: [PATCH] [digesting_libdecor] move libdecor_frame_private fields to libdecor_frame, eliminate 'private' frame --- digesting_libdecor.c | 335 +++++++++++++++++++++---------------------- digesting_libdecor.h | 7 +- 2 files changed, 167 insertions(+), 175 deletions(-) diff --git a/digesting_libdecor.c b/digesting_libdecor.c index d1fbeab..65f0227 100755 --- a/digesting_libdecor.c +++ b/digesting_libdecor.c @@ -429,17 +429,13 @@ int main(){ } { - struct libdecor_frame_private *frame_priv; + ctx.frame->ref_count = 1; - frame_priv = &ctx.frame->priv; - - frame_priv->ref_count = 1; - - frame_priv->wl_surface = ctx.wl_surface; - frame_priv->wm_capabilities = (LIBDECOR_WM_CAPABILITIES_WINDOW_MENU | - LIBDECOR_WM_CAPABILITIES_MAXIMIZE | - LIBDECOR_WM_CAPABILITIES_FULLSCREEN | - LIBDECOR_WM_CAPABILITIES_MINIMIZE); + ctx.frame->wl_surface = ctx.wl_surface; + ctx.frame->wm_capabilities = (LIBDECOR_WM_CAPABILITIES_WINDOW_MENU | + LIBDECOR_WM_CAPABILITIES_MAXIMIZE | + LIBDECOR_WM_CAPABILITIES_FULLSCREEN | + LIBDECOR_WM_CAPABILITIES_MINIMIZE); wl_list_insert(&ctx.frames, &ctx.frame->link); @@ -450,7 +446,7 @@ int main(){ LIBDECOR_ACTION_FULLSCREEN | LIBDECOR_ACTION_CLOSE); - frame_priv->visible = true; + ctx.frame->visible = true; if (ctx.init_done){ init_shell_surface(ctx.frame); @@ -652,7 +648,7 @@ constrain_content_size(const struct libdecor_frame *frame, int *width, int *height) { - const struct libdecor_limits lim = frame->priv.state.content_limits; + const struct libdecor_limits lim = frame->state.content_limits; if (lim.min_width > 0) *width = MAX(lim.min_width, *width); @@ -669,9 +665,9 @@ static bool frame_has_visible_client_side_decoration(struct libdecor_frame *frame) { /* visibility by client configuration */ - const bool vis_client = frame->priv.visible; + const bool vis_client = frame->visible; /* visibility by compositor configuration */ - const bool vis_server = (frame->priv.decoration_mode == + const bool vis_server = (frame->decoration_mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE); return vis_client && vis_server; @@ -771,7 +767,7 @@ frame_set_window_geometry(struct libdecor_frame *frame, height = content_height; } - xdg_surface_set_window_geometry(frame->priv.xdg_surface, x, y, width, height); + xdg_surface_set_window_geometry(frame->xdg_surface, x, y, width, height); } bool @@ -795,7 +791,7 @@ libdecor_configuration_get_content_size(struct libdecor_configuration *configura int left, right, top, bottom; /* Update window state for correct border size calculation */ - frame->priv.window_state = configuration->window_state; + frame->window_state = configuration->window_state; if (!libdecor_plugin_gtk_frame_get_border_size(frame, configuration, &left, &right, &top, &bottom)){ return false; } @@ -828,8 +824,8 @@ xdg_surface_configure(void *user_data, struct xdg_surface *xdg_surface, uint32_t struct libdecor_frame *frame = user_data; struct libdecor_configuration *configuration; - configuration = frame->priv.pending_configuration; - frame->priv.pending_configuration = NULL; + configuration = frame->pending_configuration; + frame->pending_configuration = NULL; if (!configuration) configuration = libdecor_configuration_new(); @@ -863,8 +859,7 @@ const struct xdg_surface_listener xdg_surface_listener = { }; static enum libdecor_window_state -parse_states(struct wl_array *states) -{ +parse_states(struct wl_array *states){ enum libdecor_window_state pending_state = LIBDECOR_WINDOW_STATE_NONE; uint32_t *p; @@ -935,12 +930,12 @@ xdg_toplevel_configure(void *user_data, window_state = parse_states(states); - frame->priv.pending_configuration = libdecor_configuration_new(); - frame->priv.pending_configuration->has_size = true; - frame->priv.pending_configuration->window_width = width; - frame->priv.pending_configuration->window_height = height; - frame->priv.pending_configuration->has_window_state = true; - frame->priv.pending_configuration->window_state = window_state; + frame->pending_configuration = libdecor_configuration_new(); + frame->pending_configuration->has_size = true; + frame->pending_configuration->window_width = width; + frame->pending_configuration->window_height = height; + frame->pending_configuration->has_window_state = true; + frame->pending_configuration->window_state = window_state; } static void @@ -972,29 +967,28 @@ xdg_toplevel_configure_bounds(void *user_data, static void xdg_toplevel_wm_capabilities(void *user_data, struct xdg_toplevel *xdg_toplevel, - struct wl_array *capabilities) -{ + struct wl_array *capabilities){ struct libdecor_frame *frame = user_data; enum xdg_toplevel_wm_capabilities *wm_cap; - frame->priv.wm_capabilities = 0; + frame->wm_capabilities = 0; wl_array_for_each(wm_cap, capabilities) { switch (*wm_cap) { case XDG_TOPLEVEL_WM_CAPABILITIES_WINDOW_MENU: { - frame->priv.wm_capabilities |= LIBDECOR_WM_CAPABILITIES_WINDOW_MENU; + frame->wm_capabilities |= LIBDECOR_WM_CAPABILITIES_WINDOW_MENU; }break; case XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE: { - frame->priv.wm_capabilities |= LIBDECOR_WM_CAPABILITIES_MAXIMIZE; + frame->wm_capabilities |= LIBDECOR_WM_CAPABILITIES_MAXIMIZE; }break; case XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN: { - frame->priv.wm_capabilities |= LIBDECOR_WM_CAPABILITIES_FULLSCREEN; + frame->wm_capabilities |= LIBDECOR_WM_CAPABILITIES_FULLSCREEN; }break; case XDG_TOPLEVEL_WM_CAPABILITIES_MINIMIZE: { - frame->priv.wm_capabilities |= LIBDECOR_WM_CAPABILITIES_MINIMIZE; + frame->wm_capabilities |= LIBDECOR_WM_CAPABILITIES_MINIMIZE; }break; default: break; @@ -1022,9 +1016,9 @@ toplevel_decoration_configure(void *data, struct libdecor_frame *frame = (struct libdecor_frame*)data; /* Ignore any _configure calls after the first, they will be * from our set_mode call. */ - if (!frame->priv.has_decoration_mode) { - frame->priv.has_decoration_mode = true; - frame->priv.decoration_mode = mode; + if (!frame->has_decoration_mode) { + frame->has_decoration_mode = true; + frame->decoration_mode = mode; } } @@ -1036,72 +1030,72 @@ xdg_toplevel_decoration_listener = { static void init_shell_surface(struct libdecor_frame *frame) { - if (frame->priv.xdg_surface) + if (frame->xdg_surface) return; - frame->priv.xdg_surface = - xdg_wm_base_get_xdg_surface(ctx.xdg_wm_base, frame->priv.wl_surface); - xdg_surface_add_listener(frame->priv.xdg_surface, + frame->xdg_surface = + xdg_wm_base_get_xdg_surface(ctx.xdg_wm_base, frame->wl_surface); + xdg_surface_add_listener(frame->xdg_surface, &xdg_surface_listener, frame); - frame->priv.xdg_toplevel = - xdg_surface_get_toplevel(frame->priv.xdg_surface); - xdg_toplevel_add_listener(frame->priv.xdg_toplevel, + frame->xdg_toplevel = + xdg_surface_get_toplevel(frame->xdg_surface); + xdg_toplevel_add_listener(frame->xdg_toplevel, &xdg_toplevel_listener, frame); - frame->priv.decoration_mode = + frame->decoration_mode = ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE; - frame->priv.toplevel_decoration = NULL; + frame->toplevel_decoration = NULL; //libdecor_frame_create_xdg_decoration(frame_priv); if (ctx.decoration_manager){ - frame->priv.toplevel_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(ctx.decoration_manager, frame->priv.xdg_toplevel); - zxdg_toplevel_decoration_v1_add_listener(frame->priv.toplevel_decoration, &xdg_toplevel_decoration_listener, frame); + frame->toplevel_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(ctx.decoration_manager, frame->xdg_toplevel); + zxdg_toplevel_decoration_v1_add_listener(frame->toplevel_decoration, &xdg_toplevel_decoration_listener, frame); } - if (frame->priv.state.parent) { - xdg_toplevel_set_parent(frame->priv.xdg_toplevel, - frame->priv.state.parent); + if (frame->state.parent) { + xdg_toplevel_set_parent(frame->xdg_toplevel, + frame->state.parent); } - if (frame->priv.state.title) { - xdg_toplevel_set_title(frame->priv.xdg_toplevel, - frame->priv.state.title); + if (frame->state.title) { + xdg_toplevel_set_title(frame->xdg_toplevel, + frame->state.title); } - if (frame->priv.state.app_id) { - xdg_toplevel_set_app_id(frame->priv.xdg_toplevel, - frame->priv.state.app_id); + if (frame->state.app_id) { + xdg_toplevel_set_app_id(frame->xdg_toplevel, + frame->state.app_id); } - if (frame->priv.pending_map) + if (frame->pending_map) do_map(frame); } void libdecor_frame_ref(struct libdecor_frame *frame){ - frame->priv.ref_count++; + frame->ref_count++; } void libdecor_frame_unref(struct libdecor_frame *frame){ - frame->priv.ref_count--; - if (frame->priv.ref_count == 0) { - if (ctx.decoration_manager && frame->priv.toplevel_decoration) { - zxdg_toplevel_decoration_v1_destroy(frame->priv.toplevel_decoration); - frame->priv.toplevel_decoration = NULL; + frame->ref_count--; + if (frame->ref_count == 0) { + if (ctx.decoration_manager && frame->toplevel_decoration) { + zxdg_toplevel_decoration_v1_destroy(frame->toplevel_decoration); + frame->toplevel_decoration = NULL; } wl_list_remove(&frame->link); - if (frame->priv.xdg_toplevel) - xdg_toplevel_destroy(frame->priv.xdg_toplevel); - if (frame->priv.xdg_surface) - xdg_surface_destroy(frame->priv.xdg_surface); + if (frame->xdg_toplevel) + xdg_toplevel_destroy(frame->xdg_toplevel); + if (frame->xdg_surface) + xdg_surface_destroy(frame->xdg_surface); libdecor_plugin_gtk_frame_free(frame); - free(frame->priv.state.title); - free(frame->priv.state.app_id); + free(frame->state.title); + free(frame->state.app_id); free(frame); } @@ -1111,7 +1105,7 @@ void libdecor_frame_set_visibility(struct libdecor_frame *frame, bool visible) { - frame->priv.visible = visible; + frame->visible = visible; /* enable/disable decorations that are managed by the compositor. * Note that, as of xdg_decoration v1, this is just a hint and there is @@ -1121,29 +1115,30 @@ libdecor_frame_set_visibility(struct libdecor_frame *frame, * See also: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/17 */ if (ctx.decoration_manager && - frame->priv.toplevel_decoration && - frame->priv.has_decoration_mode && - frame->priv.decoration_mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE) { - zxdg_toplevel_decoration_v1_set_mode(frame->priv.toplevel_decoration, - frame->priv.visible + frame->toplevel_decoration && + frame->has_decoration_mode && + frame->decoration_mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE) { + zxdg_toplevel_decoration_v1_set_mode(frame->toplevel_decoration, + frame->visible ? ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE : ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE); } - if (frame->priv.content_width <= 0 || - frame->priv.content_height <= 0) + if (frame->content_width <= 0 || + frame->content_height <= 0) return; /* enable/disable decorations that are managed by a plugin */ - if (frame_has_visible_client_side_decoration(frame)) { + if (frame_has_visible_client_side_decoration(frame)){ /* show client-side decorations */ libdecor_plugin_gtk_frame_commit(frame, NULL, NULL); - } else { + } + else{ /* destroy client-side decorations */ libdecor_plugin_gtk_frame_free(frame); } - frame_set_window_geometry(frame, frame->priv.content_width, frame->priv.content_height); + frame_set_window_geometry(frame, frame->content_width, frame->content_height); libdecor_frame_toplevel_commit(frame); } @@ -1152,25 +1147,25 @@ void libdecor_frame_set_parent(struct libdecor_frame *frame, struct libdecor_frame *parent) { - if (!frame->priv.xdg_toplevel) + if (!frame->xdg_toplevel) return; - frame->priv.state.parent = ((parent != 0) ? parent->priv.xdg_toplevel : 0); + frame->state.parent = ((parent != 0) ? parent->xdg_toplevel : 0); - xdg_toplevel_set_parent(frame->priv.xdg_toplevel, frame->priv.state.parent); + xdg_toplevel_set_parent(frame->xdg_toplevel, frame->state.parent); } void libdecor_frame_set_title(struct libdecor_frame *frame, const char *title){ - if (!STREQL(frame->priv.state.title, title)){ - free(frame->priv.state.title); - frame->priv.state.title = strdup(title); + if (!STREQL(frame->state.title, title)){ + free(frame->state.title); + frame->state.title = strdup(title); - if (!frame->priv.xdg_toplevel){ + if (!frame->xdg_toplevel){ return; } - xdg_toplevel_set_title(frame->priv.xdg_toplevel, title); + xdg_toplevel_set_title(frame->xdg_toplevel, title); libdecor_plugin_gtk_frame_property_changed(frame); } @@ -1178,18 +1173,18 @@ libdecor_frame_set_title(struct libdecor_frame *frame, const char *title){ const char * libdecor_frame_get_title(struct libdecor_frame *frame){ - return frame->priv.state.title; + return frame->state.title; } void libdecor_frame_set_app_id(struct libdecor_frame *frame, const char *app_id){ - free(frame->priv.state.app_id); - frame->priv.state.app_id = strdup(app_id); + free(frame->state.app_id); + frame->state.app_id = strdup(app_id); - if (!frame->priv.xdg_toplevel) + if (!frame->xdg_toplevel) return; - xdg_toplevel_set_app_id(frame->priv.xdg_toplevel, app_id); + xdg_toplevel_set_app_id(frame->xdg_toplevel, app_id); } static void @@ -1198,31 +1193,31 @@ notify_on_capability_change(struct libdecor_frame *frame, { struct libdecor_state *state; - if (frame->priv.capabilities == old_capabilities) + if (frame->capabilities == old_capabilities) return; - if (frame->priv.content_width == 0 || - frame->priv.content_height == 0) + if (frame->content_width == 0 || + frame->content_height == 0) return; libdecor_plugin_gtk_frame_property_changed(frame); if (!libdecor_frame_has_capability(frame, LIBDECOR_ACTION_RESIZE)) { - frame->priv.interactive_limits = frame->priv.state.content_limits; + frame->interactive_limits = frame->state.content_limits; /* set fixed window size */ libdecor_frame_set_min_content_size(frame, - frame->priv.content_width, - frame->priv.content_height); + frame->content_width, + frame->content_height); libdecor_frame_set_max_content_size(frame, - frame->priv.content_width, - frame->priv.content_height); + frame->content_width, + frame->content_height); } else { /* restore old limits */ - frame->priv.state.content_limits = frame->priv.interactive_limits; + frame->state.content_limits = frame->interactive_limits; } - state = libdecor_state_new(frame->priv.content_width, - frame->priv.content_height); + state = libdecor_state_new(frame->content_width, + frame->content_height); libdecor_frame_commit(frame, state, NULL); libdecor_state_free(state); @@ -1233,8 +1228,8 @@ void libdecor_frame_set_capabilities(struct libdecor_frame *frame, enum libdecor_capabilities capabilities) { - const enum libdecor_capabilities old_capabilities = frame->priv.capabilities; - frame->priv.capabilities |= capabilities; + const enum libdecor_capabilities old_capabilities = frame->capabilities; + frame->capabilities |= capabilities; notify_on_capability_change(frame, old_capabilities); } @@ -1242,14 +1237,14 @@ void libdecor_frame_unset_capabilities(struct libdecor_frame *frame, enum libdecor_capabilities capabilities) { - const enum libdecor_capabilities old_capabilities = frame->priv.capabilities; - frame->priv.capabilities &= ~capabilities; + const enum libdecor_capabilities old_capabilities = frame->capabilities; + frame->capabilities &= ~capabilities; notify_on_capability_change(frame, old_capabilities); } bool libdecor_frame_has_capability(struct libdecor_frame *frame, enum libdecor_capabilities capability){ - return frame->priv.capabilities & capability; + return frame->capabilities & capability; } void @@ -1272,11 +1267,11 @@ libdecor_frame_dismiss_popup(struct libdecor_frame *frame, void libdecor_frame_show_window_menu(struct libdecor_frame *frame, struct wl_seat *wl_seat, uint32_t serial, int x, int y){ - if (!frame->priv.xdg_toplevel) { + if (!frame->xdg_toplevel) { fprintf(stderr, "Can't show window menu before being mapped\n"); return; } - xdg_toplevel_show_window_menu(frame->priv.xdg_toplevel, wl_seat, serial, x, y); + xdg_toplevel_show_window_menu(frame->xdg_toplevel, wl_seat, serial, x, y); } void @@ -1297,31 +1292,31 @@ libdecor_frame_translate_coordinate(struct libdecor_frame *frame, void libdecor_frame_set_min_content_size(struct libdecor_frame *frame, int content_width, int content_height){ - frame->priv.state.content_limits.min_width = content_width; - frame->priv.state.content_limits.min_height = content_height; + frame->state.content_limits.min_width = content_width; + frame->state.content_limits.min_height = content_height; } void libdecor_frame_set_max_content_size(struct libdecor_frame *frame, int content_width, int content_height){ - frame->priv.state.content_limits.max_width = content_width; - frame->priv.state.content_limits.max_height = content_height; + frame->state.content_limits.max_width = content_width; + frame->state.content_limits.max_height = content_height; } void libdecor_frame_get_min_content_size(const struct libdecor_frame *frame, int *content_width, int *content_height){ - *content_width = frame->priv.state.content_limits.min_width; - *content_height = frame->priv.state.content_limits.min_height; + *content_width = frame->state.content_limits.min_width; + *content_height = frame->state.content_limits.min_height; } void libdecor_frame_get_max_content_size(const struct libdecor_frame *frame, int *content_width, int *content_height){ - *content_width = frame->priv.state.content_limits.max_width; - *content_height = frame->priv.state.content_limits.max_height; + *content_width = frame->state.content_limits.max_width; + *content_height = frame->state.content_limits.max_height; } enum libdecor_capabilities libdecor_frame_get_capabilities(const struct libdecor_frame *frame){ - return frame->priv.capabilities; + return frame->capabilities; } enum xdg_toplevel_resize_edge @@ -1356,70 +1351,70 @@ libdecor_frame_resize(struct libdecor_frame *frame, struct wl_seat *wl_seat, uint32_t serial, enum libdecor_resize_edge edge){ enum xdg_toplevel_resize_edge xdg_edge; xdg_edge = edge_to_xdg_edge(edge); - xdg_toplevel_resize(frame->priv.xdg_toplevel, wl_seat, serial, xdg_edge); + xdg_toplevel_resize(frame->xdg_toplevel, wl_seat, serial, xdg_edge); } void libdecor_frame_move(struct libdecor_frame *frame, struct wl_seat *wl_seat, uint32_t serial){ - xdg_toplevel_move(frame->priv.xdg_toplevel, wl_seat, serial); + xdg_toplevel_move(frame->xdg_toplevel, wl_seat, serial); } void libdecor_frame_set_minimized(struct libdecor_frame *frame) { - xdg_toplevel_set_minimized(frame->priv.xdg_toplevel); + xdg_toplevel_set_minimized(frame->xdg_toplevel); } void libdecor_frame_set_maximized(struct libdecor_frame *frame) { - xdg_toplevel_set_maximized(frame->priv.xdg_toplevel); + xdg_toplevel_set_maximized(frame->xdg_toplevel); } void libdecor_frame_unset_maximized(struct libdecor_frame *frame) { - xdg_toplevel_unset_maximized(frame->priv.xdg_toplevel); + xdg_toplevel_unset_maximized(frame->xdg_toplevel); } void libdecor_frame_set_fullscreen(struct libdecor_frame *frame, struct wl_output *output) { - xdg_toplevel_set_fullscreen(frame->priv.xdg_toplevel, output); + xdg_toplevel_set_fullscreen(frame->xdg_toplevel, output); } void libdecor_frame_unset_fullscreen(struct libdecor_frame *frame) { - xdg_toplevel_unset_fullscreen(frame->priv.xdg_toplevel); + xdg_toplevel_unset_fullscreen(frame->xdg_toplevel); } bool libdecor_frame_is_floating(struct libdecor_frame *frame) { - return state_is_floating(frame->priv.window_state); + return state_is_floating(frame->window_state); } void libdecor_frame_close(struct libdecor_frame *frame) { - xdg_toplevel_close(frame, frame->priv.xdg_toplevel); + xdg_toplevel_close(frame, frame->xdg_toplevel); } bool valid_limits(struct libdecor_frame *frame) { - if (frame->priv.state.content_limits.min_width > 0 && - frame->priv.state.content_limits.max_width > 0 && - frame->priv.state.content_limits.min_width > - frame->priv.state.content_limits.max_width) + if (frame->state.content_limits.min_width > 0 && + frame->state.content_limits.max_width > 0 && + frame->state.content_limits.min_width > + frame->state.content_limits.max_width) return false; - if (frame->priv.state.content_limits.min_height > 0 && - frame->priv.state.content_limits.max_height > 0 && - frame->priv.state.content_limits.min_height > - frame->priv.state.content_limits.max_height) + if (frame->state.content_limits.min_height > 0 && + frame->state.content_limits.max_height > 0 && + frame->state.content_limits.min_height > + frame->state.content_limits.max_height) return false; return true; @@ -1435,52 +1430,52 @@ libdecor_frame_apply_limits(struct libdecor_frame *frame, enum libdecor_window_s * configure event is received, we have to manually set the min/max * limits with the configured content size afterwards. */ if (!libdecor_frame_has_capability(frame, LIBDECOR_ACTION_RESIZE)) { - frame->priv.state.content_limits.min_width = frame->priv.content_width; - frame->priv.state.content_limits.max_width = frame->priv.content_width; + frame->state.content_limits.min_width = frame->content_width; + frame->state.content_limits.max_width = frame->content_width; - frame->priv.state.content_limits.min_height = frame->priv.content_height; - frame->priv.state.content_limits.max_height = frame->priv.content_height; + frame->state.content_limits.min_height = frame->content_height; + frame->state.content_limits.max_height = frame->content_height; } - if (frame->priv.state.content_limits.min_width > 0 && - frame->priv.state.content_limits.min_height > 0) { + if (frame->state.content_limits.min_width > 0 && + frame->state.content_limits.min_height > 0) { struct libdecor_state state_min; int win_min_width, win_min_height; - state_min.content_width = frame->priv.state.content_limits.min_width; - state_min.content_height = frame->priv.state.content_limits.min_height; + state_min.content_width = frame->state.content_limits.min_width; + state_min.content_height = frame->state.content_limits.min_height; state_min.window_state = window_state; frame_get_window_size_for(frame, &state_min, &win_min_width, &win_min_height); - xdg_toplevel_set_min_size(frame->priv.xdg_toplevel, + xdg_toplevel_set_min_size(frame->xdg_toplevel, win_min_width, win_min_height); } else { - xdg_toplevel_set_min_size(frame->priv.xdg_toplevel, 0, 0); + xdg_toplevel_set_min_size(frame->xdg_toplevel, 0, 0); } - if (frame->priv.state.content_limits.max_width > 0 && - frame->priv.state.content_limits.max_height > 0) { + if (frame->state.content_limits.max_width > 0 && + frame->state.content_limits.max_height > 0) { struct libdecor_state state_max; int win_max_width, win_max_height; - state_max.content_width = frame->priv.state.content_limits.max_width; - state_max.content_height = frame->priv.state.content_limits.max_height; + state_max.content_width = frame->state.content_limits.max_width; + state_max.content_height = frame->state.content_limits.max_height; state_max.window_state = window_state; frame_get_window_size_for(frame, &state_max, &win_max_width, &win_max_height); - xdg_toplevel_set_max_size(frame->priv.xdg_toplevel, + xdg_toplevel_set_max_size(frame->xdg_toplevel, win_max_width, win_max_height); } else { - xdg_toplevel_set_max_size(frame->priv.xdg_toplevel, 0, 0); + xdg_toplevel_set_max_size(frame->xdg_toplevel, 0, 0); } } static void libdecor_frame_apply_state(struct libdecor_frame *frame, struct libdecor_state *state){ - frame->priv.content_width = state->content_width; - frame->priv.content_height = state->content_height; + frame->content_width = state->content_width; + frame->content_height = state->content_height; libdecor_frame_apply_limits(frame, state->window_state); } @@ -1493,11 +1488,11 @@ void libdecor_frame_commit(struct libdecor_frame *frame, struct libdecor_state *state, struct libdecor_configuration *configuration){ if (configuration && configuration->has_window_state){ - frame->priv.window_state = configuration->window_state; + frame->window_state = configuration->window_state; state->window_state = configuration->window_state; } else{ - state->window_state = frame->priv.window_state; + state->window_state = frame->window_state; } libdecor_frame_apply_state(frame, state); @@ -1511,25 +1506,25 @@ libdecor_frame_commit(struct libdecor_frame *frame, struct libdecor_state *state libdecor_plugin_gtk_frame_free(frame); } - frame_set_window_geometry(frame, frame->priv.content_width, frame->priv.content_height); + frame_set_window_geometry(frame, frame->content_width, frame->content_height); if (configuration){ - xdg_surface_ack_configure(frame->priv.xdg_surface, configuration->serial); + xdg_surface_ack_configure(frame->xdg_surface, configuration->serial); } } static void do_map(struct libdecor_frame *frame) { - frame->priv.pending_map = false; - wl_surface_commit(frame->priv.wl_surface); + frame->pending_map = false; + wl_surface_commit(frame->wl_surface); } void libdecor_frame_map(struct libdecor_frame *frame) { - if (!frame->priv.xdg_surface) { - frame->priv.pending_map = true; + if (!frame->xdg_surface) { + frame->pending_map = true; return; } @@ -1538,37 +1533,37 @@ libdecor_frame_map(struct libdecor_frame *frame) struct wl_surface * libdecor_frame_get_wl_surface(struct libdecor_frame *frame){ - return frame->priv.wl_surface; + return frame->wl_surface; } struct xdg_surface * libdecor_frame_get_xdg_surface(struct libdecor_frame *frame){ - return frame->priv.xdg_surface; + return frame->xdg_surface; } struct xdg_toplevel * libdecor_frame_get_xdg_toplevel(struct libdecor_frame *frame){ - return frame->priv.xdg_toplevel; + return frame->xdg_toplevel; } int libdecor_frame_get_content_width(struct libdecor_frame *frame){ - return frame->priv.content_width; + return frame->content_width; } int libdecor_frame_get_content_height(struct libdecor_frame *frame){ - return frame->priv.content_height; + return frame->content_height; } enum libdecor_window_state libdecor_frame_get_window_state(struct libdecor_frame *frame){ - return frame->priv.window_state; + return frame->window_state; } enum libdecor_wm_capabilities libdecor_frame_get_wm_capabilities(struct libdecor_frame *frame){ - return frame->priv.wm_capabilities; + return frame->wm_capabilities; } static void diff --git a/digesting_libdecor.h b/digesting_libdecor.h index f3ef396..5d11f27 100644 --- a/digesting_libdecor.h +++ b/digesting_libdecor.h @@ -122,7 +122,7 @@ struct libdecor_limits { int max_height; }; -struct libdecor_frame_private { +struct libdecor_frame { int ref_count; struct wl_surface *wl_surface; @@ -160,10 +160,7 @@ struct libdecor_frame_private { struct libdecor_limits interactive_limits; bool visible; -}; - -struct libdecor_frame { - struct libdecor_frame_private priv; + struct wl_list link; };