| 1 |
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 |
|
| 5 |
#include "xeventmonitor_interface.h" |
| 6 |
|
| 7 |
static void registerAreaListMetaType() |
| 8 |
{ |
| 9 |
// FIX 取消注册qRegisterMetaType,会影响 dock 使用 RegisterAreas dbus接口 |
| 10 |
// 因为 libdframeworkdbus-dev 也会注册 "AreaList" 为 MonitorRect |
| 11 |
// qRegisterMetaType<AreaList>("AreaList"); |
| 12 |
qDBusRegisterMetaType<ComDeepinApiXEventMonitorInterface::AreaList>(); |
| 13 |
} |
| 14 |
Q_CONSTRUCTOR_FUNCTION(registerAreaListMetaType); |
| 15 |
|
| 16 |
QDBusArgument &operator<<(QDBusArgument &a, const ComDeepinApiXEventMonitorInterface::AreaList &rects) |
| 17 |
{ |
| 18 |
// com.deepin.api.XEventMonitor.RegisterAreas |
| 19 |
// (Array of [Struct of (Int32, Int32, Int32, Int32)] areas, Int32 flag) |
| 20 |
// use [x1, y1, x2, y2] instead of [x1, y1, w, h] |
| 21 |
a.beginArray(qRegisterMetaType<QRect>()); |
| 22 |
for (const auto &r : rects) { |
| 23 |
a.beginStructure(); |
| 24 |
a << r.left() << r.top() << r.right() << r.bottom(); |
| 25 |
a.endStructure(); |
| 26 |
} |
| 27 |
a.endArray(); |
| 28 |
return a; |
| 29 |
} |
| 30 |
|
| 31 |
const QDBusArgument &operator>>(const QDBusArgument &a, ComDeepinApiXEventMonitorInterface::AreaList &rects) |
| 32 |
{ |
| 33 |
a.beginArray(); |
| 34 |
rects.clear(); |
| 35 |
int x1 = 0 , y1 = 0 , x2 = 0 , y2 = 0 ; |
| 36 |
while (!a.atEnd()) { |
| 37 |
a.beginStructure(); |
| 38 |
a >> x1 >> y1 >> x2 >> y2; |
| 39 |
a.endStructure(); |
| 40 |
|
| 41 |
rects.append(QRect(QPoint(x1, y1), QPoint(x2, y2))); |
| 42 |
} |
| 43 |
a.endArray(); |
| 44 |
return a; |
| 45 |
} |
| 46 |
|
| 47 |
ComDeepinApiXEventMonitorInterface::ComDeepinApiXEventMonitorInterface(const QString &service, const QString &path, |
| 48 |
const char *interface, QObject *parent, |
| 49 |
const QDBusConnection &con) |
| 50 |
: QDBusAbstractInterface(service, path, interface, con, parent) |
| 51 |
{ |
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
ComDeepinApiXEventMonitorInterface::~ComDeepinApiXEventMonitorInterface() |
| 56 |
{ |
| 57 |
} |
| 58 |
|