diff options
| author | CismonX <admin@cismon.net> | 2026-11-16 09:18:21 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2026-11-16 17:21:23 +0000 |
| commit | c0d2c3e95d74cb60526ff28aec9f34ee3df545e0 (patch) | |
| tree | 96f1228f4004ebd74530c7f0aea264108eff425f | |
| parent | readme: remove sponsoring information (diff) | |
Currently, if no source specified in the OSC-52 query has data,
foot does not send any response. This does not work well with
some applications (e.g. neovim ':registers').
Also refactors the code a little bit.
Closes #2493
| -rw-r--r-- | CHANGELOG.md | 3 | ||||
| -rw-r--r-- | osc.c | 39 |
2 files changed, 16 insertions, 26 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d1a25691..f5b3aa60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -95,12 +95,15 @@ selection direction ([#2483][2483]). * Crash in `xdg_output_handle_done()` if called when a terminal is in the process of shutting down ([#2487][2487]). +* Not responding to an OSC-52 query if clipboard source has no data + ([#2493][2493]). [2432]: https://codeberg.org/dnkl/foot/pulls/2432 [2467]: https://codeberg.org/dnkl/foot/issues/2467 [2482]: https://codeberg.org/dnkl/foot/pulls/2482 [2483]: https://codeberg.org/dnkl/foot/issues/2483 [2487]: https://codeberg.org/dnkl/foot/issues/2487 +[2493]: https://codeberg.org/dnkl/foot/issues/2493 ### Security @@ -209,34 +209,20 @@ osc_from_clipboard(struct terminal *term, const char *source) } /* Use clipboard if no source has been specified */ - char src = source[0] == '\0' ? 'c' : 0; - bool from_clipboard = src == 'c'; - bool from_primary = false; + char src = 'c'; + for (char const *s = source; *s != '\0'; ++s) { + src = *s; - for (const char *s = source; - *s != '\0' && !from_clipboard && !from_primary; - s++) - { - if (*s == 'c' || *s == 'p' || *s == 's') { - src = *s; - - switch (src) { - case 'c': - from_clipboard = selection_clipboard_has_data(seat); + if (src == 'c') { + if (selection_clipboard_has_data(seat)) break; - - case 's': - case 'p': - from_primary = selection_primary_has_data(seat); + } else if (src == 'p' || src == 's') { + if (selection_primary_has_data(seat)) break; - } } else - LOG_WARN("unimplemented: clipboard source '%c'", *s); + LOG_WARN("unimplemented: clipboard source '%c'", src); } - if (!from_clipboard && !from_primary) - return; - if (term->is_sending_paste_data) { /* FIXME: we should wait for the paste to end, then continue with the OSC-52 reply */ @@ -259,14 +245,15 @@ osc_from_clipboard(struct terminal *term, const char *source) struct clip_context *ctx = xmalloc(sizeof(*ctx)); *ctx = (struct clip_context) {.seat = seat, .term = term}; - if (from_clipboard) { + if (src == 'c') { text_from_clipboard( seat, term, true, &from_clipboard_cb, &from_clipboard_done, ctx); - } - - if (from_primary) { + } else if (src == 'p' || src == 's') { text_from_primary( seat, term, true, &from_clipboard_cb, &from_clipboard_done, ctx); + } else { + /* Send empty reply for unsupported source */ + from_clipboard_done(ctx); } } |
