preliminary support for sway/wlroots compositors

This commit is contained in:
nullobsi
2021-02-01 15:45:51 -08:00
committed by borgmanJeremy
parent 2ee76addbd
commit 7a18dc096a
6 changed files with 120 additions and 2 deletions

View File

@@ -28,6 +28,7 @@
#include <QDBusInterface>
#include <QDBusReply>
#include <QDir>
#include "request.h"
#endif
ScreenGrabber::ScreenGrabber(QObject* parent)
@@ -88,6 +89,46 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool& ok)
}
break;
}
case DesktopInfo::SWAY: {
qDebug("Sway");
QDBusInterface screenshotInterface(
QStringLiteral("org.freedesktop.portal.Desktop"),
QStringLiteral("/org/freedesktop/portal/desktop"),
QStringLiteral("org.freedesktop.portal.Screenshot"));
QDBusReply<QDBusObjectPath> reply =
screenshotInterface.call(QStringLiteral("Screenshot"),
"",
QMap<QString, QVariant>());
OrgFreedesktopPortalRequestInterface request(
QStringLiteral("org.freedesktop.portal.Desktop"),
reply.value().path(),
QDBusConnection::sessionBus(),
this);
QEventLoop loop;
const auto gotSignal =
[&res, &loop](uint status,
const QVariantMap &map) {
qDebug() << "Signal" << status << map;
if (status == 0) {
QString uri = map.value("uri").toString().remove(0, 7);
qDebug() << uri;
res = QPixmap(uri);
QFile imgFile(uri);
imgFile.remove();
loop.quit();
}
};
connect(&request,
&org::freedesktop::portal::Request::Response,
gotSignal);
loop.exec();
request.Close();
if (res.isNull()) {
ok = false;
}
break;
}
default:
ok = false;
break;