Open Engid opened 1 year ago
Per ilmai:
For reference here's what I'm doing on Mac with my own windowing abstraction experiment that I'm using for slint. It's not really production-ready but seems to work as expected based on some testing. https://github.com/ilmai/plugin-things/blob/main/plugin-canvas/src/platform/mac/view.rs#L255
The boolean is checked here https://github.com/ilmai/plugin-things/blob/main/plugin-canvas/src/platform/mac/view.rs#L66 Windows and Linux have similar logic
And
set_input_focus()
is called from here https://github.com/ilmai/plugin-things/blob/main/nih_plug_slint/src/window_adapter.rs#L318
UPDATES 11/12/2023:
NOTES: set_input_focus()
defined here in a permalink url
ALSO NOTE: further comment from ilmai:
That's not enough on Windows as you need a separate message window that capture the input since Live and some other hosts don't let keyboard events through to the plugin. And on top of that, you need a message hook to catch modifier key presses since you want to always capture those and not just when the window has input focus.
(Dionysis from the Rust Audio discord here 🙂👋)
So, I am giving this a go again. I am reading the baseview
code and follow it ok but we need more clarity on what needs to be implemented. Focusing on Mac for now but if we get the interface down it should not be too difficult to implement for other platforms (famous last words 😁).
I had a look at @ilmai 's code from the link above and I can not see where the input_focus
boolean interacts with NSWindow
. From a discord conversation @ilmai has said:
you don't really need to set input focus yourself like that, but the GUI crate (vizia in this case) asking for input focus should dictate if keyboard events are passed to the parent window or not
That sounds to me as if baseview
is not handling the focus but simply storing the boolean and then it is a matter of calling the focus method from Vizia (or other GUI) which I assume already has access to the NSWindow
.
Is this correct? 🤔
This is a compilation of discussions from the discord chat from @ilmai et al.
Changes required in baseview to capture focus, pass it to client gui libraries (ie Vizia), then return focus to host if client requests it to bubble up.
Per @geom3trik in plugin-gui:
Ilmai explained: