From 356510b0aabe397fb8a242e6f828bd5cc3b81d89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 23 Aug 2016 11:43:43 +0200 Subject: [PATCH] [libkwineffects] Port getXServerVersion from X11 to xcb Removes one of the last pure XLib usages and also means that in theory we can detect the Xwayland version number. In practice that only works when restarting the compositor as detect is invoked before the XWayland connection is created. --- autotests/libkwineffects/CMakeLists.txt | 2 +- libkwineffects/kwinglplatform.cpp | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/autotests/libkwineffects/CMakeLists.txt b/autotests/libkwineffects/CMakeLists.txt index 0c87dfb5c1..e175cca7aa 100644 --- a/autotests/libkwineffects/CMakeLists.txt +++ b/autotests/libkwineffects/CMakeLists.txt @@ -15,5 +15,5 @@ kwineffects_unit_tests( add_executable(kwinglplatformtest kwinglplatformtest.cpp mock_gl.cpp ../../libkwineffects/kwinglplatform.cpp) add_test(kwineffects-kwinglplatformtest kwinglplatformtest) -target_link_libraries(kwinglplatformtest Qt5::Test Qt5::Gui Qt5::X11Extras KF5::ConfigCore) +target_link_libraries(kwinglplatformtest Qt5::Test Qt5::Gui Qt5::X11Extras KF5::ConfigCore XCB::XCB) ecm_mark_as_test(kwinglplatformtest) diff --git a/libkwineffects/kwinglplatform.cpp b/libkwineffects/kwinglplatform.cpp index 6e52a3c105..49758dd732 100644 --- a/libkwineffects/kwinglplatform.cpp +++ b/libkwineffects/kwinglplatform.cpp @@ -27,7 +27,6 @@ along with this program. If not, see . #include #include -#include #include #include @@ -62,17 +61,19 @@ static qint64 parseVersionString(const QByteArray &version) static qint64 getXServerVersion() { qint64 major, minor, patch; + major = 0; + minor = 0; + patch = 0; - Display *dpy = display(); - if (dpy && strstr(ServerVendor(dpy), "X.Org")) { - const int release = VendorRelease(dpy); - major = (release / 10000000); - minor = (release / 100000) % 100; - patch = (release / 1000) % 100; - } else { - major = 0; - minor = 0; - patch = 0; + if (xcb_connection_t *c = connection()) { + auto setup = xcb_get_setup(c); + const QByteArray vendorName(xcb_setup_vendor(setup), xcb_setup_vendor_length(setup)); + if (vendorName.contains("X.Org")) { + const int release = setup->release_number; + major = (release / 10000000); + minor = (release / 100000) % 100; + patch = (release / 1000) % 100; + } } return kVersionNumber(major, minor, patch);