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