mousepad: Implement relative mouse movements
Somehow it wasn't done.
This commit is contained in:
parent
bbac0aa085
commit
9266556510
4 changed files with 62 additions and 3 deletions
|
@ -61,7 +61,7 @@ Kirigami.Page
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: PointerLocker
|
target: PointerLocker
|
||||||
function onPointerMoved() {
|
function onPointerMoved(delta) {
|
||||||
if (!PointerLocker.isLocked) {
|
if (!PointerLocker.isLocked) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,15 @@ if(UNIX AND NOT APPLE)
|
||||||
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml
|
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml
|
||||||
BASENAME pointer-constraints-unstable-v1
|
BASENAME pointer-constraints-unstable-v1
|
||||||
)
|
)
|
||||||
|
ecm_add_qtwayland_client_protocol(wayland_SRCS
|
||||||
|
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml
|
||||||
|
BASENAME relative-pointer-unstable-v1
|
||||||
|
)
|
||||||
else()
|
else()
|
||||||
qt6_generate_wayland_protocol_client_sources(kdeconnectdeclarativeplugin FILES
|
qt6_generate_wayland_protocol_client_sources(kdeconnectdeclarativeplugin FILES
|
||||||
${WaylandProtocols_DATADIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml)
|
${WaylandProtocols_DATADIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml)
|
||||||
|
qt6_generate_wayland_protocol_client_sources(kdeconnectdeclarativeplugin FILES
|
||||||
|
${WaylandProtocols_DATADIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_sources(kdeconnectdeclarativeplugin PRIVATE ${wayland_SRCS})
|
target_sources(kdeconnectdeclarativeplugin PRIVATE ${wayland_SRCS})
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "qwayland-pointer-constraints-unstable-v1.h"
|
#include "qwayland-pointer-constraints-unstable-v1.h"
|
||||||
|
#include "qwayland-relative-pointer-unstable-v1.h"
|
||||||
#include <QtWaylandClient/qwaylandclientextension.h>
|
#include <QtWaylandClient/qwaylandclientextension.h>
|
||||||
#include <qpa/qplatformnativeinterface.h>
|
#include <qpa/qplatformnativeinterface.h>
|
||||||
|
|
||||||
|
@ -50,9 +51,52 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RelativePointerManagerV1 : public QWaylandClientExtensionTemplate<RelativePointerManagerV1>, public QtWayland::zwp_relative_pointer_manager_v1
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit RelativePointerManagerV1()
|
||||||
|
: QWaylandClientExtensionTemplate<RelativePointerManagerV1>(1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~RelativePointerManagerV1()
|
||||||
|
{
|
||||||
|
destroy();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class RelativePointerV1 : public QtWayland::zwp_relative_pointer_v1
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit RelativePointerV1(PointerLockerWayland *locker, struct ::zwp_relative_pointer_v1 *p)
|
||||||
|
: QtWayland::zwp_relative_pointer_v1(p)
|
||||||
|
, locker(locker)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~RelativePointerV1()
|
||||||
|
{
|
||||||
|
destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void zwp_relative_pointer_v1_relative_motion(uint32_t /*utime_hi*/,
|
||||||
|
uint32_t /*utime_lo*/,
|
||||||
|
wl_fixed_t dx,
|
||||||
|
wl_fixed_t dy,
|
||||||
|
wl_fixed_t /*dx_unaccel*/,
|
||||||
|
wl_fixed_t /*dy_unaccel*/) override
|
||||||
|
{
|
||||||
|
locker->pointerMoved({wl_fixed_to_double(dx), wl_fixed_to_double(dy)});
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
PointerLockerWayland *const locker;
|
||||||
|
};
|
||||||
|
|
||||||
PointerLockerWayland::PointerLockerWayland(QObject *parent)
|
PointerLockerWayland::PointerLockerWayland(QObject *parent)
|
||||||
: AbstractPointerLocker(parent)
|
: AbstractPointerLocker(parent)
|
||||||
{
|
{
|
||||||
|
m_relativePointerMgr = std::make_unique<RelativePointerManagerV1>();
|
||||||
m_pointerConstraints = new PointerConstraints;
|
m_pointerConstraints = new PointerConstraints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +128,11 @@ void PointerLockerWayland::enforceLock()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto pointer = getPointer();
|
||||||
|
if (!m_relativePointer) {
|
||||||
|
m_relativePointer.reset(new RelativePointerV1(this, m_relativePointerMgr->get_relative_pointer(pointer)));
|
||||||
|
}
|
||||||
|
|
||||||
wl_surface *wlSurface = [](QWindow *window) -> wl_surface * {
|
wl_surface *wlSurface = [](QWindow *window) -> wl_surface * {
|
||||||
if (!window) {
|
if (!window) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -98,7 +147,7 @@ void PointerLockerWayland::enforceLock()
|
||||||
}(m_window);
|
}(m_window);
|
||||||
|
|
||||||
m_lockedPointer =
|
m_lockedPointer =
|
||||||
new LockedPointer(m_pointerConstraints->lock_pointer(wlSurface, getPointer(), nullptr, PointerConstraints::lifetime::lifetime_persistent), this);
|
new LockedPointer(m_pointerConstraints->lock_pointer(wlSurface, pointer, nullptr, PointerConstraints::lifetime::lifetime_persistent), this);
|
||||||
|
|
||||||
if (!m_lockedPointer) {
|
if (!m_lockedPointer) {
|
||||||
qDebug() << "ERROR when receiving locked pointer!";
|
qDebug() << "ERROR when receiving locked pointer!";
|
||||||
|
|
|
@ -10,8 +10,10 @@
|
||||||
#include "pointerlocker.h"
|
#include "pointerlocker.h"
|
||||||
|
|
||||||
class PointerConstraints;
|
class PointerConstraints;
|
||||||
|
class RelativePointerManagerV1;
|
||||||
|
class RelativePointerV1;
|
||||||
class LockedPointer;
|
class LockedPointer;
|
||||||
class wl_pointer;
|
struct wl_pointer;
|
||||||
|
|
||||||
class PointerLockerWayland : public AbstractPointerLocker
|
class PointerLockerWayland : public AbstractPointerLocker
|
||||||
{
|
{
|
||||||
|
@ -44,6 +46,8 @@ private:
|
||||||
|
|
||||||
PointerConstraints *m_pointerConstraints;
|
PointerConstraints *m_pointerConstraints;
|
||||||
LockedPointer *m_lockedPointer = nullptr;
|
LockedPointer *m_lockedPointer = nullptr;
|
||||||
|
std::unique_ptr<RelativePointerManagerV1> m_relativePointerMgr;
|
||||||
|
std::unique_ptr<RelativePointerV1> m_relativePointer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue