Commit 0cd7a9de authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

screencast: Improve the screencasting process

Forwards the requested cursor state by the app to the compositor.
Selects the Windows tab if screens can't be selected.
parent c419d568
......@@ -90,7 +90,7 @@ uint ScreenCastPortal::SelectSources(const QDBusObjectPath &handle,
return 2;
}
session->setMultipleSources(options.value(QStringLiteral("multiple")).toBool());
session->setOptions(options);
// Might be also a RemoteDesktopSession
if (session->type() == Session::RemoteDesktop) {
......@@ -134,16 +134,14 @@ uint ScreenCastPortal::Start(const QDBusObjectPath &handle,
QScopedPointer<ScreenChooserDialog, QScopedPointerDeleteLater> screenDialog(new ScreenChooserDialog(app_id, session->multipleSources()));
Utils::setParentWindow(screenDialog.data(), parent_window);
if (options.contains(QStringLiteral("types"))) {
screenDialog->setSourceTypes(SourceTypes(options.value(QStringLiteral("types")).toUInt()));
}
screenDialog->setSourceTypes(SourceTypes(session->types()));
connect(session, &Session::closed, screenDialog.data(), &ScreenChooserDialog::reject);
if (screenDialog->exec()) {
const auto selectedScreens = screenDialog->selectedScreens();
for (quint32 outputid : selectedScreens) {
if (!WaylandIntegration::startStreamingOutput(outputid, Screencasting::Hidden)) {
if (!WaylandIntegration::startStreamingOutput(outputid, Screencasting::CursorMode(session->cursorMode()))) {
return 2;
}
}
......
......@@ -53,7 +53,7 @@ public:
uint version() const { return 1; }
uint AvailableSourceTypes() const { return Monitor; };
uint AvailableCursorModes() const { return Hidden | Embedded; };
uint AvailableCursorModes() const { return Hidden | Embedded | Metadata; };
public Q_SLOTS:
uint CreateSession(const QDBusObjectPath &handle,
......
......@@ -124,6 +124,9 @@ void ScreenChooserDialog::setSourceTypes(ScreenCastPortal::SourceTypes types)
{
m_dialog->windowsTab->setEnabled(types & ScreenCastPortal::Window);
m_dialog->screensTab->setEnabled(types & ScreenCastPortal::Monitor);
if (!m_dialog->screensTab->isEnabled()) {
m_dialog->tabWidget->setCurrentWidget(m_dialog->windowsTab);
}
}
QList<quint32> ScreenChooserDialog::selectedScreens() const
......
......@@ -159,9 +159,22 @@ bool ScreenCastSession::multipleSources() const
return m_multipleSources;
}
void ScreenCastSession::setMultipleSources(bool multipleSources)
ScreenCastPortal::SourceType ScreenCastSession::types() const
{
return m_types;
}
ScreenCastPortal::CursorModes ScreenCastSession::cursorMode() const
{
return m_cursorMode;
}
void ScreenCastSession::setOptions(const QVariantMap &options)
{
m_multipleSources = multipleSources;
m_multipleSources = options.value(QStringLiteral("multiple")).toBool();
m_cursorMode = ScreenCastPortal::CursorModes(options.value(QStringLiteral("cursor_mode")).toUInt());
m_types = ScreenCastPortal::SourceType(options.value(QStringLiteral("types")).toUInt());
}
RemoteDesktopSession::RemoteDesktopSession(QObject *parent, const QString &appId, const QString &path)
......
......@@ -25,6 +25,7 @@
#include <QDBusVirtualObject>
#include "remotedesktop.h"
#include "screencast.h"
class Session : public QDBusVirtualObject
{
......@@ -62,14 +63,18 @@ public:
explicit ScreenCastSession(QObject *parent = nullptr, const QString &appId = QString(), const QString &path = QString());
~ScreenCastSession();
void setOptions(const QVariantMap &options);
ScreenCastPortal::CursorModes cursorMode() const;
bool multipleSources() const;
void setMultipleSources(bool multipleSources);
ScreenCastPortal::SourceType types() const;
SessionType type() const override { return SessionType::ScreenCast; }
private:
bool m_multipleSources;
// TODO type
ScreenCastPortal::CursorModes m_cursorMode;
ScreenCastPortal::SourceType m_types;
};
class RemoteDesktopSession : public ScreenCastSession
......
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