-
Hello, there's a little application I'm developing that needs to run the UI off the main thread (the output is a dynamic library that is loaded into another software, a non-blocking entry point is called to perform all the initialization: I have to start the UI there, keep it alive when the init function ends; I'm currently using GTK). Reading the docs and a few discussions, it seems that slint basically requires using the main thread for creating the UI and its components, but it's possible to run tasks from other threads using Is the Qt backend able to run inside a non-main thread (on linux)? A related question: are there plans or intentions to drop this requirement in the future? Personally I'd be very happy to see a portable wgpu backend for slint, but I'm sure that's not in scope for you right now. Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The idea is that slint runs in the main thread, and you can then communicate with a thread using message queue, for example. And example of this is Cargo-UI, if you have not seen it. The idea is that each callback sends message to the thread like so:
I do think that works on Linux. But it does not work on macOs because of platform limitation, and that's also why the winit crate forbid it on all platform to be consistent. |
Beta Was this translation helpful? Give feedback.
The idea is that slint runs in the main thread, and you can then communicate with a thread using message queue, for example.
And example of this is Cargo-UI, if you have not seen it. The idea is that each callback sends message to the thread like so:
https://github.com/slint-ui/cargo-ui/blob/3e2780dbffc9f123fc5205ffe242805d887f49ad/src/main.rs#L59
Then the thread intercept the message, do the processing, and communicate the result back with
invoke_from_event_loop
, orWeak::upgrade_in_event_loop
https://github.com/slint-ui/cargo-ui/blob/3e2780dbffc9f123fc5205ffe242805d887f49ad/src/cargo.rs#L513I do think that works on Li…