atomic keyboard focus changes
In GTK, I've recently run into the following situation:
A popover is opened from a toplevel window, containing an editable label. The user clicks on the editable label to start editing, and the label goes into editing mode for a split second, but reverts right back. The next click succeeds.
What it happening here protocol-wise is that clicking on the popup generates the following events:
- button press on the popup
- keyboard leave on the toplevel
- keyboard enter on the popup
GTK handles the button press to switch the editing label to editing mode.
Then focus leaves the popover, due to the keyboard leave, which causes the editing mode to be canceled.
Then focus comes back to the editable label due to the keyboard enter, but it is too late, we are no longer in editing mode.
In discussion of this sequence with garnacho and jadahl, it was suggested that it would be great if the keyboard leave/enter events were paired somehow, so GTK can know that the keyboard is just moving between two of its surfaces, instead of leaving for good.
Ways to achieve that could be:
- Add a target surface ID to the leave event
- Add a 'keyboard frame' and guarantee that such leave/enter pairs are emitted within a keyboard frame
If the keyboard leaves to a different client, we'd see a keyboard frame-begin, keyboard leave, keyboard frame-end sequence, which tells us that the keyboard has moved elsewhere.