mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-26 15:59:50 -05:00
Fix clicking tray icon to toggle window on Linux (#3258)
KDE does not take focus from the current active window when the tray icon is clicked. This prevented toggling the window (always called bringToFront). Checking if the window is active corrects this issue. Fixes #3256, fixes #3214.
This commit is contained in:
parent
6d449aca49
commit
72de3cf9ca
@ -25,6 +25,7 @@
|
|||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QWindow>
|
||||||
|
|
||||||
#include "config-keepassx.h"
|
#include "config-keepassx.h"
|
||||||
|
|
||||||
@ -1088,9 +1089,16 @@ void MainWindow::processTrayIconTrigger()
|
|||||||
toggleWindow();
|
toggleWindow();
|
||||||
} else if (m_trayIconTriggerReason == QSystemTrayIcon::Trigger
|
} else if (m_trayIconTriggerReason == QSystemTrayIcon::Trigger
|
||||||
|| m_trayIconTriggerReason == QSystemTrayIcon::MiddleClick) {
|
|| m_trayIconTriggerReason == QSystemTrayIcon::MiddleClick) {
|
||||||
// On single/middle click focus the window if it is not hidden
|
// Toggle window if hidden
|
||||||
// and did not have focus less than a second ago, otherwise toggle
|
// If on windows, check if focus switched within the last second because
|
||||||
if (isHidden() || (Clock::currentSecondsSinceEpoch() - m_lastFocusOutTime) <= 1) {
|
// clicking the tray icon removes focus from main window
|
||||||
|
// If on Linux or macOS, check if the window is active
|
||||||
|
if (isHidden()
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
|| (Clock::currentSecondsSinceEpoch() - m_lastFocusOutTime) <= 1) {
|
||||||
|
#else
|
||||||
|
|| windowHandle()->isActive()) {
|
||||||
|
#endif
|
||||||
toggleWindow();
|
toggleWindow();
|
||||||
} else {
|
} else {
|
||||||
bringToFront();
|
bringToFront();
|
||||||
|
Loading…
Reference in New Issue
Block a user