aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-06-09 07:51:07 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-06-09 09:23:55 +0000
commit49bb00fb64a2af6c677530e07378dafe6d9cbfa2 (patch)
tree7ad3f51af1922442b7bc8fa2e3bb85d35a9ab08f
parentMerge branch 'charset-shift-fixes' (diff)
selection: add support for TEXT/STRING/UTF8_STRING mime-types in incoming offers
We were already offering these mime types for our own clipboard data, but ignored them in incoming offers. Fixes paste issues from Geany. Closes #583
-rw-r--r--CHANGELOG.md2
-rw-r--r--selection.c21
-rw-r--r--wayland.h4
3 files changed, 21 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bd701ca2..1a1bb982 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -170,6 +170,8 @@
* IL+DL (`CSI Ps L` + `CSI Ps M`) now moves the cursor to column 0.
* SS2 and SS3 (single shift) escape sequences behaving like locking
shifts (https://codeberg.org/dnkl/foot/issues/580).
+* `TEXT`+`STRING`+`UTF8_STRING` mime types not being recognized in
+ clipboard offers (https://codeberg.org/dnkl/foot/issues/583).
### Security
diff --git a/selection.c b/selection.c
index 21969208..555b32f2 100644
--- a/selection.c
+++ b/selection.c
@@ -31,6 +31,10 @@ static const char *const mime_type_map[] = {
[DATA_OFFER_MIME_TEXT_PLAIN] = "text/plain",
[DATA_OFFER_MIME_TEXT_UTF8] = "text/plain;charset=utf-8",
[DATA_OFFER_MIME_URI_LIST] = "text/uri-list",
+
+ [DATA_OFFER_MIME_TEXT_TEXT] = "TEXT",
+ [DATA_OFFER_MIME_TEXT_STRING] = "STRING",
+ [DATA_OFFER_MIME_TEXT_UTF8_STRING] = "UTF8_STRING",
};
bool
@@ -1428,9 +1432,9 @@ text_to_clipboard(struct seat *seat, struct terminal *term, char *text, uint32_t
/* Configure source */
wl_data_source_offer(clipboard->data_source, mime_type_map[DATA_OFFER_MIME_TEXT_UTF8]);
wl_data_source_offer(clipboard->data_source, mime_type_map[DATA_OFFER_MIME_TEXT_PLAIN]);
- wl_data_source_offer(clipboard->data_source, "STRING");
- wl_data_source_offer(clipboard->data_source, "TEXT");
- wl_data_source_offer(clipboard->data_source, "UTF8_STRING");
+ wl_data_source_offer(clipboard->data_source, mime_type_map[DATA_OFFER_MIME_TEXT_TEXT]);;
+ wl_data_source_offer(clipboard->data_source, mime_type_map[DATA_OFFER_MIME_TEXT_STRING]);
+ wl_data_source_offer(clipboard->data_source, mime_type_map[DATA_OFFER_MIME_TEXT_UTF8_STRING]);
wl_data_source_add_listener(clipboard->data_source, &data_source_listener, seat);
wl_data_device_set_selection(seat->data_device, clipboard->data_source, serial);
@@ -1874,9 +1878,9 @@ text_to_primary(struct seat *seat, struct terminal *term, char *text, uint32_t s
/* Configure source */
zwp_primary_selection_source_v1_offer(primary->data_source, mime_type_map[DATA_OFFER_MIME_TEXT_UTF8]);
zwp_primary_selection_source_v1_offer(primary->data_source, mime_type_map[DATA_OFFER_MIME_TEXT_PLAIN]);
- zwp_primary_selection_source_v1_offer(primary->data_source, "STRING");
- zwp_primary_selection_source_v1_offer(primary->data_source, "TEXT");
- zwp_primary_selection_source_v1_offer(primary->data_source, "UTF8_STRING");
+ zwp_primary_selection_source_v1_offer(primary->data_source, mime_type_map[DATA_OFFER_MIME_TEXT_TEXT]);
+ zwp_primary_selection_source_v1_offer(primary->data_source, mime_type_map[DATA_OFFER_MIME_TEXT_STRING]);
+ zwp_primary_selection_source_v1_offer(primary->data_source, mime_type_map[DATA_OFFER_MIME_TEXT_UTF8_STRING]);
zwp_primary_selection_source_v1_add_listener(primary->data_source, &primary_selection_source_listener, seat);
zwp_primary_selection_device_v1_set_selection(seat->primary_selection_device, primary->data_source, serial);
@@ -1988,6 +1992,8 @@ select_mime_type_for_offer(const char *_mime_type,
switch (mime_type) {
case DATA_OFFER_MIME_TEXT_PLAIN:
+ case DATA_OFFER_MIME_TEXT_TEXT:
+ case DATA_OFFER_MIME_TEXT_STRING:
/* text/plain is our least preferred type. Only use if current
* type is unset */
switch (*type) {
@@ -2001,10 +2007,13 @@ select_mime_type_for_offer(const char *_mime_type,
break;
case DATA_OFFER_MIME_TEXT_UTF8:
+ case DATA_OFFER_MIME_TEXT_UTF8_STRING:
/* text/plain;charset=utf-8 is preferred over text/plain */
switch (*type) {
case DATA_OFFER_MIME_UNSET:
case DATA_OFFER_MIME_TEXT_PLAIN:
+ case DATA_OFFER_MIME_TEXT_TEXT:
+ case DATA_OFFER_MIME_TEXT_STRING:
*type = mime_type;
break;
diff --git a/wayland.h b/wayland.h
index 4ec09544..6021497f 100644
--- a/wayland.h
+++ b/wayland.h
@@ -122,6 +122,10 @@ enum data_offer_mime_type {
DATA_OFFER_MIME_TEXT_PLAIN,
DATA_OFFER_MIME_TEXT_UTF8,
DATA_OFFER_MIME_URI_LIST,
+
+ DATA_OFFER_MIME_TEXT_TEXT,
+ DATA_OFFER_MIME_TEXT_STRING,
+ DATA_OFFER_MIME_TEXT_UTF8_STRING,
};
struct wl_window;