feat: Set app id on wayland this is required for restore tokens to work correctly
This commit is contained in:
parent
7698980576
commit
dc86538456
4 changed files with 57 additions and 0 deletions
|
|
@ -32,6 +32,10 @@
|
|||
#include <QLoggingCategory>
|
||||
#endif
|
||||
|
||||
#if defined(WINAPI_XWINDOWS) or defined(WINAPI_LIBEI)
|
||||
#include "platform/XDGPortalRegistry.h"
|
||||
#endif
|
||||
|
||||
using namespace deskflow::gui;
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
|
|
@ -47,6 +51,10 @@ int main(int argc, char *argv[])
|
|||
QLoggingCategory::setFilterRules(QStringLiteral("*.debug=true\nqt.*=false"));
|
||||
#endif
|
||||
|
||||
#if defined(WINAPI_XWINDOWS) or defined(WINAPI_LIBEI)
|
||||
deskflow::platform::setAppId();
|
||||
#endif
|
||||
|
||||
QCoreApplication::setApplicationName(kAppName);
|
||||
QCoreApplication::setOrganizationName(kAppName);
|
||||
QCoreApplication::setApplicationVersion(kVersion);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,10 @@
|
|||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#endif
|
||||
|
||||
#if defined(WINAPI_XWINDOWS) or defined(WINAPI_LIBEI)
|
||||
#include "platform/XDGPortalRegistry.h"
|
||||
#endif
|
||||
|
||||
#include <CLI/CLI.hpp>
|
||||
|
||||
using namespace deskflow;
|
||||
|
|
@ -51,6 +55,9 @@ App::App(IEventQueue *events, deskflow::ArgsBase *args)
|
|||
{
|
||||
assert(s_instance == nullptr);
|
||||
s_instance = this;
|
||||
#if defined(WINAPI_XWINDOWS) or defined(WINAPI_LIBEI)
|
||||
deskflow::platform::setAppId();
|
||||
#endif
|
||||
}
|
||||
|
||||
App::~App()
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ elseif(APPLE)
|
|||
)
|
||||
elseif(UNIX)
|
||||
set(PLATFORM_SOURCES
|
||||
XDGPortalRegistry.h
|
||||
XDGPowerManager.cpp
|
||||
XDGPowerManager.h
|
||||
XWindowsClipboard.cpp
|
||||
|
|
|
|||
41
src/lib/platform/XDGPortalRegistry.h
Normal file
41
src/lib/platform/XDGPortalRegistry.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello <sithlord48@gmail.com>
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusReply>
|
||||
|
||||
#include "platform/Wayland.h"
|
||||
|
||||
namespace deskflow::platform {
|
||||
|
||||
/**
|
||||
* @brief setAppId Set the app id for the xdg portal registry
|
||||
* All Applications should do this before attempting any other portal calls
|
||||
* If the app is runing from inside a sandbox (i.e flatpak or a snap) this call does nothing
|
||||
*/
|
||||
inline void setAppId()
|
||||
{
|
||||
// Sandboxed applications are unable to use this portal
|
||||
if (isSandboxed()) {
|
||||
return;
|
||||
}
|
||||
auto i = new QDBusInterface(
|
||||
"org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop", "org.freedesktop.host.portal.Registry",
|
||||
QDBusConnection::sessionBus(), nullptr
|
||||
);
|
||||
|
||||
if (!i->property("version").toInt()) {
|
||||
qDebug() << "portal registry not found";
|
||||
return;
|
||||
}
|
||||
|
||||
std::ignore = i->call("Register", "org.deskflow.deskflow", QVariantMap{});
|
||||
}
|
||||
|
||||
} // namespace deskflow::platform
|
||||
Loading…
Reference in a new issue