Don't try to focus the window when clicking on tray icon on Wayland

This commit is contained in:
Ilya Fedin 2020-06-21 12:42:08 +04:00 committed by John Preston
parent 68fde210c6
commit 384a71930d

View file

@ -143,7 +143,7 @@ void MainWindow::createTrayIconMenu() {
? tr::lng_disable_notifications_from_tray(tr::now)
: tr::lng_enable_notifications_from_tray(tr::now);
if (Platform::IsLinux()) {
if (Platform::IsLinux() && !Platform::IsWayland()) {
trayIconMenu->addAction(tr::lng_open_from_tray(tr::now), this, SLOT(showFromTray()));
}
trayIconMenu->addAction(tr::lng_minimize_to_tray(tr::now), this, SLOT(minimizeToTray()));
@ -596,12 +596,12 @@ void MainWindow::updateTrayMenu(bool force) {
if (!trayIconMenu || (Platform::IsWindows() && !force)) return;
auto actions = trayIconMenu->actions();
if (Platform::IsLinux()) {
if (Platform::IsLinux() && !Platform::IsWayland()) {
auto minimizeAction = actions.at(1);
minimizeAction->setEnabled(isVisible());
} else {
updateIsActive(0);
auto active = isActive();
auto active = Platform::IsWayland() ? isVisible() : isActive();
auto toggleAction = actions.at(0);
disconnect(toggleAction, SIGNAL(triggered(bool)), this, SLOT(minimizeToTray()));
disconnect(toggleAction, SIGNAL(triggered(bool)), this, SLOT(showFromTray()));
@ -610,7 +610,7 @@ void MainWindow::updateTrayMenu(bool force) {
? tr::lng_minimize_to_tray(tr::now)
: tr::lng_open_from_tray(tr::now));
}
auto notificationAction = actions.at(Platform::IsLinux() ? 2 : 1);
auto notificationAction = actions.at(Platform::IsLinux() && !Platform::IsWayland() ? 2 : 1);
auto notificationActionText = Global::DesktopNotify()
? tr::lng_disable_notifications_from_tray(tr::now)
: tr::lng_enable_notifications_from_tray(tr::now);
@ -735,7 +735,7 @@ void MainWindow::handleTrayIconActication(
updateTrayMenu(true);
QTimer::singleShot(1, this, SLOT(psShowTrayMenu()));
} else if (!skipTrayClick()) {
if (isActive()) {
if (Platform::IsWayland() ? isVisible() : isActive()) {
minimizeToTray();
} else {
showFromTray(reason);