mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Adapt to lib_base's XDP API changes
This commit is contained in:
parent
80f1f079f1
commit
62e82a42fb
4 changed files with 28 additions and 73 deletions
|
@ -10,7 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "platform/platform_file_utilities.h"
|
#include "platform/platform_file_utilities.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "base/platform/linux/base_linux_glibmm_helper.h"
|
#include "base/platform/linux/base_linux_glibmm_helper.h"
|
||||||
#include "base/platform/linux/base_linux_wayland_integration.h"
|
#include "base/platform/linux/base_linux_xdp_utilities.h"
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
#include "base/random.h"
|
#include "base/random.h"
|
||||||
|
|
||||||
|
@ -20,8 +20,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include <glibmm.h>
|
#include <glibmm.h>
|
||||||
#include <giomm.h>
|
#include <giomm.h>
|
||||||
|
|
||||||
using base::Platform::WaylandIntegration;
|
|
||||||
|
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
namespace FileDialog {
|
namespace FileDialog {
|
||||||
namespace XDP {
|
namespace XDP {
|
||||||
|
@ -29,9 +27,7 @@ namespace {
|
||||||
|
|
||||||
using Type = ::FileDialog::internal::Type;
|
using Type = ::FileDialog::internal::Type;
|
||||||
|
|
||||||
constexpr auto kXDGDesktopPortalService = "org.freedesktop.portal.Desktop"_cs;
|
constexpr auto kXDPFileChooserInterface = "org.freedesktop.portal.FileChooser"_cs;
|
||||||
constexpr auto kXDGDesktopPortalObjectPath = "/org/freedesktop/portal/desktop"_cs;
|
|
||||||
constexpr auto kXDGDesktopPortalFileChooserInterface = "org.freedesktop.portal.FileChooser"_cs;
|
|
||||||
constexpr auto kPropertiesInterface = "org.freedesktop.DBus.Properties"_cs;
|
constexpr auto kPropertiesInterface = "org.freedesktop.DBus.Properties"_cs;
|
||||||
|
|
||||||
const char *filterRegExp =
|
const char *filterRegExp =
|
||||||
|
@ -90,12 +86,12 @@ void ComputeFileChooserPortalVersion() {
|
||||||
}
|
}
|
||||||
|
|
||||||
connection->call(
|
connection->call(
|
||||||
std::string(kXDGDesktopPortalObjectPath),
|
std::string(base::Platform::XDP::kObjectPath),
|
||||||
std::string(kPropertiesInterface),
|
std::string(kPropertiesInterface),
|
||||||
"Get",
|
"Get",
|
||||||
base::Platform::MakeGlibVariant(std::tuple{
|
base::Platform::MakeGlibVariant(std::tuple{
|
||||||
Glib::ustring(
|
Glib::ustring(
|
||||||
std::string(kXDGDesktopPortalFileChooserInterface)),
|
std::string(kXDPFileChooserInterface)),
|
||||||
Glib::ustring("version"),
|
Glib::ustring("version"),
|
||||||
}),
|
}),
|
||||||
[=](const Glib::RefPtr<Gio::AsyncResult> &result) {
|
[=](const Glib::RefPtr<Gio::AsyncResult> &result) {
|
||||||
|
@ -123,7 +119,7 @@ void ComputeFileChooserPortalVersion() {
|
||||||
QString::fromStdString(e.what())));
|
QString::fromStdString(e.what())));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
std::string(kXDGDesktopPortalService));
|
std::string(base::Platform::XDP::kService));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a patched copy of file dialog from qxdgdesktopportal theme plugin.
|
// This is a patched copy of file dialog from qxdgdesktopportal theme plugin.
|
||||||
|
@ -262,17 +258,6 @@ XDPFileDialog::~XDPFileDialog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void XDPFileDialog::openPortal() {
|
void XDPFileDialog::openPortal() {
|
||||||
std::stringstream parentWindowId;
|
|
||||||
|
|
||||||
if (const auto integration = WaylandIntegration::Instance()) {
|
|
||||||
if (const auto handle = integration->nativeHandle(_parent)
|
|
||||||
; !handle.isEmpty()) {
|
|
||||||
parentWindowId << "wayland:" << handle.toStdString();
|
|
||||||
}
|
|
||||||
} else if (IsX11() && _parent) {
|
|
||||||
parentWindowId << "x11:" << std::hex << _parent->winId();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::map<Glib::ustring, Glib::VariantBase> options;
|
std::map<Glib::ustring, Glib::VariantBase> options;
|
||||||
if (!_acceptLabel.empty()) {
|
if (!_acceptLabel.empty()) {
|
||||||
options["accept_label"] = Glib::Variant<Glib::ustring>::create(
|
options["accept_label"] = Glib::Variant<Glib::ustring>::create(
|
||||||
|
@ -448,13 +433,13 @@ void XDPFileDialog::openPortal() {
|
||||||
requestPath);
|
requestPath);
|
||||||
|
|
||||||
_dbusConnection->call(
|
_dbusConnection->call(
|
||||||
std::string(kXDGDesktopPortalObjectPath),
|
std::string(base::Platform::XDP::kObjectPath),
|
||||||
std::string(kXDGDesktopPortalFileChooserInterface),
|
std::string(kXDPFileChooserInterface),
|
||||||
_acceptMode == QFileDialog::AcceptSave
|
_acceptMode == QFileDialog::AcceptSave
|
||||||
? "SaveFile"
|
? "SaveFile"
|
||||||
: "OpenFile",
|
: "OpenFile",
|
||||||
base::Platform::MakeGlibVariant(std::tuple{
|
base::Platform::MakeGlibVariant(std::tuple{
|
||||||
Glib::ustring(parentWindowId.str()),
|
base::Platform::XDP::ParentWindowID(_parent),
|
||||||
_windowTitle,
|
_windowTitle,
|
||||||
options,
|
options,
|
||||||
}),
|
}),
|
||||||
|
@ -503,7 +488,7 @@ void XDPFileDialog::openPortal() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
std::string(kXDGDesktopPortalService));
|
std::string(base::Platform::XDP::kService));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
_failedToOpen = true;
|
_failedToOpen = true;
|
||||||
_reject.fire({});
|
_reject.fire({});
|
||||||
|
|
|
@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "base/platform/linux/base_linux_glibmm_helper.h"
|
#include "base/platform/linux/base_linux_glibmm_helper.h"
|
||||||
#include "base/platform/linux/base_linux_wayland_integration.h"
|
#include "base/platform/linux/base_linux_xdp_utilities.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "base/random.h"
|
#include "base/random.h"
|
||||||
|
@ -21,16 +21,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include <giomm.h>
|
#include <giomm.h>
|
||||||
#include <private/qguiapplication_p.h>
|
#include <private/qguiapplication_p.h>
|
||||||
|
|
||||||
using base::Platform::WaylandIntegration;
|
|
||||||
|
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
namespace File {
|
namespace File {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kXDGDesktopPortalService = "org.freedesktop.portal.Desktop"_cs;
|
constexpr auto kXDPOpenURIInterface = "org.freedesktop.portal.OpenURI"_cs;
|
||||||
constexpr auto kXDGDesktopPortalObjectPath = "/org/freedesktop/portal/desktop"_cs;
|
|
||||||
constexpr auto kXDGDesktopPortalOpenURIInterface = "org.freedesktop.portal.OpenURI"_cs;
|
|
||||||
constexpr auto kPropertiesInterface = "org.freedesktop.DBus.Properties"_cs;
|
constexpr auto kPropertiesInterface = "org.freedesktop.DBus.Properties"_cs;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -41,15 +37,15 @@ bool ShowXDPOpenWithDialog(const QString &filepath) {
|
||||||
Gio::DBus::BusType::BUS_TYPE_SESSION);
|
Gio::DBus::BusType::BUS_TYPE_SESSION);
|
||||||
|
|
||||||
auto reply = connection->call_sync(
|
auto reply = connection->call_sync(
|
||||||
std::string(kXDGDesktopPortalObjectPath),
|
std::string(base::Platform::XDP::kObjectPath),
|
||||||
std::string(kPropertiesInterface),
|
std::string(kPropertiesInterface),
|
||||||
"Get",
|
"Get",
|
||||||
base::Platform::MakeGlibVariant(std::tuple{
|
base::Platform::MakeGlibVariant(std::tuple{
|
||||||
Glib::ustring(
|
Glib::ustring(
|
||||||
std::string(kXDGDesktopPortalOpenURIInterface)),
|
std::string(kXDPOpenURIInterface)),
|
||||||
Glib::ustring("version"),
|
Glib::ustring("version"),
|
||||||
}),
|
}),
|
||||||
std::string(kXDGDesktopPortalService));
|
std::string(base::Platform::XDP::kService));
|
||||||
|
|
||||||
const auto version = base::Platform::GlibVariantCast<uint>(
|
const auto version = base::Platform::GlibVariantCast<uint>(
|
||||||
base::Platform::GlibVariantCast<Glib::VariantBase>(
|
base::Platform::GlibVariantCast<Glib::VariantBase>(
|
||||||
|
@ -72,24 +68,13 @@ bool ShowXDPOpenWithDialog(const QString &filepath) {
|
||||||
const auto fdGuard = gsl::finally([&] { ::close(fd); });
|
const auto fdGuard = gsl::finally([&] { ::close(fd); });
|
||||||
|
|
||||||
const auto parentWindowId = [&]() -> Glib::ustring {
|
const auto parentWindowId = [&]() -> Glib::ustring {
|
||||||
std::stringstream result;
|
|
||||||
|
|
||||||
const auto activeWindow = Core::App().activeWindow();
|
const auto activeWindow = Core::App().activeWindow();
|
||||||
if (!activeWindow) {
|
if (!activeWindow) {
|
||||||
return result.str();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto window = activeWindow->widget()->windowHandle();
|
return base::Platform::XDP::ParentWindowID(
|
||||||
if (const auto integration = WaylandIntegration::Instance()) {
|
activeWindow->widget()->windowHandle());
|
||||||
if (const auto handle = integration->nativeHandle(window)
|
|
||||||
; !handle.isEmpty()) {
|
|
||||||
result << "wayland:" << handle.toStdString();
|
|
||||||
}
|
|
||||||
} else if (IsX11()) {
|
|
||||||
result << "x11:" << std::hex << window->winId();
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.str();
|
|
||||||
}();
|
}();
|
||||||
|
|
||||||
const auto handleToken = Glib::ustring("tdesktop")
|
const auto handleToken = Glib::ustring("tdesktop")
|
||||||
|
@ -122,7 +107,7 @@ bool ShowXDPOpenWithDialog(const QString &filepath) {
|
||||||
const Glib::VariantContainerBase ¶meters) {
|
const Glib::VariantContainerBase ¶meters) {
|
||||||
loop->quit();
|
loop->quit();
|
||||||
},
|
},
|
||||||
std::string(kXDGDesktopPortalService),
|
std::string(base::Platform::XDP::kService),
|
||||||
"org.freedesktop.portal.Request",
|
"org.freedesktop.portal.Request",
|
||||||
"Response",
|
"Response",
|
||||||
requestPath);
|
requestPath);
|
||||||
|
@ -138,8 +123,8 @@ bool ShowXDPOpenWithDialog(const QString &filepath) {
|
||||||
auto outFdList = Glib::RefPtr<Gio::UnixFDList>();
|
auto outFdList = Glib::RefPtr<Gio::UnixFDList>();
|
||||||
|
|
||||||
connection->call_sync(
|
connection->call_sync(
|
||||||
std::string(kXDGDesktopPortalObjectPath),
|
std::string(base::Platform::XDP::kObjectPath),
|
||||||
std::string(kXDGDesktopPortalOpenURIInterface),
|
std::string(kXDPOpenURIInterface),
|
||||||
"OpenFile",
|
"OpenFile",
|
||||||
Glib::VariantContainerBase::create_tuple({
|
Glib::VariantContainerBase::create_tuple({
|
||||||
Glib::Variant<Glib::ustring>::create(parentWindowId),
|
Glib::Variant<Glib::ustring>::create(parentWindowId),
|
||||||
|
@ -160,7 +145,7 @@ bool ShowXDPOpenWithDialog(const QString &filepath) {
|
||||||
}),
|
}),
|
||||||
fdList,
|
fdList,
|
||||||
outFdList,
|
outFdList,
|
||||||
std::string(kXDGDesktopPortalService));
|
std::string(base::Platform::XDP::kService));
|
||||||
|
|
||||||
if (signalId != 0) {
|
if (signalId != 0) {
|
||||||
QWindow window;
|
QWindow window;
|
||||||
|
|
|
@ -9,7 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "base/random.h"
|
#include "base/random.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "base/platform/linux/base_linux_wayland_integration.h"
|
|
||||||
#include "platform/linux/linux_desktop_environment.h"
|
#include "platform/linux/linux_desktop_environment.h"
|
||||||
#include "platform/linux/linux_wayland_integration.h"
|
#include "platform/linux/linux_wayland_integration.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
@ -56,7 +55,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace Platform;
|
using namespace Platform;
|
||||||
using BaseWaylandIntegration = base::Platform::WaylandIntegration;
|
|
||||||
using Platform::internal::WaylandIntegration;
|
using Platform::internal::WaylandIntegration;
|
||||||
|
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
|
@ -65,8 +63,6 @@ namespace {
|
||||||
constexpr auto kDesktopFile = ":/misc/telegramdesktop.desktop"_cs;
|
constexpr auto kDesktopFile = ":/misc/telegramdesktop.desktop"_cs;
|
||||||
constexpr auto kIconName = "telegram"_cs;
|
constexpr auto kIconName = "telegram"_cs;
|
||||||
|
|
||||||
constexpr auto kXDGDesktopPortalService = "org.freedesktop.portal.Desktop"_cs;
|
|
||||||
constexpr auto kXDGDesktopPortalObjectPath = "/org/freedesktop/portal/desktop"_cs;
|
|
||||||
constexpr auto kIBusPortalService = "org.freedesktop.portal.IBus"_cs;
|
constexpr auto kIBusPortalService = "org.freedesktop.portal.IBus"_cs;
|
||||||
constexpr auto kWebviewService = "org.telegram.desktop.GtkIntegration.WebviewHelper-%1-%2"_cs;
|
constexpr auto kWebviewService = "org.telegram.desktop.GtkIntegration.WebviewHelper-%1-%2"_cs;
|
||||||
|
|
||||||
|
@ -81,24 +77,13 @@ void PortalAutostart(bool start, bool silent) {
|
||||||
Gio::DBus::BusType::BUS_TYPE_SESSION);
|
Gio::DBus::BusType::BUS_TYPE_SESSION);
|
||||||
|
|
||||||
const auto parentWindowId = [&]() -> Glib::ustring {
|
const auto parentWindowId = [&]() -> Glib::ustring {
|
||||||
std::stringstream result;
|
|
||||||
|
|
||||||
const auto activeWindow = Core::App().activeWindow();
|
const auto activeWindow = Core::App().activeWindow();
|
||||||
if (!activeWindow) {
|
if (!activeWindow) {
|
||||||
return result.str();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto window = activeWindow->widget()->windowHandle();
|
return base::Platform::XDP::ParentWindowID(
|
||||||
if (const auto integration = BaseWaylandIntegration::Instance()) {
|
activeWindow->widget()->windowHandle());
|
||||||
if (const auto handle = integration->nativeHandle(window)
|
|
||||||
; !handle.isEmpty()) {
|
|
||||||
result << "wayland:" << handle.toStdString();
|
|
||||||
}
|
|
||||||
} else if (IsX11()) {
|
|
||||||
result << "x11:" << std::hex << window->winId();
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.str();
|
|
||||||
}();
|
}();
|
||||||
|
|
||||||
const auto handleToken = Glib::ustring("tdesktop")
|
const auto handleToken = Glib::ustring("tdesktop")
|
||||||
|
@ -163,7 +148,7 @@ void PortalAutostart(bool start, bool silent) {
|
||||||
|
|
||||||
loop->quit();
|
loop->quit();
|
||||||
},
|
},
|
||||||
std::string(kXDGDesktopPortalService),
|
std::string(base::Platform::XDP::kService),
|
||||||
"org.freedesktop.portal.Request",
|
"org.freedesktop.portal.Request",
|
||||||
"Response",
|
"Response",
|
||||||
requestPath);
|
requestPath);
|
||||||
|
@ -175,14 +160,14 @@ void PortalAutostart(bool start, bool silent) {
|
||||||
});
|
});
|
||||||
|
|
||||||
connection->call_sync(
|
connection->call_sync(
|
||||||
std::string(kXDGDesktopPortalObjectPath),
|
std::string(base::Platform::XDP::kObjectPath),
|
||||||
"org.freedesktop.portal.Background",
|
"org.freedesktop.portal.Background",
|
||||||
"RequestBackground",
|
"RequestBackground",
|
||||||
base::Platform::MakeGlibVariant(std::tuple{
|
base::Platform::MakeGlibVariant(std::tuple{
|
||||||
parentWindowId,
|
parentWindowId,
|
||||||
options,
|
options,
|
||||||
}),
|
}),
|
||||||
std::string(kXDGDesktopPortalService));
|
std::string(base::Platform::XDP::kService));
|
||||||
|
|
||||||
if (signalId != 0) {
|
if (signalId != 0) {
|
||||||
QWindow window;
|
QWindow window;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit a23ec1340b65c37f551a9f0870897f0a8f9e5503
|
Subproject commit 5ab3cdaef587b8ac8fdf1a96879961fd57ac7ace
|
Loading…
Add table
Reference in a new issue