Commit 9ee83def authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

wayland: Support virtual outputs when screensharing

It will add an output in KWin with FullHD resolution at 1x scaling, it's
up to users to place it however they like. They'll get the OSD to place
it as desired.
parent b55b6790
Pipeline #171702 passed with stage
in 49 seconds
......@@ -17,6 +17,10 @@ OutputsModel::OutputsModel(Options o, QObject *parent)
if (outputs.count() > 1 && (o & WorkspaceIncluded)) {
m_outputs << Output{WaylandIntegration::WaylandOutput::Workspace, 0, i18n("Full Workspace"), "Workspace"};
}
if (o & VirtualIncluded) {
static quint64 i = 0;
m_outputs << Output{WaylandIntegration::WaylandOutput::Virtual, 0, i18n("New Virtual Output"), QStringLiteral("Virtual%1").arg(i++)};
}
for (auto output : outputs) {
QString display;
switch (output.outputType()) {
......
......@@ -66,11 +66,13 @@ class OutputsModel : public QAbstractListModel
Q_OBJECT
Q_PROPERTY(bool hasSelection READ hasSelection NOTIFY hasSelectionChanged)
public:
enum Options {
enum Option {
None = 0,
WorkspaceIncluded,
WorkspaceIncluded = 0x1,
VirtualIncluded = 0x2,
};
Q_ENUM(Options);
Q_ENUM(Option);
Q_DECLARE_FLAGS(Options, Option);
OutputsModel(Options o, QObject *parent);
~OutputsModel() override;
......
......@@ -262,6 +262,10 @@ uint ScreenCastPortal::Start(const QDBusObjectPath &handle,
if (!WaylandIntegration::startStreamingWorkspace(Screencasting::CursorMode(session->cursorMode()))) {
return 2;
}
} else if (output.outputType() == WaylandIntegration::WaylandOutput::Virtual) {
if (!WaylandIntegration::startStreamingVirtual(output.uniqueId(), {1920, 1080}, Screencasting::CursorMode(session->cursorMode()))) {
return 2;
}
} else if (!WaylandIntegration::startStreamingOutput(output.waylandOutputName(), Screencasting::CursorMode(session->cursorMode()))) {
return 2;
}
......
......@@ -22,8 +22,9 @@ class ScreenCastPortal : public QDBusAbstractAdaptor
public:
enum SourceType {
Any = 0,
Monitor,
Window,
Monitor = 1,
Window = 2,
Virtual = 4,
};
Q_ENUM(SourceType);
Q_DECLARE_FLAGS(SourceTypes, SourceType)
......
......@@ -118,6 +118,13 @@ ScreencastingStream *Screencasting::createRegionStream(const QRect &g, qreal sca
return stream;
}
ScreencastingStream *Screencasting::createVirtualOutputStream(const QString &name, const QSize &s, qreal scale, Screencasting::CursorMode mode)
{
auto stream = new ScreencastingStream(this);
stream->d->init(d->stream_virtual_output(name, s.width(), s.height(), wl_fixed_from_double(scale), mode));
return stream;
}
void Screencasting::setup(::zkde_screencast_unstable_v1 *screencasting)
{
d.reset(new ScreencastingPrivate(screencasting, this));
......
......@@ -63,6 +63,7 @@ public:
ScreencastingStream *createOutputStream(KWayland::Client::Output *output, CursorMode mode);
ScreencastingStream *createWindowStream(const QString &uuid, CursorMode mode);
ScreencastingStream *createRegionStream(const QRect &geometry, qreal scale, CursorMode mode);
ScreencastingStream *createVirtualOutputStream(const QString &name, const QSize &size, qreal scale, CursorMode mode);
void setup(zkde_screencast_unstable_v1 *screencasting);
void destroy();
......
......@@ -142,7 +142,7 @@ ScreenChooserDialog::ScreenChooserDialog(const QString &appName, bool multiple,
int numberOfMonitors = 0;
if (types & ScreenCastPortal::Monitor) {
auto model = new OutputsModel(OutputsModel::WorkspaceIncluded, this);
auto model = new OutputsModel(OutputsModel::Options(OutputsModel::WorkspaceIncluded | OutputsModel::VirtualIncluded), this);
props.insert("outputsModel", QVariant::fromValue<QObject *>(model));
numberOfMonitors += model->rowCount(QModelIndex());
connect(this, &ScreenChooserDialog::clearSelection, model, &OutputsModel::clearSelection);
......
......@@ -86,6 +86,11 @@ bool WaylandIntegration::startStreamingWorkspace(Screencasting::CursorMode mode)
return globalWaylandIntegration->startStreamingWorkspace(mode);
}
bool WaylandIntegration::startStreamingVirtual(const QString &name, const QSize &size, Screencasting::CursorMode mode)
{
return globalWaylandIntegration->startStreamingVirtualOutput(name, size, mode);
}
bool WaylandIntegration::startStreamingWindow(const QMap<int, QVariant> &win)
{
return globalWaylandIntegration->startStreamingWindow(win);
......@@ -281,6 +286,17 @@ bool WaylandIntegration::WaylandIntegrationPrivate::startStreamingWorkspace(Scre
});
}
bool WaylandIntegration::WaylandIntegrationPrivate::startStreamingVirtualOutput(const QString &name, const QSize &size, Screencasting::CursorMode mode)
{
return startStreaming(m_screencasting->createVirtualOutputStream(name, size, 1, mode),
QStringLiteral("video-display"),
i18n("Recording virtual output '%1'...", name),
{
{QLatin1String("size"), size},
{QLatin1String("source_type"), static_cast<uint>(ScreenCastPortal::Virtual)},
});
}
bool WaylandIntegration::WaylandIntegrationPrivate::startStreaming(ScreencastingStream *stream,
const QString &iconName,
const QString &description,
......
......@@ -38,6 +38,7 @@ public:
Monitor,
Television,
Workspace,
Virtual,
};
QString manufacturer() const
{
......@@ -115,6 +116,7 @@ bool isStreamingAvailable();
void startStreamingInput();
bool startStreamingOutput(quint32 outputName, Screencasting::CursorMode mode);
bool startStreamingWorkspace(Screencasting::CursorMode mode);
bool startStreamingVirtual(const QString &name, const QSize &size, Screencasting::CursorMode mode);
bool startStreamingWindow(const QMap<int, QVariant> &win);
void stopAllStreaming();
......
......@@ -73,13 +73,11 @@ public:
void startStreamingInput();
bool startStreaming(ScreencastingStream *stream,
const QString &iconName,
const QString &description,
const QVariantMap &streamOptions);
bool startStreaming(ScreencastingStream *stream, const QString &iconName, const QString &description, const QVariantMap &streamOptions);
bool startStreamingOutput(quint32 outputName, Screencasting::CursorMode mode);
bool startStreamingWindow(const QMap<int, QVariant> &win);
bool startStreamingWorkspace(Screencasting::CursorMode mode);
bool startStreamingVirtualOutput(const QString &name, const QSize &size, Screencasting::CursorMode mode);
void stopStreaming(uint32_t nodeid);
void stopAllStreaming();
......
Supports Markdown
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