From b549776b68d8ca926ae99a1104c48804294e310d Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 4 Jan 2023 11:10:32 +0000 Subject: [PATCH] scene: Avoid creating SurfaceItem for Xwayland's cursor surfaces SurfaceInterface::scaleOverride() doesn't scale the bufferScale, so if the scale override is 2, but the buffer scale specified by the client is 1, bufferScale() will return 1. Xwayland cursor surface implicitly relied on this behavior. Porting cursor to SurfaceItem changed that. Now cursor surfaces honor the scale override, which makes Xwayland cursors too small. In order to properly fix, plasma has to scale Xcursor.size in xrdb. The problem is that plasma also sets XCURSOR_THEME and XCURSOR_SIZE envvars that take precedence. Plasma must stop setting those envvars, but it's doable only with Qt 6.5, which got MouseCursorTheme and MouseCursorSize hints in QPlatformTheme. --- src/scene/cursoritem.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/scene/cursoritem.cpp b/src/scene/cursoritem.cpp index 94fa958698..7cb7adc708 100644 --- a/src/scene/cursoritem.cpp +++ b/src/scene/cursoritem.cpp @@ -11,6 +11,8 @@ #include "scene/itemrenderer.h" #include "scene/scene.h" #include "scene/surfaceitem_wayland.h" +#include "wayland/surface_interface.h" +#include "wayland_server.h" namespace KWin { @@ -30,7 +32,12 @@ void CursorItem::refresh() { const CursorSource *source = Cursors::self()->currentCursor()->source(); if (auto surfaceSource = qobject_cast(source)) { - setSurface(surfaceSource->surface()); + // TODO Plasma 6: Stop setting XCURSOR_SIZE and scale Xcursor.size in xrdb. + if (surfaceSource->surface() && surfaceSource->surface()->client() == waylandServer()->xWaylandConnection()) { + setImage(surfaceSource->image()); + } else { + setSurface(surfaceSource->surface()); + } } else if (auto imageSource = qobject_cast(source)) { setImage(imageSource->image()); } else if (auto shapeSource = qobject_cast(source)) {