### Initialize neuswc Compositor Source: https://context7.com/~shrub900/neuswc/llms.txt Demonstrates how to set up the Wayland display, define manager callbacks for screens and windows, and start the compositor event loop. ```c #include #include static void new_screen(struct swc_screen *screen) { struct my_screen *s = malloc(sizeof(*s)); s->swc = screen; wl_list_init(&s->windows); swc_screen_set_handler(screen, &screen_handler, s); } static void new_window(struct swc_window *window) { struct my_window *w = malloc(sizeof(*w)); w->swc = window; swc_window_set_handler(window, &window_handler, w); swc_window_set_tiled(window); swc_window_show(window); } static const struct swc_manager manager = { .new_screen = new_screen, .new_window = new_window, .new_device = NULL, .activate = NULL, .deactivate = NULL, }; int main(void) { struct wl_display *display = wl_display_create(); if (!display) return 1; const char *socket = wl_display_add_socket_auto(display); setenv("WAYLAND_DISPLAY", socket, 1); if (!swc_initialize(display, NULL, &manager)) { wl_display_destroy(display); return 1; } wl_display_run(display); swc_finalize(); wl_display_destroy(display); return 0; } ``` -------------------------------- ### Input Bindings for Window Manager Actions (C) Source: https://context7.com/~shrub900/neuswc/llms.txt Allows registration of keyboard and mouse button bindings with modifier combinations to trigger window manager actions. Includes example handlers for spawning a terminal and closing a window, and registering key/button bindings. ```c /* Binding callback signature */ typedef void (*swc_binding_handler)(void *data, uint32_t time, uint32_t value, uint32_t state); static void spawn_terminal(void *data, uint32_t time, uint32_t value, uint32_t state) { if (state != WL_KEYBOARD_KEY_STATE_PRESSED) return; if (fork() == 0) { execl("/usr/bin/foot", "foot", NULL); _exit(1); } } static void close_focused(void *data, uint32_t time, uint32_t value, uint32_t state) { if (state != WL_KEYBOARD_KEY_STATE_PRESSED) return; if (focused_window) { swc_window_close(focused_window); } } /* Register key bindings - uses XKB keysyms */ #include /* Mod+Return spawns terminal */ swc_add_binding(SWC_BINDING_KEY, SWC_MOD_LOGO, XKB_KEY_Return, spawn_terminal, NULL); /* Mod+Shift+Q closes window */ swc_add_binding(SWC_BINDING_KEY, SWC_MOD_LOGO | SWC_MOD_SHIFT, XKB_KEY_q, close_focused, NULL); /* Mouse button binding - Mod+Click */ swc_add_binding(SWC_BINDING_BUTTON, SWC_MOD_LOGO, BTN_LEFT, start_window_move, NULL); /* Available modifiers */ /* SWC_MOD_CTRL - Control key */ /* SWC_MOD_ALT - Alt key */ /* SWC_MOD_LOGO - Super/Windows/Command key */ /* SWC_MOD_SHIFT - Shift key */ /* SWC_MOD_ANY - Match any modifier combination */ ``` -------------------------------- ### Interactive Window Move and Resize (C) Source: https://context7.com/~shrub900/neuswc/llms.txt Enables pointer-driven window movement and resizing for stacked/floating window modes. It provides functions to start and end move/resize operations, with options for specifying resize edges. ```c /* Start interactive move (window must be in stacked mode) */ swc_window_set_stacked(window); swc_window_begin_move(window); /* User drags window with pointer... */ swc_window_end_move(window); /* Start interactive resize with specific edge */ swc_window_begin_resize(window, SWC_WINDOW_EDGE_RIGHT | SWC_WINDOW_EDGE_BOTTOM); /* User drags to resize... */ swc_window_end_resize(window); /* Edge flags for resize direction */ /* SWC_WINDOW_EDGE_AUTO - auto-detect from pointer position */ /* SWC_WINDOW_EDGE_TOP - resize from top edge */ /* SWC_WINDOW_EDGE_BOTTOM - resize from bottom edge */ /* SWC_WINDOW_EDGE_LEFT - resize from left edge */ /* SWC_WINDOW_EDGE_RIGHT - resize from right edge */ ``` -------------------------------- ### Axis Binding and Pointer Events (C) Source: https://context7.com/~shrub900/neuswc/llms.txt Handles scroll wheel bindings and forwards pointer events to focused clients. Includes an example for scroll-based zoom control and functions to send pointer events. ```c /* Axis binding callback */ typedef void (*swc_axis_binding_handler)(void *data, uint32_t time, uint32_t axis, int32_t value120); static void handle_scroll_zoom(void *data, uint32_t time, uint32_t axis, int32_t value120) { /* value120 uses 120-unit convention (one notch = 120) */ float current = swc_get_zoom(); float delta = (value120 > 0) ? -0.1f : 0.1f; swc_set_zoom(current + delta); } /* Mod+Scroll for zoom control */ swc_add_axis_binding(SWC_MOD_LOGO, WL_POINTER_AXIS_VERTICAL_SCROLL, handle_scroll_zoom, NULL); /* Forward pointer events to clients when not consumed */ static void click_handler(void *data, uint32_t time, uint32_t button, uint32_t state) { /* Do custom handling... then forward to client */ swc_pointer_send_button(time, button, state); } static void scroll_handler(void *data, uint32_t time, uint32_t axis, int32_t value120) { /* Forward scroll events to focused client */ swc_pointer_send_axis(time, axis, value120); } ``` -------------------------------- ### Control Compositor Zoom (C) Source: https://context7.com/~shrub900/neuswc/llms.txt Manages compositor-level zoom for accessibility or demonstration purposes using software scaling. It provides functions to get the current zoom level, set a specific zoom level, and includes examples for incremental zooming in and out. ```c /* Get current zoom level (1.0 = normal) */ float level = swc_get_zoom(); /* Zoom in (200% magnification) */ swc_set_zoom(2.0f); /* Zoom out (50% size) */ swc_set_zoom(0.5f); /* Reset to normal */ swc_set_zoom(1.0f); /* Incremental zoom control */ static void zoom_in(void) { float current = swc_get_zoom(); swc_set_zoom(current * 1.1f); /* 10% increase */ } static void zoom_out(void) { float current = swc_get_zoom(); if (current > 0.2f) { swc_set_zoom(current / 1.1f); /* 10% decrease */ } } ``` -------------------------------- ### Tiling Window Manager Implementation in C Source: https://context7.com/~shrub900/neuswc/llms.txt This C code implements a minimal tiling window manager. It initializes the swc compositor, handles screen and window events, manages window layouts in a grid, and defines keybindings for spawning applications and exiting. Dependencies include swc, wayland-server, and xkbcommon. It takes no explicit input but responds to Wayland events and key presses. ```C #include #include #include #include #include #include struct screen { struct swc_screen *swc; struct wl_list windows; unsigned num_windows; }; struct window { struct swc_window *swc; struct screen *screen; struct wl_list link; }; static struct screen *active_screen; static struct window *focused_window; static struct wl_display *display; /* Grid layout algorithm */ static void arrange(struct screen *screen) { if (screen->num_windows == 0) return; struct swc_rectangle *area = &screen->swc->usable_geometry; unsigned cols = (unsigned)ceil(sqrt(screen->num_windows)); unsigned rows = (screen->num_windows + cols - 1) / cols; struct window *w; unsigned i = 0; wl_list_for_each(w, &screen->windows, link) { unsigned col = i % cols; unsigned row = i / cols; struct swc_rectangle geom = { .x = area->x + (area->width * col / cols) + 1, .y = area->y + (area->height * row / rows) + 1, .width = area->width / cols - 2, .height = area->height / rows - 2, }; swc_window_set_geometry(w->swc, &geom); i++; } } static void focus(struct window *window) { if (focused_window) { swc_window_set_border(focused_window->swc, 0xff888888, 1, 0, 0); } if (window) { swc_window_set_border(window->swc, 0xff4444ff, 1, 0, 0); swc_window_focus(window->swc); } else { swc_window_focus(NULL); } focused_window = window; } /* Screen handlers */ static void screen_usable_geometry_changed(void *data) { arrange(data); } static void screen_entered(void *data) { active_screen = data; } static const struct swc_screen_handler screen_handler = { .usable_geometry_changed = screen_usable_geometry_changed, .entered = screen_entered, }; /* Window handlers */ static void window_destroy(void *data) { struct window *w = data; struct window *next = wl_container_of(w->link.next, next, link); if (&next->link == &w->screen->windows) next = NULL; wl_list_remove(&w->link); w->screen->num_windows--; if (focused_window == w) focus(next); arrange(w->screen); free(w); } static void window_entered(void *data) { focus(data); } static const struct swc_window_handler window_handler = { .destroy = window_destroy, .entered = window_entered, }; /* Manager callbacks */ static void new_screen(struct swc_screen *swc) { struct screen *s = malloc(sizeof(*s)); s->swc = swc; s->num_windows = 0; wl_list_init(&s->windows); swc_screen_set_handler(swc, &screen_handler, s); active_screen = s; } static void new_window(struct swc_window *swc) { struct window *w = malloc(sizeof(*w)); w->swc = swc; w->screen = active_screen; swc_window_set_handler(swc, &window_handler, w); swc_window_set_tiled(swc); wl_list_insert(&active_screen->windows, &w->link); active_screen->num_windows++; swc_window_show(swc); arrange(active_screen); focus(w); } static const struct swc_manager manager = { .new_screen = new_screen, .new_window = new_window, }; /* Keybindings */ static void spawn(void *data, uint32_t time, uint32_t value, uint32_t state) { if (state != WL_KEYBOARD_KEY_STATE_PRESSED) return; if (fork() == 0) { execl("/usr/bin/foot", "foot", NULL); _exit(1); } } static void quit(void *data, uint32_t time, uint32_t value, uint32_t state) { if (state != WL_KEYBOARD_KEY_STATE_PRESSED) return; wl_display_terminate(display); } int main(void) { display = wl_display_create(); const char *socket = wl_display_add_socket_auto(display); setenv("WAYLAND_DISPLAY", socket, 1); if (!swc_initialize(display, NULL, &manager)) return 1; swc_add_binding(SWC_BINDING_KEY, SWC_MOD_LOGO, XKB_KEY_Return, spawn, NULL); swc_add_binding(SWC_BINDING_KEY, SWC_MOD_LOGO, XKB_KEY_q, quit, NULL); wl_display_run(display); swc_finalize(); wl_display_destroy(display); return 0; } ``` -------------------------------- ### Manage Wallpaper (C) Source: https://context7.com/~shrub900/neuswc/llms.txt Allows setting background wallpapers globally or per-screen using wld buffers or solid colors. It supports loading image buffers, assigning them to specific screens, clearing per-screen overrides, and setting a fallback solid background color. ```c #include /* Set fallback wallpaper for all screens */ struct wld_buffer *wallpaper = load_image_to_wld_buffer("wallpaper.png"); swc_wallpaper_set_buffer(wallpaper); /* Set wallpaper for specific screen (by screen ID) */ struct wld_buffer *screen1_wallpaper = load_image_to_wld_buffer("screen1.png"); swc_wallpaper_set_buffer_for_screen(0, screen1_wallpaper); /* Clear per-screen override (uses fallback) */ swc_wallpaper_set_buffer_for_screen(0, NULL); /* Set solid background color (used when no buffer set) */ uint32_t bg_color = 0xff1a1a2e; /* Dark blue (ARGB) */ swc_wallpaper_color_set(bg_color); ``` -------------------------------- ### Interactive Move and Resize Source: https://context7.com/~shrub900/neuswc/llms.txt Enable pointer-driven window movement and resizing for stacked/floating window modes. ```APIDOC ## Interactive Move and Resize Enable pointer-driven window movement and resizing for stacked/floating window modes. ### Start interactive move (window must be in stacked mode) ```c swc_window_set_stacked(window); swc_window_begin_move(window); /* User drags window with pointer... */ swc_window_end_move(window); ``` ### Start interactive resize with specific edge ```c swc_window_begin_resize(window, SWC_WINDOW_EDGE_RIGHT | SWC_WINDOW_EDGE_BOTTOM); /* User drags to resize... */ swc_window_end_resize(window); ``` ### Edge flags for resize direction - `SWC_WINDOW_EDGE_AUTO` - auto-detect from pointer position - `SWC_WINDOW_EDGE_TOP` - resize from top edge - `SWC_WINDOW_EDGE_BOTTOM` - resize from bottom edge - `SWC_WINDOW_EDGE_LEFT` - resize from left edge - `SWC_WINDOW_EDGE_RIGHT` - resize from right edge ``` -------------------------------- ### Configure Window Event Callbacks (C) Source: https://context7.com/~shrub900/neuswc/llms.txt Sets up callback functions for various window lifecycle events such as destruction, title changes, focus entry, and requests for interactive move or resize operations. These callbacks allow custom handling of window events within the SWC compositor. ```c static void window_destroy(void *data) { struct my_window *window = data; /* Remove from screen, find new focus */ struct my_window *next = find_next_window(window); remove_from_layout(window); if (focused_window == window) { focus_window(next); /* May be NULL */ } free(window); } static void window_title_changed(void *data) { struct my_window *window = data; printf("Window title: %s\n", window->swc->title); } static void window_app_id_changed(void *data) { struct my_window *window = data; printf("App ID: %s\n", window->swc->app_id); } static void window_entered(void *data) { struct my_window *window = data; /* Focus-follows-mouse behavior */ focus_window(window); } static void window_move_requested(void *data) { struct my_window *window = data; /* Client wants interactive move but window is tiled */ /* Optionally switch to stacked mode to allow it */ swc_window_set_stacked(window->swc); swc_window_begin_move(window->swc); } static void window_resize_requested(void *data) { struct my_window *window = data; swc_window_set_stacked(window->swc); swc_window_begin_resize(window->swc, SWC_WINDOW_EDGE_AUTO); } static const struct swc_window_handler window_handler = { .destroy = window_destroy, .title_changed = window_title_changed, .app_id_changed = window_app_id_changed, .parent_changed = NULL, .entered = window_entered, .move = window_move_requested, .resize = window_resize_requested, }; ``` -------------------------------- ### Screenshot and Recording Utility (swcsnap - Bash) Source: https://context7.com/~shrub900/neuswc/llms.txt Provides a command-line tool (swcsnap) for capturing screenshots and recording screen content. It supports saving to various formats (e.g., PPM, raw video) and piping output to other tools like ffmpeg for further processing. ```bash # Capture single screenshot to PPM file swcsnap image screenshot.ppm # Capture to default filename (shot.ppm) swcsnap image # Record screen to raw video file swcsnap record -o recording.raw -n 300 -r 30 # Records 300 frames at 30 fps, output is raw BGRA pixel data # Record to stdout (pipe to ffmpeg) swcsnap record -n 600 -r 60 | ffmpeg -f rawvideo -pixel_format bgra \ -video_size 1920x1080 -framerate 60 -i - output.mp4 ``` -------------------------------- ### Screenshot Utility (swcsnap) Source: https://context7.com/~shrub900/neuswc/llms.txt Command-line interface for capturing screenshots and recording screen content. ```APIDOC ## CLI: swcsnap ### Description Captures screenshots or records screen content via the compositor snap protocol. ### Usage - **Capture**: swcsnap image [filename.ppm] - **Record**: swcsnap record -o [output] -n [frames] -r [fps] ### Example swcsnap record -o recording.raw -n 300 -r 30 ``` -------------------------------- ### Configure Window Borders (C) Source: https://context7.com/~shrub900/neuswc/llms.txt Enables the configuration of window borders, supporting both single and double border styles. This allows for independent control over inner and outer border colors and widths, useful for indicating window states like active or inactive. ```c /* Single border (set outer width to 0) */ uint32_t active_color = 0xff3388ff; /* ARGB: blue */ uint32_t inactive_color = 0xff888888; /* ARGB: gray */ uint32_t border_width = 2; swc_window_set_border(focused_window, active_color, border_width, 0, 0); swc_window_set_border(unfocused_window, inactive_color, border_width, 0, 0); /* Double border for enhanced visual distinction */ uint32_t inner_color = 0xff0000ff; /* Blue inner */ uint32_t outer_color = 0xff000000; /* Black outer */ uint32_t inner_width = 2; uint32_t outer_width = 1; swc_window_set_border(window, inner_color, inner_width, outer_color, outer_width); ``` -------------------------------- ### Configure Screen Event Handlers Source: https://context7.com/~shrub900/neuswc/llms.txt Defines callbacks for handling screen lifecycle events such as destruction, geometry updates, and pointer movement to support dynamic layouts. ```c static void screen_destroy(void *data) { struct my_screen *screen = data; free(screen); } static void screen_geometry_changed(void *data) { struct my_screen *screen = data; printf("Screen geometry: %dx%d\n", screen->swc->geometry.width, screen->swc->geometry.height); } static void screen_usable_geometry_changed(void *data) { struct my_screen *screen = data; struct swc_rectangle *area = &screen->swc->usable_geometry; printf("Usable area: %d,%d %dx%d\n", area->x, area->y, area->width, area->height); rearrange_windows(screen); } static void screen_entered(void *data) { struct my_screen *screen = data; active_screen = screen; } static const struct swc_screen_handler screen_handler = { .destroy = screen_destroy, .geometry_changed = screen_geometry_changed, .usable_geometry_changed = screen_usable_geometry_changed, .entered = screen_entered, }; swc_screen_set_handler(swc_screen, &screen_handler, my_screen_data); ``` -------------------------------- ### Wallpaper Management API Source: https://context7.com/~shrub900/neuswc/llms.txt Manages background wallpapers using wld buffers or solid colors. ```APIDOC ## C API: swc_wallpaper_set_buffer ### Description Sets a global fallback wallpaper buffer. ### Parameters - **buffer** (struct wld_buffer*) - Required - The wld buffer containing the image data. ``` -------------------------------- ### Input Bindings Source: https://context7.com/~shrub900/neuswc/llms.txt Register keyboard and mouse button bindings with modifier combinations to trigger window manager actions. ```APIDOC ## Input Bindings Register keyboard and mouse button bindings with modifier combinations to trigger window manager actions. ### Binding callback signature ```c typedef void (*swc_binding_handler)(void *data, uint32_t time, uint32_t value, uint32_t state); ``` ### Example: Spawn Terminal ```c static void spawn_terminal(void *data, uint32_t time, uint32_t value, uint32_t state) { if (state != WL_KEYBOARD_KEY_STATE_PRESSED) return; if (fork() == 0) { execl("/usr/bin/foot", "foot", NULL); _exit(1); } } ``` ### Example: Close Focused Window ```c static void close_focused(void *data, uint32_t time, uint32_t value, uint32_t state) { if (state != WL_KEYBOARD_KEY_STATE_PRESSED) return; if (focused_window) { swc_window_close(focused_window); } } ``` ### Register Key Bindings (uses XKB keysyms) - **Mod+Return spawns terminal** ```c swc_add_binding(SWC_BINDING_KEY, SWC_MOD_LOGO, XKB_KEY_Return, spawn_terminal, NULL); ``` - **Mod+Shift+Q closes window** ```c swc_add_binding(SWC_BINDING_KEY, SWC_MOD_LOGO | SWC_MOD_SHIFT, XKB_KEY_q, close_focused, NULL); ``` ### Mouse Button Binding - **Mod+Click** ```c swc_add_binding(SWC_BINDING_BUTTON, SWC_MOD_LOGO, BTN_LEFT, start_window_move, NULL); ``` ### Available Modifiers - `SWC_MOD_CTRL` - Control key - `SWC_MOD_ALT` - Alt key - `SWC_MOD_LOGO` - Super/Windows/Command key - `SWC_MOD_SHIFT` - Shift key - `SWC_MOD_ANY` - Match any modifier combination ``` -------------------------------- ### Perform Window Management Operations (C) Source: https://context7.com/~shrub900/neuswc/llms.txt Provides functions to control window visibility, focus, positioning, sizing, and modes (tiled, stacked, fullscreen). These operations are essential for implementing window layout algorithms and managing the user interface. ```c /* Show and hide windows */ swc_window_show(window); swc_window_hide(window); /* Focus management - NULL clears keyboard focus */ swc_window_focus(window); swc_window_focus(NULL); /* Request window closure (sends close event to client) */ swc_window_close(window); /* Window modes */ swc_window_set_tiled(window); /* WM controls size, no shadows */ swc_window_set_stacked(window); /* Client controls size, allows move/resize */ swc_window_set_fullscreen(window, screen); /* Fullscreen on specific screen */ /* Position and size (for tiled windows) */ swc_window_set_position(window, 100, 100); swc_window_set_size(window, 800, 600); /* Combined geometry setting */ struct swc_rectangle geometry = { .x = 0, .y = 0, .width = 1920, .height = 1080 }; swc_window_set_geometry(window, &geometry); /* Query current geometry */ struct swc_rectangle current; if (swc_window_get_geometry(window, ¤t)) { printf("Window at %d,%d size %ux%u\n", current.x, current.y, current.width, current.height); } /* Get client process ID */ pid_t pid = swc_window_get_pid(window); ``` -------------------------------- ### Control Z-Axis Window Stacking (C) Source: https://context7.com/~shrub900/neuswc/llms.txt Manages the layering order of windows, allowing specific windows to be brought to the front or sent to the back. This is crucial for floating window managers and for ensuring proper visual stacking of overlapping windows. ```c /* Move window one step toward front (visible above others) */ swc_window_stack(window, -1); /* Move window one step toward back */ swc_window_stack(window, 1); /* Find topmost window at screen coordinates */ int32_t cursor_x, cursor_y; swc_cursor_position(&cursor_x, &cursor_y); struct swc_window *top = swc_window_at(cursor_x, cursor_y); if (top) { swc_window_focus(top); } ``` -------------------------------- ### Cursor Control and Appearance (C) Source: https://context7.com/~shrub900/neuswc/llms.txt Provides functionality to customize the compositor cursor appearance using built-in types or custom ARGB images. Includes functions for setting cursor types, modes, custom images, and retrieving cursor position. ```c /* Set built-in cursor type */ swc_set_cursor(SWC_CURSOR_DEFAULT); /* Normal arrow */ swc_set_cursor(SWC_CURSOR_BOX); /* Box selection */ swc_set_cursor(SWC_CURSOR_CROSS); /* Crosshair */ swc_set_cursor(SWC_CURSOR_SIGHT); /* Target sight */ swc_set_cursor(SWC_CURSOR_UP); /* Up arrow */ swc_set_cursor(SWC_CURSOR_DOWN); /* Down arrow */ /* Control cursor mode */ swc_set_cursor_mode(SWC_CURSOR_MODE_CLIENT); /* Allow client cursors */ swc_set_cursor_mode(SWC_CURSOR_MODE_COMPOSITOR); /* Force compositor cursor */ /* Custom ARGB8888 cursor image */ uint32_t cursor_pixels[32 * 32]; /* 32x32 ARGB8888 image */ /* ... fill cursor_pixels with image data ... */ swc_set_cursor_image(SWC_CURSOR_BOX, cursor_pixels, 32, 32, /* width, height */ 0, 0); /* hotspot x, y */ /* Clear custom image, revert to built-in */ swc_clear_cursor_image(SWC_CURSOR_BOX); /* Get current cursor position (24.8 fixed point as int32) */ int32_t x, y; if (swc_cursor_position(&x, &y)) { printf("Cursor at fixed-point: %d, %d\n", x, y); } ``` -------------------------------- ### Draw Overlay Box (C) Source: https://context7.com/~shrub900/neuswc/llms.txt Draws temporary box overlays on the screen for visual feedback, region marking, or window selection. It allows setting the box coordinates, color, and border width, and supports updating or clearing the overlay. ```c /* Draw a selection box overlay */ int32_t start_x = 100, start_y = 100; int32_t end_x = 500, end_y = 400; uint32_t color = 0x80ff0000; /* Semi-transparent red (ARGB) */ uint32_t border_width = 2; swc_overlay_set_box(start_x, start_y, end_x, end_y, color, border_width); /* Update overlay position (e.g., during drag) */ swc_overlay_set_box(start_x, start_y, new_end_x, new_end_y, color, border_width); /* Remove overlay when done */ swc_overlay_clear(); ``` -------------------------------- ### Display Overlay API Source: https://context7.com/~shrub900/neuswc/llms.txt Functions for rendering temporary box overlays on the screen for selection or visual feedback. ```APIDOC ## C API: swc_overlay_set_box ### Description Draws a temporary box overlay on the screen. ### Parameters - **start_x** (int32_t) - Required - Starting X coordinate - **start_y** (int32_t) - Required - Starting Y coordinate - **end_x** (int32_t) - Required - Ending X coordinate - **end_y** (int32_t) - Required - Ending Y coordinate - **color** (uint32_t) - Required - ARGB color value - **border_width** (uint32_t) - Required - Width of the border in pixels ### Request Example swc_overlay_set_box(100, 100, 500, 400, 0x80ff0000, 2); ``` -------------------------------- ### Axis Binding and Pointer Events Source: https://context7.com/~shrub900/neuswc/llms.txt Register scroll wheel bindings and forward pointer events to focused clients for features like Mod+scroll zoom. ```APIDOC ## Axis Binding and Pointer Events Register scroll wheel bindings and forward pointer events to focused clients for features like Mod+scroll zoom. ### Axis binding callback signature ```c typedef void (*swc_axis_binding_handler)(void *data, uint32_t time, uint32_t axis, int32_t value120); ``` ### Example: Scroll Zoom Control ```c static void handle_scroll_zoom(void *data, uint32_t time, uint32_t axis, int32_t value120) { /* value120 uses 120-unit convention (one notch = 120) */ float current = swc_get_zoom(); float delta = (value120 > 0) ? -0.1f : 0.1f; swc_set_zoom(current + delta); } /* Mod+Scroll for zoom control */ swc_add_axis_binding(SWC_MOD_LOGO, WL_POINTER_AXIS_VERTICAL_SCROLL, handle_scroll_zoom, NULL); ``` ### Forward Pointer Events to Clients - **Click Handler** ```c static void click_handler(void *data, uint32_t time, uint32_t button, uint32_t state) { /* Do custom handling... then forward to client */ swc_pointer_send_button(time, button, state); } ``` - **Scroll Handler** ```c static void scroll_handler(void *data, uint32_t time, uint32_t axis, int32_t value120) { /* Forward scroll events to focused client */ swc_pointer_send_axis(time, axis, value120); } ``` ``` -------------------------------- ### Display Zoom API Source: https://context7.com/~shrub900/neuswc/llms.txt Functions to control compositor-level scaling for accessibility or demonstration. ```APIDOC ## C API: swc_set_zoom ### Description Sets the magnification level of the compositor output. ### Parameters - **level** (float) - Required - Zoom factor (1.0 is normal, 2.0 is 200%) ### Request Example swc_set_zoom(2.0f); ``` -------------------------------- ### Cursor Control Source: https://context7.com/~shrub900/neuswc/llms.txt Customize the compositor cursor appearance with built-in types or custom ARGB images for mode indication. ```APIDOC ## Cursor Control Customize the compositor cursor appearance with built-in types or custom ARGB images for mode indication. ### Set Built-in Cursor Type - `swc_set_cursor(SWC_CURSOR_DEFAULT);` (Normal arrow) - `swc_set_cursor(SWC_CURSOR_BOX);` (Box selection) - `swc_set_cursor(SWC_CURSOR_CROSS);` (Crosshair) - `swc_set_cursor(SWC_CURSOR_SIGHT);` (Target sight) - `swc_set_cursor(SWC_CURSOR_UP);` (Up arrow) - `swc_set_cursor(SWC_CURSOR_DOWN);` (Down arrow) ### Control Cursor Mode - `swc_set_cursor_mode(SWC_CURSOR_MODE_CLIENT);` (Allow client cursors) - `swc_set_cursor_mode(SWC_CURSOR_MODE_COMPOSITOR);` (Force compositor cursor) ### Custom ARGB8888 Cursor Image ```c /* Custom ARGB8888 cursor image */ uint32_t cursor_pixels[32 * 32]; /* 32x32 ARGB8888 image */ /* ... fill cursor_pixels with image data ... */ swc_set_cursor_image(SWC_CURSOR_BOX, cursor_pixels, 32, 32, /* width, height */ 0, 0); /* hotspot x, y */ /* Clear custom image, revert to built-in */ swc_clear_cursor_image(SWC_CURSOR_BOX); ``` ### Get Current Cursor Position ```c /* Get current cursor position (24.8 fixed point as int32) */ int32_t x, y; if (swc_cursor_position(&x, &y)) { printf("Cursor at fixed-point: %d, %d\n", x, y); } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.