Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Network
Krfb
Commits
d91bbdcb
Commit
d91bbdcb
authored
Oct 23, 2020
by
Tobias Junghans
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use QStringLiteral to avoid runtime allocations
parent
1d429a9b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
33 deletions
+33
-33
events/xdp/xdpevents.cpp
events/xdp/xdpevents.cpp
+4
-4
framebuffers/pipewire/pw_framebuffer.cpp
framebuffers/pipewire/pw_framebuffer.cpp
+29
-29
No files found.
events/xdp/xdpevents.cpp
View file @
d91bbdcb
...
...
@@ -55,8 +55,8 @@ EventData::EventData()
void
EventData
::
init
()
{
dbusXdpRemoteDesktopService
.
reset
(
new
OrgFreedesktopPortalRemoteDesktopInterface
(
Q
Latin1
String
(
"org.freedesktop.portal.Desktop"
),
Q
Latin1
String
(
"/org/freedesktop/portal/desktop"
),
QDBusConnection
::
sessionBus
()));
dbusXdpRemoteDesktopService
.
reset
(
new
OrgFreedesktopPortalRemoteDesktopInterface
(
QString
Literal
(
"org.freedesktop.portal.Desktop"
),
QString
Literal
(
"/org/freedesktop/portal/desktop"
),
QDBusConnection
::
sessionBus
()));
}
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
)
{
const
uint
streamNodeId
=
frameBuffer
()
->
customProperty
(
Q
Latin1
String
(
"stream_node_id"
)).
toUInt
();
const
QDBusObjectPath
sessionHandle
=
frameBuffer
()
->
customProperty
(
Q
Latin1
String
(
"session_handle"
)).
value
<
QDBusObjectPath
>
();
const
uint
streamNodeId
=
frameBuffer
()
->
customProperty
(
QString
Literal
(
"stream_node_id"
)).
toUInt
();
const
QDBusObjectPath
sessionHandle
=
frameBuffer
()
->
customProperty
(
QString
Literal
(
"session_handle"
)).
value
<
QDBusObjectPath
>
();
if
(
streamNodeId
==
0
||
sessionHandle
.
path
().
isEmpty
())
{
return
;
...
...
framebuffers/pipewire/pw_framebuffer.cpp
View file @
d91bbdcb
...
...
@@ -215,11 +215,11 @@ PWFrameBuffer::Private::Private(PWFrameBuffer *q) : q(q)
void
PWFrameBuffer
::
Private
::
initDbus
()
{
qInfo
()
<<
"Initializing D-Bus connectivity with XDG Desktop Portal"
;
dbusXdpScreenCastService
.
reset
(
new
OrgFreedesktopPortalScreenCastInterface
(
Q
Latin1
String
(
"org.freedesktop.portal.Desktop"
),
Q
Latin1
String
(
"/org/freedesktop/portal/desktop"
),
dbusXdpScreenCastService
.
reset
(
new
OrgFreedesktopPortalScreenCastInterface
(
QString
Literal
(
"org.freedesktop.portal.Desktop"
),
QString
Literal
(
"/org/freedesktop/portal/desktop"
),
QDBusConnection
::
sessionBus
()));
dbusXdpRemoteDesktopService
.
reset
(
new
OrgFreedesktopPortalRemoteDesktopInterface
(
Q
Latin1
String
(
"org.freedesktop.portal.Desktop"
),
Q
Latin1
String
(
"/org/freedesktop/portal/desktop"
),
dbusXdpRemoteDesktopService
.
reset
(
new
OrgFreedesktopPortalRemoteDesktopInterface
(
QString
Literal
(
"org.freedesktop.portal.Desktop"
),
QString
Literal
(
"/org/freedesktop/portal/desktop"
),
QDBusConnection
::
sessionBus
()));
auto
version
=
dbusXdpScreenCastService
->
version
();
if
(
version
<
MIN_SUPPORTED_XDP_KDE_SC_VERSION
)
{
...
...
@@ -231,11 +231,11 @@ void PWFrameBuffer::Private::initDbus()
// create session
auto
sessionParameters
=
QVariantMap
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
{
Q
Latin1
String
(
"session_handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
QRandomGenerator
::
global
()
->
generate
())
},
{
Q
Latin1
String
(
"handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
QRandomGenerator
::
global
()
->
generate
())
}
{
QString
Literal
(
"session_handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
QRandomGenerator
::
global
()
->
generate
())
},
{
QString
Literal
(
"handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
QRandomGenerator
::
global
()
->
generate
())
}
#else
{
Q
Latin1
String
(
"session_handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
qrand
())
},
{
Q
Latin1
String
(
"handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
qrand
())
}
{
QString
Literal
(
"session_handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
qrand
())
},
{
QString
Literal
(
"handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
qrand
())
}
#endif
};
auto
sessionReply
=
dbusXdpRemoteDesktopService
->
CreateSession
(
sessionParameters
);
...
...
@@ -249,8 +249,8 @@ void PWFrameBuffer::Private::initDbus()
qInfo
()
<<
"DBus session created: "
<<
sessionReply
.
value
().
path
();
QDBusConnection
::
sessionBus
().
connect
(
QString
(),
sessionReply
.
value
().
path
(),
Q
Latin1
String
(
"org.freedesktop.portal.Request"
),
Q
Latin1
String
(
"Response"
),
QString
Literal
(
"org.freedesktop.portal.Request"
),
QString
Literal
(
"Response"
),
this
->
q
,
SLOT
(
handleXdpSessionCreated
(
uint
,
QVariantMap
)));
}
...
...
@@ -275,16 +275,16 @@ void PWFrameBuffer::Private::handleSessionCreated(quint32 &code, QVariantMap &re
return
;
}
sessionPath
=
QDBusObjectPath
(
results
.
value
(
Q
Latin1
String
(
"session_handle"
)).
toString
());
sessionPath
=
QDBusObjectPath
(
results
.
value
(
QString
Literal
(
"session_handle"
)).
toString
());
// select sources for the session
auto
selectionOptions
=
QVariantMap
{
// We have to specify it's an uint, otherwise xdg-desktop-portal will not forward it to backend implementation
{
Q
Latin1
String
(
"types"
),
QVariant
::
fromValue
<
uint
>
(
7
)
},
// request all (KeyBoard, Pointer, TouchScreen)
{
QString
Literal
(
"types"
),
QVariant
::
fromValue
<
uint
>
(
7
)
},
// request all (KeyBoard, Pointer, TouchScreen)
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
{
Q
Latin1
String
(
"handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
QRandomGenerator
::
global
()
->
generate
())
}
{
QString
Literal
(
"handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
QRandomGenerator
::
global
()
->
generate
())
}
#else
{
Q
Latin1
String
(
"handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
qrand
())
}
{
QString
Literal
(
"handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
qrand
())
}
#endif
};
auto
selectorReply
=
dbusXdpRemoteDesktopService
->
SelectDevices
(
sessionPath
,
selectionOptions
);
...
...
@@ -296,8 +296,8 @@ void PWFrameBuffer::Private::handleSessionCreated(quint32 &code, QVariantMap &re
}
QDBusConnection
::
sessionBus
().
connect
(
QString
(),
selectorReply
.
value
().
path
(),
Q
Latin1
String
(
"org.freedesktop.portal.Request"
),
Q
Latin1
String
(
"Response"
),
QString
Literal
(
"org.freedesktop.portal.Request"
),
QString
Literal
(
"Response"
),
this
->
q
,
SLOT
(
handleXdpDevicesSelected
(
uint
,
QVariantMap
)));
}
...
...
@@ -324,12 +324,12 @@ void PWFrameBuffer::Private::handleDevicesSelected(quint32 &code, QVariantMap &r
// select sources for the session
auto
selectionOptions
=
QVariantMap
{
{
Q
Latin1
String
(
"types"
),
QVariant
::
fromValue
<
uint
>
(
1
)
},
// only MONITOR is supported
{
Q
Latin1
String
(
"multiple"
),
false
},
{
QString
Literal
(
"types"
),
QVariant
::
fromValue
<
uint
>
(
1
)
},
// only MONITOR is supported
{
QString
Literal
(
"multiple"
),
false
},
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
{
Q
Latin1
String
(
"handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
QRandomGenerator
::
global
()
->
generate
())
}
{
QString
Literal
(
"handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
QRandomGenerator
::
global
()
->
generate
())
}
#else
{
Q
Latin1
String
(
"handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
qrand
())
}
{
QString
Literal
(
"handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
qrand
())
}
#endif
};
auto
selectorReply
=
dbusXdpScreenCastService
->
SelectSources
(
sessionPath
,
selectionOptions
);
...
...
@@ -341,8 +341,8 @@ void PWFrameBuffer::Private::handleDevicesSelected(quint32 &code, QVariantMap &r
}
QDBusConnection
::
sessionBus
().
connect
(
QString
(),
selectorReply
.
value
().
path
(),
Q
Latin1
String
(
"org.freedesktop.portal.Request"
),
Q
Latin1
String
(
"Response"
),
QString
Literal
(
"org.freedesktop.portal.Request"
),
QString
Literal
(
"Response"
),
this
->
q
,
SLOT
(
handleXdpSourcesSelected
(
uint
,
QVariantMap
)));
}
...
...
@@ -371,17 +371,17 @@ void PWFrameBuffer::Private::handleSourcesSelected(quint32 &code, QVariantMap &)
// start session
auto
startParameters
=
QVariantMap
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
{
Q
Latin1
String
(
"handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
QRandomGenerator
::
global
()
->
generate
())
}
{
QString
Literal
(
"handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
QRandomGenerator
::
global
()
->
generate
())
}
#else
{
Q
Latin1
String
(
"handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
qrand
())
}
{
QString
Literal
(
"handle_token"
),
QStringLiteral
(
"krfb%1"
).
arg
(
qrand
())
}
#endif
};
auto
startReply
=
dbusXdpRemoteDesktopService
->
Start
(
sessionPath
,
QString
(),
startParameters
);
startReply
.
waitForFinished
();
QDBusConnection
::
sessionBus
().
connect
(
QString
(),
startReply
.
value
().
path
(),
Q
Latin1
String
(
"org.freedesktop.portal.Request"
),
Q
Latin1
String
(
"Response"
),
QString
Literal
(
"org.freedesktop.portal.Request"
),
QString
Literal
(
"Response"
),
this
->
q
,
SLOT
(
handleXdpRemoteDesktopStarted
(
uint
,
QVariantMap
)));
}
...
...
@@ -408,7 +408,7 @@ void PWFrameBuffer::Private::handleRemoteDesktopStarted(quint32 &code, QVariantM
}
// there should be only one stream
Streams
streams
=
qdbus_cast
<
Streams
>
(
results
.
value
(
Q
Latin1
String
(
"streams"
)));
Streams
streams
=
qdbus_cast
<
Streams
>
(
results
.
value
(
QString
Literal
(
"streams"
)));
if
(
streams
.
isEmpty
())
{
// maybe we should check deeper with qdbus_cast but this suffices for now
qCWarning
(
KRFB_FB_PIPEWIRE
)
<<
"Failed to get screencast streams"
;
...
...
@@ -431,11 +431,11 @@ void PWFrameBuffer::Private::handleRemoteDesktopStarted(quint32 &code, QVariantM
return
;
}
QSize
streamResolution
=
qdbus_cast
<
QSize
>
(
streams
.
first
().
map
.
value
(
Q
Latin1
String
(
"size"
)));
QSize
streamResolution
=
qdbus_cast
<
QSize
>
(
streams
.
first
().
map
.
value
(
QString
Literal
(
"size"
)));
screenGeometry
.
width
=
streamResolution
.
width
();
screenGeometry
.
height
=
streamResolution
.
height
();
devices
=
results
.
value
(
Q
Latin1
String
(
"types"
)).
toUInt
();
devices
=
results
.
value
(
QString
Literal
(
"types"
)).
toUInt
();
pwStreamNodeId
=
streams
.
first
().
nodeId
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment