From c6dcc57c5e2b67a93f97def157c5dbdd0b2b994c Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 30 May 2021 15:05:07 +0400 Subject: [PATCH] Set _KDE_NET_WM_DESKTOP_FILE on X11 --- .../platform/linux/main_window_linux.cpp | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index 091bd46c6c..73b9c8edee 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -133,6 +133,39 @@ void XCBSkipTaskbar(QWindow *window, bool skip) { | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY, reinterpret_cast(&xev)); } + +void XCBSetDesktopFileName(QWindow *window) { + const auto connection = base::Platform::XCB::GetConnectionFromQt(); + if (!connection) { + return; + } + + const auto desktopFileAtom = base::Platform::XCB::GetAtom( + connection, + "_KDE_NET_WM_DESKTOP_FILE"); + + const auto utf8Atom = base::Platform::XCB::GetAtom( + connection, + "UTF8_STRING"); + + if (!desktopFileAtom.has_value() || !utf8Atom.has_value()) { + return; + } + + const auto filename = QGuiApplication::desktopFileName() + .chopped(8) + .toUtf8(); + + xcb_change_property( + connection, + XCB_PROP_MODE_REPLACE, + window->winId(), + *desktopFileAtom, + *utf8Atom, + 8, + filename.size(), + filename.data()); +} #endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION void SkipTaskbar(QWindow *window, bool skip) { @@ -683,6 +716,10 @@ void MainWindow::initHook() { } #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION +#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION + XCBSetDesktopFileName(windowHandle()); +#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION + LOG(("System tray available: %1").arg(Logs::b(trayAvailable()))); }