On Fri May 24 08:54:04 2024 +0000, Rémi Bernon wrote:
Fwiw, I probably missed that previously and it may be what Wayland spec suggest, but I also don't think we should send key release input when focus is lost. That's not what Windows does.
So the concern (in this and other cases) is strictly about the key events, and you would prefer if we just updated the async keyboard state?
Although that should work fine in many cases, one issue is autorepeat functionality, since it is handled (at the moment) in win32u based on key messages. We would like to: 1. Stop autorepeat when a window loses focus. 2. Start autorepeat of key if it is pressed when gaining focus.
(1) is critical to get right, but seems easy enough to achieve without key event involvement. If this matches Windows behavior, it would make sense to integrate a "has focus" check into the win32u repeat timer callback. At the moment it needs to happen from the driver too because we don't update window focus when handling the keyboard leave event (but also a special `NtUserSendHardwareInput` invocation with all scancodes up (see below) could deal with that in win32u).
(2) seems less straightforward, since there isn't currently any feedback from the wineserver to hwnd when the async key state changes. But if we use a special `NtUserSendHardwareInput` invocation as you suggest below, perhaps wineserver can detect the scenario and do something sensible here.