aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CHANGELOG.md3
-rw-r--r--osc.c39
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
diff --git a/osc.c b/osc.c
index 05281d0e..e04428aa 100644
--- a/osc.c
+++ b/osc.c
@@ -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);
}
}