diff options
author | nyorain <nyorain@gmail.com> | 2017-07-07 22:34:00 +0200 |
---|---|---|
committer | nyorain <nyorain@gmail.com> | 2017-07-07 22:34:00 +0200 |
commit | 1e894c1166d1563dacb68d6b91ade455c311b10c (patch) | |
tree | 3d03fc90d9ee1b67db9e7b8eb2ed775a3969d693 /sway | |
parent | c0f2acce4e08eecdcf29058335aece113467daee (diff) |
Handle x11 text atoms in get_clipboard ipc
Diffstat (limited to 'sway')
-rw-r--r-- | sway/ipc-server.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 70692f64..22e0137b 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c @@ -331,6 +331,14 @@ void ipc_get_pixels(wlc_handle output) { ipc_get_pixel_requests = unhandled; } +static bool is_text_target(const char *target) { + return (strncmp(target, "text/", 5) == 0 + || strcmp(target, "UTF8_STRING") == 0 + || strcmp(target, "STRING") == 0 + || strcmp(target, "TEXT") == 0 + || strcmp(target, "COMPOUND_TEXT") == 0); +} + static int ipc_selection_data_cb(int fd, uint32_t mask, void *data) { assert(data); struct get_clipboard_request *req = (struct get_clipboard_request *)data; @@ -340,7 +348,7 @@ static int ipc_selection_data_cb(int fd, uint32_t mask, void *data) { goto cleanup; } - if (mask & WLC_EVENT_READABLE || true) { + if (mask & WLC_EVENT_READABLE) { static const int step_size = 512; char *data = NULL; int ret = 0; @@ -366,7 +374,7 @@ static int ipc_selection_data_cb(int fd, uint32_t mask, void *data) { data[current] = '\0'; - if (strncmp(req->type, "text/", 5) == 0) { + if (is_text_target(req->type)) { json_object_object_add(req->json, req->type, json_object_new_string(data)); } else { @@ -378,8 +386,6 @@ static int ipc_selection_data_cb(int fd, uint32_t mask, void *data) { } free(data); - } else { - return 0; // TODO } cleanup: |