From fff550d7b8e01d7f7e50fd62829c7aad15fad94d Mon Sep 17 00:00:00 2001 From: Palo Kisa Date: Fri, 8 Apr 2022 11:12:23 +0200 Subject: [PATCH 1/2] mainmenu: Remove shortcut popup delay This was introduced as workaround for "menu not in focus after shortcut activation". But the root cause of the problem was probably in lxqt-globalkeys, where the signal was triggered on KeyPress instead of KeyRelease <- this was fixed recently. Now the delay is pointless. --- plugin-mainmenu/lxqtmainmenu.cpp | 12 +----------- plugin-mainmenu/lxqtmainmenu.h | 1 - 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/plugin-mainmenu/lxqtmainmenu.cpp b/plugin-mainmenu/lxqtmainmenu.cpp index a689db423..7a4024168 100644 --- a/plugin-mainmenu/lxqtmainmenu.cpp +++ b/plugin-mainmenu/lxqtmainmenu.cpp @@ -77,9 +77,6 @@ LXQtMainMenu::LXQtMainMenu(const ILXQtPanelPluginStartupInfo &startupInfo): mMenuCacheNotify = nullptr; #endif - mDelayedPopup.setSingleShot(true); - mDelayedPopup.setInterval(200); - connect(&mDelayedPopup, &QTimer::timeout, this, &LXQtMainMenu::showHideMenu); mHideTimer.setSingleShot(true); mHideTimer.setInterval(250); @@ -132,14 +129,7 @@ LXQtMainMenu::LXQtMainMenu(const ILXQtPanelPluginStartupInfo &startupInfo): else mShortcutSeq = mShortcut->shortcut(); }); - connect(mShortcut, &GlobalKeyShortcut::Action::activated, this, [this] { - if (!mHideTimer.isActive()) - // Delay this a little -- if we don't do this, search field - // won't be able to capture focus - // See and - // - mDelayedPopup.start(); - }); + connect(mShortcut, &GlobalKeyShortcut::Action::activated, this, &LXQtMainMenu::showHideMenu); } } diff --git a/plugin-mainmenu/lxqtmainmenu.h b/plugin-mainmenu/lxqtmainmenu.h index 7dedb297c..0d1647ce0 100644 --- a/plugin-mainmenu/lxqtmainmenu.h +++ b/plugin-mainmenu/lxqtmainmenu.h @@ -110,7 +110,6 @@ class LXQtMainMenu : public QObject, public ILXQtPanelPlugin XdgMenu mXdgMenu; #endif - QTimer mDelayedPopup; QTimer mHideTimer; QTimer mSearchTimer; QString mShortcutSeq; From 1e4cd35a0f9f613278ef52d0adad956311f2498f Mon Sep 17 00:00:00 2001 From: Palo Kisa Date: Fri, 8 Apr 2022 11:28:10 +0200 Subject: [PATCH 2/2] mainmenu: Remove unused timer This is some remnant from previous workaround to https://github.com/lxqt/lxqt/issues/549. Note: the referenced bug is not seen in current version. --- plugin-mainmenu/lxqtmainmenu.cpp | 6 ------ plugin-mainmenu/lxqtmainmenu.h | 1 - 2 files changed, 7 deletions(-) diff --git a/plugin-mainmenu/lxqtmainmenu.cpp b/plugin-mainmenu/lxqtmainmenu.cpp index 7a4024168..e6fe5cf94 100644 --- a/plugin-mainmenu/lxqtmainmenu.cpp +++ b/plugin-mainmenu/lxqtmainmenu.cpp @@ -77,9 +77,6 @@ LXQtMainMenu::LXQtMainMenu(const ILXQtPanelPluginStartupInfo &startupInfo): mMenuCacheNotify = nullptr; #endif - mHideTimer.setSingleShot(true); - mHideTimer.setInterval(250); - mSearchTimer.setSingleShot(true); connect(&mSearchTimer, &QTimer::timeout, this, &LXQtMainMenu::searchMenu); mSearchTimer.setInterval(350); // typing speed (not very fast) @@ -420,8 +417,6 @@ void LXQtMainMenu::buildMenu() mMenu->addSeparator(); menuInstallEventFilter(mMenu, this); - connect(mMenu, &QMenu::aboutToHide, &mHideTimer, QOverload<>::of(&QTimer::start)); - connect(mMenu, &QMenu::aboutToShow, &mHideTimer, &QTimer::stop); mMenu->addSeparator(); mMenu->addAction(mSearchViewAction); @@ -657,7 +652,6 @@ bool LXQtMainMenu::eventFilter(QObject *obj, QEvent *event) const QString press = QKeySequence{static_cast(mod)}.toString() % QString::fromLatin1(key_meta.valueToKey(keyEvent->key())).remove(0, 4); if (press == mShortcutSeq) { - mHideTimer.start(); mMenu->hide(); // close the app menu return true; } diff --git a/plugin-mainmenu/lxqtmainmenu.h b/plugin-mainmenu/lxqtmainmenu.h index 0d1647ce0..f751a9b45 100644 --- a/plugin-mainmenu/lxqtmainmenu.h +++ b/plugin-mainmenu/lxqtmainmenu.h @@ -110,7 +110,6 @@ class LXQtMainMenu : public QObject, public ILXQtPanelPlugin XdgMenu mXdgMenu; #endif - QTimer mHideTimer; QTimer mSearchTimer; QString mShortcutSeq; QString mMenuFile;