Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main window doesn't receive focus when Mumble-specific Windows notification is clicked #5701

Closed
Snowknight26 opened this issue May 26, 2022 · 9 comments
Labels
client external-bug Bugs caused by things outside of our control - by dependencies, "upstream" in technical jargon ui windows

Comments

@Snowknight26
Copy link
Contributor

Description

Most programs that can generate a Windows notification have their main window activated whenever the notification is clicked.

Mumble, on the other hand, seems to be the only program that activates the main window in the background. As a result, if Mumble is either minimized to the system tray or its main window is not in focus, clicking on the notification does not bring it to the foreground and focus the main window.

This is especially inconvenient when a maximized window is already in focus, as after clicking on the notification you then also have to click on Mumble in the taskbar (or Alt+Tab, etc.).

I've added a video showing the reproduction steps and issue in action.

Steps to reproduce

  1. Minimize Mumble to system tray or bring another window to the foreground (so that Mumble is in the background)
  2. Click a notification that Mumble generates (such as by having someone send a message to the channel you're in)

Mumble version

1.4.230

Mumble component

Client

OS

Windows

Reproducible?

Yes

Additional information

No response

Relevant log output

No response

Screenshots

2022-05-26_00-25-03.mp4
@Snowknight26 Snowknight26 added bug A bug (error) in the software triage This issue is waiting to be triaged by one of the project members labels May 26, 2022
@Krzmbrzl
Copy link
Member

I know that I have tried bringing something to the foreground on Windows on different occasions and the result was always that it is not possible as Windows places very strict rules on when this is allowed.

See also https://stackoverflow.com/questions/5919928/qt-need-to-bring-qt-application-to-foreground-called-from-win32-application.

However, in this specific case, it might indeed work as here Mumble should be the kast application to receive an input event (the click on the notification), so I guess it would be worth a try.

@Krzmbrzl Krzmbrzl added feature-request This issue or PR deals with a new feature client ui windows good first issue Good for first-time contributors and removed bug A bug (error) in the software triage This issue is waiting to be triaged by one of the project members labels May 26, 2022
@Snowknight26
Copy link
Contributor Author

Was browsing the source code and realized that you already handle the signal that the Qt framework emits whenever the notification is clicked.

connect(qstiIcon, SIGNAL(messageClicked()), this, SLOT(showRaiseWindow()));

MainWindow::showRaiseWindow calls activateWindow, which coincidentally states:

On Windows, if you are calling this when the application is not currently the active one then it will not make it the active window. It will change the color of the taskbar entry to indicate that the window has changed in some way. This is because Microsoft does not allow an application to interrupt what the user is currently doing in another application.

Seems to be exactly what's happening, though I'm sure there has to be a way to activate the window properly seeing as other applications can. Not going to dig further though as I'm out of my depths here.

@Krzmbrzl
Copy link
Member

Ah yeah then this is exactly the behavior that I had in mind.

In this case I'll just close this issue as an "upstream bug" where "upstream" in this case is Windows itself. If even Qt themselves state that this won't work, then I don't see a big chance of use somehow circumventing Windows's restrictions here.

@Krzmbrzl Krzmbrzl added external-bug Bugs caused by things outside of our control - by dependencies, "upstream" in technical jargon and removed good first issue Good for first-time contributors labels May 30, 2022
@Snowknight26
Copy link
Contributor Author

Snowknight26 commented May 30, 2022

Not sure I agree that this is an upstream bug.

I made a test C# win forms project, created a simple form with one TextBox and one NotifyIcon.

Form class was something along the lines of (click/resize/activate/etc. event handlers simply bind to the functions outlined below so not including the rest of the class):

   public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            notifyIcon1.Icon = Properties.Resources.Icon1;
            notifyIcon1.BalloonTipIcon = ToolTipIcon.Info;
            notifyIcon1.BalloonTipText = "Test!";
        }

        private void Form1_Resize(object sender, EventArgs e)
        {
            if(this.WindowState == FormWindowState.Minimized)
            {
                Hide();
                notifyIcon1.Visible = true;
                System.Threading.Thread.Sleep(2000);
                notifyIcon1.ShowBalloonTip(5000);
            }
        }

        private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
        {
            ActivateMainWindow();
        }

        private void notifyIcon1_BalloonTipClicked(object sender, EventArgs e)
        {
            ActivateMainWindow();
        }

        private void Form1_Activated(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + " " + DateTime.Now + " - " + this.Name + " activated\r\n";
        }

        private void Form1_Deactivate(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + " " + DateTime.Now + " - " + this.Name + " deactivated\r\n";
        }

        private void ActivateMainWindow()
        {
            Show();
            this.WindowState = FormWindowState.Normal;
            notifyIcon1.Visible = false;
        }
    }

As expected, clicking the notification that is shown when calling ShowBalloonTip() does activate the window, which illustrates that the intended behavior is definitely possible.

Digging deeper it seems that the issue might specifically be:

setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);

If you disable the option of hiding Mumble to the system tray when minimized, minimize Mumble then clicking on a notification, Mumble restores itself and is now the top-most window (even if it's still not activated). Definitely better than before because at least now the main Mumble window is in the foreground.

I don't have a C++ compiler handy to test but I feel like showRaiseWindow needs some minor modifications, maybe something along the lines of:

void MainWindow::showRaiseWindow() {
	show();
        // don't need a conditional check for being minimized since we're always removing the Qt::WindowMinimized flag
	setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
	raise();
	activateWindow();
}

That should hopefully:

  1. Restore from system tray
  2. Remove the Minimized window state
  3. Set the Active window state
  4. Set the window to be the top-most window (foreground)
  5. Activate the window

@Krzmbrzl
Copy link
Member

Krzmbrzl commented May 30, 2022

I'm afraid that messing with the minimize to tray feature in any way will become an enormous undertaking in and of itself as this is a complete mess that tends to create infinite loops and whatnot 👀

It might be worth a try though

@Krzmbrzl Krzmbrzl reopened this May 30, 2022
@Krzmbrzl Krzmbrzl added help wanted Good community contribution opportunities and removed external-bug Bugs caused by things outside of our control - by dependencies, "upstream" in technical jargon labels May 30, 2022
@Snowknight26
Copy link
Contributor Author

I gave this a shot a couple weeks ago, using some ideas from other programs that use the Qt framework and correctly bring a window to focus, but didn't have any luck solely changing what showRaiseWindow does. I wonder if a handle to the foreground process/window that triggered the notification isn't being passed properly somehow. Might have to look into how and which Mumble windows create the notification.

More reading:
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setforegroundwindow

Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jun 14, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jun 14, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jun 14, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
@Hartmnt
Copy link
Member

Hartmnt commented Jun 14, 2024

Hi,

I investigated this in #6466 and there are three issues here:

  1. The notification event on messageClicked is buggy in Qt in general https://bugreports.qt.io/browse/QTBUG-87329
  2. This thread talks about "de-minimaziation" aka "restoring" a window and "giving focus to a window" aka "activating the window" somewhat confusingly.

and most importantly

  1. As written in the linked Qt documentation of activateWindow above: It is simply a limitation of the Windows compositor/window manager to not allow applications to steal focus. This is a deliberate decision of Microsoft and honored by Qt (Qt probably has no choice in this, as Windows will unlikely provide an API for something they do not want applications to do). We have no way to work around this either. The reason this might work for other applications / in some scenarios is stated in https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setforegroundwindow
Additionally, at least one of the following conditions is true:
    The calling process is the foreground process.
    The calling process was started by the foreground process.
    There is currently no foreground window, and thus no foreground process.
    The calling process received the last input event.
    Either the foreground process or the calling process is being debugged.

Meaning that if there is no foreground window (focus on the desktop maybe?) this might work etc.


Anyway, in #6466 I modified the showRaiseWindow function and fixed the tray behavior in general. Which means that I believe that Mumble should at least be correctly restored from minimization now. If you are still using Mumble and are willing to test the changes to the tray icon, I would be very glad. I need some Windows users to test this.

However, the issue as stated here (no focus on notification click) can not be fixed by us and would require a change in the Windows compositor/window manager.

@Hartmnt Hartmnt added external-bug Bugs caused by things outside of our control - by dependencies, "upstream" in technical jargon and removed feature-request This issue or PR deals with a new feature help wanted Good community contribution opportunities labels Jun 14, 2024
@Hartmnt Hartmnt closed this as not planned Won't fix, can't repro, duplicate, stale Jun 14, 2024
@Snowknight26
Copy link
Contributor Author

If you are still using Mumble and are willing to test the changes to the tray icon, I would be very glad. I need some Windows users to test this.

Every day. 😉 Happy to test.

@Hartmnt
Copy link
Member

Hartmnt commented Jun 15, 2024

@Snowknight26 That would be really great!

This is a Mumble Windows build created by our CI pipeline:
https://dev.azure.com/Mumble-VoIP/c819eb06-7b22-4ef3-bbcd-860094454eb3/_apis/build/builds/8469/artifacts?artifactName=Windows%20%28x64%29%20installer&api-version=7.1&%24format=zip

I assume you are currently using 1.5.634, which means there should be no problem in upgrading to the test build. If you are coming from 1.4.x you might want to backup your settings file before upgrading in case the experimental build breaks something, because the settings will be migrated to a JSON file from 1.4 -> 1.5.

Please check, if the tray icon behaves "as correct as possible" in this experimental build 😅 I have also added a few questions to the bottom of #6466 which should ideally all be answered with "yes"

Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jun 23, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jun 23, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jun 23, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jun 23, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jun 23, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jun 23, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jun 24, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jun 24, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jun 24, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jun 24, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jun 25, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jun 26, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jun 26, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jun 26, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jun 30, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jul 7, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3028
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jul 8, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3028
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jul 8, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3028
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Jul 8, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3028
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Sep 14, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3028
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Sep 16, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3028
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Sep 16, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3028
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Sep 16, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3028
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Hartmnt added a commit to Hartmnt/mumble that referenced this issue Sep 16, 2024
The old tray icon implementation was very old and contained
a lot of workaround for things that probably are no longer an issue.
Furthermore, the event loop was modified in a way such that it could
end up in an infinite loop draining CPU time and rendering Mumble
unusable.

Based on the new Qt5 implementation, this commit introduces
a complete rewrite of the tray icon. The following things should be noted:

* We assume the information in the Qt documentation [1] is valid. This
means that all versions of Windows, all Linux window managers/compositors
that implement the d-bus StatusNotifierItem specification, and all versions
of macos support the functionality of QSystemTrayIcon and its notification
system. That means we can drop the platform-specific code branches and handle
messages directly with QSystemTrayIcon::sendMessage. This should for example
also be true for recent versions of Gnome, which do not have an actual system
tray, but implement the d-bus StatusNotifierItem specification. Therefore, we
can actually merge and simplify the notification code for Windows and Unix*.

* With regards to the bullet point above, we only limit the "hide to tray"
functionality behind QSystemTrayIcon::isSystemTrayAvailable (because otherwise
you would not get the Mumble window back without binding a shortcut first).
Other code branches that were previously limited when isSystemTrayAvailable
returned false were removed. According to Qt, the QSystemTrayIcon code does not
actually care if a system tray is available and will even retroactively add itself
if a tray becomes available after the application was started.

* On (X)Wayland, the minimize button in the window frame does not trigger a
minimize change event. This means that users with such a system may only be
able to "hide to tray" by 1) pressing the close button in the window frame and
enabling "minimize instead of close" 2) clicking the tray icon or the tray icon
hide action or 3) binding a shortcut to hide the window. This is either a bug
or a deliberate decision by Qt or Wayland and we have no way to do anything
about that. (QTBUG-74310)

* The "messageClicked" event is buggy in Qt on some platforms. That means that
clicking the system notification spawned by Mumble via QSystemTrayIcon::sendMessage
will (on some systems) never trigger anything especially not showing and activating
the window. This is a long-standing bug in Qt (QTBUG-87329), but we have absolutely
no way to work around this. The event is correctly hooked up in Mumble and if
this is ever fixed in Qt, this will start working again automatically.

* The tray icon has been redesigned according to state-of-the-art tray icon
design guidelines [2]. Which basically just means: 1) d9a2d47 has
been reverted to provide the user with a consistent menu 2) The main action of
the tray icon (toggle show/hide) is the first entry in the context menu
and the default action when the icon is clicked and 3) the TalkingUI toggle
action was added. Actions for double and middle mouse clicks were removed as
they might have contributed to infinite loops.

* There is no way in Windows to show and activate a window that is
not part of the current active process. If you have Mumble running in
the background and receive a message, we can not raise the Window without
you clicking the Mumble taskbar item or tray icon yourself. This
is deliberate by Microsoft and can and should not be circumvented. (mumble-voip#5701)

* This also fixes the case where the Mumble MainWindow would disappear when
pressing "OK" in the settings dialog. This happened because users would have
"minimize to tray" and "minimize on close" enabled.

[1]
https://doc.qt.io/qt-5/qsystemtrayicon.html#details
https://doc.qt.io/qt-6/qsystemtrayicon.html#details

[2] https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-notification

Fixes mumble-voip#1486
Fixes mumble-voip#3028
Fixes mumble-voip#3722
Fixes mumble-voip#3977
Fixes mumble-voip#3999
Fixes mumble-voip#5012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client external-bug Bugs caused by things outside of our control - by dependencies, "upstream" in technical jargon ui windows
Projects
None yet
Development

No branches or pull requests

3 participants