[wayland] Support pointer warping in the backends
The X11 backend can warp the pointer.
This commit is contained in:
parent
74c111ef88
commit
06fc00b4a9
7 changed files with 42 additions and 7 deletions
|
@ -304,4 +304,9 @@ void AbstractBackend::setReady(bool ready)
|
|||
emit readyChanged(m_ready);
|
||||
}
|
||||
|
||||
void AbstractBackend::warpPointer(const QPointF &globalPos)
|
||||
{
|
||||
Q_UNUSED(globalPos)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
virtual Screens *createScreens(QObject *parent = nullptr);
|
||||
virtual OpenGLBackend *createOpenGLBackend();
|
||||
virtual QPainterBackend *createQPainterBackend();
|
||||
virtual void warpPointer(const QPointF &globalPos);
|
||||
|
||||
bool usesSoftwareCursor() const {
|
||||
return m_softWareCursor;
|
||||
|
@ -67,6 +68,9 @@ public:
|
|||
void setDeviceIdentifier(const QByteArray &identifier) {
|
||||
m_deviceIdentifier = identifier;
|
||||
}
|
||||
bool supportsPointerWarping() const {
|
||||
return m_pointerWarping;
|
||||
}
|
||||
|
||||
public Q_SLOTS:
|
||||
void pointerMotion(const QPointF &position, quint32 time);
|
||||
|
@ -106,6 +110,9 @@ protected:
|
|||
QByteArray deviceIdentifier() const {
|
||||
return m_deviceIdentifier;
|
||||
}
|
||||
void setSupportsPointerWarping(bool set) {
|
||||
m_pointerWarping = set;
|
||||
}
|
||||
|
||||
private:
|
||||
void triggerCursorRepaint();
|
||||
|
@ -121,6 +128,7 @@ private:
|
|||
bool m_ready = false;
|
||||
QSize m_initialWindowSize;
|
||||
QByteArray m_deviceIdentifier;
|
||||
bool m_pointerWarping = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ namespace KWin
|
|||
X11WindowedBackend::X11WindowedBackend(QObject *parent)
|
||||
: AbstractBackend(parent)
|
||||
{
|
||||
setSupportsPointerWarping(true);
|
||||
}
|
||||
|
||||
X11WindowedBackend::~X11WindowedBackend()
|
||||
|
@ -339,4 +340,10 @@ QPainterBackend *X11WindowedBackend::createQPainterBackend()
|
|||
return new X11WindowedQPainterBackend(this);
|
||||
}
|
||||
|
||||
void X11WindowedBackend::warpPointer(const QPointF &globalPos)
|
||||
{
|
||||
xcb_warp_pointer(m_connection, m_window, m_window, 0, 0, 0, 0, globalPos.x(), globalPos.y());
|
||||
xcb_flush(m_connection);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ public:
|
|||
Screens *createScreens(QObject *parent = nullptr) override;
|
||||
OpenGLBackend *createOpenGLBackend() override;
|
||||
QPainterBackend* createQPainterBackend() override;
|
||||
void warpPointer(const QPointF &globalPos) override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void sizeChanged();
|
||||
|
|
17
input.cpp
17
input.cpp
|
@ -1049,9 +1049,24 @@ void InputRedirection::updatePointerAfterScreenChange()
|
|||
|
||||
void InputRedirection::warpPointer(const QPointF &pos)
|
||||
{
|
||||
if (m_pointerWarping) {
|
||||
if (supportsPointerWarping()) {
|
||||
#if HAVE_WAYLAND
|
||||
if (waylandServer()) {
|
||||
waylandServer()->backend()->warpPointer(pos);
|
||||
}
|
||||
#endif
|
||||
updatePointerPosition(pos);
|
||||
}
|
||||
}
|
||||
|
||||
bool InputRedirection::supportsPointerWarping() const
|
||||
{
|
||||
#if HAVE_WAYLAND
|
||||
if (waylandServer() && waylandServer()->backend()->supportsPointerWarping()) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return m_pointerWarping;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
6
input.h
6
input.h
|
@ -287,12 +287,6 @@ void InputRedirection::registerShortcut(const QKeySequence &shortcut, QAction *a
|
|||
connect(action, &QAction::triggered, receiver, slot);
|
||||
}
|
||||
|
||||
inline
|
||||
bool InputRedirection::supportsPointerWarping() const
|
||||
{
|
||||
return m_pointerWarping;
|
||||
}
|
||||
|
||||
#if HAVE_XKB
|
||||
inline
|
||||
Qt::KeyboardModifiers Xkb::modifiers() const
|
||||
|
|
|
@ -42,3 +42,8 @@ Qt::KeyboardModifiers KWin::InputRedirection::keyboardModifiers() const
|
|||
void KWin::InputRedirection::warpPointer(const QPointF&)
|
||||
{
|
||||
}
|
||||
|
||||
bool KWin::InputRedirection::supportsPointerWarping() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue