From b852033bab79749dd5e9b0e4ef5e3f01bd1f7769 Mon Sep 17 00:00:00 2001 From: reionwong Date: Sun, 30 Aug 2026 06:36:35 -0400 Subject: [PATCH] fix: migrate X11 integration to Qt6 --- CMakeLists.txt | 1 - compat/QX11Info | 36 ------------------------------------ screenlocker/application.cpp | 16 ++++++++-------- 3 files changed, 8 insertions(+), 45 deletions(-) delete mode 100644 compat/QX11Info diff --git a/CMakeLists.txt b/CMakeLists.txt index cab93d7..dd22e11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,6 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) -include_directories("${CMAKE_CURRENT_SOURCE_DIR}/compat") # set(CMAKE_AUTOUIC ON) # set(CMAKE_AUTOMOC ON) diff --git a/compat/QX11Info b/compat/QX11Info deleted file mode 100644 index 14c3543..0000000 --- a/compat/QX11Info +++ /dev/null @@ -1,36 +0,0 @@ -/* Qt 6 compatibility layer for the legacy QX11Info API. */ -#ifndef CUTEFISH_QX11INFO_COMPAT -#define CUTEFISH_QX11INFO_COMPAT - -#include -#include -#include - -class QX11Info -{ -public: - static bool isPlatformX11() - { - return nativeInterface() != nullptr; - } - - static xcb_connection_t *connection() - { - const auto native = nativeInterface(); - return native ? native->connection() : nullptr; - } - - static Display *display() - { - const auto native = nativeInterface(); - return native ? native->display() : nullptr; - } - -private: - static QNativeInterface::QX11Application *nativeInterface() - { - return qGuiApp ? qGuiApp->nativeInterface() : nullptr; - } -}; - -#endif diff --git a/screenlocker/application.cpp b/screenlocker/application.cpp index c564b53..32127b2 100644 --- a/screenlocker/application.cpp +++ b/screenlocker/application.cpp @@ -22,8 +22,8 @@ // Qt Core #include #include -#include #include +#include // Qt Quick #include @@ -74,7 +74,7 @@ Application::Application(int &argc, char **argv) connect(this, &Application::screenAdded, this, &Application::onScreenAdded); connect(this, &Application::screenRemoved, this, &Application::desktopResized); - if (QX11Info::isPlatformX11()) { + if (qGuiApp->nativeInterface()) { installNativeEventFilter(new FocusOutEventFilter); } } @@ -128,7 +128,7 @@ void Application::desktopResized() view->setGeometry(screen->geometry()); if (!m_testing) { - if (QX11Info::isPlatformX11()) { + if (qGuiApp->nativeInterface()) { view->setFlags(Qt::X11BypassWindowManagerHint); } else { view->setFlags(Qt::FramelessWindowHint); @@ -155,7 +155,7 @@ void Application::desktopResized() view->setScreen(screen); // on Wayland we may not use fullscreen as that puts all windows on one screen - if (m_testing || QX11Info::isPlatformX11()) { + if (m_testing || qGuiApp->nativeInterface()) { view->show(); } else { view->showFullScreen(); @@ -254,16 +254,16 @@ bool Application::eventFilter(QObject *obj, QEvent *event) break; } } - if (view && view->winId() && QX11Info::isPlatformX11()) { + if (view && view->winId() && qGuiApp->nativeInterface()) { // showing greeter view window, set property - static Atom tag = XInternAtom(QX11Info::display(), "_KDE_SCREEN_LOCKER", False); - XChangeProperty(QX11Info::display(), view->winId(), tag, tag, 32, PropModeReplace, nullptr, 0); + static Atom tag = XInternAtom(qGuiApp->nativeInterface()->display(), "_KDE_SCREEN_LOCKER", False); + XChangeProperty(qGuiApp->nativeInterface()->display(), view->winId(), tag, tag, 32, PropModeReplace, nullptr, 0); } // no further processing return false; } - if (event->type() == QEvent::MouseButtonPress && QX11Info::isPlatformX11()) { + if (event->type() == QEvent::MouseButtonPress && qGuiApp->nativeInterface()) { if (getActiveScreen()) { getActiveScreen()->requestActivate(); }