libdecor: pull upstream changes (a382710b on 28 apr 2022).

This commit is contained in:
ManoloFLTK 2022-05-27 10:58:23 +02:00
parent b78035624d
commit 5afd0bb44a
4 changed files with 70 additions and 47 deletions

View File

@ -165,6 +165,27 @@ static struct window *window;
static void
redraw(struct window *window);
static void
constrain_content_size(const struct libdecor_frame *frame,
int *width,
int *height)
{
int min_width, min_height, max_width, max_height;
libdecor_frame_get_min_content_size(frame, &min_width, &min_height);
libdecor_frame_get_max_content_size(frame, &max_width, &max_height);
if (min_width > 0)
*width = MAX(min_width, *width);
if (max_width > 0)
*width = MIN(*width, max_width);
if (min_height > 0)
*height = MAX(min_height, *height);
if (max_height > 0)
*height = MIN(*height, max_height);
}
static void
resize(struct window *window, int width, int height)
{
@ -175,8 +196,10 @@ resize(struct window *window, int width, int height)
return;
}
constrain_content_size(window->frame, &width, &height);
/* commit changes to decorations */
state = libdecor_state_new( width, height);
state = libdecor_state_new(width, height);
libdecor_frame_commit(window->frame, state, NULL);
libdecor_state_free(state);
/* force redraw of content and commit */

View File

@ -160,10 +160,10 @@ libdecor_notify_plugin_error(struct libdecor *context,
...);
int
libdecor_state_get_content_width (struct libdecor_state *state);
libdecor_state_get_content_width(struct libdecor_state *state);
int
libdecor_state_get_content_height (struct libdecor_state *state);
libdecor_state_get_content_height(struct libdecor_state *state);
enum libdecor_window_state
libdecor_state_get_window_state(struct libdecor_state *state);
@ -176,20 +176,4 @@ libdecor_plugin_init(struct libdecor_plugin *plugin,
void
libdecor_plugin_release(struct libdecor_plugin *plugin);
/*
* Get the min content size as set before with libdecor_frame_set_min_content_size().
*/
void
libdecor_frame_get_min_content_size(struct libdecor_frame *frame,
int *pcontent_width,
int *pcontent_height);
/*
* Get the max content size as set before with libdecor_frame_set_max_content_size().
*/
void
libdecor_frame_get_max_content_size(struct libdecor_frame *frame,
int *pcontent_width,
int *pcontent_height);
#endif /* LIBDECOR_PLUGIN_H */

View File

@ -838,17 +838,6 @@ libdecor_frame_translate_coordinate(struct libdecor_frame *frame,
}
}
LIBDECOR_EXPORT void
libdecor_frame_set_max_content_size(struct libdecor_frame *frame,
int content_width,
int content_height)
{
struct libdecor_frame_private *frame_priv = frame->priv;
frame_priv->state.content_limits.max_width = content_width;
frame_priv->state.content_limits.max_height = content_height;
}
LIBDECOR_EXPORT void
libdecor_frame_set_min_content_size(struct libdecor_frame *frame,
int content_width,
@ -861,25 +850,36 @@ libdecor_frame_set_min_content_size(struct libdecor_frame *frame,
}
LIBDECOR_EXPORT void
libdecor_frame_get_min_content_size(struct libdecor_frame *frame,
int *pcontent_width,
int *pcontent_height)
libdecor_frame_set_max_content_size(struct libdecor_frame *frame,
int content_width,
int content_height)
{
struct libdecor_frame_private *frame_priv = frame->priv;
*pcontent_width = frame_priv->state.content_limits.min_width;
*pcontent_height = frame_priv->state.content_limits.min_height;
frame_priv->state.content_limits.max_width = content_width;
frame_priv->state.content_limits.max_height = content_height;
}
LIBDECOR_EXPORT void
libdecor_frame_get_max_content_size(struct libdecor_frame *frame,
int *pcontent_width,
int *pcontent_height)
libdecor_frame_get_min_content_size(const struct libdecor_frame *frame,
int *content_width,
int *content_height)
{
struct libdecor_frame_private *frame_priv = frame->priv;
*pcontent_width = frame_priv->state.content_limits.max_width;
*pcontent_height = frame_priv->state.content_limits.max_height;
*content_width = frame_priv->state.content_limits.min_width;
*content_height = frame_priv->state.content_limits.min_height;
}
LIBDECOR_EXPORT void
libdecor_frame_get_max_content_size(const struct libdecor_frame *frame,
int *content_width,
int *content_height)
{
struct libdecor_frame_private *frame_priv = frame->priv;
*content_width = frame_priv->state.content_limits.max_width;
*content_height = frame_priv->state.content_limits.max_height;
}
LIBDECOR_EXPORT enum libdecor_capabilities
@ -1495,7 +1495,7 @@ init_plugins(struct libdecor *context)
if (!de)
break;
plugin_loader = load_plugin_loader(context,
plugin_loader = load_plugin_loader(context,
plugin_dir,
de->d_name);
if (!plugin_loader)

View File

@ -346,6 +346,16 @@ libdecor_frame_translate_coordinate(struct libdecor_frame *frame,
int *frame_x,
int *frame_y);
/**
* Set the min content size.
*
* This translates roughly to xdg_toplevel_set_min_size().
*/
void
libdecor_frame_set_min_content_size(struct libdecor_frame *frame,
int content_width,
int content_height);
/**
* Set the max content size.
*
@ -357,14 +367,20 @@ libdecor_frame_set_max_content_size(struct libdecor_frame *frame,
int content_height);
/**
* Set the min content size.
*
* This translates roughly to xdg_toplevel_set_min_size().
* Get the min content size.
*/
void
libdecor_frame_set_min_content_size(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);
/**
* Get the max content size.
*/
void
libdecor_frame_get_max_content_size(const struct libdecor_frame *frame,
int *content_width,
int *content_height);
/**
* Initiate an interactive resize.