neuswc

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

commit 685599f83287440381a42e0fa3a351ef861605cb
parent c4d83bf715920edcb3afe39c5b505e525c548df9
Author: Arthur Gusmão <arthurgusmao@proton.me>
Date:   Sun, 26 Jul 2026 14:16:11 +0000

libswc: bug fixes and improvements

Diffstat:
Mlibswc/compositor.c | 6+++++-
Mlibswc/compositor.h | 2+-
Mlibswc/decor.c | 2+-
Mlibswc/drm.c | 7+++++++
Mlibswc/keyboard.c | 2+-
Mlibswc/layer_shell.c | 5++---
Mlibswc/output.c | 9++++++++-
Mlibswc/pointer.c | 1-
Mlibswc/shm.c | 3++-
9 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/libswc/compositor.c b/libswc/compositor.c @@ -1377,6 +1377,10 @@ compositor_view_set_parent(struct compositor_view *view, { view->parent = parent; + if (!parent) { + return; + } + if (parent->visible) { compositor_view_show(view); } else { @@ -1925,7 +1929,7 @@ compositor_render_to_shm(struct screen *screen) return NULL; } - /* set reigon */ + /* set region */ pixman_region32_init_rect(&region, 0, 0, width, height); pixman_region32_init_rect(&damage, screen->base.geometry.x, screen->base.geometry.y, width, height); diff --git a/libswc/compositor.h b/libswc/compositor.h @@ -151,7 +151,7 @@ void compositor_view_damage_decor(struct compositor_view *view); /** - * get the current composited buffer for a screen for screenshotss. + * get the current composited buffer for a screen for screenshots. * returns null if no buffer */ struct wld_buffer * diff --git a/libswc/decor.c b/libswc/decor.c @@ -265,7 +265,7 @@ close_decor_string(struct compositor_view *view) /* draw decor part by tiling it across the target region. * the part buffer is repeated to fill the entirety of some width x height area, - * but only damaged regions are actually rendred*/ + * but only damaged regions are actually rendered */ static void draw_decor_part(struct wld_renderer *renderer, const struct swc_rectangle *target_geom, diff --git a/libswc/drm.c b/libswc/drm.c @@ -196,6 +196,9 @@ find_available_crtc(drmModeRes *resources, drmModeConnector *connector, for (i = 0; i < connector->count_encoders; ++i) { encoder = drmModeGetEncoder(swc.drm->fd, connector->encoders[i]); + if (!encoder) { + continue; + } possible_crtcs = encoder->possible_crtcs; drmModeFreeEncoder(encoder); @@ -380,6 +383,10 @@ drm_create_screens(struct wl_list *screens) resources = drmModeGetResources(swc.drm->fd); if (!resources) { + struct plane *p, *ptmp; + + wl_list_for_each_safe(p, ptmp, &planes, link) + plane_destroy(p); ERROR("Could not get DRM resources\n"); return false; } diff --git a/libswc/keyboard.c b/libswc/keyboard.c @@ -287,7 +287,7 @@ error2: error1: free(keyboard); error0: - return false; + return NULL; } void diff --git a/libswc/layer_shell.c b/libswc/layer_shell.c @@ -424,7 +424,7 @@ handle_surface_commit(struct wl_listener *listener, void *data) update_usable_geometry(surface); } - /* mke sure that the inital commit and also any later state change gets a fresh + /* Make sure that the initial commit and also any later state change gets a fresh * configure */ if (!surface->configured || state_changed) { send_configure(surface); @@ -454,7 +454,7 @@ modify(struct screen_modifier *modifier, const struct swc_rectangle *geom, return; } - /* shrink usuable area*/ + /* shrink usable area */ switch (exclusive_edge(surface)) { case ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP: box.y1 = MAX(box.y1, geom->y + size); @@ -529,7 +529,6 @@ layer_surface_new(struct wl_client *client, uint32_t version, uint32_t id, layer_surface->screen = screen; layer_surface->current.layer = layer; - layer_surface->pending = layer_surface->current; layer_surface->current.exclusive_zone = 0; layer_surface->current.exclusive_edge = 0; layer_surface->current.keyboard_interactivity = diff --git a/libswc/output.c b/libswc/output.c @@ -57,6 +57,7 @@ bind_output(struct wl_client *client, void *data, uint32_t version, uint32_t id) if (version >= 4) { wl_output_send_name(resource, output->name); + wl_output_send_description(resource, output->name); } if (version >= 2) { @@ -73,7 +74,7 @@ output_new(drmModeConnectorPtr connector) uint32_t i; if (!(output = malloc(sizeof(*output)))) { - ERROR("Failed to allocated output\n"); + ERROR("Failed to allocate output\n"); goto error0; } @@ -135,6 +136,12 @@ error0: void output_destroy(struct output *output) { + struct wl_resource *resource, *tmp; + + wl_list_for_each_safe(resource, tmp, &output->resources, link) + wl_resource_destroy(resource); + pixman_region32_fini(&output->current_damage); + pixman_region32_fini(&output->previous_damage); wl_array_release(&output->modes); wl_global_destroy(output->global); free(output); diff --git a/libswc/pointer.c b/libswc/pointer.c @@ -491,7 +491,6 @@ pointer_initialize(struct pointer *pointer) struct swc_rectangle *geom = &screen->base.geometry; /* Center cursor in the geometry of the first screen. */ - screen = wl_container_of(swc.screens.next, screen, link); pointer->x = wl_fixed_from_int(geom->x + geom->width / 2); pointer->y = wl_fixed_from_int(geom->y + geom->height / 2); pointer->focus_handler.enter = enter; diff --git a/libswc/shm.c b/libswc/shm.c @@ -240,7 +240,8 @@ resize(struct wl_client *client, struct wl_resource *resource, int32_t size) if (st.st_size < size) { if (ftruncate(pool->fd, size) != 0) { int saved = errno; - /* some clients seal memfd if size is already fine, allo */ + /* some clients seal memfd if size is already fine, + * alloc will fail */ if ((saved == EPERM || saved == EACCES) && fstat(pool->fd, &st) == 0 && st.st_size >= size) { goto remap;