wayland: Send tilt and rotation events, if supported
While tilt is sent on X11, we're currently only sending pressure events and not tilt/rotation events on Wayland. Since Krita is still running in X11, and it's running through XWayland - it's technically a Wayland client and gets no tilt/rotation. This fixes that issue :-) I saw !3231 which was working on complete Wayland tablet support, but it's been stagnating. I just wanted tilt & rotation support now, so I added a way to query capabilities from the `m_capabilities` variable on the private interface we already fetched. Tested on Krita using the Tablet Debug Log.
This commit is contained in:
parent
40ca578bd0
commit
37adc06603
3 changed files with 20 additions and 1 deletions
|
@ -2143,6 +2143,8 @@ public:
|
|||
|
||||
bool tabletToolEvent(TabletEvent *event) override
|
||||
{
|
||||
using namespace KWaylandServer;
|
||||
|
||||
if (!workspace()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -2205,7 +2207,17 @@ public:
|
|||
break;
|
||||
}
|
||||
const quint32 MAX_VAL = 65535;
|
||||
tool->sendPressure(MAX_VAL * event->pressure());
|
||||
|
||||
if (tool->hasCapability(TabletToolV2Interface::Pressure)) {
|
||||
tool->sendPressure(MAX_VAL * event->pressure());
|
||||
}
|
||||
if (tool->hasCapability(TabletToolV2Interface::Tilt)) {
|
||||
tool->sendTilt(event->xTilt(), event->yTilt());
|
||||
}
|
||||
if (tool->hasCapability(TabletToolV2Interface::Rotation)) {
|
||||
tool->sendRotation(event->rotation());
|
||||
}
|
||||
|
||||
tool->sendFrame(event->timestamp());
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -222,6 +222,11 @@ TabletToolV2Interface::~TabletToolV2Interface()
|
|||
}
|
||||
}
|
||||
|
||||
bool TabletToolV2Interface::hasCapability(Capability capability) const
|
||||
{
|
||||
return d->m_capabilities.contains(capability);
|
||||
}
|
||||
|
||||
void TabletToolV2Interface::setCurrentSurface(SurfaceInterface *surface)
|
||||
{
|
||||
if (d->m_surface == surface)
|
||||
|
|
|
@ -83,6 +83,8 @@ public:
|
|||
};
|
||||
Q_ENUM(Capability)
|
||||
|
||||
bool hasCapability(Capability capability) const;
|
||||
|
||||
/**
|
||||
* Sets the surface the events will be sent to.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue