summaryrefslogtreecommitdiff
path: root/pw1.patch
blob: 1f8854577de0c77fa925ca6ed01817c44349ddc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

# HG changeset patch
# User stransky <stransky@redhat.com>
# Date 1604562416 0
# Node ID 1c126b520042591194e88618ae11a6adc1da9a08
# Parent  6e2e4f0e4a95b0cae777dda9369a9e9bf49a51b1
Bug 1672987 Use PipeWire when Wayland display is actually used, r=dminor

Right now PipeWire is enabled when Wayland session is used regardless of an active Gtk backend (X11/Wayland).
Let's use PipeWire only when Wayland Gtk backend is used and disable it for X11 one to avoid possible regressions.

Differential Revision: https://phabricator.services.mozilla.com/D94588

diff --git a/third_party/libwebrtc/webrtc/modules/desktop_capture/desktop_capturer.cc b/third_party/libwebrtc/webrtc/modules/desktop_capture/desktop_capturer.cc
--- a/third_party/libwebrtc/webrtc/modules/desktop_capture/desktop_capturer.cc
+++ b/third_party/libwebrtc/webrtc/modules/desktop_capture/desktop_capturer.cc
@@ -8,16 +8,21 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
 #include "modules/desktop_capture/desktop_capturer.h"
 
 #include "modules/desktop_capture/desktop_capture_options.h"
 #include "modules/desktop_capture/desktop_capturer_differ_wrapper.h"
 
+#if defined(WEBRTC_USE_PIPEWIRE) || defined(USE_X11)
+#include <gtk/gtk.h>
+#include <gtk/gtkx.h>
+#endif
+
 namespace webrtc {
 
 DesktopCapturer::~DesktopCapturer() = default;
 
 void DesktopCapturer::SetSharedMemoryFactory(
     std::unique_ptr<SharedMemoryFactory> shared_memory_factory) {}
 
 void DesktopCapturer::SetExcludedWindow(WindowId window) {}
@@ -67,21 +72,37 @@ std::unique_ptr<DesktopCapturer> Desktop
   if (capturer && options.detect_updated_region()) {
     capturer.reset(new DesktopCapturerDifferWrapper(std::move(capturer)));
   }
 
   return capturer;
 }
 
 #if defined(WEBRTC_USE_PIPEWIRE) || defined(USE_X11)
-bool DesktopCapturer::IsRunningUnderWayland() {
+// Return true if Firefox is actually running with Wayland backend.
+static bool IsWaylandDisplayUsed() {
+  const auto display = gdk_display_get_default();
+  if (display == nullptr) {
+    // We're running in headless mode.
+    return false;
+  }
+  return !GDK_IS_X11_DISPLAY(display);
+}
+
+// Return true if Firefox is actually running on Wayland enabled session.
+// It means some screensharing capabilities may be limited.
+static bool IsWaylandSessionUsed() {
   const char* xdg_session_type = getenv("XDG_SESSION_TYPE");
   if (!xdg_session_type || strncmp(xdg_session_type, "wayland", 7) != 0)
     return false;
 
   if (!(getenv("WAYLAND_DISPLAY")))
     return false;
 
   return true;
 }
+
+bool DesktopCapturer::IsRunningUnderWayland() {
+  return IsWaylandSessionUsed() ? IsWaylandDisplayUsed() : false;
+}
 #endif  // defined(WEBRTC_USE_PIPEWIRE) || defined(USE_X11)
 
 }  // namespace webrtc

bgstack15