Skip to content

Implement new_event_loop_proxy for PluginCanvasPlatform#11

Merged
ilmai merged 2 commits intoilmai:mainfrom
emuell:feature/event-loop-proxy
Apr 22, 2026
Merged

Implement new_event_loop_proxy for PluginCanvasPlatform#11
ilmai merged 2 commits intoilmai:mainfrom
emuell:feature/event-loop-proxy

Conversation

@emuell
Copy link
Copy Markdown
Contributor

@emuell emuell commented Mar 25, 2026

This is needed for slint::invoke_from_event_loop and similar functions to work.

I started using invoke_from_event_loop and wondered why it didn't work. The missing impl can be worked around by adding a custom thread-safe event queue in custom editors, but it's nice to use the well-documented Slint feature instead.

@ilmai
Copy link
Copy Markdown
Owner

ilmai commented Mar 26, 2026

Hey, thanks for the PRs. Just FYI I'm quite busy with my plugin release right now so might take a while to review especially the larger standalone build PR.

@emuell
Copy link
Copy Markdown
Contributor Author

emuell commented Mar 26, 2026

Sure thing. Nothing's urgent here. Good luck with the release!

@emuell emuell force-pushed the feature/event-loop-proxy branch from 9f2257c to 70495c8 Compare April 2, 2026 20:28
@emuell emuell force-pushed the feature/event-loop-proxy branch from 70495c8 to 00d1902 Compare April 13, 2026 07:06
Comment thread plugin-canvas-slint/src/platform.rs
... which is needed for `slint::invoke_from_event_loop` and co
@emuell
Copy link
Copy Markdown
Contributor Author

emuell commented Apr 22, 2026

I don't think the order is important here, and also not which window actually pulls and applies the event. Main purpose of slint::invoke_from_event_loop() is to push an event to the event thread.

If an event references a window, it must pass a weak ref to the window anyway and check if it's still valid. Just like https://docs.rs/slint/latest/slint/struct.Weak.html#method.upgrade_in_event_loop does.

Also I don't see how to access PluginCanvasWindowAdapter within new_event_loop_proxy. Would need to do some ugly thread_local hacking to pass around the context then.

@ilmai
Copy link
Copy Markdown
Owner

ilmai commented Apr 22, 2026

Good point, this is similar to the slint limitation which made me use thread locals when generating window adapters (which is fragily in theory but probably works in practice). We can keep this as is. Maybe add a comment explaining that this is making plugin instances share the event queue which isn't ideal but current slint limitations don't allow us to separate them.

@emuell emuell force-pushed the feature/event-loop-proxy branch from 00d1902 to 2cd426f Compare April 22, 2026 15:33
@ilmai ilmai merged commit 0e623a6 into ilmai:main Apr 22, 2026
3 checks passed
@emuell emuell deleted the feature/event-loop-proxy branch April 22, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants