mirror of
https://github.com/swaywm/sway.git
synced 2024-11-13 22:14:08 +01:00
Handle x11 text atoms in get_clipboard ipc
This commit is contained in:
parent
c0f2acce4e
commit
1e894c1166
@ -331,6 +331,14 @@ void ipc_get_pixels(wlc_handle output) {
|
|||||||
ipc_get_pixel_requests = unhandled;
|
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) {
|
static int ipc_selection_data_cb(int fd, uint32_t mask, void *data) {
|
||||||
assert(data);
|
assert(data);
|
||||||
struct get_clipboard_request *req = (struct get_clipboard_request *)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;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & WLC_EVENT_READABLE || true) {
|
if (mask & WLC_EVENT_READABLE) {
|
||||||
static const int step_size = 512;
|
static const int step_size = 512;
|
||||||
char *data = NULL;
|
char *data = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -366,7 +374,7 @@ static int ipc_selection_data_cb(int fd, uint32_t mask, void *data) {
|
|||||||
|
|
||||||
data[current] = '\0';
|
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_object_add(req->json, req->type,
|
||||||
json_object_new_string(data));
|
json_object_new_string(data));
|
||||||
} else {
|
} else {
|
||||||
@ -378,8 +386,6 @@ static int ipc_selection_data_cb(int fd, uint32_t mask, void *data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
} else {
|
|
||||||
return 0; // TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
Loading…
Reference in New Issue
Block a user