Skip to content

Commit

Permalink
linux-pipewire: Clear cursor texture on empty bitmap
Browse files Browse the repository at this point in the history
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 #4895
  • Loading branch information
rmader committed Mar 14, 2023
1 parent b31344d commit 0a0e062
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugins/linux-pipewire/pipewire.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,11 @@ 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(
Expand All @@ -732,8 +737,6 @@ 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);
obs_pw->cursor.texture = gs_texture_create(
obs_pw->cursor.width, obs_pw->cursor.height,
gs_format, 1, &bitmap_data, GS_DYNAMIC);
Expand Down

0 comments on commit 0a0e062

Please sign in to comment.