mirror of
https://github.com/KDE/krfb
synced 2026-07-01 07:31:16 -07:00
Use QStringLiteral to avoid runtime allocations
This commit is contained in:
@@ -55,8 +55,8 @@ EventData::EventData()
|
|||||||
|
|
||||||
void EventData::init()
|
void EventData::init()
|
||||||
{
|
{
|
||||||
dbusXdpRemoteDesktopService.reset(new OrgFreedesktopPortalRemoteDesktopInterface(QLatin1String("org.freedesktop.portal.Desktop"),
|
dbusXdpRemoteDesktopService.reset(new OrgFreedesktopPortalRemoteDesktopInterface(QStringLiteral("org.freedesktop.portal.Desktop"),
|
||||||
QLatin1String("/org/freedesktop/portal/desktop"), QDBusConnection::sessionBus()));
|
QStringLiteral("/org/freedesktop/portal/desktop"), QDBusConnection::sessionBus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void XdpEventHandler::handleKeyboard(bool down, rfbKeySym keySym)
|
void XdpEventHandler::handleKeyboard(bool down, rfbKeySym keySym)
|
||||||
@@ -69,8 +69,8 @@ void XdpEventHandler::handleKeyboard(bool down, rfbKeySym keySym)
|
|||||||
|
|
||||||
void XdpEventHandler::handlePointer(int buttonMask, int x, int y)
|
void XdpEventHandler::handlePointer(int buttonMask, int x, int y)
|
||||||
{
|
{
|
||||||
const uint streamNodeId = frameBuffer()->customProperty(QLatin1String("stream_node_id")).toUInt();
|
const uint streamNodeId = frameBuffer()->customProperty(QStringLiteral("stream_node_id")).toUInt();
|
||||||
const QDBusObjectPath sessionHandle = frameBuffer()->customProperty(QLatin1String("session_handle")).value<QDBusObjectPath>();
|
const QDBusObjectPath sessionHandle = frameBuffer()->customProperty(QStringLiteral("session_handle")).value<QDBusObjectPath>();
|
||||||
|
|
||||||
if (streamNodeId == 0 || sessionHandle.path().isEmpty()) {
|
if (streamNodeId == 0 || sessionHandle.path().isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -215,11 +215,11 @@ PWFrameBuffer::Private::Private(PWFrameBuffer *q) : q(q)
|
|||||||
void PWFrameBuffer::Private::initDbus()
|
void PWFrameBuffer::Private::initDbus()
|
||||||
{
|
{
|
||||||
qInfo() << "Initializing D-Bus connectivity with XDG Desktop Portal";
|
qInfo() << "Initializing D-Bus connectivity with XDG Desktop Portal";
|
||||||
dbusXdpScreenCastService.reset(new OrgFreedesktopPortalScreenCastInterface(QLatin1String("org.freedesktop.portal.Desktop"),
|
dbusXdpScreenCastService.reset(new OrgFreedesktopPortalScreenCastInterface(QStringLiteral("org.freedesktop.portal.Desktop"),
|
||||||
QLatin1String("/org/freedesktop/portal/desktop"),
|
QStringLiteral("/org/freedesktop/portal/desktop"),
|
||||||
QDBusConnection::sessionBus()));
|
QDBusConnection::sessionBus()));
|
||||||
dbusXdpRemoteDesktopService.reset(new OrgFreedesktopPortalRemoteDesktopInterface(QLatin1String("org.freedesktop.portal.Desktop"),
|
dbusXdpRemoteDesktopService.reset(new OrgFreedesktopPortalRemoteDesktopInterface(QStringLiteral("org.freedesktop.portal.Desktop"),
|
||||||
QLatin1String("/org/freedesktop/portal/desktop"),
|
QStringLiteral("/org/freedesktop/portal/desktop"),
|
||||||
QDBusConnection::sessionBus()));
|
QDBusConnection::sessionBus()));
|
||||||
auto version = dbusXdpScreenCastService->version();
|
auto version = dbusXdpScreenCastService->version();
|
||||||
if (version < MIN_SUPPORTED_XDP_KDE_SC_VERSION) {
|
if (version < MIN_SUPPORTED_XDP_KDE_SC_VERSION) {
|
||||||
@@ -231,11 +231,11 @@ void PWFrameBuffer::Private::initDbus()
|
|||||||
// create session
|
// create session
|
||||||
auto sessionParameters = QVariantMap {
|
auto sessionParameters = QVariantMap {
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||||
{ QLatin1String("session_handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate()) },
|
{ QStringLiteral("session_handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate()) },
|
||||||
{ QLatin1String("handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate()) }
|
{ QStringLiteral("handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate()) }
|
||||||
#else
|
#else
|
||||||
{ QLatin1String("session_handle_token"), QStringLiteral("krfb%1").arg(qrand()) },
|
{ QStringLiteral("session_handle_token"), QStringLiteral("krfb%1").arg(qrand()) },
|
||||||
{ QLatin1String("handle_token"), QStringLiteral("krfb%1").arg(qrand()) }
|
{ QStringLiteral("handle_token"), QStringLiteral("krfb%1").arg(qrand()) }
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
auto sessionReply = dbusXdpRemoteDesktopService->CreateSession(sessionParameters);
|
auto sessionReply = dbusXdpRemoteDesktopService->CreateSession(sessionParameters);
|
||||||
@@ -249,8 +249,8 @@ void PWFrameBuffer::Private::initDbus()
|
|||||||
qInfo() << "DBus session created: " << sessionReply.value().path();
|
qInfo() << "DBus session created: " << sessionReply.value().path();
|
||||||
QDBusConnection::sessionBus().connect(QString(),
|
QDBusConnection::sessionBus().connect(QString(),
|
||||||
sessionReply.value().path(),
|
sessionReply.value().path(),
|
||||||
QLatin1String("org.freedesktop.portal.Request"),
|
QStringLiteral("org.freedesktop.portal.Request"),
|
||||||
QLatin1String("Response"),
|
QStringLiteral("Response"),
|
||||||
this->q,
|
this->q,
|
||||||
SLOT(handleXdpSessionCreated(uint, QVariantMap)));
|
SLOT(handleXdpSessionCreated(uint, QVariantMap)));
|
||||||
}
|
}
|
||||||
@@ -275,16 +275,16 @@ void PWFrameBuffer::Private::handleSessionCreated(quint32 &code, QVariantMap &re
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionPath = QDBusObjectPath(results.value(QLatin1String("session_handle")).toString());
|
sessionPath = QDBusObjectPath(results.value(QStringLiteral("session_handle")).toString());
|
||||||
|
|
||||||
// select sources for the session
|
// select sources for the session
|
||||||
auto selectionOptions = QVariantMap {
|
auto selectionOptions = QVariantMap {
|
||||||
// We have to specify it's an uint, otherwise xdg-desktop-portal will not forward it to backend implementation
|
// We have to specify it's an uint, otherwise xdg-desktop-portal will not forward it to backend implementation
|
||||||
{ QLatin1String("types"), QVariant::fromValue<uint>(7) }, // request all (KeyBoard, Pointer, TouchScreen)
|
{ QStringLiteral("types"), QVariant::fromValue<uint>(7) }, // request all (KeyBoard, Pointer, TouchScreen)
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||||
{ QLatin1String("handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate()) }
|
{ QStringLiteral("handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate()) }
|
||||||
#else
|
#else
|
||||||
{ QLatin1String("handle_token"), QStringLiteral("krfb%1").arg(qrand()) }
|
{ QStringLiteral("handle_token"), QStringLiteral("krfb%1").arg(qrand()) }
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
auto selectorReply = dbusXdpRemoteDesktopService->SelectDevices(sessionPath, selectionOptions);
|
auto selectorReply = dbusXdpRemoteDesktopService->SelectDevices(sessionPath, selectionOptions);
|
||||||
@@ -296,8 +296,8 @@ void PWFrameBuffer::Private::handleSessionCreated(quint32 &code, QVariantMap &re
|
|||||||
}
|
}
|
||||||
QDBusConnection::sessionBus().connect(QString(),
|
QDBusConnection::sessionBus().connect(QString(),
|
||||||
selectorReply.value().path(),
|
selectorReply.value().path(),
|
||||||
QLatin1String("org.freedesktop.portal.Request"),
|
QStringLiteral("org.freedesktop.portal.Request"),
|
||||||
QLatin1String("Response"),
|
QStringLiteral("Response"),
|
||||||
this->q,
|
this->q,
|
||||||
SLOT(handleXdpDevicesSelected(uint, QVariantMap)));
|
SLOT(handleXdpDevicesSelected(uint, QVariantMap)));
|
||||||
}
|
}
|
||||||
@@ -324,12 +324,12 @@ void PWFrameBuffer::Private::handleDevicesSelected(quint32 &code, QVariantMap &r
|
|||||||
|
|
||||||
// select sources for the session
|
// select sources for the session
|
||||||
auto selectionOptions = QVariantMap {
|
auto selectionOptions = QVariantMap {
|
||||||
{ QLatin1String("types"), QVariant::fromValue<uint>(1) }, // only MONITOR is supported
|
{ QStringLiteral("types"), QVariant::fromValue<uint>(1) }, // only MONITOR is supported
|
||||||
{ QLatin1String("multiple"), false },
|
{ QStringLiteral("multiple"), false },
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||||
{ QLatin1String("handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate()) }
|
{ QStringLiteral("handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate()) }
|
||||||
#else
|
#else
|
||||||
{ QLatin1String("handle_token"), QStringLiteral("krfb%1").arg(qrand()) }
|
{ QStringLiteral("handle_token"), QStringLiteral("krfb%1").arg(qrand()) }
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
auto selectorReply = dbusXdpScreenCastService->SelectSources(sessionPath, selectionOptions);
|
auto selectorReply = dbusXdpScreenCastService->SelectSources(sessionPath, selectionOptions);
|
||||||
@@ -341,8 +341,8 @@ void PWFrameBuffer::Private::handleDevicesSelected(quint32 &code, QVariantMap &r
|
|||||||
}
|
}
|
||||||
QDBusConnection::sessionBus().connect(QString(),
|
QDBusConnection::sessionBus().connect(QString(),
|
||||||
selectorReply.value().path(),
|
selectorReply.value().path(),
|
||||||
QLatin1String("org.freedesktop.portal.Request"),
|
QStringLiteral("org.freedesktop.portal.Request"),
|
||||||
QLatin1String("Response"),
|
QStringLiteral("Response"),
|
||||||
this->q,
|
this->q,
|
||||||
SLOT(handleXdpSourcesSelected(uint, QVariantMap)));
|
SLOT(handleXdpSourcesSelected(uint, QVariantMap)));
|
||||||
}
|
}
|
||||||
@@ -371,17 +371,17 @@ void PWFrameBuffer::Private::handleSourcesSelected(quint32 &code, QVariantMap &)
|
|||||||
// start session
|
// start session
|
||||||
auto startParameters = QVariantMap {
|
auto startParameters = QVariantMap {
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||||
{ QLatin1String("handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate()) }
|
{ QStringLiteral("handle_token"), QStringLiteral("krfb%1").arg(QRandomGenerator::global()->generate()) }
|
||||||
#else
|
#else
|
||||||
{ QLatin1String("handle_token"), QStringLiteral("krfb%1").arg(qrand()) }
|
{ QStringLiteral("handle_token"), QStringLiteral("krfb%1").arg(qrand()) }
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
auto startReply = dbusXdpRemoteDesktopService->Start(sessionPath, QString(), startParameters);
|
auto startReply = dbusXdpRemoteDesktopService->Start(sessionPath, QString(), startParameters);
|
||||||
startReply.waitForFinished();
|
startReply.waitForFinished();
|
||||||
QDBusConnection::sessionBus().connect(QString(),
|
QDBusConnection::sessionBus().connect(QString(),
|
||||||
startReply.value().path(),
|
startReply.value().path(),
|
||||||
QLatin1String("org.freedesktop.portal.Request"),
|
QStringLiteral("org.freedesktop.portal.Request"),
|
||||||
QLatin1String("Response"),
|
QStringLiteral("Response"),
|
||||||
this->q,
|
this->q,
|
||||||
SLOT(handleXdpRemoteDesktopStarted(uint, QVariantMap)));
|
SLOT(handleXdpRemoteDesktopStarted(uint, QVariantMap)));
|
||||||
}
|
}
|
||||||
@@ -408,7 +408,7 @@ void PWFrameBuffer::Private::handleRemoteDesktopStarted(quint32 &code, QVariantM
|
|||||||
}
|
}
|
||||||
|
|
||||||
// there should be only one stream
|
// there should be only one stream
|
||||||
Streams streams = qdbus_cast<Streams>(results.value(QLatin1String("streams")));
|
Streams streams = qdbus_cast<Streams>(results.value(QStringLiteral("streams")));
|
||||||
if (streams.isEmpty()) {
|
if (streams.isEmpty()) {
|
||||||
// maybe we should check deeper with qdbus_cast but this suffices for now
|
// maybe we should check deeper with qdbus_cast but this suffices for now
|
||||||
qCWarning(KRFB_FB_PIPEWIRE) << "Failed to get screencast streams";
|
qCWarning(KRFB_FB_PIPEWIRE) << "Failed to get screencast streams";
|
||||||
@@ -431,11 +431,11 @@ void PWFrameBuffer::Private::handleRemoteDesktopStarted(quint32 &code, QVariantM
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize streamResolution = qdbus_cast<QSize>(streams.first().map.value(QLatin1String("size")));
|
QSize streamResolution = qdbus_cast<QSize>(streams.first().map.value(QStringLiteral("size")));
|
||||||
screenGeometry.width = streamResolution.width();
|
screenGeometry.width = streamResolution.width();
|
||||||
screenGeometry.height = streamResolution.height();
|
screenGeometry.height = streamResolution.height();
|
||||||
|
|
||||||
devices = results.value(QLatin1String("types")).toUInt();
|
devices = results.value(QStringLiteral("types")).toUInt();
|
||||||
|
|
||||||
pwStreamNodeId = streams.first().nodeId;
|
pwStreamNodeId = streams.first().nodeId;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user