PipeWire capturer: request mouse cursor to be part of the stream

We need to specify that the cursor should be included in the stream as
by default xdg-desktop-portal defaults to hidden cursor.

Bug: chromium:1202526
Change-Id: Ic4742da2e51f7ed28cb9d7b6b0c069c1fa7d0cee
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/214782
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34137}
This commit is contained in:
Jan Grulich 2021-04-09 15:53:57 +02:00 committed by WebRTC LUCI CQ
parent 2182096e66
commit e52cfab633
2 changed files with 23 additions and 0 deletions

View File

@ -1026,6 +1026,23 @@ void BaseCapturerPipeWire::SourcesRequest() {
// We don't want to allow selection of multiple sources.
g_variant_builder_add(&builder, "{sv}", "multiple",
g_variant_new_boolean(false));
Scoped<GVariant> variant(
g_dbus_proxy_get_cached_property(proxy_, "AvailableCursorModes"));
if (variant.get()) {
uint32_t modes = 0;
g_variant_get(variant.get(), "u", &modes);
// Request mouse cursor to be embedded as part of the stream, otherwise it
// is hidden by default. Make request only if this mode is advertised by
// the portal implementation.
if (modes &
static_cast<uint32_t>(BaseCapturerPipeWire::CursorMode::kEmbedded)) {
g_variant_builder_add(&builder, "{sv}", "cursor_mode",
g_variant_new_uint32(static_cast<uint32_t>(
BaseCapturerPipeWire::CursorMode::kEmbedded)));
}
}
variant_string = g_strdup_printf("webrtc%d", g_random_int_range(0, G_MAXINT));
g_variant_builder_add(&builder, "{sv}", "handle_token",
g_variant_new_string(variant_string.get()));

View File

@ -47,6 +47,12 @@ class BaseCapturerPipeWire : public DesktopCapturer {
kAny = 0b11
};
enum class CursorMode : uint32_t {
kHidden = 0b01,
kEmbedded = 0b10,
kMetadata = 0b100
};
explicit BaseCapturerPipeWire(CaptureSourceType source_type);
~BaseCapturerPipeWire() override;