input: update serial on each key press/release and mouse button

The serial is used when copying/pasting data from the clipboard. Up
until now, we’ve used the serial from the keyboard/mouse enter
events.

This works in most cases, but breaks in the following example:

  $ wl-copy  WLCOPY
  /* Ctrl+Shift+v works fine (pastes "WLCOPY") */

  $ printf "\033]52;c;eHl6\a"
  /* Ctrl+Shift+v pastes "WLCOPY" instead of "xyz" */

Shifting focus away and then back to the foot window, and re-executing
the printf works, suggesting the “enter” serial is no longer valid
after another process(?) has copied something to the clipboard.

Updating the serial on key press/release (and the corresponding mouse
serial on mouse button events) seems to fix this.

I’ve also tested that “normal” copy/paste operations, within the same
foot instance, and between foot and other applications, are still
working. In at least river (wlroots based), and GNOME/mutter.

Closes #753
This commit is contained in:
Daniel Eklöf 2021-10-20 18:47:36 +02:00
parent 174f8870c7
commit 8691ad8b2e
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 4 additions and 0 deletions

View file

@ -61,6 +61,8 @@
* Fix crashes after enabling CSD at runtime when `csd.size` is 0.
* Convert `\r` to `\n` when reading clipboard data
(https://codeberg.org/dnkl/foot/issues/752).
* Clipboard occasionally ceasing to work, until window has been
re-focused (https://codeberg.org/dnkl/foot/issues/753).
### Security

View file

@ -954,6 +954,7 @@ static void
key_press_release(struct seat *seat, struct terminal *term, uint32_t serial,
uint32_t key, uint32_t state)
{
seat->kbd.serial = serial;
if (seat->kbd.xkb == NULL ||
seat->kbd.xkb_keymap == NULL ||
seat->kbd.xkb_state == NULL)
@ -1723,6 +1724,7 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
struct wayland *wayl = seat->wayl;
struct terminal *term = seat->mouse_focus;
seat->pointer.serial = serial;
seat->pointer.hidden = false;
xassert(term != NULL);