Repository navigation
Fixed(app): Prevent stale bottom margin during non-IME layout passes - #5442
Open
qwerty123yucy wants to merge 1 commit into
Open
qwerty123yucy wants to merge 1 commit into
qwerty123yucy wants to merge 1 commit into
Conversation
qwerty123yucy
force-pushed
the
pr/fix-non-ime-margin-jitter
branch
from
November 17, 2026 05:04
8816791 to
f7c2dad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In
TermuxActivityRootView.onGlobalLayout(), once the soft keyboard has been opened and closed at least twice (lastMarginBottom != null), theisVisible && !setMarginbranch ("Bottom margin already equals 0") executes:This pre-arms
marginBottomwith the previous keyboard height while the keyboard is closed, assuming the nextonMeasure()call will be caused by the keyboard reopening. However, any unrelated layout pass while the keyboard is closed—such as opening/closing the leftDrawerLayoutsession drawer or toggling toolbar visibility—also invokesTermuxActivityRootView.onMeasure(), applying the stalelastMarginBottomfor one layout pass beforeonGlobalLayout()resets it back to0.That transient shrink/expand cycle causes
TerminalView.onSizeChanged()->updateSize()to resize the PTY twice (SIGWINCH), visibly jumping the viewport and causing running shells/TUIs to reflow when opening the session drawer.Changes & Trade-offs
marginBottom = nullinstead oflastMarginBottomin theBottom margin already equals 0branch so non-IME layout passes while the keyboard is closed keepmarginBottom = 0.lastMarginBottomtried to avoid a 1-frame adjustment on devices whereSOFT_INPUT_ADJUST_RESIZEfails to push up the extra-keys/candidates row when reopening the keyboard. Not pre-arming while closed means those specific fallback cases adjust ononGlobalLayout()rather thanonMeasure(), in exchange for eliminating guaranteed false-positive PTY resizes (SIGWINCH) during every non-IME layout pass while the keyboard is closed.Build.VERSION.SDK_INT >= Build.VERSION_CODES.R, where platformWindowInsets.Type.ime()reliably reports IME state, unlike Android 7–10 as noted inKeyboardUtils), guard the hidden-bottom branch withisImeVisibleApi30()so transient non-IME layout occlusions cannot apply a bottom margin when no IME is visible.Testing
./gradlew testand./gradlew assembleDebugin CI.v0.118.3for Android device testing.