mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-08 04:22:55 +00:00
UI: Move QTToGSWindow outside of Qt wrappers
This commit is contained in:
parent
988b5e4563
commit
1c4966d471
|
@ -13,6 +13,14 @@
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||||
|
#include <obs-nix-platform.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_WAYLAND
|
||||||
|
#include <qpa/qplatformnativeinterface.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
class SurfaceEventFilter : public QObject {
|
class SurfaceEventFilter : public QObject {
|
||||||
OBSQTDisplay *display;
|
OBSQTDisplay *display;
|
||||||
|
|
||||||
|
@ -62,6 +70,38 @@ static inline QColor rgba_to_color(uint32_t rgba)
|
||||||
(rgba >> 16) & 0xFF, (rgba >> 24) & 0xFF);
|
(rgba >> 16) & 0xFF, (rgba >> 24) & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool QTToGSWindow(QWindow *window, gs_window &gswindow)
|
||||||
|
{
|
||||||
|
bool success = true;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
gswindow.hwnd = (HWND)window->winId();
|
||||||
|
#elif __APPLE__
|
||||||
|
gswindow.view = (id)window->winId();
|
||||||
|
#else
|
||||||
|
switch (obs_get_nix_platform()) {
|
||||||
|
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);
|
||||||
|
success = gswindow.display != nullptr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
success = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
OBSQTDisplay::OBSQTDisplay(QWidget *parent, Qt::WindowFlags flags)
|
OBSQTDisplay::OBSQTDisplay(QWidget *parent, Qt::WindowFlags flags)
|
||||||
: QWidget(parent, flags)
|
: QWidget(parent, flags)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,14 +32,6 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
|
|
||||||
#if !defined(_WIN32) && !defined(__APPLE__)
|
|
||||||
#include <obs-nix-platform.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_WAYLAND
|
|
||||||
#include <qpa/qplatformnativeinterface.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline void OBSErrorBoxva(QWidget *parent, const char *msg, va_list args)
|
static inline void OBSErrorBoxva(QWidget *parent, const char *msg, va_list args)
|
||||||
{
|
{
|
||||||
char full_message[8192];
|
char full_message[8192];
|
||||||
|
@ -120,38 +112,6 @@ void OBSMessageBox::critical(QWidget *parent, const QString &title,
|
||||||
mb.exec();
|
mb.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QTToGSWindow(QWindow *window, gs_window &gswindow)
|
|
||||||
{
|
|
||||||
bool success = true;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
gswindow.hwnd = (HWND)window->winId();
|
|
||||||
#elif __APPLE__
|
|
||||||
gswindow.view = (id)window->winId();
|
|
||||||
#else
|
|
||||||
switch (obs_get_nix_platform()) {
|
|
||||||
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);
|
|
||||||
success = gswindow.display != nullptr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
success = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t TranslateQtKeyboardEventModifiers(Qt::KeyboardModifiers mods)
|
uint32_t TranslateQtKeyboardEventModifiers(Qt::KeyboardModifiers mods)
|
||||||
{
|
{
|
||||||
int obsModifiers = INTERACT_NONE;
|
int obsModifiers = INTERACT_NONE;
|
||||||
|
|
|
@ -37,7 +37,6 @@ class QComboBox;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
class QLayout;
|
class QLayout;
|
||||||
class QString;
|
class QString;
|
||||||
struct gs_window;
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QToolBar;
|
class QToolBar;
|
||||||
|
|
||||||
|
@ -60,8 +59,6 @@ public:
|
||||||
|
|
||||||
void OBSErrorBox(QWidget *parent, const char *msg, ...);
|
void OBSErrorBox(QWidget *parent, const char *msg, ...);
|
||||||
|
|
||||||
bool QTToGSWindow(QWindow *window, gs_window &gswindow);
|
|
||||||
|
|
||||||
uint32_t TranslateQtKeyboardEventModifiers(Qt::KeyboardModifiers mods);
|
uint32_t TranslateQtKeyboardEventModifiers(Qt::KeyboardModifiers mods);
|
||||||
|
|
||||||
QDataStream &
|
QDataStream &
|
||||||
|
|
Loading…
Reference in a new issue