diff options
author | Vlad Zahorodnii <[email protected]> | 2025-04-02 21:38:54 +0300 |
---|---|---|
committer | Vlad Zahorodnii <[email protected]> | 2025-04-11 14:54:31 +0300 |
commit | fa1fab994e76c19a08903e9b641732ce388a30bd (patch) | |
tree | abe78e82f75a14cf0e7b53aeabc1076bc49a1403 | |
parent | d0df02ad8a20316410ac51db86e2df4ae24f0d7f (diff) |
dbusmenu: Skip registration with the registrar on Wayland
The RegisterWindow request expects a window id. The QDBusMenuBar uses
the QWindow::winId() property for that. On X11, the winId() returns
the XID of the window. On Wayland, the winId() returns an integer that
has meaning only to the application, there are no global window ids on
Wayland. The menubar should be registered using other means, for
example using the kde-appmenu protocol, which QtWayland already does.
The QDBusMenuBar can skip synchronously calling the RegisterWindow
request on Wayland because the menu will be registered using a different
api.
Pick-to: 6.9
Change-Id: I6b2968624c5c9ddbdc93807f65eac369dc7a993a
Reviewed-by: David Edmundson <[email protected]>
Reviewed-by: Liang Qi <[email protected]>
-rw-r--r-- | src/gui/platform/unix/dbusmenu/qdbusmenubar.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/gui/platform/unix/dbusmenu/qdbusmenubar.cpp b/src/gui/platform/unix/dbusmenu/qdbusmenubar.cpp index 6fa0e8b36af..153dedf54ac 100644 --- a/src/gui/platform/unix/dbusmenu/qdbusmenubar.cpp +++ b/src/gui/platform/unix/dbusmenu/qdbusmenubar.cpp @@ -118,15 +118,18 @@ void QDBusMenuBar::registerMenuBar() if (!connection.registerObject(m_objectPath, m_menu)) return; - QDBusMenuRegistrarInterface registrar(REGISTRAR_SERVICE, REGISTRAR_PATH, connection, this); - QDBusPendingReply<> r = registrar.RegisterWindow(m_window->winId(), QDBusObjectPath(m_objectPath)); - r.waitForFinished(); - if (r.isError()) { - qWarning("Failed to register window menu, reason: %s (\"%s\")", - qUtf8Printable(r.error().name()), qUtf8Printable(r.error().message())); - connection.unregisterObject(m_objectPath); - return; + if (QGuiApplication::platformName() == "xcb"_L1) { + QDBusMenuRegistrarInterface registrar(REGISTRAR_SERVICE, REGISTRAR_PATH, connection, this); + QDBusPendingReply<> r = registrar.RegisterWindow(m_window->winId(), QDBusObjectPath(m_objectPath)); + r.waitForFinished(); + if (r.isError()) { + qWarning("Failed to register window menu, reason: %s (\"%s\")", + qUtf8Printable(r.error().name()), qUtf8Printable(r.error().message())); + connection.unregisterObject(m_objectPath); + return; + } } + const auto unixServices = dynamic_cast<QDesktopUnixServices *>( QGuiApplicationPrivate::platformIntegration()->services()); unixServices->registerDBusMenuForWindow(m_window, connection.baseService(), m_objectPath); @@ -137,12 +140,14 @@ void QDBusMenuBar::unregisterMenuBar() QDBusConnection connection = QDBusConnection::sessionBus(); if (m_window) { - QDBusMenuRegistrarInterface registrar(REGISTRAR_SERVICE, REGISTRAR_PATH, connection, this); - QDBusPendingReply<> r = registrar.UnregisterWindow(m_window->winId()); - r.waitForFinished(); - if (r.isError()) - qWarning("Failed to unregister window menu, reason: %s (\"%s\")", - qUtf8Printable(r.error().name()), qUtf8Printable(r.error().message())); + if (QGuiApplication::platformName() == "xcb"_L1) { + QDBusMenuRegistrarInterface registrar(REGISTRAR_SERVICE, REGISTRAR_PATH, connection, this); + QDBusPendingReply<> r = registrar.UnregisterWindow(m_window->winId()); + r.waitForFinished(); + if (r.isError()) + qWarning("Failed to unregister window menu, reason: %s (\"%s\")", + qUtf8Printable(r.error().name()), qUtf8Printable(r.error().message())); + } const auto unixServices = dynamic_cast<QDesktopUnixServices *>( QGuiApplicationPrivate::platformIntegration()->services()); |