From 0a36dc9d80a95c63ea54c8fc0aaa4ce1b6b28909 Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Tue, 14 Mar 2023 13:28:20 +0100 Subject: [PATCH] linux-pipewire: Clear cursor texture on empty bitmap If we receive an empty cursor bitmap - one without valid size - we should hide the cursor. Do so by clearing the texture. This fixes visible cursors when recording various games with Wayland compositors. Closes https://github.com/obsproject/obs-studio/issues/4895 --- plugins/linux-pipewire/pipewire.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/linux-pipewire/pipewire.c b/plugins/linux-pipewire/pipewire.c index ada92cfe7..d639e86df 100644 --- a/plugins/linux-pipewire/pipewire.c +++ b/plugins/linux-pipewire/pipewire.c @@ -719,6 +719,10 @@ read_metadata: bitmap = SPA_MEMBER(cursor, cursor->bitmap_offset, struct spa_meta_bitmap); + if (bitmap) + g_clear_pointer(&obs_pw->cursor.texture, + gs_texture_destroy); + if (bitmap && bitmap->size.width > 0 && bitmap->size.height > 0 && lookup_format_info_from_spa_format( @@ -732,8 +736,7 @@ read_metadata: obs_pw->cursor.width = bitmap->size.width; obs_pw->cursor.height = bitmap->size.height; - g_clear_pointer(&obs_pw->cursor.texture, - gs_texture_destroy); + assert(obs_pw->cursor.texture == NULL); obs_pw->cursor.texture = gs_texture_create( obs_pw->cursor.width, obs_pw->cursor.height, gs_format, 1, &bitmap_data, GS_DYNAMIC);