From 573302b5ab125419dc8c2c0be035a45ba5e26639 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 ada92cfe700073..d639e86df0f256 100644 --- a/plugins/linux-pipewire/pipewire.c +++ b/plugins/linux-pipewire/pipewire.c @@ -719,6 +719,10 @@ static void on_process_cb(void *user_data) 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 @@ static void on_process_cb(void *user_data) 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);