Repository navigation
Added: Add soft-keyboard-pan-main-screen property to avoid PTY resize on IME toggle - #5444
Open
qwerty123yucy wants to merge 1 commit into
Open
qwerty123yucy wants to merge 1 commit into
qwerty123yucy wants to merge 1 commit into
Conversation
…ze on IME toggle Add an opt-in `soft-keyboard-pan-main-screen` boolean property in `termux.properties` (default: `false`) and `TerminalView.setSoftKeyboardPansMainScreen()` to decouple the visual viewport height (`mVisualRows`) from the main-screen PTY row count (`mRows`) when the soft keyboard opens or closes. - Keep main-screen PTY dimensions (`TIOCGWINSZ` / `SIGWINCH`) fixed to the unobscured terminal height while panning `mTopRow` up to `getMaxTopRow()` so inline TUIs, multi-line prompts, and ongoing shell output do not reflow or redraw destructively on every keyboard toggle. - Preserve standard PTY resizing whenever the alternate screen buffer (`?1049h`, e.g. `vim`, `less`, `htop`, `tmux`) is active so full-screen applications continue to fit the visible area above the keyboard. - Preserve existing behavior completely when `soft-keyboard-pan-main-screen` is `false` (the default).
qwerty123yucy
force-pushed
the
pr/ime-visual-viewport
branch
from
November 17, 2026 07:42
3d2e59a to
e44826c
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
When the soft keyboard opens or closes, Android shrinks/expands
TerminalViewandupdateSize()resizes the PTY row count (TIOCGWINSZ+SIGWINCH) on both the alternate screen and the main screen.While resizing the PTY is desirable for full-screen alternate-buffer apps (
vim,less,htop,tmux), on the main screen (!isAlternateBufferActive()) every keyboard toggle triggersTerminalBuffer.resize()and sendsSIGWINCHto foreground shells and inline TUIs (e.g. multi-line prompts,fzf --height, CLI REPLs), causing line reflows, duplicate prompt redraws, or broken cursor-relative inline layouts.Changes
default: false):soft-keyboard-pan-main-screentoTermuxPropertyConstants(TERMUX_APP_PROPERTIES_LISTandTERMUX_DEFAULT_FALSE_BOOLEAN_BEHAVIOUR_PROPERTIES_LIST),TermuxSharedProperties.shouldSoftKeyboardPanMainScreen(),TermuxTerminalViewClient.onReloadProperties(), andTerminalView.setSoftKeyboardPansMainScreen(boolean).false(the default),TerminalView,TerminalEmulator, and PTY sizing behave identically tomaster.TerminalView.resolveLayoutHeight()(using API-guardedWindowInsetson API 23+ /WindowInsets.Type.ime()on API 30+ and root content margin, invalidated on non-IME toolbar changes viaonToolbarGeometryChanged()). In multi-window / floating-window mode (Activity.isInMultiWindowMode(), unwrappingContextWrapper), fall back directly toviewHeightso global IME insets are not misapplied when the keyboard is detached or pan-handled by the window manager.mEmulator.mRows) sized tolayoutRowswhile settingmEmulator.setVisualRows(visibleRows)to the visible area above the IME.mTopRowon the main screen to pan positively within[0, mEmulator.getMaxTopRow()]wheregetMaxTopRow()bounds the viewport to the active cursor row andgetLowestNonEmptyScreenRow(), keeping the active prompt or inline status bar above the keyboard without sendingSIGWINCH.targetPtyRows = visibleRows) whenever the alternate screen buffer (?1049h) is active, syncing PTY rows across?1049h/?1049ltransitions.ResizeTest):testMainScreenVisualRowsDecoupledFromPtyRows()testing fresh prompts, bottom inline status bars,?1049h/?1049lalternate-buffer transitions, and viewport restoration.(Note for reviewers: This PR is independent of #5443, though both touch
TerminalView/TerminalRenderer/TerminalEmulator. Happy to rebase whichever is reviewed second.)Testing
./gradlew test(ResizeTest#testMainScreenVisualRowsDecoupledFromPtyRowsand full test suite) and./gradlew assembleDebugin CI.v0.118.3build stacked together with Changed(terminal-view): Anchor scrollback to document rows and use OverScroller sub-pixel scrolling #5443 (keyboard show/hide on main vs. alternate screen, split-screen, and floating window); standalonemasterbranch verified via unit tests and CI build.