aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar nyorain <nyorain@gmail.com>2017-07-07 22:34:00 +0200
committerLibravatar nyorain <nyorain@gmail.com>2017-07-07 22:34:00 +0200
commit1e894c1166d1563dacb68d6b91ade455c311b10c (patch)
tree3d03fc90d9ee1b67db9e7b8eb2ed775a3969d693
parentRework get_clipboard implementation (diff)
downloadsway-1e894c1166d1563dacb68d6b91ade455c311b10c.tar.gz
sway-1e894c1166d1563dacb68d6b91ade455c311b10c.tar.zst
sway-1e894c1166d1563dacb68d6b91ade455c311b10c.zip
Handle x11 text atoms in get_clipboard ipc
-rw-r--r--sway/ipc-server.c14
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) {
331 ipc_get_pixel_requests = unhandled; 331 ipc_get_pixel_requests = unhandled;
332} 332}
333 333
334static bool is_text_target(const char *target) {
335 return (strncmp(target, "text/", 5) == 0
336 || strcmp(target, "UTF8_STRING") == 0
337 || strcmp(target, "STRING") == 0
338 || strcmp(target, "TEXT") == 0
339 || strcmp(target, "COMPOUND_TEXT") == 0);
340}
341
334static int ipc_selection_data_cb(int fd, uint32_t mask, void *data) { 342static int ipc_selection_data_cb(int fd, uint32_t mask, void *data) {
335 assert(data); 343 assert(data);
336 struct get_clipboard_request *req = (struct get_clipboard_request *)data; 344 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) {
340 goto cleanup; 348 goto cleanup;
341 } 349 }
342 350
343 if (mask & WLC_EVENT_READABLE || true) { 351 if (mask & WLC_EVENT_READABLE) {
344 static const int step_size = 512; 352 static const int step_size = 512;
345 char *data = NULL; 353 char *data = NULL;
346 int ret = 0; 354 int ret = 0;
@@ -366,7 +374,7 @@ static int ipc_selection_data_cb(int fd, uint32_t mask, void *data) {
366 374
367 data[current] = '\0'; 375 data[current] = '\0';
368 376
369 if (strncmp(req->type, "text/", 5) == 0) { 377 if (is_text_target(req->type)) {
370 json_object_object_add(req->json, req->type, 378 json_object_object_add(req->json, req->type,
371 json_object_new_string(data)); 379 json_object_new_string(data));
372 } else { 380 } else {
@@ -378,8 +386,6 @@ static int ipc_selection_data_cb(int fd, uint32_t mask, void *data) {
378 } 386 }
379 387
380 free(data); 388 free(data);
381 } else {
382 return 0; // TODO
383 } 389 }
384 390
385cleanup: 391cleanup: