~eliasnaur/gio#155: 
Using gio with systray

Hello, I'm trying to use gio with https://github.com/getlantern/systray

systray.Run(onReady, onExit) blocks and must be run on the main thread.

gio's app.Main() also blocks and must be run on the main thread. This isn't a problem on windows but on macos I can either run gio or systray. If you attempt to run either in a go routine, the app will crash.

Is there a way around this? It would be cool if gio had built-in support for adding icon/menu in notification area because it's useful in desktop apps.

Status
REPORTED
Submitter
~buffrr
Assigned to
No-one
Submitted
a month ago
Updated
a month ago
Labels
No labels applied.

~eliasnaur a month ago

On Fri Aug 14, 2020 at 00:42, ~buffrr wrote:

Hello, I'm trying to use gio with https://github.com/getlantern/systray

systray.Run(onReady, onExit) blocks and must be run on the main thread.

gio's app.Main() also blocks and must be run on the main thread. This isn't a problem on windows but on macos I can either run gio or systray. If you attempt to run either in a go routine, the app will crash.

Is there a way around this?

Probably not without changing either Gio or the systray package.

It's unfortunate that macOS require everything UI to happen on a single thread. Gio's app.Main ends up in gio_main,

https://git.sr.ht/~eliasnaur/gio/tree/master/app/internal/window/os_macos.m#L175

so one strategy is to move everything else than "[NSApp Run]" elsewhere. I moved some of gio_main out in https://gioui.org/commit/4408c2a6 but didn't succeed in moving everything out.

Another strategy is to change or fork systray to tolerate someone else starting the main loop, effectively emptying package systray's app.Main equivalent.

Elias

Register here or Log in to comment, or comment via email.