Skip to content

hyprland 0.57.0-3.5: the keyboard on a touch, and the input method's done - #786

Open
angelrenefm wants to merge 4 commits into
derekross:mainfrom
angelrenefm:hyprland-ime-on-touch
Open

angelrenefm wants to merge 4 commits into
derekross:mainfrom
angelrenefm:hyprland-ime-on-touch

Conversation

@angelrenefm

@angelrenefm angelrenefm commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #785. This branch is on top of it, so its first commit is #785's (hyprland 3.4, the wl_output geometry). The second and third commits are new.

What and why

0004, the keyboard on a touch (behind a switch). A text field that takes focus on its own brought up the on-screen keyboard over half the screen. Chromium's address bar does this every time a window opens, and so does a GTK text view like Omawrite's. On Android the keyboard comes up only when you touch the field.

With OMAMOBILE_IME_ON_TOUCH=1 in Hyprland's environment (read once at startup; unset, nothing changes):

  • A field enabled within 800 ms of a touch or click activates the input method at once, as before.
  • A field enabled with no touch waits. 200 ms after the next touch or click ends, if it is still the focused, enabled field, it activates.
  • A tap on a link or elsewhere takes the focus away first, so the keyboard stays down.
  • Only a touch or click on the field's own app counts. A back gesture or a tap on a recent app's card (the shell's surfaces) brings an app forward without the keyboard.

Chromium and GTK send no text-input request after that tap until the input method is active (checked with WAYLAND_DEBUG=1), so the compositor has to decide. A keyboard brought up by hand still types, because squeekboard falls back to its virtual keyboard.

0005, the input method's done (a stock bug, no switch). When the window of a focused text field closed, CTextInput::destroy() deactivated the input method without a done, so the deactivation never applied. squeekboard stayed active, and a keyboard hidden by hand (hideKeyboard) stayed hidden for every later field until squeekboard was restarted. Its state machine only clears the manual hide on an active/inactive transition, and that transition never arrived. deactivateIME() now sends the done when no text input will commit a state after it.

Tested

On my Pixel 7 (Hyprland built with these patches, OMAMOBILE_IME_ON_TOUCH=1), with taps from a virtual touchscreen (uinput) and squeekboard's Visible read over D-Bus:

case result
Chromium opened, no touch keyboard down, window 360x755 (6 of 6)
then a tap on the address bar keyboard up, window 360x422 (5 of 5)
then a tap on the page instead keyboard down (2 of 2)
keyboard hidden by hand, window closed and reopened, tap on the address bar keyboard up (2 of 2; without 0005: 0 of 3)
Omawrite (GTK) opened, then a tap on the text down, then up (4 of 4)
back gesture from recent apps to Foot, or a tap on its card keyboard down (before the second commit: up)

tools/pr-check passes, the sha256sums match, and both patches apply with --fuzz=0 after 0001-0003.

Notes

I used AI help (Claude) to work on this.

@derekross

Copy link
Copy Markdown
Owner

Thank you, Ángel. Both halves are well made. The keyboard on a touch is behind OMAMOBILE_IME_ON_TOUCH, and with it unset I read the patched code through: the text input takes main's path, and what's left is two timestamps and a call that returns at once, so other phones see no change. The missing done after a text input's window closes is a real stock bug, and your before/after (0 of 3, then 2 of 2) shows it.

The sums match, and 0004 and 0005 apply with --fuzz=0 on top of #785, and together with the other two open Hyprland PRs in any order.

0005 changes every phone, so it goes into the same Pixel 7 Pro run as the other three, in one build. This one merges last, after #785, as 0.57.0-3.7 with the patches renamed 0006-… and 0007-…; I'll do the renumbering and drop #785's commit from your branch when I merge.

Two questions about 0004 with the switch on, for before panther turns it on rather than for this merge:

  1. onTouchDown stamps m_lastPressTime at the top but sets m_lastPressSurface only at the end, after its early returns (a cancelled touch, one taken by a workspace swipe, nothing under the finger). A touch like that leaves the previous press's surface with a fresh time, and its touch-up still runs textInputPressEnded(), so it can count as a touch on the focused app. Resetting m_lastPressSurface next to the timestamp (and on a button press) would close it.
  2. Does a drag on Chromium's page, with the address bar focused and its keyboard still waiting, bring the keyboard up 200 ms after the finger lifts? Your table has a tap on the page; a scroll would be worth one try.

angelrenefm and others added 4 commits November 15, 2026 14:18
A rotation changes the transform but not the mode, so Hyprland sent
wl_output.done without a new wl_output.geometry: clients bound before
the rotation kept the old transform. squeekboard, bound at login, then
sized itself for portrait in landscape and covered the whole screen
(apps that open the keyboard were left -18 px tall on a Pixel 7).

0003 makes every wl_output done carry the whole state (scale, mode,
geometry with the transform), which updateState already sends on a
mode change.

On the Pixel 7: a client bound before a quarter turn now gets geometry
with transform 1, and 0 on the way back (before: done only, transform
stayed 0). Chromium in landscape with the keyboard up is 107 px tall at
squeekboard's default horizontal scale (before: -18), and the
horizontal scale setting takes effect again (134 px at 0.85, 161 at 0.7).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…done

0004 (only with OMAMOBILE_IME_ON_TOUCH=1 in Hyprland's environment): a
text field that takes focus on its own, as Chromium's address bar does
when a window opens, no longer brings up the on-screen keyboard. The
input method is activated for a field enabled within 800 ms of a touch
or click, or 200 ms after a later touch ends while the field is still
the focused, enabled one, as on Android.

0005: closing the window of a focused text field deactivated the input
method without a done, so the deactivation never applied. squeekboard
stayed active, and a keyboard hidden by hand stayed hidden for every
later field until it was restarted.

On a Pixel 7 with the switch on: Chromium opened with no touch keeps
the whole screen (755 px) and the keyboard down, 6 of 6; a tap on its
address bar brings it up (422 px), 5 of 5; a tap on the page leaves it
down, 2 of 2; after hiding it by hand, closing and reopening, a tap on
the address bar brings it up again, 2 of 2 (before 0005: 0 of 3). An
Omawrite (GTK) window behaves the same, 4 of 4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With OMAMOBILE_IME_ON_TOUCH=1, any touch in the 800 ms before a text
field was enabled brought the keyboard up. A back gesture in recent
apps, or a tap on a recent app's card, brings an app forward, and a
terminal or a focused field there then enabled its text input right
after the shell's touch: the keyboard came up over the app on its own.

The touch or click now has to have gone down on a surface of the
field's own client, both for the immediate activation and for the
deferred one after the next touch.

Tested on my Pixel 7 (Hyprland cross-built with these patches,
portrait): back from recent apps to Foot, keyboard down (was up); tap
on Foot's card in recent apps, keyboard down; Chromium opened, keyboard
down, tap on the address bar, up, tap on the page, down. A run of 19
shell gestures (home, drawer, recent apps, back, keyboard) passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
onTouchDown stamped the time at the top but set the pressed surface only
at the end, after its early returns (a cancelled touch, one taken by a
workspace swipe, nothing under the finger). Such a touch left the
previous press's surface with a fresh time, and its touch-up still ran
textInputPressEnded(), so it could count as a touch on the focused app.
The surface is now cleared next to the time. A button press already sets
it before anything can return.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@angelrenefm
angelrenefm force-pushed the hyprland-ime-on-touch branch from 7ff49d7 to 4025ecd Compare November 15, 2026 13:19
@angelrenefm

Copy link
Copy Markdown
Contributor Author

Thank you, Derek. Both questions, with the switch on:

  1. The early returns. You're right. onTouchDown now clears m_lastPressSurface next to the timestamp, so a
    touch that returns early (cancelled, taken by a workspace swipe, nothing under the finger) counts on no surface,
    and its touch-up can't bring the keyboard up. A button press already sets the surface at the top of
    onMouseButton, before anything can return (to the pointer focus, or to none), so it needed no change. It's one
    new commit on this branch. All the patches apply with --fuzz=0 on the 0.57.0 tarball in the PKGBUILD's order,
    and the checksum is updated. It builds for aarch64. I haven't run this build on the phone yet: it needs a session
    restart. I can't easily make a cancelled touch on purpose, so I haven't tested that case directly.
  2. A drag on Chromium's page. It doesn't bring the keyboard up. I opened Chromium on about:blank (address bar
    focused, keyboard waiting), dragged the page from y=1800 to y=900 over 400 ms and read squeekboard's Visible
    1.5 s later: false, 3 of 3. Screenshots before and after the
    drag show why: Chromium takes the focus off the address bar on the drag, as it does on a tap. When the 200 ms
    timer fires there is no focused field left.

I've also added the Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> trailer to every commit on this branch,
#785's included, as CONTRIBUTING asks. The trees are unchanged.

@angelrenefm

Copy link
Copy Markdown
Contributor Author

A follow-up on your first question: the case happens on the phone. I've now run this branch's build on my Pixel 7, with the switch on.

My test script takes a screenshot with grim right before each tap. With that, some taps never reach the app. In a trace of Omawrite (WAYLAND_DEBUG=1), 3 of 5 taps after a screenshot delivered no wl_touch.down at all. In those 3 the keyboard stayed down, and in the 2 that arrived it came up. With no screenshot before the tap, all 5 arrived and the keyboard came up 5 of 5.

The build before this commit passed the same script every time (4 of 4 on Omawrite). I didn't trace it then, so I can't show that those taps were lost too, but that matches the early return you described: a fresh time with the previous press's surface. I haven't looked into why a tap right after a screencopy gets dropped.

On this build the 19 shell gestures I run (home, drawer, recent apps, back, keyboard) give the same results as before.

@derekross

Copy link
Copy Markdown
Owner

Thank you, Ángel, for both answers and for finding the case on the phone.

The reset next to the timestamp is the right fix. I read it through in the patched tree: m_lastPressSurface is only read on paths that need OMAMOBILE_IME_ON_TOUCH=1, so with the switch unset it's one store per touch that nothing reads, and other phones see no change. And the drag result (Chromium drops the address bar's focus, so the timer finds no field) answers my second question.

Your screenshot observation is interesting: taps that never reach the app right after a grim. It doesn't hold anything up here, but if you happen to try one grim and a tap on the current 0.57.0-3.3, that would tell us whether it's older than these patches. I'll keep screenshots away from taps in my own run.

I've applied all four open Hyprland changes together in every order they could merge, and the compositor comes out the same each time, so this goes in last as 0.57.0-3.7 with 0006-… and 0007-…, after #785 and the combined run on my Pixel 7 Pro. I'll rebase it onto main once #785 is in and do the renumbering myself; nothing more is needed from you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants