lighterowl / transgui

A fork of Transmission Remote GUI
GNU General Public License v2.0
152 stars 4 forks source link

Showing a torrent completed notification brings the main window to the foreground #83

Closed metaclam closed 4 months ago

metaclam commented 6 months ago

Maybe I'm missing a setting, but can we turn off the notification for completed torrents? Can we at least not have the app foreground itself when a torrent is completed?

On MacOS Sonoma.

lighterowl commented 4 months ago

The application doesn't foreground itself when a torrent is completed on Windows or Linux, so this is macOS specific (and unwanted, I presume) behaviour.

You can turn off notifications by unchecking Tools > Application options > Show notifications in tray icon. This is enabled by default.

lighterowl commented 4 months ago

Can't reproduce on Big Sur, will try Sonoma once I get around to installing it.

lighterowl commented 4 months ago

Sorry, this appears to be standard Lazarus behaviour on macOS. I reproduced this on Big Sur too.

I created a very simple application that shows a window and starts a 10-second timer. When the timer interval elapses, a notification is shown by using TTrayIcon.ShowBalloonHint, the same function that transgui uses. After starting the application and letting it run in the background, it foregrounds itself after 10 seconds when the pop-up is shown.

Here's the Lazarus bug report : https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41016

A proper fix for this would be to use the macOS APIs for delivering notifications but given my total lack of experience with macOS and ObjC/Pascal bindings, I'm not signing up for that. The Lazarus wiki has some example code, but it uses the API that was deprecated in macOS 11.

lighterowl commented 4 months ago

Great news, the bug report was picked up by a Lazarus developer who implemented support for native notifications on macOS. This means that notifications are now going to look like this : Screenshot_2024-07-09_22-14-04

(don't pay attention to the icon as this was running in a makeshift AppBundle)

In line with standard macOS behaviour, you will need to allow displaying notifications from transgui when it first tries to display one : Screenshot_2024-07-09_22-12-13

It should also be possible to block notifications in system settings instead of just in the application itself. Of course, the application's main window is no longer brought to the foreground.

I will close this ticket once I integrate the new Lazarus code into my own fork and first transgui builds with this feature are available.

lighterowl commented 4 months ago

Tested on Intel Big Sur, Intel Sonoma, and M1 Monterey.