fyne-io / systray

a cross platfrom Go library to place an icon and menu in the notification area
Apache License 2.0
223 stars 41 forks source link

darwin: Stop the systray on quit rather than terminating the app #81

Closed anacrolix closed 1 week ago

anacrolix commented 1 month ago

On Darwin, quitting the systray terminates the current process. That's always been a pain. This stops the event loop, and systray.Run should return after calling systray.Quit.

anacrolix commented 1 month ago

Changes applied.

andydotxyz commented 1 month ago

Thanks for looking at this. I have tested and it does not seem to reliably work on completing the example code. Any thoughts on this?

[anacrolix-master] ><> go run .                                                                         
Requesting quit
Finished quitting
andy@Fyreball /Users/andy/Code/Fyne/systray/example                                                                                                            7s [8:55AM]
[anacrolix-master] ><> go run .
Requesting quit
andy@Fyreball /Users/andy/Code/Fyne/systray/example                                                                                                            7s [8:55AM]
[anacrolix-master] ><> 
anacrolix commented 1 month ago

Yes, the quit is issued asynchronously, and main can exit before the quit handler completes. The correct behaviour is to report quitting after systray.Run returns. I've updated the example to make it deterministic in this respect.

anacrolix commented 2 weeks ago

Hello, were you able to test/confirm this?

andydotxyz commented 1 week ago

quit is issued asynchronously, and main can exit before the quit handler completes.

Doesn't this seem problematic? We need to know that the handlers all complete. (for compatibility if nothing else surely?)

anacrolix commented 1 week ago

I think you misunderstand. I fixed the code so that it always reports completion, where previously it raced.

anacrolix commented 1 week ago

Cheers