Set _KDE_NET_WM_DESKTOP_FILE on X11

This commit is contained in:
Ilya Fedin 2021-05-30 15:05:07 +04:00 committed by John Preston
parent cf8e1cfd0f
commit c6dcc57c5e

View File

@ -133,6 +133,39 @@ void XCBSkipTaskbar(QWindow *window, bool skip) {
| XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY,
reinterpret_cast<const char*>(&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())));
}