linux-pipewire: Explicitly enumerate cursor modes
The ScreenCast portal defines 3 cursor modes [1]: * Hidden: no visible cursor (value: 1) * Embedded: cursor is drawn in the frames (value: 2) * Metadata: cursor is sent as stream metadata (value: 4) The values are power-of-two due to be used as flags. Explicitly listing these values in an enum improves legibility of the code, so do that instead of hardcoding 1, 2, and 4. [1] https://github.com/flatpak/xdg-desktop-portal/blob/main/data/org.freedesktop.portal.ScreenCast.xml#L302-L316
This commit is contained in:
parent
1267081e5c
commit
e7815dff66
@ -1228,15 +1228,19 @@ static void select_source(obs_pipewire_data *obs_pw)
|
|||||||
|
|
||||||
available_cursor_modes = portal_get_available_cursor_modes();
|
available_cursor_modes = portal_get_available_cursor_modes();
|
||||||
|
|
||||||
if (available_cursor_modes & 4)
|
if (available_cursor_modes & PORTAL_CURSOR_MODE_METADATA)
|
||||||
g_variant_builder_add(&builder, "{sv}", "cursor_mode",
|
g_variant_builder_add(
|
||||||
g_variant_new_uint32(4));
|
&builder, "{sv}", "cursor_mode",
|
||||||
else if ((available_cursor_modes & 2) && obs_pw->cursor.visible)
|
g_variant_new_uint32(PORTAL_CURSOR_MODE_METADATA));
|
||||||
g_variant_builder_add(&builder, "{sv}", "cursor_mode",
|
else if ((available_cursor_modes & PORTAL_CURSOR_MODE_EMBEDDED) &&
|
||||||
g_variant_new_uint32(2));
|
obs_pw->cursor.visible)
|
||||||
|
g_variant_builder_add(
|
||||||
|
&builder, "{sv}", "cursor_mode",
|
||||||
|
g_variant_new_uint32(PORTAL_CURSOR_MODE_EMBEDDED));
|
||||||
else
|
else
|
||||||
g_variant_builder_add(&builder, "{sv}", "cursor_mode",
|
g_variant_builder_add(
|
||||||
g_variant_new_uint32(1));
|
&builder, "{sv}", "cursor_mode",
|
||||||
|
g_variant_new_uint32(PORTAL_CURSOR_MODE_HIDDEN));
|
||||||
|
|
||||||
if (portal_get_screencast_version() >= 4) {
|
if (portal_get_screencast_version() >= 4) {
|
||||||
g_variant_builder_add(&builder, "{sv}", "persist_mode",
|
g_variant_builder_add(&builder, "{sv}", "persist_mode",
|
||||||
|
@ -23,6 +23,12 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
|
enum portal_cursor_mode {
|
||||||
|
PORTAL_CURSOR_MODE_HIDDEN = 1 << 0,
|
||||||
|
PORTAL_CURSOR_MODE_EMBEDDED = 1 << 1,
|
||||||
|
PORTAL_CURSOR_MODE_METADATA = 1 << 2,
|
||||||
|
};
|
||||||
|
|
||||||
uint32_t portal_get_available_capture_types(void);
|
uint32_t portal_get_available_capture_types(void);
|
||||||
uint32_t portal_get_available_cursor_modes(void);
|
uint32_t portal_get_available_cursor_modes(void);
|
||||||
uint32_t portal_get_screencast_version(void);
|
uint32_t portal_get_screencast_version(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user