diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt --- a/shell/CMakeLists.txt +++ b/shell/CMakeLists.txt @@ -93,6 +93,7 @@ KF5::XmlGui KF5::Package KF5::WaylandClient + KF5::WindowSystem ) target_include_directories(plasmashell PRIVATE "${CMAKE_BINARY_DIR}") target_compile_definitions(plasmashell PRIVATE -DPROJECT_VERSION="${PROJECT_VERSION}") diff --git a/shell/autotests/CMakeLists.txt b/shell/autotests/CMakeLists.txt --- a/shell/autotests/CMakeLists.txt +++ b/shell/autotests/CMakeLists.txt @@ -9,6 +9,7 @@ Qt5::Test Qt5::Gui KF5::Service + KF5::WindowSystem ) if(HAVE_X11) target_link_libraries(${_testname} ${X11_LIBRARIES} ${XCB_LIBRARIES} ) diff --git a/shell/screenpool.h b/shell/screenpool.h --- a/shell/screenpool.h +++ b/shell/screenpool.h @@ -65,6 +65,7 @@ QHash m_idForConnector; QTimer m_configSaveTimer; + int m_xrandrExtensionOffset; }; #endif // SCREENPOOL_H diff --git a/shell/screenpool.cpp b/shell/screenpool.cpp --- a/shell/screenpool.cpp +++ b/shell/screenpool.cpp @@ -22,6 +22,7 @@ #include #include +#include #if HAVE_X11 #include @@ -34,12 +35,19 @@ : QObject(parent), m_configGroup(KConfigGroup(config, QStringLiteral("ScreenConnectors"))) { - qApp->installNativeEventFilter(this); m_configSaveTimer.setSingleShot(true); connect(&m_configSaveTimer, &QTimer::timeout, this, [this](){ m_configGroup.sync(); }); + +#ifdef HAVE_X11 + if (KWindowSystem::isPlatformX11()) { + qApp->installNativeEventFilter(this); + const xcb_query_extension_reply_t* reply = xcb_get_extension_data(QX11Info::connection(), &xcb_randr_id); + m_xrandrExtensionOffset = reply->first_event; + } +#endif } void ScreenPool::load() @@ -185,9 +193,8 @@ const auto responseType = XCB_EVENT_RESPONSE_TYPE(ev); - const xcb_query_extension_reply_t* reply = xcb_get_extension_data(QX11Info::connection(), &xcb_randr_id); - if (responseType == reply->first_event + XCB_RANDR_SCREEN_CHANGE_NOTIFY) { + if (responseType == m_xrandrExtensionOffset + XCB_RANDR_SCREEN_CHANGE_NOTIFY) { if (qGuiApp->primaryScreen()->name() != primaryConnector()) { //new screen? if (id(qGuiApp->primaryScreen()->name()) < 0) {