From bedc01b10868568006cc53cf187ef8ed164d6fed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 20 Oct 2016 10:25:37 +0200 Subject: [PATCH] [kwineffects] Add hide/show cursor to EffectsHandler Summary: The implementation delegates to the Platform to perform the actual show/hide of the cursor image. This replaces the implementation in the zoom effect which so far directly interacted with xfixes to show/hide the cursor. This is now provided by the x11/standalone platform. And due to this change the zoom effect can now properly hide the cursor on platform DRM (wayland) as well. Test Plan: Zoom effect on Wayland hides the cursor Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D3120 --- autotests/mock_effectshandler.h | 4 ++++ effects.cpp | 10 ++++++++++ effects.h | 3 +++ effects/zoom/zoom.cpp | 5 ++--- libkwineffects/kwineffects.h | 14 ++++++++++++++ 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/autotests/mock_effectshandler.h b/autotests/mock_effectshandler.h index d19f3796ca..8a0179c861 100644 --- a/autotests/mock_effectshandler.h +++ b/autotests/mock_effectshandler.h @@ -241,6 +241,10 @@ public: return KWin::PlatformCursorImage(); } + void hideCursor() override {} + + void showCursor() override {} + private: bool m_animationsSuported = true; }; diff --git a/effects.cpp b/effects.cpp index cd687bf5c4..1a731bf649 100644 --- a/effects.cpp +++ b/effects.cpp @@ -1564,6 +1564,16 @@ PlatformCursorImage EffectsHandlerImpl::cursorImage() const return kwinApp()->platform()->cursorImage(); } +void EffectsHandlerImpl::hideCursor() +{ + kwinApp()->platform()->hideCursor(); +} + +void EffectsHandlerImpl::showCursor() +{ + kwinApp()->platform()->showCursor(); +} + //**************************************** // EffectWindowImpl //**************************************** diff --git a/effects.h b/effects.h index ccacc80eeb..e6a316c61a 100644 --- a/effects.h +++ b/effects.h @@ -230,6 +230,9 @@ public: PlatformCursorImage cursorImage() const override; + void hideCursor() override; + void showCursor() override; + Scene *scene() const { return m_scene; } diff --git a/effects/zoom/zoom.cpp b/effects/zoom/zoom.cpp index 6c9865bd2c..1af89efd02 100644 --- a/effects/zoom/zoom.cpp +++ b/effects/zoom/zoom.cpp @@ -38,7 +38,6 @@ along with this program. If not, see . #include #include #endif -#include namespace KWin { @@ -153,7 +152,7 @@ void ZoomEffect::showCursor() if (isMouseHidden) { disconnect(effects, &EffectsHandler::cursorShapeChanged, this, &ZoomEffect::recreateTexture); // show the previously hidden mouse-pointer again and free the loaded texture/picture. - xcb_xfixes_show_cursor(xcbConnection(), x11RootWindow()); + effects->showCursor(); texture.reset(); #ifdef KWIN_HAVE_XRENDER_COMPOSITING xrenderPicture.reset(); @@ -178,7 +177,7 @@ void ZoomEffect::hideCursor() #endif } if (shouldHide) { - xcb_xfixes_hide_cursor(xcbConnection(), x11RootWindow()); + effects->hideCursor(); connect(effects, &EffectsHandler::cursorShapeChanged, this, &ZoomEffect::recreateTexture); isMouseHidden = true; } diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index e96a777ea2..d57a368d35 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -1192,6 +1192,20 @@ public: **/ virtual PlatformCursorImage cursorImage() const = 0; + /** + * The cursor image should be hidden. + * @see showCursor + * @since 5.9 + **/ + virtual void hideCursor() = 0; + + /** + * The cursor image should be shown again after having been hidden.. + * @see hideCursor + * @since 5.9 + **/ + virtual void showCursor() = 0; + /** * @return @ref KConfigGroup which holds given effect's config options **/