### Quick Start Build and Run Example Source: https://github.com/libdecor/libdecor/blob/master/README.md Builds libdecor and its demo application, then sets up the development environment for running the demo. ```bash meson build -Dinstall_demo=true && meson compile -C build ``` ```bash meson devenv -C build libdecor-demo ``` -------------------------------- ### Install Dependencies via apt Source: https://github.com/libdecor/libdecor/blob/master/README.md Installs necessary development libraries for libdecor using the apt package manager. ```bash sudo apt install meson libwayland-dev wayland-protocols libpango1.0-dev libdbus-1-dev libegl-dev libopengl-dev libxkbcommon-dev libgtk-3-dev ``` -------------------------------- ### Install Release Build Source: https://github.com/libdecor/libdecor/blob/master/README.md Installs libdecor and its default plugins after a release build. ```bash meson install -C build ``` -------------------------------- ### Custom Installation Prefix Source: https://github.com/libdecor/libdecor/blob/master/README.md Configures the build to install libdecor to a custom prefix directory. ```bash meson build --buildtype release -Dprefix=$HOME/.local/ ``` -------------------------------- ### Install Meson via pip Source: https://github.com/libdecor/libdecor/blob/master/README.md Installs or updates the Meson build system to the latest version using pip. ```bash pip3 install -U meson ``` -------------------------------- ### Install Dependencies via dnf Source: https://github.com/libdecor/libdecor/blob/master/README.md Installs necessary development libraries for libdecor using the dnf package manager. ```bash sudo dnf install meson wayland-devel wayland-protocols-devel pango-devel dbus-devel mesa-libEGL-devel libglvnd-devel libxkbcommon-devel gtk3-devel ``` -------------------------------- ### Complete EGL Application with libdecor Source: https://context7.com/libdecor/libdecor/llms.txt This C code provides a full example of an EGL application using libdecor for Wayland window decorations. It includes necessary includes, window structure definition, and callback implementations for frame configuration, closing, and committing. The main function initializes Wayland, EGL, libdecor context, decorates the surface, and enters the event loop. ```c #include #include #include #include #include struct window { struct wl_display *display; struct wl_compositor *compositor; struct wl_surface *surface; struct libdecor_frame *frame; struct wl_egl_window *egl_window; EGLDisplay egl_display; EGLContext egl_context; EGLSurface egl_surface; int width, height; bool open, configured; }; static void frame_configure(struct libdecor_frame *frame, struct libdecor_configuration *configuration, void *user_data) { struct window *window = user_data; struct libdecor_state *state; int width, height; if (!libdecor_configuration_get_content_size(configuration, frame, &width, &height)) { width = 400; height = 300; } wl_egl_window_resize(window->egl_window, width, height, 0, 0); window->width = width; window->height = height; state = libdecor_state_new(width, height); libdecor_frame_commit(frame, state, configuration); libdecor_state_free(state); window->configured = true; } static void frame_close(struct libdecor_frame *frame, void *user_data) { struct window *window = user_data; window->open = false; } static void frame_commit(struct libdecor_frame *frame, void *user_data) { struct window *window = user_data; eglSwapBuffers(window->egl_display, window->egl_surface); } static struct libdecor_frame_interface frame_iface = { frame_configure, frame_close, frame_commit, }; static void libdecor_error(struct libdecor *context, enum libdecor_error error, const char *message) { fprintf(stderr, "Error: %s\n", message); exit(1); } static struct libdecor_interface decor_iface = { libdecor_error }; int main(void) { struct window window = { .open = true }; window.display = wl_display_connect(NULL); /* ... registry setup to get compositor ... */ window.surface = wl_compositor_create_surface(window.compositor); /* ... EGL setup ... */ struct libdecor *context = libdecor_new(window.display, &decor_iface); libdecor_set_handle_application_cursor(context, true); window.frame = libdecor_decorate(context, window.surface, &frame_iface, &window); libdecor_frame_set_app_id(window.frame, "egl-app"); libdecor_frame_set_title(window.frame, "EGL Window"); libdecor_frame_map(window.frame); while (!window.configured) libdecor_dispatch(context, 0); while (window.open) { libdecor_dispatch(context, 0); glClearColor(0.2f, 0.4f, 0.6f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); eglSwapBuffers(window.egl_display, window.egl_surface); } libdecor_unref(context); return 0; } ``` -------------------------------- ### Initiate Interactive Window Operations with libdecor Source: https://context7.com/libdecor/libdecor/llms.txt Starts interactive window move or resize operations, typically triggered by pointer events. `libdecor_frame_move` initiates a move, `libdecor_frame_resize` initiates a resize from a specific edge, and `libdecor_frame_show_window_menu` displays the window menu. ```c #include /* Handle pointer button to initiate move */ static void pointer_button(void *data, struct wl_pointer *pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state) { struct window *window = data; if (state != WL_POINTER_BUTTON_STATE_PRESSED) return; if (button == BTN_LEFT) { /* Left click initiates window move */ libdecor_frame_move(window->frame, window->seat, serial); } else if (button == BTN_MIDDLE) { /* Middle click shows window menu */ libdecor_frame_show_window_menu(window->frame, window->seat, serial, window->pointer_x, window->pointer_y); } } /* Initiate edge resize */ libdecor_frame_resize(frame, seat, serial, LIBDECOR_RESIZE_EDGE_BOTTOM_RIGHT); /* Available resize edges */ 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, }; ``` -------------------------------- ### Get Configured Content Size Source: https://context7.com/libdecor/libdecor/llms.txt Retrieves the expected content size from a configuration event. Returns false if the configuration doesn't contain size information, in which case fallback dimensions are used. ```c #include static void handle_configure(struct libdecor_frame *frame, struct libdecor_configuration *configuration, void *user_data) { struct window *window = user_data; int width, height; /* Try to get size from configuration */ if (!libdecor_configuration_get_content_size(configuration, frame, &width, &height)) { /* Use stored floating dimensions as fallback */ width = window->floating_width; height = window->floating_height; } /* Handle zero dimensions */ if (width == 0) width = window->floating_width; if (height == 0) height = window->floating_height; printf("Configured to %dx%d\n", width, height); } ``` -------------------------------- ### libdecor_frame_set_fullscreen / unset_fullscreen Source: https://context7.com/libdecor/libdecor/llms.txt Enters or exits fullscreen mode. Optionally specify a target output for multi-monitor setups. ```APIDOC ## libdecor_frame_set_fullscreen / unset_fullscreen - Fullscreen Mode ### Description Enters or exits fullscreen mode. Optionally specify a target output for multi-monitor setups. ### Method `libdecor_frame_set_fullscreen(frame, output)` `libdecor_frame_unset_fullscreen(frame)` ### Parameters #### Path Parameters - **frame** (libdecor_frame*) - The libdecor frame object. - **output** (struct wl_output*) - The target output for fullscreen mode. `NULL` to use any available output. ### Request Example ```c #include /* Enter fullscreen on any output */ libdecor_frame_set_fullscreen(frame, NULL); /* Enter fullscreen on specific output */ struct wl_output *target_output = get_primary_output(); libdecor_frame_set_fullscreen(frame, target_output); /* Exit fullscreen */ libdecor_frame_unset_fullscreen(frame); ``` ### Response This function does not return a value. Errors are typically handled via libdecor's error reporting mechanism. ``` -------------------------------- ### Get Window State Flags Source: https://context7.com/libdecor/libdecor/llms.txt Retrieves window state flags from a configuration event, including active, maximized, fullscreen, tiled, and suspended states. Individual flags can be checked using bitwise AND operations. ```c #include static void handle_configure(struct libdecor_frame *frame, struct libdecor_configuration *configuration, void *user_data) { enum libdecor_window_state window_state; if (!libdecor_configuration_get_window_state(configuration, &window_state)) { window_state = LIBDECOR_WINDOW_STATE_NONE; } /* Check individual state flags */ if (window_state & LIBDECOR_WINDOW_STATE_ACTIVE) { printf("Window is active (focused)\n"); } if (window_state & LIBDECOR_WINDOW_STATE_MAXIMIZED) { printf("Window is maximized\n"); } if (window_state & LIBDECOR_WINDOW_STATE_FULLSCREEN) { printf("Window is fullscreen\n"); } if (window_state & LIBDECOR_WINDOW_STATE_TILED_LEFT) { printf("Window is tiled to the left\n"); } if (window_state & LIBDECOR_WINDOW_STATE_SUSPENDED) { printf("Window is suspended\n"); } } ``` ```c /* All available window states */ 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, }; ``` -------------------------------- ### Set Window Title Source: https://context7.com/libdecor/libdecor/llms.txt Sets the window title that appears in the decoration's title bar. Supports Unicode characters, including emojis. Examples show setting a simple title and cycling through a list of titles. ```c #include /* Set simple title */ libdecor_frame_set_title(frame, "My Application"); /* Titles with Unicode */ static const char *titles[] = { "Hello!", "Привет!", "你好!", "こんにちは!", }; /* Cycle through titles */ static size_t title_index = 0; libdecor_frame_set_title(frame, titles[title_index]); title_index = (title_index + 1) % 4; ``` -------------------------------- ### Run Demo with Cairo Plugin (Older Meson) Source: https://github.com/libdecor/libdecor/blob/master/README.md Executes the libdecor demo application, ensuring it uses the cairo plugin by specifying the plugin directory. ```bash ./build/demo/libdecor-demo ``` -------------------------------- ### Content State Management with libdecor_state_new/free Source: https://context7.com/libdecor/libdecor/llms.txt Creates and manages window state objects representing the configured content dimensions. States are used to commit configuration changes to the frame. ```c #include /* Create state with specific dimensions */ int width = 800; int height = 600; struct libdecor_state *state = libdecor_state_new(width, height); /* Commit state in response to configure event */ libdecor_frame_commit(frame, state, configuration); /* Free state when done */ libdecor_state_free(state); /* Application-driven resize (when floating) */ void resize_window(struct window *window, int width, int height) { if (!libdecor_frame_is_floating(window->frame)) { printf("Cannot resize in non-floating mode\n"); return; } struct libdecor_state *state = libdecor_state_new(width, height); libdecor_frame_commit(window->frame, state, NULL); libdecor_state_free(state); window->width = width; window->height = height; redraw(window); } ``` -------------------------------- ### Create libdecor Context Source: https://context7.com/libdecor/libdecor/llms.txt Initializes a libdecor context for a Wayland display. Requires a Wayland connection and an interface for error callbacks. The main loop dispatches Wayland events. ```c #include #include static void handle_error(struct libdecor *context, enum libdecor_error error, const char *message) { fprintf(stderr, "libdecor error (%d): %s\n", error, message); exit(EXIT_FAILURE); } static struct libdecor_interface libdecor_iface = { .error = handle_error, }; int main(void) { struct wl_display *wl_display = wl_display_connect(NULL); if (!wl_display) { fprintf(stderr, "No Wayland connection\n"); return EXIT_FAILURE; } /* Create libdecor context */ struct libdecor *context = libdecor_new(wl_display, &libdecor_iface); /* Main event loop */ while (libdecor_dispatch(context, -1) >= 0) { /* Process events */ } libdecor_unref(context); wl_display_disconnect(wl_display); return EXIT_SUCCESS; } ``` -------------------------------- ### Debug Build with Sanitizer and Warnings Source: https://github.com/libdecor/libdecor/blob/master/README.md Configures a debug build with AddressSanitizer enabled and maximum warning level for development. ```bash meson build -Dinstall_demo=true -Db_sanitize=address -Dwarning_level=3 ``` -------------------------------- ### Manage Fullscreen Mode with libdecor Source: https://context7.com/libdecor/libdecor/llms.txt Enters or exits fullscreen mode. `libdecor_frame_set_fullscreen` can optionally take a `wl_output` to specify the target monitor. Use `libdecor_frame_unset_fullscreen` to exit. ```c #include /* Enter fullscreen on any output */ libdecor_frame_set_fullscreen(frame, NULL); /* Enter fullscreen on specific output */ struct wl_output *target_output = get_primary_output(); libdecor_frame_set_fullscreen(frame, target_output); /* Exit fullscreen */ libdecor_frame_unset_fullscreen(frame); ``` -------------------------------- ### libdecor_new - Create a libdecor Context Source: https://context7.com/libdecor/libdecor/llms.txt Creates a new libdecor context instance for the given Wayland display. This context manages decorated windows and dispatches Wayland server events. An interface structure must be provided for error callbacks. ```APIDOC ## libdecor_new - Create a libdecor Context ### Description Creates a new libdecor context instance for the given Wayland display. The context manages the lifecycle of decorated windows and dispatches events from the Wayland server. An interface structure must be provided to handle error callbacks. ### Method (Implicitly part of initialization, not a direct HTTP method) ### Endpoint (N/A - Library function) ### Parameters #### Path Parameters (N/A) #### Query Parameters (N/A) #### Request Body (N/A) ### Request Example ```c #include #include static void handle_error(struct libdecor *context, enum libdecor_error error, const char *message) { fprintf(stderr, "libdecor error (%d): %s\n", error, message); exit(EXIT_FAILURE); } static struct libdecor_interface libdecor_iface = { .error = handle_error, }; int main(void) { struct wl_display *wl_display = wl_display_connect(NULL); if (!wl_display) { fprintf(stderr, "No Wayland connection\n"); return EXIT_FAILURE; } /* Create libdecor context */ struct libdecor *context = libdecor_new(wl_display, &libdecor_iface); /* Main event loop */ while (libdecor_dispatch(context, -1) >= 0) { /* Process events */ } libdecor_unref(context); wl_display_disconnect(wl_display); return EXIT_SUCCESS; } ``` ### Response #### Success Response (200) (N/A - Function returns a pointer) #### Response Example (N/A) ``` -------------------------------- ### Set Plugin Directory for Older Meson Versions Source: https://github.com/libdecor/libdecor/blob/master/README.md Exports the LIBDECOR_PLUGIN_DIR environment variable to point to the cairo plugin directory for older Meson versions. ```bash export LIBDECOR_PLUGIN_DIR=build/src/plugins/cairo/ ``` -------------------------------- ### Set Window Size Constraints with libdecor Source: https://context7.com/libdecor/libdecor/llms.txt Defines minimum and maximum content size constraints for a window. These limits are respected by the compositor and decorations during interactive resizing. Use `libdecor_frame_set_min_content_size` and `libdecor_frame_set_max_content_size`. Retrieve current constraints with `libdecor_frame_get_min_content_size` and `libdecor_frame_get_max_content_size`. ```c #include /* Set minimum window size (240x160 pixels) */ libdecor_frame_set_min_content_size(frame, 240, 160); /* Set maximum window size (1920x1080 pixels) */ libdecor_frame_set_max_content_size(frame, 1920, 1080); /* Get current constraints */ int min_w, min_h, max_w, max_h; libdecor_frame_get_min_content_size(frame, &min_w, &min_h); libdecor_frame_get_max_content_size(frame, &max_w, &max_h); printf("Size constraints: min=%dx%d, max=%dx%d\n", min_w, min_h, max_w, max_h); /* Constrain a size to valid range */ void constrain_size(const struct libdecor_frame *frame, int *width, int *height) { int min_w, min_h, max_w, max_h; libdecor_frame_get_min_content_size(frame, &min_w, &min_h); libdecor_frame_get_max_content_size(frame, &max_w, &max_h); if (min_w > 0) *width = (*width > min_w) ? *width : min_w; if (max_w > 0) *width = (*width < max_w) ? *width : max_w; if (min_h > 0) *height = (*height > min_h) ? *height : min_h; if (max_h > 0) *height = (*height < max_h) ? *height : max_h; } ``` -------------------------------- ### Release Build Configuration Source: https://github.com/libdecor/libdecor/blob/master/README.md Configures and builds libdecor for a release, specifying the build type. ```bash meson build --buildtype release ``` -------------------------------- ### Control Window Maximization with libdecor Source: https://context7.com/libdecor/libdecor/llms.txt Manages the window maximization state. Use `libdecor_frame_set_maximized` to maximize the window and `libdecor_frame_unset_maximized` to restore it. `libdecor_frame_is_floating` checks if the window is in a non-maximized, non-fullscreen, non-tiled state. ```c #include /* Maximize the window */ libdecor_frame_set_maximized(frame); /* Restore from maximized state */ libdecor_frame_unset_maximized(frame); /* Check if floating (not maximized/fullscreen/tiled) */ if (libdecor_frame_is_floating(frame)) { printf("Window is in floating mode\n"); } ``` -------------------------------- ### Configure Window Capabilities with libdecor Source: https://context7.com/libdecor/libdecor/llms.txt Controls which window actions are available. Setting capabilities affects decoration buttons and user interactions. Use `libdecor_frame_set_capabilities` to enable and `libdecor_frame_unset_capabilities` to disable specific actions. Check current capabilities with `libdecor_frame_has_capability`. ```c #include /* Enable all standard capabilities */ libdecor_frame_set_capabilities(frame, LIBDECOR_ACTION_MOVE | LIBDECOR_ACTION_RESIZE | LIBDECOR_ACTION_MINIMIZE | LIBDECOR_ACTION_FULLSCREEN | LIBDECOR_ACTION_CLOSE); /* Create fixed-size window (disable resize) */ libdecor_frame_unset_capabilities(frame, LIBDECOR_ACTION_RESIZE); /* Check if resize is enabled */ if (libdecor_frame_has_capability(frame, LIBDECOR_ACTION_RESIZE)) { printf("Window is resizable\n"); } else { printf("Window has fixed size\n"); } /* Toggle resize capability */ if (libdecor_frame_has_capability(frame, LIBDECOR_ACTION_RESIZE)) { libdecor_frame_unset_capabilities(frame, LIBDECOR_ACTION_RESIZE); } else { libdecor_frame_set_capabilities(frame, LIBDECOR_ACTION_RESIZE); } ``` -------------------------------- ### Decorate Wayland Surface Source: https://context7.com/libdecor/libdecor/llms.txt Decorates a wl_surface with window decorations, creating xdg_surface and xdg_toplevel. It requires frame interface callbacks for configuration, close requests, and commit notifications. The frame is then mapped and properties like app ID and title can be set. ```c #include static void handle_configure(struct libdecor_frame *frame, struct libdecor_configuration *configuration, void *user_data) { struct window *window = user_data; int width, height; enum libdecor_window_state window_state; struct libdecor_state *state; /* Get window state */ if (!libdecor_configuration_get_window_state(configuration, &window_state)) window_state = LIBDECOR_WINDOW_STATE_NONE; /* Get content size or use defaults */ if (!libdecor_configuration_get_content_size(configuration, frame, &width, &height)) { width = window->default_width; height = window->default_height; } /* Create and commit state */ state = libdecor_state_new(width, height); libdecor_frame_commit(frame, state, configuration); libdecor_state_free(state); /* Redraw content at new size */ window->width = width; window->height = height; redraw(window); } static void handle_close(struct libdecor_frame *frame, void *user_data) { struct window *window = user_data; window->running = false; } static void handle_commit(struct libdecor_frame *frame, void *user_data) { struct window *window = user_data; wl_surface_commit(window->wl_surface); } static struct libdecor_frame_interface frame_iface = { .configure = handle_configure, .close = handle_close, .commit = handle_commit, }; /* Usage */ struct wl_surface *wl_surface = wl_compositor_create_surface(compositor); struct libdecor_frame *frame = libdecor_decorate(context, wl_surface, &frame_iface, window); libdecor_frame_set_app_id(frame, "my-application"); libdecor_frame_set_title(frame, "My Window"); libdecor_frame_map(frame); ``` -------------------------------- ### libdecor_frame_set_capabilities Source: https://context7.com/libdecor/libdecor/llms.txt Configures which window actions are available. This affects decoration buttons and user interactions. Use bitwise OR to combine multiple capabilities. ```APIDOC ## libdecor_frame_set_capabilities - Configure Window Capabilities ### Description Controls which window actions are available. Setting capabilities affects decoration buttons (e.g., whether maximize button is shown) and user interactions. ### Method `libdecor_frame_set_capabilities(frame, capabilities)` `libdecor_frame_unset_capabilities(frame, capabilities)` `libdecor_frame_has_capability(frame, capability)` ### Parameters #### Path Parameters - **frame** (libdecor_frame*) - The libdecor frame object. - **capabilities** (libdecor_actions) - Bitmask of capabilities to set or unset. - **capability** (libdecor_action) - A single capability to check. ### Request Example ```c #include /* Enable all standard capabilities */ libdecor_frame_set_capabilities(frame, LIBDECOR_ACTION_MOVE | LIBDECOR_ACTION_RESIZE | LIBDECOR_ACTION_MINIMIZE | LIBDECOR_ACTION_FULLSCREEN | LIBDECOR_ACTION_CLOSE); /* Create fixed-size window (disable resize) */ libdecor_frame_unset_capabilities(frame, LIBDECOR_ACTION_RESIZE); /* Check if resize is enabled */ if (libdecor_frame_has_capability(frame, LIBDECOR_ACTION_RESIZE)) { printf("Window is resizable\n"); } else { printf("Window has fixed size\n"); } /* Toggle resize capability */ if (libdecor_frame_has_capability(frame, LIBDECOR_ACTION_RESIZE)) { libdecor_frame_unset_capabilities(frame, LIBDECOR_ACTION_RESIZE); } else { libdecor_frame_set_capabilities(frame, LIBDECOR_ACTION_RESIZE); } ``` ### Response This function does not return a value. Errors are typically handled via libdecor's error reporting mechanism. ``` -------------------------------- ### libdecor_decorate - Decorate a Wayland Surface Source: https://context7.com/libdecor/libdecor/llms.txt Decorates a given wl_surface with window decorations. This function creates the underlying xdg_surface and xdg_toplevel, managing windowing integration events. The frame interface handles callbacks for configure, close, and commit events. ```APIDOC ## libdecor_decorate - Decorate a Wayland Surface ### Description Decorates a given wl_surface with window decorations. This creates the underlying xdg_surface and xdg_toplevel, handling all windowing integration events. The frame interface provides callbacks for configure events, close requests, and commit notifications. ### Method (Implicitly part of initialization, not a direct HTTP method) ### Endpoint (N/A - Library function) ### Parameters #### Path Parameters (N/A) #### Query Parameters (N/A) #### Request Body (N/A) ### Request Example ```c #include static void handle_configure(struct libdecor_frame *frame, struct libdecor_configuration *configuration, void *user_data) { struct window *window = user_data; int width, height; enum libdecor_window_state window_state; struct libdecor_state *state; /* Get window state */ if (!libdecor_configuration_get_window_state(configuration, &window_state)) window_state = LIBDECOR_WINDOW_STATE_NONE; /* Get content size or use defaults */ if (!libdecor_configuration_get_content_size(configuration, frame, &width, &height)) { width = window->default_width; height = window->default_height; } /* Create and commit state */ state = libdecor_state_new(width, height); libdecor_frame_commit(frame, state, configuration); libdecor_state_free(state); /* Redraw content at new size */ window->width = width; window->height = height; redraw(window); } static void handle_close(struct libdecor_frame *frame, void *user_data) { struct window *window = user_data; window->running = false; } static void handle_commit(struct libdecor_frame *frame, void *user_data) { struct window *window = user_data; wl_surface_commit(window->wl_surface); } static struct libdecor_frame_interface frame_iface = { .configure = handle_configure, .close = handle_close, .commit = handle_commit, }; /* Usage */ struct wl_surface *wl_surface = wl_compositor_create_surface(compositor); struct libdecor_frame *frame = libdecor_decorate(context, wl_surface, &frame_iface, window); libdecor_frame_set_app_id(frame, "my-application"); libdecor_frame_set_title(frame, "My Window"); libdecor_frame_map(frame); ``` ### Response #### Success Response (200) (N/A - Function returns a pointer) #### Response Example (N/A) ``` -------------------------------- ### Content State Management Source: https://context7.com/libdecor/libdecor/llms.txt Creates and manages window state objects representing the configured content dimensions. States are used to commit configuration changes to the frame. ```APIDOC ## libdecor_state_new / free - Content State Management ### Description Creates and manages window state objects representing the configured content dimensions. States are used to commit configuration changes to the frame. ### Method (Not specified, likely function calls) ### Endpoint (Not applicable, these are library functions) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example ```c #include /* Create state with specific dimensions */ int width = 800; int height = 600; struct libdecor_state *state = libdecor_state_new(width, height); /* Commit state in response to configure event */ libdecor_frame_commit(frame, state, configuration); /* Free state when done */ libdecor_state_free(state); /* Application-driven resize (when floating) */ void resize_window(struct window *window, int width, int height) { if (!libdecor_frame_is_floating(window->frame)) { printf("Cannot resize in non-floating mode\n"); return; } struct libdecor_state *state = libdecor_state_new(width, height); libdecor_frame_commit(window->frame, state, NULL); libdecor_state_free(state); window->width = width; window->height = height; redraw(window); } ``` ### Response #### Success Response (200) (Not applicable, these are function calls) #### Response Example (None) ``` -------------------------------- ### libdecor_frame_set_parent Source: https://context7.com/libdecor/libdecor/llms.txt Establishes a parent-child relationship between windows, creating a stacking order for toplevel windows. ```APIDOC ## libdecor_frame_set_parent - Window Hierarchy ### Description Sets a parent frame for the window, creating a stacking relationship between toplevel windows. ### Method (Not specified, likely a function call within C code) ### Endpoint (Not applicable, this is a C function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example ```c #include /* Create child window stacked above parent */ struct libdecor_frame *parent_frame = /* main window frame */; struct libdecor_frame *dialog_frame = libdecor_decorate(context, dialog_surface, &frame_iface, dialog); libdecor_frame_set_parent(dialog_frame, parent_frame); libdecor_frame_set_title(dialog_frame, "Dialog"); libdecor_frame_map(dialog_frame); ``` ### Response #### Success Response (None, function modifies state) #### Response Example (See C code example for usage) ``` -------------------------------- ### libdecor_configuration_get_content_size Source: https://context7.com/libdecor/libdecor/llms.txt Retrieves the configured content size from a libdecor configuration event. Returns false if size information is not present. ```APIDOC ## libdecor_configuration_get_content_size - Get Configured Size ### Description Retrieves the expected content size from a configuration event. Returns false if the configuration doesn't contain size information. ### Method (Not specified, likely a function call within C code) ### Endpoint (Not applicable, this is a C function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example ```c #include static void handle_configure(struct libdecor_frame *frame, struct libdecor_configuration *configuration, void *user_data) { struct window *window = user_data; int width, height; /* Try to get size from configuration */ if (!libdecor_configuration_get_content_size(configuration, frame, &width, &height)) { /* Use stored floating dimensions as fallback */ width = window->floating_width; height = window->floating_height; } /* Handle zero dimensions */ if (width == 0) width = window->floating_width; if (height == 0) height = window->floating_height; printf("Configured to %dx%d\n", width, height); } ``` ### Response #### Success Response (Boolean indicating success, width and height are output parameters) #### Response Example (See C code example for usage) ``` -------------------------------- ### Popup Management with libdecor_frame_popup_grab/ungrab Source: https://context7.com/libdecor/libdecor/llms.txt Manages popup grabs for proper dismissal when clicking outside the popup. Call when mapping/unmapping xdg_popup surfaces. ```c #include /* When opening a popup */ struct xdg_popup *popup = xdg_surface_get_popup(popup_surface, libdecor_frame_get_xdg_surface(frame), positioner); xdg_popup_grab(popup, seat, serial); wl_surface_commit(popup_surface); /* Notify libdecor about popup grab */ libdecor_frame_popup_grab(frame, seat_name); /* When closing popup */ libdecor_frame_popup_ungrab(frame, seat_name); xdg_popup_destroy(popup); /* Handle dismiss_popup callback */ static void handle_dismiss_popup(struct libdecor_frame *frame, const char *seat_name, void *user_data) { struct window *window = user_data; if (window->popup) { popup_destroy(window->popup); window->popup = NULL; } } ``` -------------------------------- ### Compile Debug Build Source: https://github.com/libdecor/libdecor/blob/master/README.md Compiles the project after configuring a debug build with sanitizers and warnings. ```bash meson compile -C build ``` -------------------------------- ### libdecor_configuration_get_window_state Source: https://context7.com/libdecor/libdecor/llms.txt Retrieves the window state flags from a configuration event, including active, maximized, fullscreen, tiled, and suspended states. ```APIDOC ## libdecor_configuration_get_window_state - Get Window State ### Description Retrieves the window state flags from a configuration event. Includes active, maximized, fullscreen, tiled, and suspended states. ### Method (Not specified, likely a function call within C code) ### Endpoint (Not applicable, this is a C function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example ```c #include static void handle_configure(struct libdecor_frame *frame, struct libdecor_configuration *configuration, void *user_data) { enum libdecor_window_state window_state; if (!libdecor_configuration_get_window_state(configuration, &window_state)) { window_state = LIBDECOR_WINDOW_STATE_NONE; } /* Check individual state flags */ if (window_state & LIBDECOR_WINDOW_STATE_ACTIVE) { printf("Window is active (focused)\n"); } if (window_state & LIBDECOR_WINDOW_STATE_MAXIMIZED) { printf("Window is maximized\n"); } if (window_state & LIBDECOR_WINDOW_STATE_FULLSCREEN) { printf("Window is fullscreen\n"); } if (window_state & LIBDECOR_WINDOW_STATE_TILED_LEFT) { printf("Window is tiled to the left\n"); } if (window_state & LIBDECOR_WINDOW_STATE_SUSPENDED) { printf("Window is suspended\n"); } } /* All available window states */ 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, }; ``` ### Response #### Success Response (Boolean indicating success, window_state is an output parameter) #### Response Example (See C code example for usage) ``` -------------------------------- ### Event Dispatching with libdecor_dispatch Source: https://context7.com/libdecor/libdecor/llms.txt Dispatches events from the Wayland server. Should be called when data is available on the file descriptor returned by libdecor_get_fd(). The timeout parameter controls blocking behavior. ```c #include #include /* Non-blocking dispatch in render loop */ while (window->running) { if (libdecor_dispatch(context, 0) < 0) { fprintf(stderr, "Dispatch error\n"); break; } draw(window); } /* Blocking dispatch with timeout */ while (libdecor_dispatch(context, 500) >= 0) { /* Process every 500ms or when events arrive */ } /* Using poll for event-driven loop */ int fd = libdecor_get_fd(context); struct pollfd pfd = { .fd = fd, .events = POLLIN }; while (window->running) { poll(&pfd, 1, -1); if (pfd.revents & POLLIN) { if (libdecor_dispatch(context, 0) < 0) { break; } } } ``` -------------------------------- ### libdecor_frame_set_min/max_content_size Source: https://context7.com/libdecor/libdecor/llms.txt Sets minimum and maximum content size constraints for the window. These limits are respected during interactive resize operations. ```APIDOC ## libdecor_frame_set_min/max_content_size - Size Constraints ### Description Sets minimum and maximum content size constraints for the window. The compositor and decorations respect these limits during interactive resize operations. ### Method `libdecor_frame_set_min_content_size(frame, width, height)` `libdecor_frame_set_max_content_size(frame, width, height)` `libdecor_frame_get_min_content_size(frame, &min_w, &min_h)` `libdecor_frame_get_max_content_size(frame, &max_w, &max_h)` ### Parameters #### Path Parameters - **frame** (libdecor_frame*) - The libdecor frame object. - **width** (int) - The desired width constraint. - **height** (int) - The desired height constraint. - **min_w**, **min_h** (int*) - Pointers to store the minimum width and height. - **max_w**, **max_h** (int*) - Pointers to store the maximum width and height. ### Request Example ```c #include /* Set minimum window size (240x160 pixels) */ libdecor_frame_set_min_content_size(frame, 240, 160); /* Set maximum window size (1920x1080 pixels) */ libdecor_frame_set_max_content_size(frame, 1920, 1080); /* Get current constraints */ int min_w, min_h, max_w, max_h; libdecor_frame_get_min_content_size(frame, &min_w, &min_h); libdecor_frame_get_max_content_size(frame, &max_w, &max_h); printf("Size constraints: min=%dx%d, max=%dx%d\n", min_w, min_h, max_w, max_h); /* Constrain a size to valid range */ void constrain_size(const struct libdecor_frame *frame, int *width, int *height) { int min_w, min_h, max_w, max_h; libdecor_frame_get_min_content_size(frame, &min_w, &min_h); libdecor_frame_get_max_content_size(frame, &max_w, &max_h); if (min_w > 0) *width = (*width > min_w) ? *width : min_w; if (max_w > 0) *width = (*width < max_w) ? *width : max_w; if (min_h > 0) *height = (*height > min_h) ? *height : min_h; if (max_h > 0) *height = (*height < max_h) ? *height : max_h; } ``` ### Response This function does not return a value. Errors are typically handled via libdecor's error reporting mechanism. ``` -------------------------------- ### libdecor_frame_move / resize Source: https://context7.com/libdecor/libdecor/llms.txt Initiates interactive move or resize operations, typically triggered by pointer button events on the content surface. ```APIDOC ## libdecor_frame_move / resize - Interactive Operations ### Description Initiates interactive move or resize operations, typically triggered by pointer button events on the content surface. ### Method `libdecor_frame_move(frame, seat, serial)` `libdecor_frame_resize(frame, seat, serial, edge)` `libdecor_frame_show_window_menu(frame, seat, serial, x, y)` ### Parameters #### Path Parameters - **frame** (libdecor_frame*) - The libdecor frame object. - **seat** (struct wl_seat*) - The Wayland seat. - **serial** (uint32_t) - The Wayland event serial. - **edge** (enum libdecor_resize_edge) - The edge to initiate resize from. - **x**, **y** (int) - Coordinates for showing the window menu. ### Request Example ```c #include /* Handle pointer button to initiate move */ static void pointer_button(void *data, struct wl_pointer *pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state) { struct window *window = data; if (state != WL_POINTER_BUTTON_STATE_PRESSED) return; if (button == BTN_LEFT) { /* Left click initiates window move */ libdecor_frame_move(window->frame, window->seat, serial); } else if (button == BTN_MIDDLE) { /* Middle click shows window menu */ libdecor_frame_show_window_menu(window->frame, window->seat, serial, window->pointer_x, window->pointer_y); } } /* Initiate edge resize */ libdecor_frame_resize(frame, seat, serial, LIBDECOR_RESIZE_EDGE_BOTTOM_RIGHT); /* Available resize edges */ 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, }; ``` ### Response This function does not return a value. Errors are typically handled via libdecor's error reporting mechanism. ``` -------------------------------- ### Event Dispatching Source: https://context7.com/libdecor/libdecor/llms.txt Dispatches events from the Wayland server. Should be called when data is available on the file descriptor returned by libdecor_get_fd(). The timeout parameter controls blocking behavior. ```APIDOC ## libdecor_dispatch - Event Dispatching ### Description Dispatches events from the Wayland server. Should be called when data is available on the file descriptor returned by libdecor_get_fd(). The timeout parameter controls blocking behavior. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable, this is a library function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example ```c #include #include /* Non-blocking dispatch in render loop */ while (window->running) { if (libdecor_dispatch(context, 0) < 0) { fprintf(stderr, "Dispatch error\n"); break; } draw(window); } /* Blocking dispatch with timeout */ while (libdecor_dispatch(context, 500) >= 0) { /* Process every 500ms or when events arrive */ } /* Using poll for event-driven loop */ int fd = libdecor_get_fd(context); struct pollfd pfd = { .fd = fd, .events = POLLIN }; while (window->running) { poll(&pfd, 1, -1); if (pfd.revents & POLLIN) { if (libdecor_dispatch(context, 0) < 0) { break; } } } ``` ### Response #### Success Response (200) (Not applicable, this is a function call) #### Response Example (None) ``` -------------------------------- ### Popup Management Source: https://context7.com/libdecor/libdecor/llms.txt Manages popup grabs for proper dismissal when clicking outside the popup. Call when mapping/unmapping xdg_popup surfaces. ```APIDOC ## libdecor_frame_popup_grab / ungrab - Popup Management ### Description Manages popup grabs for proper dismissal when clicking outside the popup. Call when mapping/unmapping xdg_popup surfaces. ### Method (Not specified, likely function calls) ### Endpoint (Not applicable, these are library functions) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example ```c #include /* When opening a popup */ struct xdg_popup *popup = xdg_surface_get_popup(popup_surface, libdecor_frame_get_xdg_surface(frame), positioner); xdg_popup_grab(popup, seat, serial); wl_surface_commit(popup_surface); /* Notify libdecor about popup grab */ libdecor_frame_popup_grab(frame, seat_name); /* When closing popup */ libdecor_frame_popup_ungrab(frame, seat_name); xdg_popup_destroy(popup); /* Handle dismiss_popup callback */ static void handle_dismiss_popup(struct libdecor_frame *frame, const char *seat_name, void *user_data) { struct window *window = user_data; if (window->popup) { popup_destroy(window->popup); window->popup = NULL; } } ``` ### Response #### Success Response (200) (Not applicable, these are function calls) #### Response Example (None) ``` -------------------------------- ### Translate Coordinates with libdecor_frame_translate_coordinate Source: https://context7.com/libdecor/libdecor/llms.txt Translates content surface local coordinates to toplevel window local coordinates. Useful for positioning popups or showing context menus. ```c #include /* Translate surface coordinates for popup positioning */ int surface_x = 100; int surface_y = 50; int frame_x, frame_y; libdecor_frame_translate_coordinate(frame, surface_x, surface_y, &frame_x, &frame_y); /* Use translated coordinates for popup anchor */ struct xdg_positioner *positioner = xdg_wm_base_create_positioner(wm_base); xdg_positioner_set_anchor_rect(positioner, frame_x, frame_y, 1, 1); ``` -------------------------------- ### Toggle Decoration Visibility Source: https://context7.com/libdecor/libdecor/llms.txt Controls whether decorations are visible. Applications can use this to implement borderless mode. ```APIDOC ## libdecor_frame_set_visibility - Toggle Decoration Visibility ### Description Controls whether decorations are visible. Applications can use this to implement borderless mode. ### Method (Not specified, likely a function call) ### Endpoint (Not applicable, this is a library function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example ```c #include /* Hide decorations for borderless window */ libdecor_frame_set_visibility(frame, false); /* Show decorations */ libdecor_frame_set_visibility(frame, true); /* Toggle visibility */ bool visible = libdecor_frame_is_visible(frame); libdecor_frame_set_visibility(frame, !visible); printf("Decorations are now %s\n", visible ? "hidden" : "visible"); ``` ### Response #### Success Response (200) (Not applicable, this is a function call) #### Response Example (None) ```