Closed MohamedRejeb closed 3 weeks ago
HWND
is handle for any native view on Windows, not "window" handle. Compose provides it as-is from AWT.
Interop blending is just putting Compose above the interop and makes it transparent. So since events are received to top-most view, yes, it's not the same to swing. For interop view compose redispatching events to right view manually via AWT/Swing API.
So the situation is explainable but it's about implementation defaults of not only Compose but also AWT/Swing.
Is there a way to get the handle for Compose view?
Well Compose has a few views internally. Public windowHandle
is for rendering one (used in skia). Getting handle for other components again is AWT implementation details (with all lightweight/heavyweight specifics), but theoretically it should seem something like https://stackoverflow.com/a/413895/1703290
Another reference: https://github.com/openjdk/jdk/blob/8ffc35d117846a7a2aa08afed662273d2f887770/src/java.desktop/windows/native/libawt/windows/awt_Component.h#L165
But again, please note that it might vary across JDK distributions
Currently it's working fine. I'm accepting events from all views of the window but sometimes I'm getting some unwanted events (ex: events for window top bar) which is filtered now using PointerEventType.Enter
and PointerEventType.Exit
to enable/disable the listener. But I want to improve it more by forcing a single HWND
to receive the events from.
I will check the references.
Thank you!
I was trying capturing native input events in desktop to get some data related to stylus (pressure, tilt...) and I used
window.windowHandle
to access native window and it's working fine for macos. But for windows I realised that theHWND
created by thewindowHandle
is different than theHWND
coming with the events when the cursor is on top of my composables. But when I move the cursor on top of the window top bar or on top of swing components theHWND
coming with the events is the same as theHWND
from thewindowHandle
in case of interop blending is disabled but when I enable interop blending even hovering on top of swing components gives a differentHWND
than the events. I'm not sure what's happening exactly behind the scenes but I think that compose is getting rendered on a kind of invisible window on top of the swing window (Sometimes closing the app doesn't go well and only the compose content disappears but the window and swing components remains visible which increased my suspicion that there's two windows on top of each other).Affected platforms
Versions