Fixes#120217 where releasing both left and right shift keys
simultaneously would result in one of the shift keys not receiving the
KEYUP event. Previously an edge case was implemented that handled
shift key release with WM_INPUT for when a shift key was released while
the other was held. This change would handle all shift key release with
WM_INPUT instead of partially with WM_INPUT and partially with WM_KEYUP
for consistent handling.
When a soft keyboard's backspace sends KEYCODE_DEL via sendKeyEvent(),
GodotEditText.onKeyDown() delegates to super.onKeyDown() which modifies
the EditText's Editable, triggering beforeTextChanged() in
GodotTextInputWrapper, which then forwards KEYCODE_DEL to the engine.
However, the EditText is only seeded with text up to the cursor position
(mOriginText) when the keyboard opens. Once the user backspaces through
all of that content, the EditText becomes empty. At that point,
super.onKeyDown(KEYCODE_DEL) on an empty EditText makes no change to the
Editable, so beforeTextChanged() never fires and the engine receives no
DEL event — even though the engine's own buffer still has text before
the cursor.
This causes a visible bug: the user can delete characters they typed in
the current session, but backspacing further into pre-existing text does
nothing. Re-tapping the field fixes it temporarily because showKeyboard()
is called again, reseeding the EditText with the current text and cursor
position.
Fixed this by forwarding KEYCODE_DEL directly to the engine when the
EditText is empty, bypassing the TextWatcher path that can't fire in
that state. This produces no double events since beforeTextChanged()
is physically unable to fire on an empty field.
Move DEL release event from onKeyDown to onKeyUp
Kotlin's `==` on the proxy compiles to `proxy.equals(args[0])`, which
the JDK proxy dispatches back through the InvocationHandler, hitting
the same branch and recursing into StackOverflowError. Use `===` for
reference equality, matching the default Object#equals behavior.
Object.hashCode() must return Int (32-bit), but the proxy InvocationHandler
returned godotObjectID directly (Long, 64-bit). When a HashMap-like container
called proxy.hashCode(), the auto-generated proxy did (Integer) result on a
java.lang.Long and threw ClassCastException.
Signed-off-by: Muteem <29696635+Muteem@users.noreply.github.com>
JDK contract: InvocationHandler.invoke's args parameter is null when
the proxied interface method takes no arguments. The proxy handlers
in AndroidRuntimePlugin used `*args` directly, which spread-deref'd
null and threw NullPointerException.
Signed-off-by: Muteem <29696635+Muteem@users.noreply.github.com>
There are two "focus lost" signals in the Godot X11 display server:
1. `FocusOut` - native X11 signal
2. `NOTIFICATION_APPLICATION_FOCUS_OUT` - Godot signal after 250ms of
no other window getting focus.
When focus is lost, the intent is to clear any input pressed events so
that, when focus returns, we have a clean slate.
The bug is that the pressed events are (attempted to be) cleared on the
first signal, X11's `FocusOut`. This is always a no-op because it
returns early if the application still has focus. Godot's X11 server
only sets that flag after the second signal, not the first.
Move the pressed event clearing from the first signal handler to the
second. This makes clearing pressed events do what it says.
This does not affect Wayland because it does not have the 250ms grace
period.
Simple repro is to load any 3D scene, hold 'W' and, while 'W' is held,
click on any non-Godot window. Release 'W', click back to Godot, and
hold RMB. It will zoom forward as if 'W' is still pressed.
After the fix, the same test has RMB look around as expected when no
other keys are pressed.
Fixes#118897
Godot suppresses X11 BadWindow errors during some operations because
they can occur with normal usage.
X11 errors are asynchronous. Sometimes, when a BadWindow error is sent,
it is dequeued after the original non-BadWindow-suppressing error
handler has been restored. This results in an error callstack being
shown to the user.
Call `XSync` before restoring the original error handler. This ensures
that any queued BadWindow errors go to the suppressing handler.
Fixes#117814
Previously the Wayland display server would attempt to enable
HDR output and try to detect if it failed afterwards which had some issues.
Now we can query the rendering driver for support and avoid ever enabling
HDR output when this would fail.