diff --git a/autotests/integration/screencasting_test.cpp b/autotests/integration/screencasting_test.cpp index 429e10f5e5..c721687d56 100644 --- a/autotests/integration/screencasting_test.cpp +++ b/autotests/integration/screencasting_test.cpp @@ -12,6 +12,7 @@ #include "libkwineffects/glplatform.h" #include "pointer_input.h" #include "scene/workspacescene.h" +#include "utils/kernel.h" #include "wayland_server.h" #include "window.h" #include "workspace.h" @@ -92,7 +93,7 @@ private: void ScreencastingTest::init() { // TODO: Remove this when CI is updated to ubuntu 22.04 or something with a newer kernel. - const Version kernelVersion = GLPlatform::instance()->kernelVersion(); + const Version kernelVersion = linuxKernelVersion(); if (kernelVersion.major() == 5 && kernelVersion.minor() <= 4) { QSKIP("drmPrimeFDToHandle() randomly fails"); return; diff --git a/autotests/libkwineffects/kwinglplatformtest.cpp b/autotests/libkwineffects/kwinglplatformtest.cpp index 6bc10fb51a..2c5764b23d 100644 --- a/autotests/libkwineffects/kwinglplatformtest.cpp +++ b/autotests/libkwineffects/kwinglplatformtest.cpp @@ -156,7 +156,6 @@ void GLPlatformTest::testPriorDetect() QCOMPARE(gl->mesaVersion(), Version()); QCOMPARE(gl->galliumVersion(), Version()); QCOMPARE(gl->serverVersion(), Version()); - QCOMPARE(gl->kernelVersion(), Version()); QCOMPARE(gl->driverVersion(), Version()); QCOMPARE(gl->driver(), Driver_Unknown); diff --git a/src/libkwineffects/glplatform.cpp b/src/libkwineffects/glplatform.cpp index 3f5499c3b1..2cadf74872 100644 --- a/src/libkwineffects/glplatform.cpp +++ b/src/libkwineffects/glplatform.cpp @@ -43,17 +43,6 @@ static Version getXServerVersion() return Version(0, 0, 0); } -static Version getKernelVersion() -{ - struct utsname name; - uname(&name); - - if (qstrcmp(name.sysname, "Linux") == 0) { - return Version::parseString(name.release); - } - return Version(0, 0, 0); -} - // Extracts the portion of a string that matches a regular expression static QString extract(const QString &text, const QString &pattern) { @@ -817,7 +806,6 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) } m_serverVersion = getXServerVersion(); - m_kernelVersion = getKernelVersion(); if (m_supportsGLSL) { // Parse the GLSL version @@ -1187,9 +1175,6 @@ void GLPlatform::printResults() const if (serverVersion().isValid()) { print(QByteArrayLiteral("X server version:"), versionToString8(m_serverVersion)); } - if (kernelVersion().isValid()) { - print(QByteArrayLiteral("Linux kernel version:"), versionToString8(m_kernelVersion)); - } print(QByteArrayLiteral("Requires strict binding:"), !m_looseBinding ? QByteArrayLiteral("yes") : QByteArrayLiteral("no")); print(QByteArrayLiteral("GLSL shaders:"), m_supportsGLSL ? QByteArrayLiteral("yes") : QByteArrayLiteral("no")); @@ -1242,11 +1227,6 @@ Version GLPlatform::serverVersion() const return m_serverVersion; } -Version GLPlatform::kernelVersion() const -{ - return m_kernelVersion; -} - Version GLPlatform::driverVersion() const { if (isMesaDriver()) { diff --git a/src/libkwineffects/glplatform.h b/src/libkwineffects/glplatform.h index 08725010ad..08684f1b4f 100644 --- a/src/libkwineffects/glplatform.h +++ b/src/libkwineffects/glplatform.h @@ -236,13 +236,6 @@ public: */ Version serverVersion() const; - /** - * Returns the Linux kernel version. - * - * If the kernel is not a Linux kernel, this method returns 0. - */ - Version kernelVersion() const; - /** * Returns the driver version. * @@ -404,7 +397,6 @@ public: * @see driverVersion * @see mesaVersion * @see galliumVersion - * @see kernelVersion * @see serverVersion */ static QString versionToString(const Version &version); @@ -464,7 +456,6 @@ private: Version m_driverVersion; Version m_galliumVersion; Version m_serverVersion; - Version m_kernelVersion; bool m_looseBinding : 1; bool m_supportsGLSL : 1; bool m_textureNPOT : 1; diff --git a/src/utils/common.h b/src/utils/common.h index 8088e6194e..1f1d6f7eb7 100644 --- a/src/utils/common.h +++ b/src/utils/common.h @@ -15,6 +15,7 @@ #include // kwin #include "libkwineffects/kwinglobals.h" +#include "libkwineffects/version.h" // Qt #include #include diff --git a/src/utils/kernel.h b/src/utils/kernel.h new file mode 100644 index 0000000000..34bcabab03 --- /dev/null +++ b/src/utils/kernel.h @@ -0,0 +1,28 @@ +/* + KWin - the KDE window manager + This file is part of the KDE project. + + SPDX-FileCopyrightText: 2023 Xaver Hugl + + SPDX-License-Identifier: GPL-2.0-or-later +*/ +#pragma once +#include "libkwineffects/version.h" + +#include + +namespace KWin +{ + +inline static Version linuxKernelVersion() +{ + struct utsname name; + uname(&name); + + if (qstrcmp(name.sysname, "Linux") == 0) { + return Version::parseString(name.release); + } + return Version(0, 0, 0); +} + +} diff --git a/src/workspace.cpp b/src/workspace.cpp index e162498221..8aba56b79a 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -54,6 +54,7 @@ #include "placementtracker.h" #include "tiles/tilemanager.h" #include "useractions.h" +#include "utils/kernel.h" #include "utils/xcbutils.h" #include "virtualdesktops.h" #include "was_user_interaction_x11_filter.h" @@ -1798,8 +1799,8 @@ QString Workspace::supportInformation() const if (platform->serverVersion().isValid()) { support.append(QStringLiteral("X server version: ") + GLPlatform::versionToString(platform->serverVersion()) + QStringLiteral("\n")); } - if (platform->kernelVersion().isValid()) { - support.append(QStringLiteral("Linux kernel version: ") + GLPlatform::versionToString(platform->kernelVersion()) + QStringLiteral("\n")); + if (auto kernelVersion = linuxKernelVersion(); kernelVersion.isValid()) { + support.append(QStringLiteral("Linux kernel version: ") + GLPlatform::versionToString(kernelVersion) + QStringLiteral("\n")); } support.append(QStringLiteral("Direct rendering: "));