haiku: Fixed keyboard input.

_GetWinID() doesn't work with keyboard-related BMessages, because Haiku
assumes you know what window has keyboard focus at the time, so these events
don't have a `window-id` property. So when this call failed, the key event
handler would return early.

This was probably a copy/paste error that snuck in at some point, as SDL2
doesn't have this issue.
This commit is contained in:
Ryan C. Gordon 2025-02-12 17:17:14 -05:00
parent d2b7a84651
commit 1354affd28
No known key found for this signature in database
GPG Key ID: FA148B892AB48044
1 changed files with 12 additions and 13 deletions

View File

@ -293,12 +293,9 @@ class SDL_BLooper : public BLooper
void _HandleKey(BMessage *msg) void _HandleKey(BMessage *msg)
{ {
SDL_Window *win;
int32 winID;
int32 scancode; int32 scancode;
bool down; bool down;
if ( if (
!_GetWinID(msg, &winID) ||
msg->FindInt32("key-scancode", &scancode) != B_OK || msg->FindInt32("key-scancode", &scancode) != B_OK ||
msg->FindBool("key-down", &down) != B_OK) { msg->FindBool("key-down", &down) != B_OK) {
return; return;
@ -306,8 +303,9 @@ class SDL_BLooper : public BLooper
SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, scancode, HAIKU_GetScancodeFromBeKey(scancode), down); SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, scancode, HAIKU_GetScancodeFromBeKey(scancode), down);
win = GetSDLWindow(winID); if (down) {
if (down && SDL_TextInputActive(win)) { SDL_Window *win = SDL_GetKeyboardFocus();
if (win && SDL_TextInputActive(win)) {
const int8 *keyUtf8; const int8 *keyUtf8;
ssize_t count; ssize_t count;
if (msg->FindData("key-utf8", B_INT8_TYPE, (const void **)&keyUtf8, &count) == B_OK) { if (msg->FindData("key-utf8", B_INT8_TYPE, (const void **)&keyUtf8, &count) == B_OK) {
@ -318,6 +316,7 @@ class SDL_BLooper : public BLooper
} }
} }
} }
}
void _HandleMouseFocus(BMessage *msg) void _HandleMouseFocus(BMessage *msg)
{ {