summaryrefslogtreecommitdiff
path: root/libdecor/src/libdecor.c
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2024-03-12 14:09:35 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2024-03-12 14:09:35 +0100
commit70a9c4d40768a1221dcc8fd9614aec55f0496394 (patch)
treecb265c9afc67f58e64f8a2b54478805f23c02c79 /libdecor/src/libdecor.c
parent38af0c823b6338637bccf7d0b70c88d3a861fe6a (diff)
Update libdecor to upstream commit 09875530 dated March 3, 2024
Diffstat (limited to 'libdecor/src/libdecor.c')
-rw-r--r--libdecor/src/libdecor.c85
1 files changed, 80 insertions, 5 deletions
diff --git a/libdecor/src/libdecor.c b/libdecor/src/libdecor.c
index 6fc184c10..3ede71280 100644
--- a/libdecor/src/libdecor.c
+++ b/libdecor/src/libdecor.c
@@ -51,7 +51,8 @@
struct libdecor {
int ref_count;
- struct libdecor_interface *iface;
+ const struct libdecor_interface *iface;
+ void *user_data;
struct libdecor_plugin *plugin;
bool plugin_ready;
@@ -100,7 +101,7 @@ struct libdecor_frame_private {
struct wl_surface *wl_surface;
- struct libdecor_frame_interface *iface;
+ const struct libdecor_frame_interface *iface;
void *user_data;
struct xdg_surface *xdg_surface;
@@ -127,6 +128,8 @@ struct libdecor_frame_private {
enum libdecor_capabilities capabilities;
+ enum libdecor_wm_capabilities wm_capabilities;
+
/* original limits for interactive resize */
struct libdecor_limits interactive_limits;
@@ -396,6 +399,9 @@ parse_states(struct wl_array *states)
case XDG_TOPLEVEL_STATE_TILED_BOTTOM:
pending_state |= LIBDECOR_WINDOW_STATE_TILED_BOTTOM;
break;
+ case XDG_TOPLEVEL_STATE_RESIZING:
+ pending_state |= LIBDECOR_WINDOW_STATE_RESIZING;
+ break;
#ifdef HAVE_XDG_SHELL_V6
case XDG_TOPLEVEL_STATE_SUSPENDED:
pending_state |= LIBDECOR_WINDOW_STATE_SUSPENDED;
@@ -452,10 +458,34 @@ xdg_toplevel_configure_bounds(void *data,
}
static void
-xdg_toplevel_wm_capabilities(void *data,
+xdg_toplevel_wm_capabilities(void *user_data,
struct xdg_toplevel *xdg_toplevel,
struct wl_array *capabilities)
{
+ struct libdecor_frame *frame = user_data;
+ struct libdecor_frame_private *frame_priv = frame->priv;
+ enum xdg_toplevel_wm_capabilities *wm_cap;
+
+ frame_priv->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;
+ break;
+ case XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE:
+ frame_priv->wm_capabilities |= LIBDECOR_WM_CAPABILITIES_MAXIMIZE;
+ break;
+ case XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN:
+ frame_priv->wm_capabilities |= LIBDECOR_WM_CAPABILITIES_FULLSCREEN;
+ break;
+ case XDG_TOPLEVEL_WM_CAPABILITIES_MINIMIZE:
+ frame_priv->wm_capabilities |= LIBDECOR_WM_CAPABILITIES_MINIMIZE;
+ break;
+ default:
+ break;
+ }
+ }
}
#endif
@@ -546,7 +576,7 @@ init_shell_surface(struct libdecor_frame *frame)
LIBDECOR_EXPORT struct libdecor_frame *
libdecor_decorate(struct libdecor *context,
struct wl_surface *wl_surface,
- struct libdecor_frame_interface *iface,
+ const struct libdecor_frame_interface *iface,
void *user_data)
{
struct libdecor_plugin *plugin = context->plugin;
@@ -569,6 +599,10 @@ libdecor_decorate(struct libdecor *context,
frame_priv->wl_surface = wl_surface;
frame_priv->iface = iface;
frame_priv->user_data = user_data;
+ frame_priv->wm_capabilities = LIBDECOR_WM_CAPABILITIES_WINDOW_MENU |
+ LIBDECOR_WM_CAPABILITIES_MAXIMIZE |
+ LIBDECOR_WM_CAPABILITIES_FULLSCREEN |
+ LIBDECOR_WM_CAPABILITIES_MINIMIZE;
wl_list_insert(&context->frames, &frame->link);
@@ -628,6 +662,18 @@ libdecor_frame_unref(struct libdecor_frame *frame)
}
}
+LIBDECOR_EXPORT void *
+libdecor_frame_get_user_data(struct libdecor_frame *frame)
+{
+ return frame->priv->user_data;
+}
+
+LIBDECOR_EXPORT void
+libdecor_frame_set_user_data(struct libdecor_frame *frame, void *user_data)
+{
+ frame->priv->user_data = user_data;
+}
+
LIBDECOR_EXPORT void
libdecor_frame_set_visibility(struct libdecor_frame *frame,
bool visible)
@@ -1235,6 +1281,14 @@ libdecor_frame_get_window_state(struct libdecor_frame *frame)
return frame_priv->window_state;
}
+LIBDECOR_EXPORT enum libdecor_wm_capabilities
+libdecor_frame_get_wm_capabilities(struct libdecor_frame *frame)
+{
+ struct libdecor_frame_private *frame_priv = frame->priv;
+
+ return frame_priv->wm_capabilities;
+}
+
LIBDECOR_EXPORT int
libdecor_plugin_init(struct libdecor_plugin *plugin,
struct libdecor *context,
@@ -1624,6 +1678,18 @@ retry_next:
return 0;
}
+LIBDECOR_EXPORT void *
+libdecor_get_user_data(struct libdecor *context)
+{
+ return context->user_data;
+}
+
+LIBDECOR_EXPORT void
+libdecor_set_user_data(struct libdecor *context, void *user_data)
+{
+ context->user_data = user_data;
+}
+
LIBDECOR_EXPORT int
libdecor_get_fd(struct libdecor *context)
{
@@ -1701,7 +1767,15 @@ libdecor_unref(struct libdecor *context)
LIBDECOR_EXPORT struct libdecor *
libdecor_new(struct wl_display *wl_display,
- struct libdecor_interface *iface)
+ const struct libdecor_interface *iface)
+{
+ return libdecor_new_with_user_data(wl_display, iface, NULL);
+}
+
+LIBDECOR_EXPORT struct libdecor *
+libdecor_new_with_user_data(struct wl_display *wl_display,
+ const struct libdecor_interface *iface,
+ void *user_data)
{
struct libdecor *context;
@@ -1709,6 +1783,7 @@ libdecor_new(struct wl_display *wl_display,
context->ref_count = 1;
context->iface = iface;
+ context->user_data = user_data;
context->wl_display = wl_display;
context->wl_registry = wl_display_get_registry(wl_display);
wl_registry_add_listener(context->wl_registry,