Commit 30b536b7 authored by David Jarvie's avatar David Jarvie
Browse files

Use QNativeInterface to access X11 connection for Qt >= 6.2

parent 49ad4052
Pipeline #197094 passed with stage
in 4 minutes and 47 seconds
......@@ -121,7 +121,7 @@ if (X11_FOUND)
if (QT_MAJOR_VERSION STREQUAL "5")
find_package(Qt5X11Extras ${QT_REQUIRED_VERSION} REQUIRED NO_MODULE)
else()
find_package(Qt${QT_MAJOR_VERSION} ${REQUIRED_QT_VERSION} CONFIG REQUIRED Gui) # qtx11extras_p.h
find_package(Qt${QT_MAJOR_VERSION} ${QT_REQUIRED_VERSION} CONFIG REQUIRED Gui) # qtx11extras_p.h for Qt6 < 6.2
endif()
endif()
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
......
......@@ -338,8 +338,10 @@ endif()
if(X11_FOUND)
if (QT_MAJOR_VERSION STREQUAL "5")
target_link_libraries(kalarm_bin Qt${QT_MAJOR_VERSION}::X11Extras ${X11_X11_LIB})
elseif (Qt6_VERSION_MINOR LESS 2)
target_link_libraries(kalarm_bin Qt6::GuiPrivate ${X11_X11_LIB})
else()
target_link_libraries(kalarm_bin Qt6::GuiPrivate ${X11_X11_LIB})
target_link_libraries(kalarm_bin ${X11_X11_LIB})
endif()
endif()
......
......@@ -36,7 +36,9 @@
#if KDEPIM_HAVE_X11
#include <KWindowInfo>
#include <netwm.h>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
#include <QGuiApplication>
#elif QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <private/qtx11extras_p.h>
#else
#include <QX11Info>
......@@ -1339,7 +1341,15 @@ FullScreenType haveFullScreenWindow(int screen)
#if KDEPIM_HAVE_X11
if (KWindowSystem::isPlatformX11())
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
using namespace QNativeInterface;
auto* x11App = qGuiApp->nativeInterface<QX11Application>();
if (!x11App)
return type;
xcb_connection_t* connection = x11App->connection();
#else
xcb_connection_t* connection = QX11Info::connection();
#endif
const NETRootInfo rootInfo(connection, NET::ClientList | NET::ActiveWindow, NET::Properties2(), screen);
const xcb_window_t rootWindow = rootInfo.rootWindow();
const xcb_window_t activeWindow = rootInfo.activeWindow();
......@@ -1373,7 +1383,15 @@ FullScreenType findFullScreenWindows(const QVector<QRect>& screenRects, QVector<
#if KDEPIM_HAVE_X11
if (KWindowSystem::isPlatformX11())
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
using namespace QNativeInterface;
auto* x11App = qGuiApp->nativeInterface<QX11Application>();
if (!x11App)
return type;
xcb_connection_t* connection = x11App->connection();
#else
xcb_connection_t* connection = QX11Info::connection();
#endif
const NETRootInfo rootInfo(connection, NET::ClientList | NET::ActiveWindow, NET::Properties2());
const xcb_window_t rootWindow = rootInfo.rootWindow();
const xcb_window_t activeWindow = rootInfo.activeWindow();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment