From 429ad60b749faa94551fbacf68051883570c2736 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Wed, 25 Feb 2026 19:31:45 -0800 Subject: [PATCH] [digesting_libdecor] move types and forward declarations into a separate header --- digesting_libdecor.c | 984 +------------------------------------------ digesting_libdecor.h | 639 ++++++++++++++++++++++++++++ 2 files changed, 652 insertions(+), 971 deletions(-) create mode 100644 digesting_libdecor.h diff --git a/digesting_libdecor.c b/digesting_libdecor.c index 948d63a..1d2af92 100755 --- a/digesting_libdecor.c +++ b/digesting_libdecor.c @@ -4,8 +4,9 @@ gtk_flags="$(pkg-config --cflags --libs gtk+-3.0)" dbus_flags="$(pkg-config --cflags --libs dbus-1)" #echo "gtk_flags: $gtk_flags" #echo "dbus_flags: $dbus_flags" +root_path="$PWD" mkdir -p build -clang -o build/demo -g digesting_libdecor.c $gtk_flags $dbus_flags -Iwayland -I$libdecor_path/src -I$libdecor_path/src/plugins -I$libdecor_path/build -lwayland-client -lwayland-cursor -lwayland-egl -lEGL -lm +clang -o build/demo -g $root_path/digesting_libdecor.c $gtk_flags $dbus_flags -Iwayland -I$libdecor_path/src -I$libdecor_path/src/plugins -I$libdecor_path/build -lwayland-client -lwayland-cursor -lwayland-egl -lEGL -lm exit 0 #endif @@ -59,394 +60,7 @@ exit 0 #include "xdg-shell-client-protocol.c" #include "xdg-decoration-client-protocol.c" -//#include -#ifndef LIBDECOR_H -#define LIBDECOR_H - -struct xdg_toplevel; -struct libdecor_frame; -struct libdecor_configuration; -struct libdecor_state; - -enum libdecor_error { - LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE, - LIBDECOR_ERROR_INVALID_FRAME_CONFIGURATION, -}; - -enum libdecor_window_state { - LIBDECOR_WINDOW_STATE_NONE = 0, - LIBDECOR_WINDOW_STATE_ACTIVE = 1 << 0, - LIBDECOR_WINDOW_STATE_MAXIMIZED = 1 << 1, - LIBDECOR_WINDOW_STATE_FULLSCREEN = 1 << 2, - LIBDECOR_WINDOW_STATE_TILED_LEFT = 1 << 3, - LIBDECOR_WINDOW_STATE_TILED_RIGHT = 1 << 4, - LIBDECOR_WINDOW_STATE_TILED_TOP = 1 << 5, - LIBDECOR_WINDOW_STATE_TILED_BOTTOM = 1 << 6, - LIBDECOR_WINDOW_STATE_SUSPENDED = 1 << 7, - LIBDECOR_WINDOW_STATE_RESIZING = 1 << 8, - LIBDECOR_WINDOW_STATE_CONSTRAINED_LEFT = 1 << 9, - LIBDECOR_WINDOW_STATE_CONSTRAINED_RIGHT = 1 << 10, - LIBDECOR_WINDOW_STATE_CONSTRAINED_TOP = 1 << 11, - LIBDECOR_WINDOW_STATE_CONSTRAINED_BOTTOM = 1 << 12, -}; - -enum libdecor_resize_edge { - LIBDECOR_RESIZE_EDGE_NONE, - LIBDECOR_RESIZE_EDGE_TOP, - LIBDECOR_RESIZE_EDGE_BOTTOM, - LIBDECOR_RESIZE_EDGE_LEFT, - LIBDECOR_RESIZE_EDGE_TOP_LEFT, - LIBDECOR_RESIZE_EDGE_BOTTOM_LEFT, - LIBDECOR_RESIZE_EDGE_RIGHT, - LIBDECOR_RESIZE_EDGE_TOP_RIGHT, - LIBDECOR_RESIZE_EDGE_BOTTOM_RIGHT, -}; - -enum libdecor_capabilities { - LIBDECOR_ACTION_MOVE = 1 << 0, - LIBDECOR_ACTION_RESIZE = 1 << 1, - LIBDECOR_ACTION_MINIMIZE = 1 << 2, - LIBDECOR_ACTION_FULLSCREEN = 1 << 3, - LIBDECOR_ACTION_CLOSE = 1 << 4, -}; - -enum libdecor_wm_capabilities { - LIBDECOR_WM_CAPABILITIES_WINDOW_MENU = 1 << 0, - LIBDECOR_WM_CAPABILITIES_MAXIMIZE = 1 << 1, - LIBDECOR_WM_CAPABILITIES_FULLSCREEN = 1 << 2, - LIBDECOR_WM_CAPABILITIES_MINIMIZE = 1 << 3 -}; - -/** - * Add a reference to the frame object. - */ -void -libdecor_frame_ref(struct libdecor_frame *frame); - -/** - * Remove a reference to the frame object. When the reference count reaches - * zero, the frame object is destroyed. - */ -void -libdecor_frame_unref(struct libdecor_frame *frame); - -/** - * Get the user data associated with this libdecor frame. - */ -void * -libdecor_frame_get_user_data(struct libdecor_frame *frame); - -/** - * Set the user data associated with this libdecor frame. - */ -void -libdecor_frame_set_user_data(struct libdecor_frame *frame, void *user_data); - -/** - * Set the visibility of the frame. - * - * If an application wants to be borderless, it can set the frame visibility to - * false. - */ -void -libdecor_frame_set_visibility(struct libdecor_frame *frame, - bool visible); - -/** - * Get the visibility of the frame. - */ -bool -libdecor_frame_is_visible(struct libdecor_frame *frame); - - -/** - * Set the parent of the window. - * - * This can be used to stack multiple toplevel windows above or under each - * other. - */ -void -libdecor_frame_set_parent(struct libdecor_frame *frame, - struct libdecor_frame *parent); - -/** - * Set the title of the window. - */ -void -libdecor_frame_set_title(struct libdecor_frame *frame, - const char *title); - -/** - * Get the title of the window. - */ -const char * -libdecor_frame_get_title(struct libdecor_frame *frame); - -/** - * Set the application ID of the window. - */ -void -libdecor_frame_set_app_id(struct libdecor_frame *frame, - const char *app_id); - -/** - * Set new capabilities of the window. - * - * This determines whether e.g. a window decoration should show a maximize - * button, etc. - * - * Setting a capability does not implicitly unset any other. - */ -void -libdecor_frame_set_capabilities(struct libdecor_frame *frame, - enum libdecor_capabilities capabilities); - -/** - * Unset capabilities of the window. - * - * The opposite of libdecor_frame_set_capabilities. - */ -void -libdecor_frame_unset_capabilities(struct libdecor_frame *frame, - enum libdecor_capabilities capabilities); - -/** - * Check whether the window has any of the given capabilities. - */ -bool -libdecor_frame_has_capability(struct libdecor_frame *frame, - enum libdecor_capabilities capability); - -/** - * Show the window menu. - */ -void -libdecor_frame_show_window_menu(struct libdecor_frame *frame, - struct wl_seat *wl_seat, - uint32_t serial, - int x, - int y); - -/** - * Issue a popup grab on the window. Call this when a xdg_popup is mapped, so - * that it can be properly dismissed by the decorations. - */ -void -libdecor_frame_popup_grab(struct libdecor_frame *frame, - const char *seat_name); - -/** - * Release the popup grab. Call this when you unmap a popup. - */ -void -libdecor_frame_popup_ungrab(struct libdecor_frame *frame, - const char *seat_name); - -/** - * Translate content surface local coordinates to toplevel window local - * coordinates. - * - * This can be used to translate surface coordinates to coordinates useful for - * e.g. showing the window menu, or positioning a popup. - */ -void -libdecor_frame_translate_coordinate(struct libdecor_frame *frame, - int surface_x, - int surface_y, - 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. - * - * This translates roughly to xdg_toplevel_set_max_size(). - */ -void -libdecor_frame_set_max_content_size(struct libdecor_frame *frame, - int content_width, - int content_height); - -/** - * Get the min content size. - */ -void -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. - * - * This roughly translates to xdg_toplevel_resize(). - */ -void -libdecor_frame_resize(struct libdecor_frame *frame, - struct wl_seat *wl_seat, - uint32_t serial, - enum libdecor_resize_edge edge); - -/** - * Initiate an interactive move. - * - * This roughly translates to xdg_toplevel_move(). - */ -void -libdecor_frame_move(struct libdecor_frame *frame, - struct wl_seat *wl_seat, - uint32_t serial); - -/** - * Commit a new window state. This can be called on application driven resizes - * when the window is floating, or in response to received configurations, i.e. - * from e.g. interactive resizes or state changes. - */ -void -libdecor_frame_commit(struct libdecor_frame *frame, - struct libdecor_state *state, - struct libdecor_configuration *configuration); - -/** - * Minimize the window. - * - * Roughly translates to xdg_toplevel_set_minimized(). - */ -void -libdecor_frame_set_minimized(struct libdecor_frame *frame); - -/** - * Maximize the window. - * - * Roughly translates to xdg_toplevel_set_maximized(). - */ -void -libdecor_frame_set_maximized(struct libdecor_frame *frame); - -/** - * Unmaximize the window. - * - * Roughly translates to xdg_toplevel_unset_maximized(). - */ -void -libdecor_frame_unset_maximized(struct libdecor_frame *frame); - -/** - * Fullscreen the window. - * - * Roughly translates to xdg_toplevel_set_fullscreen(). - */ -void -libdecor_frame_set_fullscreen(struct libdecor_frame *frame, - struct wl_output *output); - -/** - * Unfullscreen the window. - * - * Roughly translates to xdg_toplevel_unset_unfullscreen(). - */ -void -libdecor_frame_unset_fullscreen(struct libdecor_frame *frame); - -/** - * Return true if the window is floating. - * - * A window is floating when it's not maximized, tiled, fullscreen, or in any - * similar way with a fixed size and state. - * Note that this function uses the "applied" configuration. If this function - * is used in the 'configure' callback, the provided configuration has to be - * applied via 'libdecor_frame_commit' first, before it will reflect the current - * window state from the provided configuration. - */ -bool -libdecor_frame_is_floating(struct libdecor_frame *frame); - -/** - * Close the window. - * - * Roughly translates to xdg_toplevel_close(). - */ -void -libdecor_frame_close(struct libdecor_frame *frame); - -/** - * Map the window. - * - * This will eventually result in the initial configure event. - */ -void -libdecor_frame_map(struct libdecor_frame *frame); - -/** - * Get the associated xdg_surface for content wl_surface. - */ -struct xdg_surface * -libdecor_frame_get_xdg_surface(struct libdecor_frame *frame); - -/** - * Get the associated xdg_toplevel for the content wl_surface. - */ -struct xdg_toplevel * -libdecor_frame_get_xdg_toplevel(struct libdecor_frame *frame); - -/** - * Get the supported window manager capabilities for the window. - */ -enum libdecor_wm_capabilities -libdecor_frame_get_wm_capabilities(struct libdecor_frame *frame); - -/** - * Create a new content surface state. - */ -struct libdecor_state * -libdecor_state_new(int width, - int height); - -/** - * Free a content surface state. - */ -void -libdecor_state_free(struct libdecor_state *state); - -/** - * Get the expected size of the content for this configuration. - * - * If the configuration doesn't contain a size, false is returned. - */ -bool -libdecor_configuration_get_content_size(struct libdecor_configuration *configuration, - struct libdecor_frame *frame, - int *width, - int *height); - -/** - * Get the window state for this configuration. - * - * If the configuration doesn't contain any associated window state, false is - * returned, and the application should assume the window state remains - * unchanged. - */ -bool -libdecor_configuration_get_window_state(struct libdecor_configuration *configuration, - enum libdecor_window_state *window_state); - -#endif /* LIBDECOR_H */ +#include "digesting_libdecor.h" // X(N:name,R:return,P:params) @@ -460,37 +74,6 @@ X(glClearColor, void, (GLfloat r, GLfloat g, GLfloat b, GLfloat a)) GL_FUNCS_XLIST(X) #undef X -typedef struct Ctx{ - /* globals */ - struct wl_display *wl_display; - struct wl_registry *wl_registry; - struct wl_compositor *wl_compositor; - struct xdg_wm_base *xdg_wm_base; - struct zxdg_decoration_manager_v1 *decoration_manager; - - struct wl_list frames; - struct wl_callback *init_callback; - struct libdecor_plugin *plugin; - bool plugin_ready; - bool init_done; - bool has_error; - - /* window */ - struct wl_surface *wl_surface; - struct libdecor_frame *libdecor_frame; - struct wl_egl_window *wl_egl_window; - int configured; - int w; - int h; - int close_signal; - //struct xdg_surface *xdg_surface; - //struct xdg_toplevel *xdg_toplevel; - //struct wl_region *wl_region; - EGLDisplay egl_display; - EGLContext egl_context; - EGLSurface egl_surface; -} Ctx; - static Ctx ctx = {0}; @@ -500,36 +83,8 @@ enum libdecor_plugin_capabilities { LIBDECOR_PLUGIN_CAPABILITY_BASE = 1 << 0, }; -struct libdecor_plugin_description { - /* API version the plugin is compatible with. */ - int api_version; - - /* Human readable string describing the plugin. */ - char *description; - - /* A plugin has a bitmask of capabilities. The plugin loader can use this - * to load a plugin with the right capabilities. */ - enum libdecor_plugin_capabilities capabilities; - - /* - * The priorities field points to a list of per desktop priorities. - * properties[i].desktop is matched against XDG_CURRENT_DESKTOP when - * determining what plugin to use. The last entry in the list MUST have - * the priorities[i].desktop pointer set to NULL as a default - * priority. - */ - const struct libdecor_plugin_priority *priorities; - - /* Vfunc used for constructing a plugin instance. */ - libdecor_plugin_constructor constructor; - - /* NULL terminated list of incompatible symbols. */ - char *conflicting_symbols[1024]; -}; - const struct wl_registry_listener scrap__registry_listener; const struct wl_callback_listener init_wl_display_callback_listener; -const struct libdecor_plugin_description libdecor_plugin_description; /* (1) Appendix A: wl_registry::global @@ -652,6 +207,7 @@ libdecorevent__frame_bounds(struct libdecor_frame *frame, struct libdecor_frame* libdecor_decorate(struct wl_surface *wl_surface, void *user_data); int libdecor_dispatch(int timeout); +static struct libdecor_plugin * libdecor_plugin_new(void); int main(){ /*~ NOTE: @@ -699,14 +255,14 @@ int main(){ } if (ctx.wl_display != 0 && ctx.wl_compositor != 0){ - ctx.init_callback = wl_display_sync(ctx.wl_display); - wl_callback_add_listener(ctx.init_callback, + ctx.wl_callback = wl_display_sync(ctx.wl_display); + wl_callback_add_listener(ctx.wl_callback, &init_wl_display_callback_listener, 0); wl_list_init(&ctx.frames); - ctx.plugin = libdecor_plugin_description.constructor(); + ctx.plugin = libdecor_plugin_new(); if (ctx.plugin == 0){ fprintf(stderr, "Failed to load static plugin: failed to init\n"); exit(1); @@ -984,242 +540,7 @@ int main(){ * SOFTWARE. */ -//#include "config.h" -/* Version number of package */ -#define VERSION "0.2.2" - -/* Plugin directiory path */ -#define LIBDECOR_PLUGIN_DIR "/usr/local/lib/x86_64-linux-gnu/libdecor/plugins-1" - -/* Plugin API version */ -#define LIBDECOR_PLUGIN_API_VERSION 1 - -#define HAS_DBUS - -/* #undef HAVE_MKOSTEMP */ -#define HAVE_POSIX_FALLOCATE -#define HAVE_MEMFD_CREATE -#define HAVE_GETTID - - -//#include "libdecor-fallback.h" -#ifndef LIBDECOR_FALLBACK_H -#define LIBDECOR_FALLBACK_H - -struct libdecor_plugin * -libdecor_fallback_plugin_new(void); - -#endif /* LIBDECOR_FALLBACK_H */ - - -//#include "libdecor-plugin.h" -#ifndef LIBDECOR_PLUGIN_H -#define LIBDECOR_PLUGIN_H - -struct libdecor_frame_private; - -struct libdecor_frame { - struct libdecor_frame_private *priv; - struct wl_list link; -}; - -struct libdecor_plugin_private; - -struct libdecor_plugin { - struct libdecor_plugin_private *priv; -}; - -#define LIBDECOR_PLUGIN_PRIORITY_HIGH 1000 -#define LIBDECOR_PLUGIN_PRIORITY_MEDIUM 100 -#define LIBDECOR_PLUGIN_PRIORITY_LOW 0 - -struct libdecor_plugin_priority { - const char *desktop; - int priority; -}; - -struct libdecor_plugin_interface { - void (* destroy)(struct libdecor_plugin *plugin); - - int (* get_fd)(struct libdecor_plugin *plugin); - int (* dispatch)(struct libdecor_plugin *plugin, - int timeout); - - void (* set_handle_application_cursor)(struct libdecor_plugin *plugin, - bool handle_cursor); - - struct libdecor_frame * (* frame_new)(struct libdecor_plugin *plugin); - void (* frame_free)(struct libdecor_plugin *plugin, - struct libdecor_frame *frame); - void (* frame_commit)(struct libdecor_plugin *plugin, - struct libdecor_frame *frame, - struct libdecor_state *state, - struct libdecor_configuration *configuration); - void (*frame_property_changed)(struct libdecor_plugin *plugin, - struct libdecor_frame *frame); - void (* frame_popup_grab)(struct libdecor_plugin *plugin, - struct libdecor_frame *frame, - const char *seat_name); - void (* frame_popup_ungrab)(struct libdecor_plugin *plugin, - struct libdecor_frame *frame, - const char *seat_name); - - bool (* frame_get_border_size)(struct libdecor_plugin *plugin, - struct libdecor_frame *frame, - struct libdecor_configuration *configuration, - int *left, - int *right, - int *top, - int *bottom); - - /* Reserved */ - void (* reserved0)(void); - void (* reserved1)(void); - void (* reserved2)(void); - void (* reserved3)(void); - void (* reserved4)(void); - void (* reserved5)(void); - void (* reserved6)(void); - void (* reserved7)(void); - void (* reserved8)(void); - void (* reserved9)(void); -}; - -struct wl_surface * -libdecor_frame_get_wl_surface(struct libdecor_frame *frame); - -int -libdecor_frame_get_content_width(struct libdecor_frame *frame); - -int -libdecor_frame_get_content_height(struct libdecor_frame *frame); - -enum libdecor_window_state -libdecor_frame_get_window_state(struct libdecor_frame *frame); - -enum libdecor_capabilities -libdecor_frame_get_capabilities(const struct libdecor_frame *frame); - -void -libdecor_frame_dismiss_popup(struct libdecor_frame *frame, - const char *seat_name); - -void -libdecor_frame_toplevel_commit(struct libdecor_frame *frame); - -void -libdecor_notify_plugin_ready(void); - -void -libdecor_notify_plugin_error(enum libdecor_error error, - const char *__restrict fmt, - ...); - -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); - -int -libdecor_plugin_init(struct libdecor_plugin *plugin, struct libdecor_plugin_interface *iface); - -void -libdecor_plugin_release(struct libdecor_plugin *plugin); - -#endif /* LIBDECOR_PLUGIN_H */ - -//#include "utils.h" -#ifndef UTILS_H -#define UTILS_H - -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) - -#ifndef ARRAY_LENGTH -#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) -#endif - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) -#endif - -#endif /* UTILS_H */ - - //#include "libdecor.c" -struct libdecor_state { - enum libdecor_window_state window_state; - - int content_width; - int content_height; -}; - -struct libdecor_limits { - int min_width; - int min_height; - int max_width; - int max_height; -}; - -struct libdecor_configuration { - uint32_t serial; - - bool has_window_state; - enum libdecor_window_state window_state; - - bool has_size; - int window_width; - int window_height; -}; - -struct libdecor_frame_private { - int ref_count; - - struct wl_surface *wl_surface; - - void *user_data; - - struct xdg_surface *xdg_surface; - struct xdg_toplevel *xdg_toplevel; - struct zxdg_toplevel_decoration_v1 *toplevel_decoration; - - bool pending_map; - - struct { - char *app_id; - char *title; - struct libdecor_limits content_limits; - struct xdg_toplevel *parent; - } state; - - struct libdecor_configuration *pending_configuration; - - int content_width; - int content_height; - - enum libdecor_window_state window_state; - - bool has_decoration_mode; - enum zxdg_toplevel_decoration_v1_mode decoration_mode; - - enum libdecor_capabilities capabilities; - - enum libdecor_wm_capabilities wm_capabilities; - - /* original limits for interactive resize */ - struct libdecor_limits interactive_limits; - - bool visible; -}; - -struct libdecor_plugin_private { - struct libdecor_plugin_interface *iface; -}; - /* gather all states at which a window is non-floating */ static const enum libdecor_window_state states_non_floating = LIBDECOR_WINDOW_STATE_MAXIMIZED | LIBDECOR_WINDOW_STATE_FULLSCREEN | @@ -2479,7 +1800,7 @@ init_wl_display_callback(void *user_data, ctx.init_done = true; wl_callback_destroy(callback); - ctx.init_callback = NULL; + ctx.wl_callback = 0; if (ctx.xdg_wm_base == 0){ notify_error(LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE, @@ -2540,8 +1861,8 @@ cleanup(void){ if (ctx.plugin != 0){ ctx.plugin->priv->iface->destroy(ctx.plugin); } - if (ctx.init_callback != 0){ - wl_callback_destroy(ctx.init_callback); + if (ctx.wl_callback != 0){ + wl_callback_destroy(ctx.wl_callback); } if (ctx.xdg_wm_base != 0){ xdg_wm_base_destroy(ctx.xdg_wm_base); @@ -2552,11 +1873,6 @@ cleanup(void){ } //#include "libdecor-fallback.c" -struct libdecor_plugin_fallback { - struct libdecor_plugin plugin; - struct libdecor *context; -}; - static void libdecor_plugin_fallback_destroy(struct libdecor_plugin *plugin) { @@ -2595,7 +1911,7 @@ libdecor_plugin_fallback_dispatch(struct libdecor_plugin *plugin, fds[0] = (struct pollfd) { wl_display_get_fd(wl_display), POLLIN }; - ret = poll(fds, ARRAY_SIZE (fds), timeout); + ret = poll(fds, ARRAY_LENGTH(fds), timeout); if (ret > 0) { if (fds[0].revents & POLLIN) { wl_display_read_events(wl_display); @@ -2714,32 +2030,7 @@ libdecor_fallback_plugin_new(void){ return &plugin->plugin; } -//#include "libdecor-cairo-blur.h" - -int -blur_surface(cairo_surface_t *surface, int margin); - -void -render_shadow(cairo_t *cr, cairo_surface_t *surface, - int x, int y, int width, int height, int margin, int top_margin); - - //#include "libdecor-cairo-blur.c" -/* - * functions 'blur_surface' and 'render_shadow' from weston project: - * https://gitlab.freedesktop.org/wayland/weston/raw/master/shared/cairo-util.c - */ - -/** - * Compile-time computation of number of items in a hardcoded array. - * - * @param a the array being measured. - * @return the number of items hardcoded into the array. - */ -#ifndef ARRAY_LENGTH -#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) -#endif - int blur_surface(cairo_surface_t *surface, int margin) { @@ -2950,29 +2241,6 @@ render_shadow(cairo_t *cr, cairo_surface_t *surface, cairo_reset_clip(cr); } -//#include "desktop-settings.h" - -enum libdecor_color_scheme { - LIBDECOR_COLOR_SCHEME_DEFAULT, - LIBDECOR_COLOR_SCHEME_PREFER_DARK, - LIBDECOR_COLOR_SCHEME_PREFER_LIGHT, -}; - -bool -libdecor_get_cursor_settings(char **theme, int *size); - -enum libdecor_color_scheme -libdecor_get_color_scheme(); - -//#include "os-compatibility.h" -#ifndef OS_COMPATIBILITY_H -#define OS_COMPATIBILITY_H - -int -libdecor_os_create_anonymous_file(off_t size); - -#endif /* OS_COMPATIBILITY_H */ - //#include "os-compatibility.c" #ifndef HAVE_MKOSTEMP static int @@ -3132,44 +2400,7 @@ libdecor_os_create_anonymous_file(off_t size) return fd; } - //#include "plugins/gtk/libdecor-gtk.c" -static const size_t SHADOW_MARGIN = 24; /* grabbable part of the border */ - -static const char *cursor_names[] = { - "top_side", - "bottom_side", - "left_side", - "top_left_corner", - "bottom_left_corner", - "right_side", - "top_right_corner", - "bottom_right_corner" -}; - -enum header_element { - HEADER_NONE, - HEADER_FULL, /* entire header bar */ - HEADER_TITLE, /* label */ - HEADER_MIN, - HEADER_MAX, - HEADER_CLOSE, -}; - -enum titlebar_gesture_state { - TITLEBAR_GESTURE_STATE_INIT, - TITLEBAR_GESTURE_STATE_BUTTON_PRESSED, - TITLEBAR_GESTURE_STATE_CONSUMED, - TITLEBAR_GESTURE_STATE_DISCARDED, -}; - -struct header_element_data { - const char *name; - enum header_element type; - /* pointer to button or NULL if not found*/ - GtkWidget *widget; - GtkStateFlags state; -}; static void find_widget_by_name(GtkWidget *widget, void *data) @@ -3235,7 +2466,7 @@ get_header_focus(const GtkHeaderBar *header_bar, const int x, const int y) static const enum header_element elems[] = {HEADER_TITLE, HEADER_MIN, HEADER_MAX, HEADER_CLOSE}; - for (size_t i = 0; i < ARRAY_SIZE(elems); i++) { + for (size_t i = 0; i < ARRAY_LENGTH(elems); i++) { struct header_element_data elem = find_widget_by_type(GTK_WIDGET(header_bar), elems[i]); if (elem.widget) { @@ -3263,175 +2494,6 @@ streq(const char *str1, return false; } -enum decoration_type { - DECORATION_TYPE_NONE, - DECORATION_TYPE_ALL, - DECORATION_TYPE_TITLE_ONLY -}; - -enum component { - NONE = 0, - SHADOW, - HEADER, -}; - -struct seat { - struct libdecor_plugin_gtk *plugin_gtk; - - char *name; - - struct wl_seat *wl_seat; - struct wl_pointer *wl_pointer; - struct wl_touch *wl_touch; - - struct wl_surface *cursor_surface; - struct wl_cursor *current_cursor; - int cursor_scale; - struct wl_list cursor_outputs; - - struct wl_cursor_theme *cursor_theme; - /* cursors for resize edges and corners */ - struct wl_cursor *cursors[ARRAY_LENGTH(cursor_names)]; - struct wl_cursor *cursor_left_ptr; - - struct wl_surface *pointer_focus; - struct wl_surface *touch_focus; - - int pointer_x, pointer_y; - - uint32_t touch_down_time_stamp; - - uint32_t serial; - - bool grabbed; - - struct wl_list link; -}; - -struct output { - struct libdecor_plugin_gtk *plugin_gtk; - - struct wl_output *wl_output; - uint32_t id; - int scale; - - struct wl_list link; -}; - -struct buffer { - struct wl_buffer *wl_buffer; - bool in_use; - bool is_detached; - - void *data; - size_t data_size; - int width; - int height; - int scale; - int buffer_width; - int buffer_height; -}; - -struct border_component { - enum component type; - struct wl_surface *wl_surface; - struct wl_subsurface *wl_subsurface; - struct buffer *buffer; - bool opaque; - struct wl_list output_list; - int scale; - - struct wl_list child_components; /* border_component::link */ - struct wl_list link; /* border_component::child_components */ -}; - -struct surface_output { - struct output *output; - struct wl_list link; -}; - -struct cursor_output { - struct output *output; - struct wl_list link; -}; - -struct libdecor_frame_gtk { - struct libdecor_frame frame; - - struct libdecor_plugin_gtk *plugin_gtk; - - int content_width; - int content_height; - - enum libdecor_window_state window_state; - - enum decoration_type decoration_type; - - char *title; - - enum libdecor_capabilities capabilities; - - struct border_component *active; - struct border_component *touch_active; - - struct border_component *focus; - struct border_component *grab; - - bool shadow_showing; - struct border_component shadow; - - GtkWidget *window; /* offscreen window for rendering */ - GtkWidget *header; /* header bar with widgets */ - struct border_component headerbar; - struct header_element_data hdr_focus; - - /* store pre-processed shadow tile */ - cairo_surface_t *shadow_blur; - - struct wl_list link; - - struct { - enum titlebar_gesture_state state; - int button_pressed_count; - uint32_t first_pressed_button; - uint32_t first_pressed_time; - double pressed_x; - double pressed_y; - uint32_t pressed_serial; - } titlebar_gesture; -}; - -struct libdecor_plugin_gtk { - struct libdecor_plugin plugin; - - struct wl_callback *globals_callback; - struct wl_callback *globals_callback_shm; - - struct libdecor *context; - - struct wl_registry *wl_registry; - struct wl_subcompositor *wl_subcompositor; - struct wl_compositor *wl_compositor; - - struct wl_shm *wl_shm; - struct wl_callback *shm_callback; - bool has_argb; - - struct wl_list visible_frame_list; - struct wl_list seat_list; - struct wl_list output_list; - - char *cursor_theme_name; - int cursor_size; - - uint32_t color_scheme_setting; - - int double_click_time_ms; - int drag_threshold; - - bool handle_cursor; -}; - static const char *libdecor_gtk_proxy_tag = "libdecor-gtk"; static bool @@ -3622,7 +2684,7 @@ libdecor_plugin_gtk_dispatch(struct libdecor_plugin *plugin, fds[0] = (struct pollfd) { wl_display_get_fd(wl_display), POLLIN }; - ret = poll(fds, ARRAY_SIZE (fds), timeout); + ret = poll(fds, ARRAY_LENGTH(fds), timeout); if (ret > 0) { if (fds[0].revents & POLLIN) { wl_display_read_events(wl_display); @@ -5341,12 +4403,6 @@ handle_button_on_shadow(struct libdecor_frame_gtk *frame_gtk, } } -enum titlebar_gesture { - TITLEBAR_GESTURE_DOUBLE_CLICK, - TITLEBAR_GESTURE_MIDDLE_CLICK, - TITLEBAR_GESTURE_RIGHT_CLICK, -}; - static void handle_titlebar_gesture(struct libdecor_frame_gtk *frame_gtk, struct seat *seat, @@ -6084,20 +5140,6 @@ static struct libdecor_plugin_priority priorities[] = { { NULL, LIBDECOR_PLUGIN_PRIORITY_HIGH } }; -const struct libdecor_plugin_description -libdecor_plugin_description = { - .api_version = LIBDECOR_PLUGIN_API_VERSION, - .capabilities = LIBDECOR_PLUGIN_CAPABILITY_BASE, - .description = "GTK3 plugin", - .priorities = priorities, - .constructor = libdecor_plugin_new, - .conflicting_symbols = { - "png_free", - "gdk_get_use_xshm", - NULL, - }, -}; - //#include "desktop-settings.c" static bool diff --git a/digesting_libdecor.h b/digesting_libdecor.h new file mode 100644 index 0000000..f18aa68 --- /dev/null +++ b/digesting_libdecor.h @@ -0,0 +1,639 @@ +/* + * Copyright © 2012 Collabora, Ltd. + * Copyright © 2012 Intel Corporation + * Copyright © 2017-2018 Red Hat Inc. + * Copyright © 2018 Jonas Ådahl + * Copyright © 2021 Christian Rauch + * Copyright © 2024 Colin Kinloch + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef DIGESTING_LIBDECOR_H +#define DIGESTING_LIBDECOR_H + +// config.h + +/* Version number of package */ +#define VERSION "0.2.2" + +/* Plugin directiory path */ +#define LIBDECOR_PLUGIN_DIR "/usr/local/lib/x86_64-linux-gnu/libdecor/plugins-1" + +/* Plugin API version */ +#define LIBDECOR_PLUGIN_API_VERSION 1 + +#define HAS_DBUS + +/* #undef HAVE_MKOSTEMP */ +#define HAVE_POSIX_FALLOCATE +#define HAVE_MEMFD_CREATE +#define HAVE_GETTID + +// utils.h + +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) + +#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) + +// libdecor.h + +struct libdecor_frame; +struct libdecor_configuration; +struct libdecor_state; + +enum libdecor_error { + LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE, + LIBDECOR_ERROR_INVALID_FRAME_CONFIGURATION, +}; + +enum libdecor_window_state { + LIBDECOR_WINDOW_STATE_NONE = 0, + LIBDECOR_WINDOW_STATE_ACTIVE = 1 << 0, + LIBDECOR_WINDOW_STATE_MAXIMIZED = 1 << 1, + LIBDECOR_WINDOW_STATE_FULLSCREEN = 1 << 2, + LIBDECOR_WINDOW_STATE_TILED_LEFT = 1 << 3, + LIBDECOR_WINDOW_STATE_TILED_RIGHT = 1 << 4, + LIBDECOR_WINDOW_STATE_TILED_TOP = 1 << 5, + LIBDECOR_WINDOW_STATE_TILED_BOTTOM = 1 << 6, + LIBDECOR_WINDOW_STATE_SUSPENDED = 1 << 7, + LIBDECOR_WINDOW_STATE_RESIZING = 1 << 8, + LIBDECOR_WINDOW_STATE_CONSTRAINED_LEFT = 1 << 9, + LIBDECOR_WINDOW_STATE_CONSTRAINED_RIGHT = 1 << 10, + LIBDECOR_WINDOW_STATE_CONSTRAINED_TOP = 1 << 11, + LIBDECOR_WINDOW_STATE_CONSTRAINED_BOTTOM = 1 << 12, +}; + +enum libdecor_resize_edge { + LIBDECOR_RESIZE_EDGE_NONE, + LIBDECOR_RESIZE_EDGE_TOP, + LIBDECOR_RESIZE_EDGE_BOTTOM, + LIBDECOR_RESIZE_EDGE_LEFT, + LIBDECOR_RESIZE_EDGE_TOP_LEFT, + LIBDECOR_RESIZE_EDGE_BOTTOM_LEFT, + LIBDECOR_RESIZE_EDGE_RIGHT, + LIBDECOR_RESIZE_EDGE_TOP_RIGHT, + LIBDECOR_RESIZE_EDGE_BOTTOM_RIGHT, +}; + +enum libdecor_capabilities { + LIBDECOR_ACTION_MOVE = 1 << 0, + LIBDECOR_ACTION_RESIZE = 1 << 1, + LIBDECOR_ACTION_MINIMIZE = 1 << 2, + LIBDECOR_ACTION_FULLSCREEN = 1 << 3, + LIBDECOR_ACTION_CLOSE = 1 << 4, +}; + +enum libdecor_wm_capabilities { + LIBDECOR_WM_CAPABILITIES_WINDOW_MENU = 1 << 0, + LIBDECOR_WM_CAPABILITIES_MAXIMIZE = 1 << 1, + LIBDECOR_WM_CAPABILITIES_FULLSCREEN = 1 << 2, + LIBDECOR_WM_CAPABILITIES_MINIMIZE = 1 << 3 +}; + +// libdecor-plugin.h + +struct libdecor_frame_private; + +struct libdecor_frame { + struct libdecor_frame_private *priv; + struct wl_list link; +}; + +struct libdecor_plugin_private; + +struct libdecor_plugin { + struct libdecor_plugin_private *priv; +}; + +#define LIBDECOR_PLUGIN_PRIORITY_HIGH 1000 +#define LIBDECOR_PLUGIN_PRIORITY_MEDIUM 100 +#define LIBDECOR_PLUGIN_PRIORITY_LOW 0 + +struct libdecor_plugin_priority { + const char *desktop; + int priority; +}; + +struct libdecor_plugin_interface { + void (* destroy)(struct libdecor_plugin *plugin); + + int (* get_fd)(struct libdecor_plugin *plugin); + int (* dispatch)(struct libdecor_plugin *plugin, + int timeout); + + void (* set_handle_application_cursor)(struct libdecor_plugin *plugin, + bool handle_cursor); + + struct libdecor_frame * (* frame_new)(struct libdecor_plugin *plugin); + void (* frame_free)(struct libdecor_plugin *plugin, + struct libdecor_frame *frame); + void (* frame_commit)(struct libdecor_plugin *plugin, + struct libdecor_frame *frame, + struct libdecor_state *state, + struct libdecor_configuration *configuration); + void (*frame_property_changed)(struct libdecor_plugin *plugin, + struct libdecor_frame *frame); + void (* frame_popup_grab)(struct libdecor_plugin *plugin, + struct libdecor_frame *frame, + const char *seat_name); + void (* frame_popup_ungrab)(struct libdecor_plugin *plugin, + struct libdecor_frame *frame, + const char *seat_name); + + bool (* frame_get_border_size)(struct libdecor_plugin *plugin, + struct libdecor_frame *frame, + struct libdecor_configuration *configuration, + int *left, + int *right, + int *top, + int *bottom); +}; + +// #include "libdecor.c" + +struct libdecor_state { + enum libdecor_window_state window_state; + + int content_width; + int content_height; +}; + +struct libdecor_limits { + int min_width; + int min_height; + int max_width; + int max_height; +}; + +struct libdecor_configuration { + uint32_t serial; + + bool has_window_state; + enum libdecor_window_state window_state; + + bool has_size; + int window_width; + int window_height; +}; + +struct libdecor_frame_private { + int ref_count; + + struct wl_surface *wl_surface; + + void *user_data; + + struct xdg_surface *xdg_surface; + struct xdg_toplevel *xdg_toplevel; + struct zxdg_toplevel_decoration_v1 *toplevel_decoration; + + bool pending_map; + + struct { + char *app_id; + char *title; + struct libdecor_limits content_limits; + struct xdg_toplevel *parent; + } state; + + struct libdecor_configuration *pending_configuration; + + int content_width; + int content_height; + + enum libdecor_window_state window_state; + + bool has_decoration_mode; + enum zxdg_toplevel_decoration_v1_mode decoration_mode; + + enum libdecor_capabilities capabilities; + + enum libdecor_wm_capabilities wm_capabilities; + + /* original limits for interactive resize */ + struct libdecor_limits interactive_limits; + + bool visible; +}; + +struct libdecor_plugin_private { + struct libdecor_plugin_interface *iface; +}; + +// #include "libdecor-fallback.c" + +struct libdecor_plugin_fallback { + struct libdecor_plugin plugin; + struct libdecor *context; +}; + +// #include "desktop-settings.h" + +enum libdecor_color_scheme { + LIBDECOR_COLOR_SCHEME_DEFAULT, + LIBDECOR_COLOR_SCHEME_PREFER_DARK, + LIBDECOR_COLOR_SCHEME_PREFER_LIGHT, +}; + +// #include "plugins/gtk/libdecor-gtk.c" + +static const size_t SHADOW_MARGIN = 24; +static const char *cursor_names[] = { + "top_side", + "bottom_side", + "left_side", + "top_left_corner", + "bottom_left_corner", + "right_side", + "top_right_corner", + "bottom_right_corner" +}; + +enum header_element { + HEADER_NONE, + HEADER_FULL, /* entire header bar */ + HEADER_TITLE, /* label */ + HEADER_MIN, + HEADER_MAX, + HEADER_CLOSE, +}; + +enum titlebar_gesture_state { + TITLEBAR_GESTURE_STATE_INIT, + TITLEBAR_GESTURE_STATE_BUTTON_PRESSED, + TITLEBAR_GESTURE_STATE_CONSUMED, + TITLEBAR_GESTURE_STATE_DISCARDED, +}; + +struct header_element_data { + const char *name; + enum header_element type; + /* pointer to button or NULL if not found*/ + GtkWidget *widget; + GtkStateFlags state; +}; + +enum decoration_type { + DECORATION_TYPE_NONE, + DECORATION_TYPE_ALL, + DECORATION_TYPE_TITLE_ONLY +}; + +enum component { + NONE = 0, + SHADOW, + HEADER, +}; + +struct seat { + struct libdecor_plugin_gtk *plugin_gtk; + + char *name; + + struct wl_seat *wl_seat; + struct wl_pointer *wl_pointer; + struct wl_touch *wl_touch; + + struct wl_surface *cursor_surface; + struct wl_cursor *current_cursor; + int cursor_scale; + struct wl_list cursor_outputs; + + struct wl_cursor_theme *cursor_theme; + /* cursors for resize edges and corners */ + struct wl_cursor *cursors[ARRAY_LENGTH(cursor_names)]; + struct wl_cursor *cursor_left_ptr; + + struct wl_surface *pointer_focus; + struct wl_surface *touch_focus; + + int pointer_x, pointer_y; + + uint32_t touch_down_time_stamp; + + uint32_t serial; + + bool grabbed; + + struct wl_list link; +}; + +struct output { + struct libdecor_plugin_gtk *plugin_gtk; + + struct wl_output *wl_output; + uint32_t id; + int scale; + + struct wl_list link; +}; + +struct buffer { + struct wl_buffer *wl_buffer; + bool in_use; + bool is_detached; + + void *data; + size_t data_size; + int width; + int height; + int scale; + int buffer_width; + int buffer_height; +}; + +struct border_component { + enum component type; + struct wl_surface *wl_surface; + struct wl_subsurface *wl_subsurface; + struct buffer *buffer; + bool opaque; + struct wl_list output_list; + int scale; + + struct wl_list child_components; /* border_component::link */ + struct wl_list link; /* border_component::child_components */ +}; + +struct surface_output { + struct output *output; + struct wl_list link; +}; + +struct cursor_output { + struct output *output; + struct wl_list link; +}; + +struct libdecor_frame_gtk { + struct libdecor_frame frame; + + struct libdecor_plugin_gtk *plugin_gtk; + + int content_width; + int content_height; + + enum libdecor_window_state window_state; + + enum decoration_type decoration_type; + + char *title; + + enum libdecor_capabilities capabilities; + + struct border_component *active; + struct border_component *touch_active; + + struct border_component *focus; + struct border_component *grab; + + bool shadow_showing; + struct border_component shadow; + + GtkWidget *window; /* offscreen window for rendering */ + GtkWidget *header; /* header bar with widgets */ + struct border_component headerbar; + struct header_element_data hdr_focus; + + /* store pre-processed shadow tile */ + cairo_surface_t *shadow_blur; + + struct wl_list link; + + struct { + enum titlebar_gesture_state state; + int button_pressed_count; + uint32_t first_pressed_button; + uint32_t first_pressed_time; + double pressed_x; + double pressed_y; + uint32_t pressed_serial; + } titlebar_gesture; +}; + +struct libdecor_plugin_gtk { + struct libdecor_plugin plugin; + + struct wl_callback *globals_callback; + struct wl_callback *globals_callback_shm; + + struct libdecor *context; + + struct wl_registry *wl_registry; + struct wl_subcompositor *wl_subcompositor; + struct wl_compositor *wl_compositor; + + struct wl_shm *wl_shm; + struct wl_callback *shm_callback; + bool has_argb; + + struct wl_list visible_frame_list; + struct wl_list seat_list; + struct wl_list output_list; + + char *cursor_theme_name; + int cursor_size; + + uint32_t color_scheme_setting; + + int double_click_time_ms; + int drag_threshold; + + bool handle_cursor; +}; + +enum titlebar_gesture { + TITLEBAR_GESTURE_DOUBLE_CLICK, + TITLEBAR_GESTURE_MIDDLE_CLICK, + TITLEBAR_GESTURE_RIGHT_CLICK, +}; + + +// libdecor.h +void libdecor_frame_ref(struct libdecor_frame *frame); +void libdecor_frame_unref(struct libdecor_frame *frame); +void *libdecor_frame_get_user_data(struct libdecor_frame *frame); +void libdecor_frame_set_user_data(struct libdecor_frame *frame, void *user_data); +void libdecor_frame_set_visibility(struct libdecor_frame *frame, + bool visible); +bool libdecor_frame_is_visible(struct libdecor_frame *frame); + +void libdecor_frame_set_parent(struct libdecor_frame *frame, + struct libdecor_frame *parent); +void libdecor_frame_set_title(struct libdecor_frame *frame, + const char *title); +const char * libdecor_frame_get_title(struct libdecor_frame *frame); +void libdecor_frame_set_app_id(struct libdecor_frame *frame, + const char *app_id); +void libdecor_frame_set_capabilities(struct libdecor_frame *frame, + enum libdecor_capabilities capabilities); +void libdecor_frame_unset_capabilities(struct libdecor_frame *frame, + enum libdecor_capabilities capabilities); +bool libdecor_frame_has_capability(struct libdecor_frame *frame, + enum libdecor_capabilities capability); +void libdecor_frame_show_window_menu(struct libdecor_frame *frame, + struct wl_seat *wl_seat, + uint32_t serial, + int x, + int y); + +void libdecor_frame_popup_grab(struct libdecor_frame *frame, + const char *seat_name); +void libdecor_frame_popup_ungrab(struct libdecor_frame *frame, + const char *seat_name); +void libdecor_frame_translate_coordinate(struct libdecor_frame *frame, + int surface_x, + int surface_y, + int *frame_x, + int *frame_y); +void libdecor_frame_set_min_content_size(struct libdecor_frame *frame, + int content_width, + int content_height); +void libdecor_frame_set_max_content_size(struct libdecor_frame *frame, + int content_width, + int content_height); +void libdecor_frame_get_min_content_size(const struct libdecor_frame *frame, + int *content_width, + int *content_height); +void libdecor_frame_get_max_content_size(const struct libdecor_frame *frame, + int *content_width, + int *content_height); +void libdecor_frame_resize(struct libdecor_frame *frame, + struct wl_seat *wl_seat, + uint32_t serial, + enum libdecor_resize_edge edge); +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, + struct libdecor_configuration *configuration); +void libdecor_frame_set_minimized(struct libdecor_frame *frame); +void libdecor_frame_set_maximized(struct libdecor_frame *frame); +void libdecor_frame_unset_maximized(struct libdecor_frame *frame); +void libdecor_frame_set_fullscreen(struct libdecor_frame *frame, + struct wl_output *output); +void libdecor_frame_unset_fullscreen(struct libdecor_frame *frame); +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 xdg_surface * libdecor_frame_get_xdg_surface(struct libdecor_frame *frame); +struct xdg_toplevel * libdecor_frame_get_xdg_toplevel(struct libdecor_frame *frame); +enum libdecor_wm_capabilities libdecor_frame_get_wm_capabilities(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, + int *height); +bool libdecor_configuration_get_window_state(struct libdecor_configuration *configuration, + enum libdecor_window_state *window_state); + +// libdecor-plugin.h + +struct wl_surface * libdecor_frame_get_wl_surface(struct libdecor_frame *frame); + +int libdecor_frame_get_content_width(struct libdecor_frame *frame); + +int libdecor_frame_get_content_height(struct libdecor_frame *frame); + +enum libdecor_window_state libdecor_frame_get_window_state(struct libdecor_frame *frame); + +enum libdecor_capabilities libdecor_frame_get_capabilities(const struct libdecor_frame *frame); + +void libdecor_frame_dismiss_popup(struct libdecor_frame *frame, + const char *seat_name); + +void libdecor_frame_toplevel_commit(struct libdecor_frame *frame); + +void libdecor_notify_plugin_ready(void); + +void libdecor_notify_plugin_error(enum libdecor_error error, + const char *__restrict fmt, + ...); + +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); + +int libdecor_plugin_init(struct libdecor_plugin *plugin, struct libdecor_plugin_interface *iface); + +void libdecor_plugin_release(struct libdecor_plugin *plugin); + +// #include "libdecor-fallback.h" + +struct libdecor_plugin * libdecor_fallback_plugin_new(void); + +// #include "libdecor-cairo-blur.h" + +int blur_surface(cairo_surface_t *surface, int margin); +void render_shadow(cairo_t *cr, cairo_surface_t *surface, + int x, int y, int width, int height, int margin, int top_margin); + +// #include "desktop-settings.h" + +bool libdecor_get_cursor_settings(char **theme, int *size); +enum libdecor_color_scheme libdecor_get_color_scheme(); + + +// #include "os-compatibility.h" + +int libdecor_os_create_anonymous_file(off_t size); + +// digesting_libdecor + +typedef struct Ctx{ + /* globals */ + struct wl_display *wl_display; + struct wl_registry *wl_registry; + struct wl_compositor *wl_compositor; + struct xdg_wm_base *xdg_wm_base; + struct zxdg_decoration_manager_v1 *decoration_manager; + + struct wl_list frames; + struct wl_callback *wl_callback; + struct libdecor_plugin *plugin; + bool plugin_ready; + bool init_done; + bool has_error; + + /* window */ + struct wl_surface *wl_surface; + struct libdecor_frame *libdecor_frame; + struct wl_egl_window *wl_egl_window; + int configured; + int w; + int h; + int close_signal; + //struct xdg_surface *xdg_surface; + //struct xdg_toplevel *xdg_toplevel; + //struct wl_region *wl_region; + EGLDisplay egl_display; + EGLContext egl_context; + EGLSurface egl_surface; +} Ctx; + +#endif //DIGESTING_LIBDECOR_H