From 39f91477903a22094a81b9cdcad2af96d5d14347 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 29 Dec 2020 16:13:53 +0400 Subject: [PATCH] Check for dbus menu exporter instead of menu path --- .../platform/linux/main_window_linux.cpp | 17 +++++++++-------- .../platform/linux/main_window_linux.h | 1 - 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index 145847c50..00a48742d 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -67,6 +67,7 @@ namespace { constexpr auto kPanelTrayIconName = "telegram-panel"_cs; constexpr auto kMutePanelTrayIconName = "telegram-mute-panel"_cs; constexpr auto kAttentionPanelTrayIconName = "telegram-attention-panel"_cs; + constexpr auto kPropertiesInterface = "org.freedesktop.DBus.Properties"_cs; constexpr auto kTrayIconFilename = "tdesktop-trayicon-XXXXXX.png"_cs; @@ -78,6 +79,8 @@ constexpr auto kAppMenuService = "com.canonical.AppMenu.Registrar"_cs; constexpr auto kAppMenuObjectPath = "/com/canonical/AppMenu/Registrar"_cs; constexpr auto kAppMenuInterface = kAppMenuService; +constexpr auto kMainMenuObjectPath = "/MenuBar"_cs; + bool TrayIconMuted = true; int32 TrayIconCount = 0; base::flat_map TrayIconImageBack; @@ -760,8 +763,8 @@ void MainWindow::handleAppMenuOwnerChanged( LOG(("Not using D-Bus global menu.")); } - if (_appMenuSupported && !_mainMenuPath.isEmpty()) { - RegisterAppMenu(winId(), _mainMenuPath); + if (_appMenuSupported && _mainMenuExporter) { + RegisterAppMenu(winId(), kMainMenuObjectPath.utf16()); } else { UnregisterAppMenu(winId()); } @@ -1076,14 +1079,12 @@ void MainWindow::createGlobalMenu() { about->setMenuRole(QAction::AboutQtRole); - _mainMenuPath = qsl("/MenuBar"); - _mainMenuExporter = new DBusMenuExporter( - _mainMenuPath, + kMainMenuObjectPath.utf16(), psMainMenu); if (_appMenuSupported) { - RegisterAppMenu(winId(), _mainMenuPath); + RegisterAppMenu(winId(), kMainMenuObjectPath.utf16()); } updateGlobalMenu(); @@ -1215,9 +1216,9 @@ void MainWindow::handleVisibleChangedHook(bool visible) { } #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION - if (_appMenuSupported && !_mainMenuPath.isEmpty()) { + if (_appMenuSupported && _mainMenuExporter) { if (visible) { - RegisterAppMenu(winId(), _mainMenuPath); + RegisterAppMenu(winId(), kMainMenuObjectPath.utf16()); } else { UnregisterAppMenu(winId()); } diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.h b/Telegram/SourceFiles/platform/linux/main_window_linux.h index 3132b7acb..5e06aadbe 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.h +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.h @@ -92,7 +92,6 @@ private: bool _appMenuSupported = false; DBusMenuExporter *_mainMenuExporter = nullptr; - QString _mainMenuPath; std::unique_ptr _gsdMediaKeys;