Remove touch-extension protocol

This removes the special case touch-extension protocol for Qt.
Touch input should work with all compositors, not just Qt-based,
through the wl_touch interface, and the world has come a long
way since this was added.

Task-number: QTBUG-133223
Change-Id: I89d404ac87270d8b3c6a9015d3a72fac5919b0b9
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2025-02-11 15:02:38 +01:00
parent 8de2aae8c1
commit d7731dd110
7 changed files with 0 additions and 322 deletions

View File

@ -1,38 +0,0 @@
<protocol name="touch_extension">
<copyright>
Copyright (C) 2015 The Qt Company Ltd.
SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
</copyright>
<interface name="qt_touch_extension" version="1">
<event name="touch">
<arg name="time" type="uint" />
<arg name="id" type="uint" />
<arg name="state" type="uint" />
<arg name="x" type="int" />
<arg name="y" type="int" />
<arg name="normalized_x" type="int" />
<arg name="normalized_y" type="int" />
<arg name="width" type="int" />
<arg name="height" type="int" />
<arg name="pressure" type="uint" />
<arg name="velocity_x" type="int" />
<arg name="velocity_y" type="int" />
<arg name="flags" type="uint" />
<arg name="rawdata" type="array" />
</event>
<enum name="flags">
<entry name="mouse_from_touch" value="0x1" />
</enum>
<event name="configure">
<arg name="flags" type="uint" />
</event>
<request name="dummy">
</request>
</interface>
</protocol>

View File

@ -52,7 +52,6 @@ qt_internal_add_module(WaylandClient
qwaylandshmwindow.cpp qwaylandshmwindow_p.h
qwaylandsubsurface.cpp qwaylandsubsurface_p.h
qwaylandsurface.cpp qwaylandsurface_p.h
qwaylandtouch.cpp qwaylandtouch_p.h
qwaylandviewport.cpp qwaylandviewport_p.h
qwaylandwindow.cpp qwaylandwindow_p.h
qwaylandwindowmanagerintegration.cpp qwaylandwindowmanagerintegration_p.h
@ -117,7 +116,6 @@ qt6_generate_wayland_protocol_client_sources(WaylandClient
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/xdg-toplevel-drag/xdg-toplevel-drag-v1.xml
${CMAKE_CURRENT_SOURCE_DIR}/../extensions/qt-text-input-method-unstable-v1.xml
${CMAKE_CURRENT_SOURCE_DIR}/../extensions/qt-windowmanager.xml
${CMAKE_CURRENT_SOURCE_DIR}/../extensions/touch-extension.xml
${CMAKE_CURRENT_SOURCE_DIR}/hardwareintegration/../../extensions/hardware-integration.xml
${CMAKE_CURRENT_SOURCE_DIR}/hardwareintegration/../../extensions/server-buffer-extension.xml
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/color-management/xx-color-management-v4.xml

View File

@ -39,7 +39,6 @@
#include "qwaylandpointergestures_p.h"
#include "qwaylandsubsurface_p.h"
#include "qwaylandtouch_p.h"
#if QT_CONFIG(tabletevent)
#include "qwaylandtabletv2_p.h"
#endif
@ -668,8 +667,6 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
mGlobals.subCompositor.reset(
new WithDestructor<QtWayland::wl_subcompositor, wl_subcompositor_destroy>(registry,
id, 1));
} else if (interface == QLatin1String(QWaylandTouchExtension::interface()->name)) {
mGlobals.touchExtension.reset(new QWaylandTouchExtension(this, id));
#if QT_CONFIG(tabletevent)
} else if (interface == QLatin1String(QWaylandTabletManagerV2::interface()->name)) {
mGlobals.tabletManager.reset(new QWaylandTabletManagerV2(this, id, qMin(1, int(version))));

View File

@ -82,7 +82,6 @@ class QWaylandPrimarySelectionDeviceManagerV1;
class QWaylandTabletManagerV2;
#endif
class QWaylandPointerGestures;
class QWaylandTouchExtension;
class QWaylandWindow;
class QWaylandIntegration;
class QWaylandHardwareIntegration;
@ -174,10 +173,6 @@ public:
{
return mGlobals.pointerGestures.get();
}
QWaylandTouchExtension *touchExtension() const
{
return mGlobals.touchExtension.get();
}
QtWayland::qt_text_input_method_manager_v1 *textInputMethodManager() const
{
return mGlobals.textInputMethodManager.get();
@ -342,7 +337,6 @@ private:
std::unique_ptr<QWaylandDataDeviceManager> dndSelectionHandler;
#endif
std::unique_ptr<QtWayland::wl_subcompositor> subCompositor;
std::unique_ptr<QWaylandTouchExtension> touchExtension;
#if QT_CONFIG(tabletevent)
std::unique_ptr<QWaylandTabletManagerV2> tabletManager;
#endif

View File

@ -23,7 +23,6 @@
#include "qwaylandtabletv2_p.h"
#endif
#include "qwaylandpointergestures_p.h"
#include "qwaylandtouch_p.h"
#include "qwaylandscreen_p.h"
#include "qwaylandcursor_p.h"
#include "qwaylanddisplay_p.h"
@ -1457,10 +1456,6 @@ void QWaylandInputDevice::Touch::touch_cancel()
{
mPendingTouchPoints.clear();
QWaylandTouchExtension *touchExt = mParent->mQDisplay->touchExtension();
if (touchExt)
touchExt->touchCanceled();
mFocus = nullptr;
QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
}

View File

@ -1,189 +0,0 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qwaylandtouch_p.h"
#include "qwaylandinputdevice_p.h"
#include "qwaylanddisplay_p.h"
#include "qwaylandsurface_p.h"
#include <QtGui/QPointingDevice>
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
QWaylandTouchExtension::QWaylandTouchExtension(QWaylandDisplay *display, uint32_t id)
: QtWayland::qt_touch_extension(display->wl_registry(), id, 1),
mDisplay(display),
mTouchDevice(nullptr),
mPointsLeft(0),
mFlags(0),
mMouseSourceId(-1),
mInputDevice(nullptr)
{
}
QWaylandTouchExtension::~QWaylandTouchExtension()
{
qt_touch_extension_destroy(object());
}
void QWaylandTouchExtension::registerDevice(int caps)
{
// TODO number of touchpoints, actual name and ID
mTouchDevice = new QPointingDevice(QLatin1String("some touchscreen"), 0,
QInputDevice::DeviceType::TouchScreen, QPointingDevice::PointerType::Finger,
QInputDevice::Capabilities(caps), 10, 0);
QWindowSystemInterface::registerInputDevice(mTouchDevice);
}
static inline qreal fromFixed(int f)
{
return f / qreal(10000);
}
void QWaylandTouchExtension::touch_extension_touch(uint32_t time,
uint32_t id, uint32_t state, int32_t x, int32_t y,
int32_t normalized_x, int32_t normalized_y,
int32_t width, int32_t height, uint32_t pressure,
int32_t velocity_x, int32_t velocity_y,
uint32_t flags, wl_array *rawdata)
{
if (!mInputDevice) {
QList<QWaylandInputDevice *> inputDevices = mDisplay->inputDevices();
if (inputDevices.isEmpty()) {
qWarning("qt_touch_extension: handle_touch: No input devices");
return;
}
mInputDevice = inputDevices.first();
}
QWaylandWindow *win = mInputDevice->touchFocus();
if (!win)
win = mInputDevice->pointerFocus();
if (!win)
win = mInputDevice->keyboardFocus();
if (!win || !win->window()) {
qWarning("qt_touch_extension: handle_touch: No pointer focus");
return;
}
mTargetWindow = win->window();
QWindowSystemInterface::TouchPoint tp;
tp.id = id;
tp.state = QEventPoint::State(int(state & 0xFFFF));
int sentPointCount = state >> 16;
if (!mPointsLeft) {
Q_ASSERT(sentPointCount > 0);
mPointsLeft = sentPointCount;
}
if (!mTouchDevice)
registerDevice(flags >> 16);
tp.area = QRectF(0, 0, fromFixed(width), fromFixed(height));
// Got surface-relative coords but need a (virtual) screen position.
QPointF relPos = QPointF(fromFixed(x), fromFixed(y));
tp.area.moveCenter(mTargetWindow->mapToGlobal(relPos));
tp.normalPosition.setX(fromFixed(normalized_x));
tp.normalPosition.setY(fromFixed(normalized_y));
tp.pressure = pressure / 255.0;
tp.velocity.setX(fromFixed(velocity_x));
tp.velocity.setY(fromFixed(velocity_y));
if (rawdata) {
const int rawPosCount = rawdata->size / sizeof(float) / 2;
float *p = static_cast<float *>(rawdata->data);
for (int i = 0; i < rawPosCount; ++i) {
float x = *p++;
float y = *p++;
tp.rawPositions.append(QPointF(x, y));
}
}
mTouchPoints.append(tp);
mTimestamp = time;
if (!--mPointsLeft)
sendTouchEvent();
}
void QWaylandTouchExtension::sendTouchEvent()
{
// Copy all points, that are in the previous but not in the current list, as stationary.
for (int i = 0; i < mPrevTouchPoints.size(); ++i) {
const QWindowSystemInterface::TouchPoint &prevPoint(mPrevTouchPoints.at(i));
if (prevPoint.state == QEventPoint::Released)
continue;
bool found = false;
for (int j = 0; j < mTouchPoints.size(); ++j)
if (mTouchPoints.at(j).id == prevPoint.id) {
found = true;
break;
}
if (!found) {
QWindowSystemInterface::TouchPoint p = prevPoint;
p.state = QEventPoint::Stationary;
mTouchPoints.append(p);
}
}
if (mTouchPoints.isEmpty()) {
mPrevTouchPoints.clear();
return;
}
QWindowSystemInterface::handleTouchEvent(mTargetWindow, mTimestamp, mTouchDevice, mTouchPoints);
QEventPoint::States states = {};
for (int i = 0; i < mTouchPoints.size(); ++i)
states |= mTouchPoints.at(i).state;
if (mFlags & QT_TOUCH_EXTENSION_FLAGS_MOUSE_FROM_TOUCH) {
const bool firstPress = states == QEventPoint::Pressed;
if (firstPress)
mMouseSourceId = mTouchPoints.first().id;
for (int i = 0; i < mTouchPoints.size(); ++i) {
const QWindowSystemInterface::TouchPoint &tp(mTouchPoints.at(i));
if (tp.id == mMouseSourceId) {
const bool released = tp.state == QEventPoint::Released;
Qt::MouseButtons buttons = released ? Qt::NoButton : Qt::LeftButton;
QEvent::Type eventType = firstPress ? QEvent::MouseButtonPress
: released ? QEvent::MouseButtonRelease
: QEvent::MouseMove;
mLastMouseGlobal = tp.area.center();
QPoint globalPoint = mLastMouseGlobal.toPoint();
QPointF delta = mLastMouseGlobal - globalPoint;
mLastMouseLocal = mTargetWindow->mapFromGlobal(globalPoint) + delta;
QWindowSystemInterface::handleMouseEvent(mTargetWindow, mTimestamp, mLastMouseLocal, mLastMouseGlobal,
buttons, Qt::LeftButton, eventType);
if (buttons == Qt::NoButton)
mMouseSourceId = -1;
break;
}
}
}
mPrevTouchPoints = mTouchPoints;
mTouchPoints.clear();
if (states == QEventPoint::Released)
mPrevTouchPoints.clear();
}
void QWaylandTouchExtension::touchCanceled()
{
mTouchPoints.clear();
mPrevTouchPoints.clear();
if (mMouseSourceId != -1)
QWindowSystemInterface::handleMouseEvent(mTargetWindow, mTimestamp, mLastMouseLocal, mLastMouseGlobal, Qt::NoButton, Qt::LeftButton, QEvent::MouseButtonRelease);
}
void QWaylandTouchExtension::touch_extension_configure(uint32_t flags)
{
mFlags = flags;
}
}
QT_END_NAMESPACE

View File

@ -1,79 +0,0 @@
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QWAYLANDTOUCH_H
#define QWAYLANDTOUCH_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <qpa/qwindowsysteminterface.h>
#include <QtWaylandClient/private/qwayland-touch-extension.h>
#include <QtWaylandClient/qtwaylandclientglobal.h>
#include <QtCore/private/qglobal_p.h>
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
class QWaylandDisplay;
class QWaylandInputDevice;
class Q_WAYLANDCLIENT_EXPORT QWaylandTouchExtension : public QtWayland::qt_touch_extension
{
public:
QWaylandTouchExtension(QWaylandDisplay *display, uint32_t id);
~QWaylandTouchExtension() override;
void touchCanceled();
private:
void registerDevice(int caps);
QWaylandDisplay *mDisplay = nullptr;
void touch_extension_touch(uint32_t time,
uint32_t id,
uint32_t state,
int32_t x,
int32_t y,
int32_t normalized_x,
int32_t normalized_y,
int32_t width,
int32_t height,
uint32_t pressure,
int32_t velocity_x,
int32_t velocity_y,
uint32_t flags,
struct wl_array *rawdata) override;
void touch_extension_configure(uint32_t flags) override;
void sendTouchEvent();
QList<QWindowSystemInterface::TouchPoint> mTouchPoints;
QList<QWindowSystemInterface::TouchPoint> mPrevTouchPoints;
QPointingDevice *mTouchDevice = nullptr;
uint32_t mTimestamp;
int mPointsLeft;
uint32_t mFlags;
int mMouseSourceId;
QPointF mLastMouseLocal;
QPointF mLastMouseGlobal;
QWindow *mTargetWindow = nullptr;
QWaylandInputDevice *mInputDevice = nullptr;
};
}
QT_END_NAMESPACE
#endif // QWAYLANDTOUCH_H