neuswc

patched neuswc library (tracked)
git clone https://git.daat.foo/neuswc.git
Log | Files | Refs | README | LICENSE

commit 0f683bf5656fade38ae9667cb00e4bac5a5b322d
parent 502f272bd529815a19d839c138e02854657c37c0
Author: sewn <sewn@disroot.org>
Date:   Sat, 14 Mar 2026 11:49:42 +0300

Add support for xdg-output-manager protocol

Diffstat:
M.gitignore | 3+--
Mlibswc/internal.h | 1+
Mlibswc/output.c | 1+
Mlibswc/output.h | 1+
Mlibswc/swc.c | 9+++++++++
Alibswc/xdg_output.c | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alibswc/xdg_output.h | 33+++++++++++++++++++++++++++++++++
7 files changed, 123 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -13,4 +13,4 @@ launch/swc-launch # Generated from convert_font.c and cursor.pcf cursor/convert_font -cursor/cursor_data.h -\ No newline at end of file +cursor/cursor_data.h diff --git a/libswc/internal.h b/libswc/internal.h @@ -54,6 +54,7 @@ struct swc { struct wl_global *subcompositor; struct wl_global *wallpaper_manager; struct wl_global *xdg_decoration_manager; + struct wl_global *xdg_output_manager; struct wl_global *xdg_shell; #ifdef ENABLE_XWAYLAND diff --git a/libswc/output.c b/libswc/output.c @@ -31,6 +31,7 @@ bind_output(struct wl_client *client, void *data, uint32_t version, uint32_t id) return; } + output->resource = resource; wl_resource_set_implementation(resource, &output_impl, output, &remove_resource); wl_list_insert(&output->resources, wl_resource_get_link(resource)); diff --git a/libswc/output.h b/libswc/output.h @@ -9,6 +9,7 @@ struct wl_display; struct output { + struct wl_resource *resource; struct screen *screen; char name[24]; diff --git a/libswc/swc.c b/libswc/swc.c @@ -44,6 +44,7 @@ #include "wallpaper.h" #include "window.h" #include "xdg_decoration.h" +#include "xdg_output.h" #include "xdg_shell.h" #ifdef ENABLE_XWAYLAND #include "xserver.h" @@ -258,6 +259,12 @@ swc_initialize(struct wl_display *display, struct wl_event_loop *event_loop, goto error17; } + swc.xdg_output_manager = xdg_output_manager_create(display); + if (!swc.xdg_output_manager) { + ERROR("Could not initialize XDG output manager\n"); + goto error17; + } + setup_compositor(); return true; @@ -308,8 +315,10 @@ swc_finalize(void) #ifdef ENABLE_XWAYLAND xserver_finalize(); #endif + wl_global_destroy(swc.xdg_output_manager); wl_global_destroy(swc.wallpaper_manager); wl_global_destroy(swc.snap_manager); + wl_global_destroy(swc.select_manager); wl_global_destroy(swc.panel_manager); wl_global_destroy(swc.xdg_decoration_manager); wl_global_destroy(swc.xdg_shell); diff --git a/libswc/xdg_output.c b/libswc/xdg_output.c @@ -0,0 +1,77 @@ +/* swc: libswc/xdg_output.c + * + * Copyright (c) 2026 sewn <sewn@disroot.org> + * + * 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 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. + */ + +#include "xdg_output.h" +#include "output.h" +#include "screen.h" +#include "util.h" + +#include "xdg-output-unstable-v1-server-protocol.h" + +static const struct zxdg_output_v1_interface output_impl = { + .destroy = destroy_resource, +}; + +static void +get_output(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *output_resource) +{ + struct output *output = + wl_resource_get_user_data(output_resource); + struct swc_rectangle *geom = &output->screen->base.geometry; + + resource = wl_resource_create(client, &zxdg_output_v1_interface, wl_resource_get_version(resource), id); + if (!resource) { + wl_client_post_no_memory(client); + return; + } + + wl_resource_set_implementation(resource, &output_impl, NULL, NULL); + zxdg_output_v1_send_logical_position(resource, geom->x, geom->y); + zxdg_output_v1_send_logical_size(resource, geom->width, geom->height); + zxdg_output_v1_send_name(resource, output->name); + wl_output_send_done(output->resource); +} + +static const struct zxdg_output_manager_v1_interface output_manager_impl = { + .destroy = destroy_resource, + .get_xdg_output = get_output, +}; + +static void +bind_output_manager(struct wl_client *client, void *data, uint32_t version, uint32_t id) +{ + struct wl_resource *resource; + + resource = wl_resource_create(client, &zxdg_output_manager_v1_interface, version, id); + if (!resource) { + wl_client_post_no_memory(client); + return; + } + wl_resource_set_implementation(resource, &output_manager_impl, NULL, NULL); +} + +struct wl_global * +xdg_output_manager_create(struct wl_display *display) +{ + return wl_global_create(display, &zxdg_output_manager_v1_interface, 3, NULL, &bind_output_manager); +} diff --git a/libswc/xdg_output.h b/libswc/xdg_output.h @@ -0,0 +1,33 @@ +/* swc: libswc/xdg_output.h + * + * Copyright (c) 2026 sewn <sewn@disroot.org> + * + * 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 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 SWC_XDG_OUTPUT_H +#define SWC_XDG_OUTPUT_H + +struct wl_display; +struct wl_global; + +struct wl_global * +xdg_output_manager_create(struct wl_display *display); + +#endif