[digesting_libdecor] move libdecor_frame_private fields to libdecor_frame, eliminate 'private' frame

main
Allen Webster 2026-02-26 16:27:42 -08:00
parent 617f855443
commit babb2ccb59
2 changed files with 167 additions and 175 deletions

View File

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

View File

@ -122,7 +122,7 @@ struct libdecor_limits {
int max_height; int max_height;
}; };
struct libdecor_frame_private { struct libdecor_frame {
int ref_count; int ref_count;
struct wl_surface *wl_surface; struct wl_surface *wl_surface;
@ -160,10 +160,7 @@ struct libdecor_frame_private {
struct libdecor_limits interactive_limits; struct libdecor_limits interactive_limits;
bool visible; bool visible;
};
struct libdecor_frame {
struct libdecor_frame_private priv;
struct wl_list link; struct wl_list link;
}; };