2020-10-06 07:03:37 +00:00
|
|
|
From ee7de65649ce502b68cd0b2a1da8cf15f016cc0d Mon Sep 17 00:00:00 2001
|
2020-08-09 11:22:33 +00:00
|
|
|
From: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
|
|
|
Date: Mon, 9 Mar 2020 21:23:37 -0300
|
2020-10-06 07:03:37 +00:00
|
|
|
Subject: [PATCH 14/25] UI: Retrieve Wayland surface from QWindow
|
2020-08-09 11:22:33 +00:00
|
|
|
|
|
|
|
On Wayland, we want to query the window's underlying
|
|
|
|
platform for the Wayland surface, instead of foolishly
|
|
|
|
retrieving the X11 display.
|
|
|
|
|
|
|
|
Pass QWindow instead of WId directly, and set the surface
|
|
|
|
as the platform data on Wayland systems.
|
|
|
|
---
|
|
|
|
UI/qt-display.cpp | 2 +-
|
|
|
|
UI/qt-wrappers.cpp | 28 +++++++++++++++++++++++-----
|
|
|
|
UI/qt-wrappers.hpp | 3 ++-
|
|
|
|
3 files changed, 26 insertions(+), 7 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/UI/qt-display.cpp b/UI/qt-display.cpp
|
|
|
|
index 1bb97c7b..685ee6f9 100644
|
|
|
|
--- a/UI/qt-display.cpp
|
|
|
|
+++ b/UI/qt-display.cpp
|
|
|
|
@@ -89,7 +89,7 @@ void OBSQTDisplay::CreateDisplay()
|
|
|
|
info.format = GS_BGRA;
|
|
|
|
info.zsformat = GS_ZS_NONE;
|
|
|
|
|
|
|
|
- QTToGSWindow(winId(), info.window);
|
|
|
|
+ QTToGSWindow(windowHandle(), info.window);
|
|
|
|
|
|
|
|
display = obs_display_create(&info, backgroundColor);
|
|
|
|
|
|
|
|
diff --git a/UI/qt-wrappers.cpp b/UI/qt-wrappers.cpp
|
2020-10-06 07:03:37 +00:00
|
|
|
index b9d00a78..040d1bb6 100644
|
2020-08-09 11:22:33 +00:00
|
|
|
--- a/UI/qt-wrappers.cpp
|
|
|
|
+++ b/UI/qt-wrappers.cpp
|
2020-10-06 07:03:37 +00:00
|
|
|
@@ -28,9 +28,14 @@
|
|
|
|
#include <QFileDialog>
|
2020-08-09 11:22:33 +00:00
|
|
|
|
|
|
|
#if !defined(_WIN32) && !defined(__APPLE__)
|
|
|
|
+#include <obs-nix-platform.h>
|
|
|
|
#include <QX11Info>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#ifdef ENABLE_WAYLAND
|
|
|
|
+#include <qpa/qplatformnativeinterface.h>
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
static inline void OBSErrorBoxva(QWidget *parent, const char *msg, va_list args)
|
|
|
|
{
|
|
|
|
char full_message[4096];
|
2020-10-06 07:03:37 +00:00
|
|
|
@@ -106,15 +111,28 @@ void OBSMessageBox::critical(QWidget *parent, const QString &title,
|
2020-08-09 11:22:33 +00:00
|
|
|
mb.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
-void QTToGSWindow(WId windowId, gs_window &gswindow)
|
|
|
|
+void QTToGSWindow(QWindow *window, gs_window &gswindow)
|
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
|
|
|
- gswindow.hwnd = (HWND)windowId;
|
|
|
|
+ gswindow.hwnd = (HWND)window->winId();
|
|
|
|
#elif __APPLE__
|
|
|
|
- gswindow.view = (id)windowId;
|
|
|
|
+ gswindow.view = (id)window->winId();
|
|
|
|
#else
|
|
|
|
- gswindow.id = windowId;
|
|
|
|
- gswindow.display = QX11Info::display();
|
|
|
|
+ switch (obs_get_nix_platform()) {
|
|
|
|
+ case OBS_NIX_PLATFORM_X11_GLX:
|
|
|
|
+ case OBS_NIX_PLATFORM_X11_EGL:
|
|
|
|
+ gswindow.id = window->winId();
|
|
|
|
+ gswindow.display = obs_get_nix_platform_display();
|
|
|
|
+ break;
|
|
|
|
+#ifdef ENABLE_WAYLAND
|
|
|
|
+ case OBS_NIX_PLATFORM_WAYLAND:
|
|
|
|
+ QPlatformNativeInterface *native =
|
|
|
|
+ QGuiApplication::platformNativeInterface();
|
|
|
|
+ gswindow.display =
|
|
|
|
+ native->nativeResourceForWindow("surface", window);
|
|
|
|
+ break;
|
|
|
|
+#endif
|
|
|
|
+ }
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/UI/qt-wrappers.hpp b/UI/qt-wrappers.hpp
|
2020-10-06 07:03:37 +00:00
|
|
|
index 71b11354..51c4f937 100644
|
2020-08-09 11:22:33 +00:00
|
|
|
--- a/UI/qt-wrappers.hpp
|
|
|
|
+++ b/UI/qt-wrappers.hpp
|
|
|
|
@@ -20,6 +20,7 @@
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QWidget>
|
|
|
|
+#include <QWindow>
|
|
|
|
#include <QThread>
|
|
|
|
#include <obs.hpp>
|
|
|
|
|
|
|
|
@@ -55,7 +56,7 @@ public:
|
|
|
|
|
|
|
|
void OBSErrorBox(QWidget *parent, const char *msg, ...);
|
|
|
|
|
|
|
|
-void QTToGSWindow(WId windowId, gs_window &gswindow);
|
|
|
|
+void QTToGSWindow(QWindow *window, gs_window &gswindow);
|
|
|
|
|
|
|
|
uint32_t TranslateQtKeyboardEventModifiers(Qt::KeyboardModifiers mods);
|
|
|
|
|
|
|
|
--
|
|
|
|
2.28.0
|
|
|
|
|