[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.
This commit is contained in:
Martin Gräßlin 2016-08-23 11:43:43 +02:00
parent 9aa6b2c1e5
commit 356510b0aa
2 changed files with 13 additions and 12 deletions

View file

@ -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)

View file

@ -27,7 +27,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QOpenGLContext>
#include <sys/utsname.h>
#include <X11/Xlib.h>
#include <iostream>
#include <iomanip>
@ -62,17 +61,19 @@ static qint64 parseVersionString(const QByteArray &version)
static qint64 getXServerVersion()
{
qint64 major, minor, patch;
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);