diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-06-09 07:51:07 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-06-09 09:23:55 +0000 |
| commit | 49bb00fb64a2af6c677530e07378dafe6d9cbfa2 (patch) | |
| tree | 7ad3f51af1922442b7bc8fa2e3bb85d35a9ab08f /selection.c | |
| parent | Merge 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
Diffstat (limited to 'selection.c')
| -rw-r--r-- | selection.c | 21 |
1 files changed, 15 insertions, 6 deletions
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; |
