!8 Accepting the tablet serial for the xdg_toplevel move/resize function
Merge pull request !8 from 刘杰/work/tablet
This commit is contained in:
parent
8e7fc0f6e6
commit
be82be6502
|
@ -1,3 +1,9 @@
|
|||
kwayland-server (5.24.4-ok4.4) nile; urgency=medium
|
||||
|
||||
* Accepting the tablet serial for the xdg_toplevel move/resize function.
|
||||
|
||||
-- Jie Liu <liujie01@kylinos.cn> Mon, 19 Feb 2024 18:09:41 +0800
|
||||
|
||||
kwayland-server (5.24.4-ok4.3) nile; urgency=medium
|
||||
|
||||
* Add dialog-v1 protocols.
|
||||
|
|
237
debian/patches/0006-8-Accepting-the-tablet-serial-for-the-xdg_toplevel-m.patch
vendored
Normal file
237
debian/patches/0006-8-Accepting-the-tablet-serial-for-the-xdg_toplevel-m.patch
vendored
Normal file
|
@ -0,0 +1,237 @@
|
|||
From: =?utf-8?b?5YiY5p2w?= <liujie01@kylinos.cn>
|
||||
Date: Mon, 19 Feb 2024 10:11:09 +0000
|
||||
Subject: =?utf-8?q?!8_Accepting_the_tablet_serial_for_the_xdg=5Ftoplevel_mo?=
|
||||
=?utf-8?q?ve/resize_function_Merge_pull_request_!8_from_=E5=88=98=E6=9D=B0?=
|
||||
=?utf-8?q?/work/tablet?=
|
||||
|
||||
---
|
||||
autotests/server/test_tablet_interface.cpp | 3 +-
|
||||
src/server/tablet_v2_interface.cpp | 65 ++++++++++++++++++++----------
|
||||
src/server/tablet_v2_interface.h | 20 ++++-----
|
||||
3 files changed, 55 insertions(+), 33 deletions(-)
|
||||
|
||||
diff --git a/autotests/server/test_tablet_interface.cpp b/autotests/server/test_tablet_interface.cpp
|
||||
index 282ffbc..ec1f1b8 100644
|
||||
--- a/autotests/server/test_tablet_interface.cpp
|
||||
+++ b/autotests/server/test_tablet_interface.cpp
|
||||
@@ -265,7 +265,8 @@ void TestTabletInterface::testAdd()
|
||||
QCOMPARE(m_tabletSeatClient->m_tablets.count(), 1);
|
||||
|
||||
QSignalSpy toolSpy(m_tabletSeatClient, &TabletSeat::toolAdded);
|
||||
- m_tool = seatInterface->addTool(KWaylandServer::TabletToolV2Interface::Pen, 0, 0, {TabletToolV2Interface::Tilt, TabletToolV2Interface::Pressure});
|
||||
+ m_tool =
|
||||
+ seatInterface->addTool(KWaylandServer::TabletToolV2Interface::Pen, 0, 0, {TabletToolV2Interface::Tilt, TabletToolV2Interface::Pressure}, "my tablet");
|
||||
QVERIFY(m_tool);
|
||||
QVERIFY(toolSpy.wait() || toolSpy.count() == 1);
|
||||
QCOMPARE(m_tabletSeatClient->m_tools.count(), 1);
|
||||
diff --git a/src/server/tablet_v2_interface.cpp b/src/server/tablet_v2_interface.cpp
|
||||
index 8af8060..c025c78 100644
|
||||
--- a/src/server/tablet_v2_interface.cpp
|
||||
+++ b/src/server/tablet_v2_interface.cpp
|
||||
@@ -189,6 +189,7 @@ public:
|
||||
}
|
||||
|
||||
Display *const m_display;
|
||||
+ quint32 m_downSerial = 0;
|
||||
bool m_cleanup = false;
|
||||
bool m_removed = false;
|
||||
QPointer<SurfaceInterface> m_surface;
|
||||
@@ -207,10 +208,8 @@ TabletToolV2Interface::TabletToolV2Interface(Display *display,
|
||||
uint32_t hsl,
|
||||
uint32_t hih,
|
||||
uint32_t hil,
|
||||
- const QVector<Capability> &capabilities,
|
||||
- QObject *parent)
|
||||
- : QObject(parent)
|
||||
- , d(new TabletToolV2InterfacePrivate(this, display, type, hsh, hsl, hih, hil, capabilities))
|
||||
+ const QVector<Capability> &capabilities)
|
||||
+ : d(new TabletToolV2InterfacePrivate(this, display, type, hsh, hsl, hih, hil, capabilities))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -244,6 +243,11 @@ void TabletToolV2Interface::setCurrentSurface(SurfaceInterface *surface)
|
||||
Q_EMIT cursorChanged(d->m_cursors.value(d->targetResource()));
|
||||
}
|
||||
|
||||
+quint32 TabletToolV2Interface::downSerial() const
|
||||
+{
|
||||
+ return d->m_downSerial;
|
||||
+}
|
||||
+
|
||||
bool TabletToolV2Interface::isClientSupported() const
|
||||
{
|
||||
return d->m_surface && d->targetResource();
|
||||
@@ -318,12 +322,15 @@ void TabletToolV2Interface::sendProximityOut()
|
||||
|
||||
void TabletToolV2Interface::sendDown()
|
||||
{
|
||||
- d->send_down(d->targetResource(), d->m_display->nextSerial());
|
||||
+ const auto serial = d->m_display->nextSerial();
|
||||
+ d->send_down(d->targetResource(), serial);
|
||||
+ d->m_downSerial = serial;
|
||||
}
|
||||
|
||||
void TabletToolV2Interface::sendUp()
|
||||
{
|
||||
d->send_up(d->targetResource());
|
||||
+ d->m_downSerial = 0;
|
||||
}
|
||||
|
||||
class TabletPadRingV2InterfacePrivate : public QtWaylandServer::zwp_tablet_pad_ring_v2
|
||||
@@ -626,8 +633,10 @@ public:
|
||||
sendPadAdded(resource, pad);
|
||||
}
|
||||
|
||||
- for (auto *tool : qAsConst(m_tools)) {
|
||||
- sendToolAdded(resource, tool);
|
||||
+ for (const auto &tools : std::as_const(m_tools)) {
|
||||
+ for (auto *tool : tools) {
|
||||
+ sendToolAdded(resource, tool);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -689,7 +698,7 @@ public:
|
||||
}
|
||||
|
||||
TabletSeatV2Interface *const q;
|
||||
- QVector<TabletToolV2Interface *> m_tools;
|
||||
+ QHash<QString, QList<TabletToolV2Interface *>> m_tools;
|
||||
QHash<QString, TabletV2Interface *> m_tablets;
|
||||
QHash<QString, TabletPadV2Interface *> m_pads;
|
||||
Display *const m_display;
|
||||
@@ -706,7 +715,8 @@ TabletSeatV2Interface::~TabletSeatV2Interface() = default;
|
||||
TabletToolV2Interface *TabletSeatV2Interface::addTool(TabletToolV2Interface::Type type,
|
||||
quint64 hardwareSerial,
|
||||
quint64 hardwareId,
|
||||
- const QVector<TabletToolV2Interface::Capability> &capabilities)
|
||||
+ const QVector<TabletToolV2Interface::Capability> &capabilities,
|
||||
+ const QString &deviceSysName)
|
||||
{
|
||||
constexpr auto MAX_UINT_32 = std::numeric_limits<quint32>::max();
|
||||
auto tool = new TabletToolV2Interface(d->m_display,
|
||||
@@ -715,17 +725,12 @@ TabletToolV2Interface *TabletSeatV2Interface::addTool(TabletToolV2Interface::Typ
|
||||
hardwareSerial & MAX_UINT_32,
|
||||
hardwareId >> 32,
|
||||
hardwareId & MAX_UINT_32,
|
||||
- capabilities,
|
||||
- this);
|
||||
+ capabilities);
|
||||
for (QtWaylandServer::zwp_tablet_seat_v2::Resource *resource : d->resourceMap()) {
|
||||
d->sendToolAdded(resource, tool);
|
||||
}
|
||||
|
||||
- d->m_tools.append(tool);
|
||||
- QObject::connect(tool, &QObject::destroyed, this, [this](QObject *object) {
|
||||
- auto tti = static_cast<TabletToolV2Interface *>(object);
|
||||
- d->m_tools.removeAll(tti);
|
||||
- });
|
||||
+ d->m_tools[deviceSysName].append(tool);
|
||||
return tool;
|
||||
}
|
||||
|
||||
@@ -771,13 +776,17 @@ void TabletSeatV2Interface::removeDevice(const QString &sysname)
|
||||
{
|
||||
delete d->m_tablets.take(sysname);
|
||||
delete d->m_pads.take(sysname);
|
||||
+
|
||||
+ qDeleteAll(d->m_tools.take(sysname));
|
||||
}
|
||||
|
||||
TabletToolV2Interface *TabletSeatV2Interface::toolByHardwareId(quint64 hardwareId) const
|
||||
{
|
||||
- for (TabletToolV2Interface *tool : qAsConst(d->m_tools)) {
|
||||
- if (tool->d->hardwareId() == hardwareId) {
|
||||
- return tool;
|
||||
+ for (const auto &tools : std::as_const(d->m_tools)) {
|
||||
+ for (TabletToolV2Interface *tool : tools) {
|
||||
+ if (tool->d->hardwareId() == hardwareId) {
|
||||
+ return tool;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
@@ -785,9 +794,12 @@ TabletToolV2Interface *TabletSeatV2Interface::toolByHardwareId(quint64 hardwareI
|
||||
|
||||
TabletToolV2Interface *TabletSeatV2Interface::toolByHardwareSerial(quint64 hardwareSerial, TabletToolV2Interface::Type type) const
|
||||
{
|
||||
- for (TabletToolV2Interface *tool : qAsConst(d->m_tools)) {
|
||||
- if (tool->d->hardwareSerial() == hardwareSerial && tool->d->m_type == type)
|
||||
- return tool;
|
||||
+ for (const auto &tools : std::as_const(d->m_tools)) {
|
||||
+ for (TabletToolV2Interface *tool : tools) {
|
||||
+ if (tool->d->hardwareSerial() == hardwareSerial && tool->d->m_type == type) {
|
||||
+ return tool;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -845,6 +857,15 @@ bool TabletSeatV2Interface::isClientSupported(ClientConnection *client) const
|
||||
return d->resourceMap().value(*client);
|
||||
}
|
||||
|
||||
+bool TabletSeatV2Interface::hasImplicitGrab(quint32 serial) const
|
||||
+{
|
||||
+ return std::any_of(d->m_tools.cbegin(), d->m_tools.cend(), [serial](const auto &tools) {
|
||||
+ return std::any_of(tools.cbegin(), tools.cend(), [serial](const auto tool) {
|
||||
+ return tool->downSerial() == serial;
|
||||
+ });
|
||||
+ });
|
||||
+}
|
||||
+
|
||||
TabletManagerV2Interface::~TabletManagerV2Interface() = default;
|
||||
|
||||
} // namespace KWaylandServer
|
||||
diff --git a/src/server/tablet_v2_interface.h b/src/server/tablet_v2_interface.h
|
||||
index fe091e2..2644407 100644
|
||||
--- a/src/server/tablet_v2_interface.h
|
||||
+++ b/src/server/tablet_v2_interface.h
|
||||
@@ -92,6 +92,8 @@ public:
|
||||
void setCurrentSurface(SurfaceInterface *surface);
|
||||
bool isClientSupported() const;
|
||||
|
||||
+ quint32 downSerial() const;
|
||||
+
|
||||
void sendProximityIn(TabletV2Interface *tablet);
|
||||
void sendProximityOut();
|
||||
void sendUp();
|
||||
@@ -112,14 +114,7 @@ Q_SIGNALS:
|
||||
private:
|
||||
friend class TabletSeatV2InterfacePrivate;
|
||||
friend class TabletSeatV2Interface;
|
||||
- explicit TabletToolV2Interface(Display *display,
|
||||
- Type type,
|
||||
- quint32 hsh,
|
||||
- quint32 hsl,
|
||||
- quint32 hih,
|
||||
- quint32 hil,
|
||||
- const QVector<Capability> &capability,
|
||||
- QObject *parent);
|
||||
+ explicit TabletToolV2Interface(Display *display, Type type, quint32 hsh, quint32 hsl, quint32 hih, quint32 hil, const QVector<Capability> &capability);
|
||||
QScopedPointer<TabletToolV2InterfacePrivate> d;
|
||||
};
|
||||
|
||||
@@ -272,8 +267,11 @@ public:
|
||||
quint32 modes,
|
||||
quint32 currentMode,
|
||||
TabletV2Interface *tablet);
|
||||
- TabletToolV2Interface *
|
||||
- addTool(TabletToolV2Interface::Type type, quint64 hardwareSerial, quint64 hardwareId, const QVector<TabletToolV2Interface::Capability> &capabilities);
|
||||
+ TabletToolV2Interface *addTool(TabletToolV2Interface::Type type,
|
||||
+ quint64 hardwareSerial,
|
||||
+ quint64 hardwareId,
|
||||
+ const QVector<TabletToolV2Interface::Capability> &capabilities,
|
||||
+ const QString &deviceSysName);
|
||||
|
||||
TabletToolV2Interface *toolByHardwareId(quint64 hardwareId) const;
|
||||
TabletToolV2Interface *toolByHardwareSerial(quint64 hardwareSerial, TabletToolV2Interface::Type type) const;
|
||||
@@ -283,6 +281,8 @@ public:
|
||||
|
||||
bool isClientSupported(ClientConnection *client) const;
|
||||
|
||||
+ bool hasImplicitGrab(quint32 serial) const;
|
||||
+
|
||||
private:
|
||||
friend class TabletManagerV2InterfacePrivate;
|
||||
explicit TabletSeatV2Interface(Display *display, QObject *parent);
|
|
@ -3,3 +3,4 @@
|
|||
0003-kwayland-server-5.24.4-ok4.1.patch
|
||||
0004-kwayland-server-5.24.4-ok4.2.patch
|
||||
0005-7-add-dialog-protocols.patch
|
||||
0006-8-Accepting-the-tablet-serial-for-the-xdg_toplevel-m.patch
|
||||
|
|
Loading…
Reference in New Issue