Commit ce19c66b authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Make it possible to stream only input

Summary: No need to share our screen contents to be able to move the mouse.

Test Plan:
Ported KDE Connect to it, works.
https://invent.kde.org/kde/kdeconnect-kde/merge_requests/199

Reviewers: #plasma, #kde_connect

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26875
parent bfd614bb
......@@ -140,6 +140,10 @@ uint RemoteDesktopPortal::Start(const QDBusObjectPath &handle,
}
results.insert(QStringLiteral("streams"), streams);
} else {
qCWarning(XdgDesktopPortalKdeRemoteDesktop()) << "Only stream input";
WaylandIntegration::startStreamingInput();
WaylandIntegration::authenticate();
}
results.insert(QStringLiteral("devices"), QVariant::fromValue<uint>(remoteDesktopDialog->deviceTypes()));
......
......@@ -71,6 +71,11 @@ bool WaylandIntegration::isStreamingEnabled()
return globalWaylandIntegration->isStreamingEnabled();
}
void WaylandIntegration::startStreamingInput()
{
globalWaylandIntegration->startStreamingInput();
}
bool WaylandIntegration::startStreaming(quint32 outputName)
{
return globalWaylandIntegration->startStreaming(outputName);
......@@ -244,6 +249,11 @@ void WaylandIntegration::WaylandIntegrationPrivate::bindOutput(int outputName, i
m_bindOutputs << output;
}
void WaylandIntegration::WaylandIntegrationPrivate::startStreamingInput()
{
m_streamInput = true;
}
bool WaylandIntegration::WaylandIntegrationPrivate::startStreaming(quint32 outputName)
{
WaylandOutput output = m_outputMap.value(outputName);
......@@ -254,6 +264,7 @@ bool WaylandIntegration::WaylandIntegrationPrivate::startStreaming(quint32 outpu
connect(m_stream, &ScreenCastStream::startStreaming, this, [this, output] {
m_streamingEnabled = true;
startStreamingInput();
bindOutput(output.waylandOutputName(), output.waylandOutputVersion());
});
......@@ -310,6 +321,7 @@ bool WaylandIntegration::WaylandIntegrationPrivate::startStreaming(quint32 outpu
void WaylandIntegration::WaylandIntegrationPrivate::stopStreaming()
{
m_streamInput = false;
if (m_streamingEnabled) {
m_streamingEnabled = false;
......@@ -330,35 +342,35 @@ void WaylandIntegration::WaylandIntegrationPrivate::stopStreaming()
void WaylandIntegration::WaylandIntegrationPrivate::requestPointerButtonPress(quint32 linuxButton)
{
if (m_streamingEnabled && m_fakeInput) {
if (m_streamInput && m_fakeInput) {
m_fakeInput->requestPointerButtonPress(linuxButton);
}
}
void WaylandIntegration::WaylandIntegrationPrivate::requestPointerButtonRelease(quint32 linuxButton)
{
if (m_streamingEnabled && m_fakeInput) {
if (m_streamInput && m_fakeInput) {
m_fakeInput->requestPointerButtonRelease(linuxButton);
}
}
void WaylandIntegration::WaylandIntegrationPrivate::requestPointerMotion(const QSizeF &delta)
{
if (m_streamingEnabled && m_fakeInput) {
if (m_streamInput && m_fakeInput) {
m_fakeInput->requestPointerMove(delta);
}
}
void WaylandIntegration::WaylandIntegrationPrivate::requestPointerMotionAbsolute(const QPointF &pos)
{
if (m_streamingEnabled && m_fakeInput) {
if (m_streamInput && m_fakeInput) {
m_fakeInput->requestPointerMoveAbsolute(pos + m_streamedScreenPosition);
}
}
void WaylandIntegration::WaylandIntegrationPrivate::requestPointerAxisDiscrete(Qt::Orientation axis, qreal delta)
{
if (m_streamingEnabled && m_fakeInput) {
if (m_streamInput && m_fakeInput) {
m_fakeInput->requestPointerAxis(axis, delta);
}
}
......
......@@ -84,6 +84,7 @@ Q_SIGNALS:
bool isEGLInitialized();
bool isStreamingEnabled();
void startStreamingInput();
bool startStreaming(quint32 outputName);
void stopStreaming();
......
......@@ -70,6 +70,7 @@ public:
bool isStreamingEnabled() const;
void bindOutput(int outputName, int outputVersion);
void startStreamingInput();
bool startStreaming(quint32 outputName);
void stopStreaming();
......@@ -91,6 +92,7 @@ protected Q_SLOTS:
private:
bool m_eglInitialized;
bool m_streamingEnabled;
bool m_streamInput = false;
bool m_registryInitialized;
bool m_waylandAuthenticationRequested;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment