diff --git a/src/backend/wayland/wl_screen.c b/src/backend/wayland/wl_screen.c index 63f0014..8e7f2c4 100644 --- a/src/backend/wayland/wl_screen.c +++ b/src/backend/wayland/wl_screen.c @@ -596,19 +596,12 @@ wl_monitors_query(WScreen *scr, WHeadGeometry **heads_out, int *count_out) return; } - /* Rebuild head data from current layout */ + /* Rebuild head data from current layout. + * The caller takes ownership of the returned head array + * (freed on the next call to wl_screen_refresh_heads). */ wl_screen_refresh_heads(scr); - if (scr->head_count == 0 || !scr->heads) { - *heads_out = NULL; - *count_out = 0; - return; - } - - /* Return a copy the caller owns */ - WHeadGeometry *out = wmalloc(sizeof(WHeadGeometry) * scr->head_count); - memcpy(out, scr->heads, sizeof(WHeadGeometry) * scr->head_count); - *heads_out = out; + *heads_out = scr->heads; *count_out = scr->head_count; }