From 06bf67c1462c4192fcc376fbb785d3a0b9c57873 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 1 Aug 2018 20:14:55 +0300 Subject: [PATCH] Don't show PopupMenu for inactive window on macOS. On macOS context menu (right click) doesn't activate the window that was clicked. - You can't activate it yourself if some other application is active. - It's hard to make menu work while window still is inactive (like macOS menus). Because when you left-click anything after right click Qt makes the window something-like-focused (it shows on top and receives input), but not really (it still displays as inactive, cursor not blinking and all). Looks like Qt bug. --- Telegram/SourceFiles/ui/widgets/popup_menu.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Telegram/SourceFiles/ui/widgets/popup_menu.cpp b/Telegram/SourceFiles/ui/widgets/popup_menu.cpp index 1ce30aa6b..4ea20b648 100644 --- a/Telegram/SourceFiles/ui/widgets/popup_menu.cpp +++ b/Telegram/SourceFiles/ui/widgets/popup_menu.cpp @@ -423,6 +423,12 @@ void PopupMenu::popup(const QPoint &p) { } void PopupMenu::showMenu(const QPoint &p, PopupMenu *parent, TriggeredSource source) { + if (cPlatform() == dbipMac || cPlatform() == dbipMacOld) { + if (!parent && !static_cast(QApplication::instance())->activeWindow()) { + crl::on_main(this, [=] { show(); hideFast(); }); + return; + } + } _parent = parent; auto origin = PanelAnimation::Origin::TopLeft;