firefox/pw1.patch

79 lines
2.7 KiB
Diff
Raw Normal View History

# 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