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
icc-effect-5.14.5
Martin Gräßlin 2016-10-18 09:45:49 +02:00
parent ea52ef9e57
commit 5b9da55e75
2 changed files with 10 additions and 20 deletions

View File

@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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<QByteArray> 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

View File

@ -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: