From 5f0002c6c61224788115eae35df69d65a612584d Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Mon, 21 Mar 2022 11:01:10 -0700 Subject: [PATCH] Backport MR #2163 (edited to cover vbox) to fix VM cursor offset (#2063969) --- 2163-edited.patch | 63 +++++++++++++++++++++++++++++++++++++++++++++++ kwin.spec | 11 ++++++++- 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 2163-edited.patch diff --git a/2163-edited.patch b/2163-edited.patch new file mode 100644 index 0000000..b6cd48f --- /dev/null +++ b/2163-edited.patch @@ -0,0 +1,63 @@ +From e686da9ddedd820d3a7c3c21033c48276c251636 Mon Sep 17 00:00:00 2001 +From: Xaver Hugl +Date: Sun, 20 Mar 2022 05:12:48 +0100 +Subject: [PATCH] backends/drm: fall back to legacy mode in virtual machines + +Virtual machines aren't properly supporting atomic mode setting yet, which +causes the cursor to be offset, and will cause more issues with overlay +planes. In order to prevent that from impacting users, fall back to legacy, +unless KWIN_DRM_NO_AMS is set. + +BUG: 427060 +FIXED-IN: 5.24.4 +--- + src/backends/drm/drm_gpu.cpp | 11 +++++++---- + src/backends/drm/drm_gpu.h | 1 + + 2 files changed, 8 insertions(+), 4 deletions(-) + +diff --git a/src/backends/drm/drm_gpu.cpp b/src/backends/drm/drm_gpu.cpp +index 51b8719f57..26d6b27b04 100644 +--- a/src/backends/drm/drm_gpu.cpp ++++ b/src/backends/drm/drm_gpu.cpp +@@ -75,9 +75,10 @@ DrmGpu::DrmGpu(DrmBackend *backend, const QString &devNode, int fd, dev_t device + m_addFB2ModifiersSupported = drmGetCap(fd, DRM_CAP_ADDFB2_MODIFIERS, &capability) == 0 && capability == 1; + qCDebug(KWIN_DRM) << "drmModeAddFB2WithModifiers is" << (m_addFB2ModifiersSupported ? "supported" : "not supported") << "on GPU" << m_devNode; + +- // find out if this GPU is using the NVidia proprietary driver ++ // find out what driver this kms device is using + DrmScopedPointer version(drmGetVersion(fd)); + m_isNVidia = strstr(version->name, "nvidia-drm"); ++ m_isVirtualMachine = strstr(version->name, "virtio") || strstr(version->name, "qxl") || strstr(version->name, "vmwgfx") || strstr(version->name, "vboxvideo"); + m_gbmDevice = gbm_create_device(m_fd); + + m_socketNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this); +@@ -148,9 +149,11 @@ clockid_t DrmGpu::presentationClock() const + void DrmGpu::initDrmResources() + { + // try atomic mode setting +- bool tmp = false; +- bool noAMS = qEnvironmentVariableIntValue("KWIN_DRM_NO_AMS", &tmp) != 0 && tmp; +- if (noAMS) { ++ bool isEnvVarSet = false; ++ bool noAMS = qEnvironmentVariableIntValue("KWIN_DRM_NO_AMS", &isEnvVarSet) != 0 && isEnvVarSet; ++ if (m_isVirtualMachine && !isEnvVarSet) { ++ qCWarning(KWIN_DRM, "Atomic Mode Setting disabled on GPU %s because of cursor offset issues in virtual machines", qPrintable(m_devNode)); ++ } else if (noAMS) { + qCWarning(KWIN_DRM) << "Atomic Mode Setting requested off via environment variable. Using legacy mode on GPU" << m_devNode; + } else if(drmSetClientCap(m_fd, DRM_CLIENT_CAP_ATOMIC, 1) != 0) { + qCWarning(KWIN_DRM) << "drmSetClientCap for Atomic Mode Setting failed. Using legacy mode on GPU" << m_devNode; +diff --git a/src/backends/drm/drm_gpu.h b/src/backends/drm/drm_gpu.h +index 97c2d8ddc2..1e1f7e3b15 100644 +--- a/src/backends/drm/drm_gpu.h ++++ b/src/backends/drm/drm_gpu.h +@@ -118,6 +118,7 @@ private: + bool m_atomicModeSetting; + bool m_addFB2ModifiersSupported = false; + bool m_isNVidia; ++ bool m_isVirtualMachine; + clockid_t m_presentationClock; + gbm_device* m_gbmDevice; + EGLDisplay m_eglDisplay = EGL_NO_DISPLAY; +-- +GitLab + diff --git a/kwin.spec b/kwin.spec index db82955..7102fe0 100644 --- a/kwin.spec +++ b/kwin.spec @@ -17,7 +17,7 @@ Name: kwin Version: 5.24.3 -Release: 2%{?dist} +Release: 3%{?dist} Summary: KDE Window manager # all sources are effectively GPLv2+, except for: @@ -40,6 +40,12 @@ Source0: http://download.kde.org/%{stable}/plasma/%{version}/%{name}-%{version}. ## proposed patches +# Fallback to legacy mode in VMs to fix cursor offset bug: +# https://invent.kde.org/plasma/kwin/-/merge_requests/2163 +# https://bugzilla.redhat.com/show_bug.cgi?id=2063969 +# edited to add 'vboxvideo' for VirtualBox +Patch0: 2163-edited.patch + # Base BuildRequires: extra-cmake-modules BuildRequires: kf5-rpm-macros @@ -368,6 +374,9 @@ make test ARGS="--output-on-failure --timeout 10" -C %{_target_platform} ||: %changelog +* Mon Mar 21 2022 Adam Williamson - 5.24.3-3 +- Backport MR #2163 (edited to cover vbox) to fix VM cursor offset (#2063969) + * Thu Mar 10 2022 Marc Deop - 5.24.3-2 - Rebuild (qt5)