Use QX11Application with Qt >= 6.2, use QX11Info with Qt 5
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
#define TRANSLATIONS_DIR "${CMAKE_INSTALL_PREFIX}/share/strawberry/translations"
|
||||
|
||||
#cmakedefine HAVE_QPA_QPLATFORMNATIVEINTERFACE_H
|
||||
#cmakedefine HAVE_X11EXTRAS
|
||||
|
||||
#cmakedefine ENABLE_WIN32_CONSOLE
|
||||
|
||||
|
||||
@@ -37,7 +37,15 @@
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xproto.h>
|
||||
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||
# include <QGuiApplication>
|
||||
#elif defined(HAVE_X11EXTRAS)
|
||||
# include <QX11Info>
|
||||
#elif defined(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H)
|
||||
# include <qpa/qplatformnativeinterface.h>
|
||||
#else
|
||||
# error "Missing Qt >= 6.2, X11Extras or qpa/qplatformnativeinterface.h header."
|
||||
#endif
|
||||
|
||||
const QVector<quint32> GlobalShortcut::mask_modifiers_ = QVector<quint32>() << 0 << Mod2Mask << LockMask << (Mod2Mask | LockMask);
|
||||
|
||||
@@ -45,6 +53,23 @@ namespace {
|
||||
|
||||
Display *X11Display() {
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) // 6.2: Use the new native interface.
|
||||
|
||||
if (!qApp) return nullptr;
|
||||
|
||||
if (QNativeInterface::QX11Application *x11_app = qApp->nativeInterface<QNativeInterface::QX11Application>()) {
|
||||
return x11_app->display();
|
||||
}
|
||||
else {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_X11EXTRAS) // Qt 5: Use X11Extras
|
||||
|
||||
return QX11Info::display();
|
||||
|
||||
#elif defined(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H) // Use private headers.
|
||||
|
||||
if (!qApp) return nullptr;
|
||||
|
||||
QPlatformNativeInterface *native = qApp->platformNativeInterface();
|
||||
@@ -53,10 +78,31 @@ Display *X11Display() {
|
||||
void *display = native->nativeResourceForIntegration("display");
|
||||
return reinterpret_cast<Display*>(display);
|
||||
|
||||
#else
|
||||
|
||||
# error "Missing Qt >= 6.2, X11Extras or qpa/qplatformnativeinterface.h header."
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
quint32 AppRootWindow() {
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) // 6.2: Use the new native interface.
|
||||
|
||||
if (QNativeInterface::QX11Application *x11_app = qApp->nativeInterface<QNativeInterface::QX11Application>()) {
|
||||
return static_cast<xcb_window_t>(reinterpret_cast<quintptr>(x11_app->connection()));
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_X11EXTRAS) // Qt 5: Use X11Extras
|
||||
|
||||
return QX11Info::appRootWindow();
|
||||
|
||||
#elif defined(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H) // Use private headers.
|
||||
|
||||
if (!qApp) return 0;
|
||||
|
||||
QPlatformNativeInterface *native = qApp->platformNativeInterface();
|
||||
@@ -67,6 +113,12 @@ quint32 AppRootWindow() {
|
||||
|
||||
return static_cast<xcb_window_t>(reinterpret_cast<quintptr>(native->nativeResourceForScreen("rootwindow", screen)));
|
||||
|
||||
#else
|
||||
|
||||
# error "Missing Qt >= 6.2, X11Extras or qpa/qplatformnativeinterface.h header."
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -55,7 +55,10 @@
|
||||
#include <QSettings>
|
||||
#include <QFlags>
|
||||
#include <QtEvents>
|
||||
#if defined(HAVE_X11) && defined(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H)
|
||||
|
||||
#ifdef HAVE_X11EXTRAS
|
||||
# include <QX11Info>
|
||||
#elif defined(HAVE_X11) && defined(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H)
|
||||
# include <qpa/qplatformnativeinterface.h>
|
||||
#endif
|
||||
|
||||
@@ -213,7 +216,9 @@ void OSDPretty::ScreenRemoved(QScreen *screen) {
|
||||
|
||||
bool OSDPretty::IsTransparencyAvailable() {
|
||||
|
||||
#if defined(HAVE_X11) && defined(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H)
|
||||
#ifdef HAVE_X11EXTRAS
|
||||
return QX11Info::isCompositingManagerRunning();
|
||||
#elif defined(HAVE_X11) && defined(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H)
|
||||
if (qApp) {
|
||||
QPlatformNativeInterface *native = qApp->platformNativeInterface();
|
||||
QScreen *screen = popup_screen_ == nullptr ? QGuiApplication::primaryScreen() : popup_screen_;
|
||||
|
||||
Reference in New Issue
Block a user