Repository navigation
Conversation
AI-assisted: ChatGPT was used while preparing this change.
AI-assisted: ChatGPT was used while preparing this change.
AI-assisted: ChatGPT was used while preparing this change.
Yes this is the same bug as #1845 trying to solve, just another symptom of it. I really don't want to fix this by special-casing either IMEs or Popup-Grabs. Clearly the Grab-logic is insufficient and we need nested grabs. A solution that correctly (imo) addresses this issue would refactor the whole grab logic to allow multiple grabs at once. (Sorry, I am aware this is frustrating and you probably put some work into this.) |
So I've been thinking about that since I've worked on the touch refactor & tablet stuff. I'm not sure if we want multiple grabs, or if some kind of grab nesting would be preferred. Its already possible to have some kind of nesting using
I wonder if we should add a The reason I think nesting is better is mainly for touch input, since the outer grab can act as an event router once sub grab are bound to specific touch slots, and it's easier to reimplement multiple grabs via nested grabs than the other way around |
It's fine, I only hope to get this fixed somehow. It's a long-standing issue and it hasn't really moved forward over the last year despite multiple attempts. Thanks, I see how 1845 is relevant.
So basically we have this choice, and, if we still intend to go the nested way, a choice between nested approaches - the composite grab approach of Ph4ntomas or a core-managed stack/chain approach. What approach is the way to go? |
FWIW the two aren't necessarily mutually exclusive. Nested/composite grabs are flexible enough for Smithay to provide pre-made combinators. |
My main fear with this approach is the combination complexity. So popup-grabs can nest a DnD grab, can they also nest an IME grab?
Do you happen to know how they handle popup grabs? Given they conflict with various other things like IME or DnD? I assume the popup + dnd works on them as well.
I am not sure just because other compositors differ in how they do this necessarily implies much for smithay. Smithay's job is to built abstractions. They can be cumbersome at times causing bugs like this one, but this is also what makes smithay a powerful tool. Of the three you listed only weston even has a library and wlroots is much more opinionated in it's apis that smithay.
Yes I fully expect that. Imo somebody just needs to sit down trying to come up with a design solving all of these issues. Preferably also building some clear test-clients for this specific behavior. |
Yeah I fully agree on that. OTOH, apart from some basic use-case that Smithay could provide, most of the complexity would be on the compositor side. For my example with touch input, it's only something I thought about because I'd like users to be able to scroll several window at the same time at some point, with each having its own set of
Assuming all grabs share the same trait, I think it would be best for some of these to be Stacks / Queue would be easiest to deal with as only the 'top' grab would be called, but indeed the stacking/queuing order would matter. Once we start dealing with several nested grab with each having their own side effect and/or policy wrt event propagation (to other grab or target) is where the complexity really appear.
Agreed. It would help to have a clear feedback somewhere for the various cases we'd like to solve (IME, Popup/DnD, true multitouch support) |
It's a pain to use libreoffice on systems with IME on COSMIC right now. GTK popups do not open at all if IME is running. It's been quite infuriating, so I'm pretty desperate to fix the situation.
Summary
Input-method v2 currently implements grab_keyboard as a Smithay KeyboardGrab. This makes it mutually exclusive with compositor routing grabs, such as popup grabs: installing one replaces the other.
This PR moves the input-method keyboard grab to a post-routing input interceptor instead. Routing grabs still decide where keyboard input goes, while the input method can intercept physical keyboard events after that decision.
This allows popup and input-method grabs to coexist without changing KeyboardGrab semantics.
Changes
Issues
This addresses the overlapping popup/IME keyboard-grab limitation described in niri-wm/niri#3899, which can cause popups to stop working while an IME keyboard grab is active.
Testing
I have confirmed libreoffice popups work correctly with a running IME after the change. They also grab keyboard input and after closing return it properly.
Downstream note
Compositors that used KeyboardHandle::is_grabbed() to detect an input-method protocol grab should use InputMethodHandle::keyboard_grabbed() for that purpose instead.
In particular, I've found cosmic-comp's XWayland eavesdropping path to be requiring this, and this will need a companion PR.
niri already distinguishes the input-method protocol grab through InputMethodHandle::keyboard_grabbed(), but has a workaround that avoids installing popup keyboard grabs while an IME grab is active. That workaround can be removed once using this change.
AI disclosure
The code has been generated by ChatGPT, since Rust isn't my forte. But it's been thoroughly read, understood, and architecturally improved by me quite a few times before arriving here.
Checklist