d70bd2435b
This allows for compositor managed different co-ordinate space between kwin's logical co-ordinate space and a client's logical co-ordinate space. When combined with a modified kwin!1959 this allows us to set a DPI in xrdb and mark all xwayland windows as being 2x (or other) and avoid upscales for xwayland clients in a way that doesn't impact other wayland clients or require third-party changes. Any use of fractional values is in layers we control instead of over the wire. kwayland-server is the right place for this abstraction as we need Outputs to differ on a per resource basis. Something we can't control from within kwin. Right now only protocols used by Xwayland are covered. If we covered remaining protocols we can offer user-control on all remaining clients which could open up other possibilities such as a user controlled dynamic resizing, or adapt to possible future protocol changes with wayland scaling.
127 lines
3.4 KiB
C++
127 lines
3.4 KiB
C++
/*
|
|
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
|
|
SPDX-FileCopyrightText: 2020 Adrien Faveraux <ad1rie3@hotmail.fr>
|
|
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
*/
|
|
#include "touch_interface.h"
|
|
#include "clientconnection.h"
|
|
#include "display.h"
|
|
#include "seat_interface.h"
|
|
#include "surface_interface.h"
|
|
#include "touch_interface_p.h"
|
|
|
|
namespace KWaylandServer
|
|
{
|
|
TouchInterfacePrivate *TouchInterfacePrivate::get(TouchInterface *touch)
|
|
{
|
|
return touch->d.data();
|
|
}
|
|
|
|
TouchInterfacePrivate::TouchInterfacePrivate(TouchInterface *q, SeatInterface *seat)
|
|
: q(q)
|
|
, seat(seat)
|
|
{
|
|
}
|
|
|
|
void TouchInterfacePrivate::touch_release(Resource *resource)
|
|
{
|
|
wl_resource_destroy(resource->handle);
|
|
}
|
|
|
|
QList<TouchInterfacePrivate::Resource *> TouchInterfacePrivate::touchesForClient(ClientConnection *client) const
|
|
{
|
|
return resourceMap().values(client->client());
|
|
}
|
|
|
|
TouchInterface::TouchInterface(SeatInterface *seat)
|
|
: d(new TouchInterfacePrivate(this, seat))
|
|
{
|
|
}
|
|
|
|
TouchInterface::~TouchInterface()
|
|
{
|
|
}
|
|
|
|
SurfaceInterface *TouchInterface::focusedSurface() const
|
|
{
|
|
return d->focusedSurface;
|
|
}
|
|
|
|
void TouchInterface::setFocusedSurface(SurfaceInterface *surface)
|
|
{
|
|
d->focusedSurface = surface;
|
|
}
|
|
|
|
void TouchInterface::sendCancel()
|
|
{
|
|
if (!d->focusedSurface) {
|
|
return;
|
|
}
|
|
|
|
const auto touchResources = d->touchesForClient(d->focusedSurface->client());
|
|
for (TouchInterfacePrivate::Resource *resource : touchResources) {
|
|
d->send_cancel(resource->handle);
|
|
}
|
|
}
|
|
|
|
void TouchInterface::sendFrame()
|
|
{
|
|
if (!d->focusedSurface) {
|
|
return;
|
|
}
|
|
|
|
const auto touchResources = d->touchesForClient(d->focusedSurface->client());
|
|
for (TouchInterfacePrivate::Resource *resource : touchResources) {
|
|
d->send_frame(resource->handle);
|
|
}
|
|
}
|
|
|
|
void TouchInterface::sendMotion(qint32 id, const QPointF &localPos)
|
|
{
|
|
if (!d->focusedSurface) {
|
|
return;
|
|
}
|
|
|
|
QPointF pos = d->focusedSurface->toSurfaceLocal(localPos);
|
|
|
|
const auto touchResources = d->touchesForClient(d->focusedSurface->client());
|
|
for (TouchInterfacePrivate::Resource *resource : touchResources) {
|
|
d->send_motion(resource->handle, d->seat->timestamp(), id, wl_fixed_from_double(pos.x()), wl_fixed_from_double(pos.y()));
|
|
}
|
|
}
|
|
|
|
void TouchInterface::sendUp(qint32 id, quint32 serial)
|
|
{
|
|
if (!d->focusedSurface) {
|
|
return;
|
|
}
|
|
|
|
const auto touchResources = d->touchesForClient(d->focusedSurface->client());
|
|
for (TouchInterfacePrivate::Resource *resource : touchResources) {
|
|
d->send_up(resource->handle, serial, d->seat->timestamp(), id);
|
|
}
|
|
}
|
|
|
|
void TouchInterface::sendDown(qint32 id, quint32 serial, const QPointF &localPos)
|
|
{
|
|
if (!d->focusedSurface) {
|
|
return;
|
|
}
|
|
|
|
QPointF pos = d->focusedSurface->toSurfaceLocal(localPos);
|
|
|
|
const auto touchResources = d->touchesForClient(d->focusedSurface->client());
|
|
for (TouchInterfacePrivate::Resource *resource : touchResources) {
|
|
d->send_down(resource->handle,
|
|
serial,
|
|
d->seat->timestamp(),
|
|
d->focusedSurface->resource(),
|
|
id,
|
|
wl_fixed_from_double(pos.x()),
|
|
wl_fixed_from_double(pos.y()));
|
|
}
|
|
}
|
|
|
|
} // namespace KWaylandServer
|