2323
2424#include < QPaintEvent>
2525#include < QPainter>
26- #ifndef _WIN32
27- #ifndef APPLE
28- #include < qpa/qplatformnativeinterface.h>
29- #endif
30- #endif
26+
3127#include < QDateTime>
3228
3329#include " OpenGLSupport.h"
5046
5147using namespace melonDS ;
5248
49+ #if !defined(_WIN32) && !defined(APPLE)
50+ #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
51+ using namespace QNativeInterface ;
52+ #else
53+ #include < qpa/qplatformnativeinterface.h>
54+ #endif
55+ #endif
56+
5357
5458const u32 kOSDMargin = 6 ;
5559const int kLogoWidth = 192 ;
@@ -1285,8 +1289,25 @@ std::optional<WindowInfo> ScreenPanelGL::getWindowInfo()
12851289 wi.type = WindowInfo::Type::MacOS;
12861290 wi.window_handle = reinterpret_cast <void *>(winId ());
12871291 #else
1288- QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface ();
12891292 const QString platform_name = QGuiApplication::platformName ();
1293+
1294+ #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
1295+ if (platform_name == QStringLiteral (" xcb" ))
1296+ {
1297+ wi.type = WindowInfo::Type::X11 ;
1298+ const QX11Application* x11 = qApp->nativeInterface <QX11Application>();
1299+ wi.display_connection = x11->display ();
1300+ wi.window_handle = reinterpret_cast <void *>(winId ());
1301+ }
1302+ else if (platform_name == QStringLiteral (" wayland" ))
1303+ {
1304+ wi.type = WindowInfo::Type::Wayland;
1305+ const QWaylandApplication* wl = qApp->nativeInterface <QWaylandApplication>();
1306+ wi.display_connection = wl->display ();
1307+ wi.window_handle = reinterpret_cast <void *>(winId ());
1308+ }
1309+ #else
1310+ QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface ();
12901311 if (platform_name == QStringLiteral (" xcb" ))
12911312 {
12921313 wi.type = WindowInfo::Type::X11 ;
@@ -1303,9 +1324,9 @@ std::optional<WindowInfo> ScreenPanelGL::getWindowInfo()
13031324 wi.display_connection = pni->nativeResourceForWindow (" display" , handle);
13041325 wi.window_handle = pni->nativeResourceForWindow (" surface" , handle);
13051326 }
1327+ #endif
13061328 else
13071329 {
1308- // qCritical() << "Unknown PNI platform " << platform_name;
13091330 Platform::Log (Platform::LogLevel::Error, " Unknown PNI platform %s\n " , platform_name.toStdString ().c_str ());
13101331 return std::nullopt ;
13111332 }
0 commit comments