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

'Hide in tray when minimized' feature doesn't work on Wayland #5012

Closed
2xsaiko opened this issue May 19, 2021 · 3 comments · May be fixed by #6466
Closed

'Hide in tray when minimized' feature doesn't work on Wayland #5012

2xsaiko opened this issue May 19, 2021 · 3 comments · May be fixed by #6466
Labels
client external-bug Bugs caused by things outside of our control - by dependencies, "upstream" in technical jargon linux ui

Comments

@2xsaiko
Copy link

2xsaiko commented May 19, 2021

Describe the bug
When the feature is enabled and the window is minimized, it sticks around in the taskbar. The only way to actually get it to go to the tray is to close the window so the Close/Minimize dialog box pops up and then select Minimize.

Steps to Reproduce
Steps to reproduce the behavior:

  1. Enable 'Hide in tray when minimized' in settings
  2. Click the minimize button in the window decoration
  3. Window gets minimized normally but doesn't close itself

Expected behavior
The window closes itself so that it's gone from the taskbar and only visible in the tray.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):
Operating System: Gentoo
KDE Plasma Version: 5.21.90
KDE Frameworks Version: 5.82.0
Qt Version: 5.15.2
Kernel Version: 5.12.4-gentoo (64-bit)
Graphics Platform: Wayland
Mumble Version: commit 998eb37 (17 May 2021)

@Krzmbrzl
Copy link
Member

Window gets minimized normally but doesn't close itself

With "doesn't close itself" I assume you mean that it does not remove itself from the taskbar so that it is only visible in the Tray. Is that correct?

@2xsaiko
Copy link
Author

2xsaiko commented May 19, 2021

Yeah, exactly.

@Krzmbrzl Krzmbrzl added bug A bug (error) in the software client linux ui labels May 19, 2021
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

I investigated this in #6466

This is a limitation of (X)Wayland (or possibly a bug in Qt) which we have no way of fixing or working around. In the new tray implementation you will be able to minimize to tray by:

  • Clicking the close button of the Mumble MainWindow, provided that you selected "Always minimize" in the settings or hit the additional "Minimize" button you were already talking about
  • Clicking the tray icon, or the first action within the context menu of the tray icon
  • Binding a shortcut to "Show/Hide Mumble"
  • Opening Mumble with --hidden

which will all do exactly the same.

https://bugreports.qt.io/browse/QTBUG-74310

@Hartmnt Hartmnt added external-bug Bugs caused by things outside of our control - by dependencies, "upstream" in technical jargon and removed bug A bug (error) in the software labels Jun 14, 2024
@Hartmnt Hartmnt closed this as not planned Won't fix, can't repro, duplicate, stale Jun 14, 2024
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 linux ui
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants