From 5b9da55e75e1dd435ec3d4799e8743bb76d6e5c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 18 Oct 2016 09:45:49 +0200 Subject: [PATCH] Implement cursor shape tracking on Wayland Summary: So far the tracking for cursor shape was done incorrectly on Wayland by only listening to X11 cursor changes. That's from a time when KWin/Wayland was still run on top of an X server. Nowadays the Platform tracks cursor shape changes and emits changes to it. Xwayland cursor changes go through the normal Wayland way so it's just one way to get it on Wayland. This change adds the required connect and changes the signal signature in Cursor by dropping the serial argument. No user of the signal uses the argument and on Wayland we don't have a serial for the cursor. So it can be dropped. Test Plan: Zoom effect updates cursor shape correctly on Wayland Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D3095 --- cursor.cpp | 27 +++++++++------------------ cursor.h | 3 +-- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/cursor.cpp b/cursor.cpp index 69f4918b25..e8f9646336 100644 --- a/cursor.cpp +++ b/cursor.cpp @@ -24,6 +24,7 @@ along with this program. If not, see . #include "input.h" #include "keyboard_input.h" #include "main.h" +#include "platform.h" #include "utils.h" #include "xcbutils.h" // KDE @@ -228,11 +229,12 @@ void Cursor::doStopCursorTracking() void Cursor::notifyCursorChanged(uint32_t serial) { + Q_UNUSED(serial) if (m_cursorTrackingCounter <= 0) { // cursor change tracking is currently disabled, so don't emit signal return; } - emit cursorChanged(serial); + emit cursorChanged(); } QVector Cursor::cursorAlternativeNames(const QByteArray &name) const @@ -388,13 +390,6 @@ InputRedirectionCursor::InputRedirectionCursor(QObject *parent) #ifndef KCMRULES connect(input(), &InputRedirection::keyboardModifiersChanged, this, &InputRedirectionCursor::slotModifiersChanged); - connect(kwinApp(), &Application::x11ConnectionChanged, this, - [this] { - if (isCursorTracking()) { - doStartCursorTracking(); - } - }, Qt::QueuedConnection - ); #endif } @@ -434,20 +429,16 @@ void InputRedirectionCursor::slotPointerButtonChanged() void InputRedirectionCursor::doStartCursorTracking() { - if (!kwinApp()->x11Connection()) { - return; - } - xcb_xfixes_select_cursor_input(connection(), rootWindow(), XCB_XFIXES_CURSOR_NOTIFY_MASK_DISPLAY_CURSOR); - // TODO: also track the Wayland cursor +#ifndef KCMRULES + connect(kwinApp()->platform(), &Platform::cursorChanged, this, &Cursor::cursorChanged); +#endif } void InputRedirectionCursor::doStopCursorTracking() { - if (!kwinApp()->x11Connection()) { - return; - } - xcb_xfixes_select_cursor_input(connection(), rootWindow(), 0); - // TODO: also track the Wayland cursor +#ifndef KCMRULES + disconnect(kwinApp()->platform(), &Platform::cursorChanged, this, &Cursor::cursorChanged); +#endif } } // namespace diff --git a/cursor.h b/cursor.h index a5f82b7244..f81d214423 100644 --- a/cursor.h +++ b/cursor.h @@ -141,11 +141,10 @@ Q_SIGNALS: * * To enable these signals use @link startCursorTracking. * - * @param serial The serial number of the new selected cursor. * @see startCursorTracking * @see stopCursorTracking */ - void cursorChanged(uint32_t serial); + void cursorChanged(); void themeChanged(); protected: