diff options
Diffstat (limited to 'src/platform/wayland/clipboard.c')
| -rw-r--r-- | src/platform/wayland/clipboard.c | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/platform/wayland/clipboard.c b/src/platform/wayland/clipboard.c index 8ca9b93..cf39b6c 100644 --- a/src/platform/wayland/clipboard.c +++ b/src/platform/wayland/clipboard.c @@ -25,7 +25,7 @@ struct transfer { struct offer *drop; struct wl_surface *drop_surface; int fd, id; - yasl_timer_id timeout; + yasl_private_timer_id timeout; char *text; size_t len, offset, capacity; uint64_t request_id; @@ -48,7 +48,7 @@ struct clipboard { struct offer *drag_offer; struct primary_offer *primary_selection; struct primary_offer *primary_pending_offers; - struct yasl_loop *loop; + struct yasl_private_loop *loop; struct transfer *transfers; char *text; char *primary_text; @@ -70,7 +70,7 @@ const char *clipboard_drag_mime(void) return mime; } -static void drag_event(struct clipboard *c, enum yasl_drag_event ev, +static void drag_event(struct clipboard *c, enum yasl_private_drag_event ev, wl_fixed_t x, wl_fixed_t y) { if (c->drag) @@ -78,7 +78,7 @@ static void drag_event(struct clipboard *c, enum yasl_drag_event ev, c->drag_ud); } -static void drop_event(struct clipboard *c, enum yasl_drop_event ev) +static void drop_event(struct clipboard *c, enum yasl_private_drop_event ev) { if (c->drop && c->drag_surface) c->drop(ev, c->drag_surface, wl_fixed_to_double(c->drag_x), @@ -89,7 +89,7 @@ static void free_offer(struct offer *o); static void transfer_end(struct transfer *t, bool complete); -static uint64_t transfer_timeout(void *ud, yasl_timer_id id, uint64_t interval) +static uint64_t transfer_timeout(void *ud, yasl_private_timer_id id, uint64_t interval) { (void)interval; struct transfer *t = ud; @@ -106,9 +106,9 @@ static void transfer_end(struct transfer *t, bool complete) struct transfer **p = &owner->transfers; while (*p && *p != t) p = &(*p)->next; if (*p) *p = t->next; - yasl_loop_del_fd(owner->loop, t->id); + yasl_private_loop_del_fd(owner->loop, t->id); if (t->timeout) - yasl_loop_del_timer(owner->loop, t->timeout); + yasl_private_loop_del_timer(owner->loop, t->timeout); close(t->fd); if (t->drop) { if (complete && wl_data_offer_get_version(t->drop->proxy) >= @@ -124,7 +124,7 @@ static void transfer_end(struct transfer *t, bool complete) struct wl_surface *surface = t->drop_surface; uint64_t request_id = t->request_id; bool uri_list = t->uri_list; - enum yasl_transfer_status status = complete ? YASL_TRANSFER_OK : YASL_TRANSFER_FAILED; + enum yasl_private_transfer_status status = complete ? YASL_PRIVATE_TRANSFER_OK : YASL_PRIVATE_TRANSFER_FAILED; const char *text = complete ? (t->text ? t->text : "") : NULL; size_t len = complete ? t->len : 0; if (notify) @@ -156,7 +156,7 @@ static int transfer_io(int fd, short events, void *ud) if (n > 0) { t->len += (size_t)n; } else if (n == 0) { - bool valid = yasl_utf8_validate(t->text, t->len); + bool valid = yasl_private_utf8_validate(t->text, t->len); transfer_end(t, valid); } else if (errno != EAGAIN && errno != EINTR) transfer_end(t, false); } @@ -176,12 +176,12 @@ static struct transfer *start_transfer_text(struct clipboard *c, int fd, bool se if (!t->text) { close(fd); free(t); return NULL; } t->len = strlen(t->text); } - t->id = yasl_loop_add_fd(c->loop, fd, sending ? POLLOUT : POLLIN, transfer_io, t); + t->id = yasl_private_loop_add_fd(c->loop, fd, sending ? POLLOUT : POLLIN, transfer_io, t); if (t->id < 0) { close(fd); free(t->text); free(t); return NULL; } - t->timeout = yasl_loop_add_timer(c->loop, CLIPBOARD_TRANSFER_TIMEOUT_NS, + t->timeout = yasl_private_loop_add_timer(c->loop, CLIPBOARD_TRANSFER_TIMEOUT_NS, transfer_timeout, t); if (!t->timeout) { - yasl_loop_del_fd(c->loop, t->id); + yasl_private_loop_del_fd(c->loop, t->id); close(fd); free(t->text); free(t); @@ -311,9 +311,9 @@ static void drag_offer_enter(void *ud, struct wl_data_device *device, uint32_t s c->drag_y = y; c->drag_surface = surface; if (o && o->tab) - drag_event(c, YASL_DRAG_OVER, x, y); + drag_event(c, YASL_PRIVATE_DRAG_OVER, x, y); else if (o && !o->tab && (o->uri_list || o->mime)) - drop_event(c, YASL_DROP_OVER); + drop_event(c, YASL_PRIVATE_DROP_OVER); } } static void drag_offer_clear(void *ud, struct wl_data_device *device) @@ -321,10 +321,10 @@ static void drag_offer_clear(void *ud, struct wl_data_device *device) (void)device; struct clipboard *c = ud; if (c->drag_offer && c->drag_offer->tab) - drag_event(c, YASL_DRAG_LEAVE, c->drag_x, c->drag_y); + drag_event(c, YASL_PRIVATE_DRAG_LEAVE, c->drag_x, c->drag_y); else if (c->drag_offer && !c->drag_offer->tab && (c->drag_offer->uri_list || c->drag_offer->mime)) - drop_event(c, YASL_DROP_LEAVE); + drop_event(c, YASL_PRIVATE_DROP_LEAVE); free_offer(c->drag_offer); c->drag_offer = NULL; c->drag_surface = NULL; @@ -336,10 +336,10 @@ static void drag_motion(void *ud, struct wl_data_device *device, uint32_t time, c->drag_x = x; c->drag_y = y; if (c->drag_offer && c->drag_offer->tab) - drag_event(c, YASL_DRAG_OVER, x, y); + drag_event(c, YASL_PRIVATE_DRAG_OVER, x, y); else if (c->drag_offer && !c->drag_offer->tab && (c->drag_offer->uri_list || c->drag_offer->mime)) - drop_event(c, YASL_DROP_OVER); + drop_event(c, YASL_PRIVATE_DROP_OVER); } static void drag_drop(void *ud, struct wl_data_device *device) { @@ -350,11 +350,11 @@ static void drag_drop(void *ud, struct wl_data_device *device) c->drag_offer = NULL; bool v3 = wl_data_offer_get_version(o->proxy) >= 3; if (o->tab) { - drag_event(c, YASL_DRAG_DROP, c->drag_x, c->drag_y); + drag_event(c, YASL_PRIVATE_DRAG_DROP, c->drag_x, c->drag_y); if (v3) wl_data_offer_finish(o->proxy); } else if (o && !o->tab && (o->uri_list || o->mime)) { - drop_event(c, YASL_DROP_LEAVE); + drop_event(c, YASL_PRIVATE_DROP_LEAVE); int fds[2]; if (pipe2(fds, O_CLOEXEC) == 0) { wl_data_offer_receive(o->proxy, o->uri_list ? "text/uri-list" : o->mime, fds[1]); @@ -522,7 +522,7 @@ struct wl_data_device *clipboard_data_device(const struct clipboard *c) } struct clipboard *clipboard_create(struct wl_display *display, struct wl_data_device_manager *manager, - struct wl_seat *seat, struct yasl_loop *loop, + struct wl_seat *seat, struct yasl_private_loop *loop, clipboard_receive_fn receive, void *ud) { if (!manager || !seat) return NULL; @@ -603,7 +603,7 @@ bool clipboard_copy(struct clipboard *c, const char *text, uint32_t serial) void clipboard_paste(struct clipboard *c, struct wl_surface *target) { if (c && target) - (void)clipboard_request_paste(c, YASL_CLIPBOARD, target, 0); + (void)clipboard_request_paste(c, YASL_PRIVATE_CLIPBOARD, target, 0); } bool clipboard_copy_primary(struct clipboard *c, const char *text, uint32_t serial) @@ -630,24 +630,24 @@ bool clipboard_copy_primary(struct clipboard *c, const char *text, uint32_t seri void clipboard_paste_primary(struct clipboard *c, struct wl_surface *target) { if (c && target) - (void)clipboard_request_paste(c, YASL_PRIMARY, target, 0); + (void)clipboard_request_paste(c, YASL_PRIVATE_PRIMARY, target, 0); } -bool clipboard_request_paste(struct clipboard *c, enum yasl_selection selection, +bool clipboard_request_paste(struct clipboard *c, enum yasl_private_selection selection, struct wl_surface *target, uint64_t request_id) { if (!c || !target || !c->receive) return false; int fds[2]; - if (selection == YASL_PRIMARY) { + if (selection == YASL_PRIVATE_PRIMARY) { if (!c->primary_device || !c->primary_selection || !c->primary_selection->mime) { c->receive(NULL, 0, false, target, request_id, - YASL_TRANSFER_UNAVAILABLE, c->ud); + YASL_PRIVATE_TRANSFER_UNAVAILABLE, c->ud); return true; } if (pipe2(fds, O_CLOEXEC) < 0) { c->receive(NULL, 0, false, target, request_id, - YASL_TRANSFER_FAILED, c->ud); + YASL_PRIVATE_TRANSFER_FAILED, c->ud); return true; } zwp_primary_selection_offer_v1_receive(c->primary_selection->proxy, @@ -656,12 +656,12 @@ bool clipboard_request_paste(struct clipboard *c, enum yasl_selection selection, } else { if (!c->device || !c->selection || !c->selection->mime) { c->receive(NULL, 0, false, target, request_id, - YASL_TRANSFER_UNAVAILABLE, c->ud); + YASL_PRIVATE_TRANSFER_UNAVAILABLE, c->ud); return true; } if (pipe2(fds, O_CLOEXEC) < 0) { c->receive(NULL, 0, false, target, request_id, - YASL_TRANSFER_FAILED, c->ud); + YASL_PRIVATE_TRANSFER_FAILED, c->ud); return true; } wl_data_offer_receive(c->selection->proxy, c->selection->mime, fds[1]); @@ -670,7 +670,7 @@ bool clipboard_request_paste(struct clipboard *c, enum yasl_selection selection, struct transfer *transfer = start_transfer_paste(c, fds[0], target, request_id); if (!transfer) { c->receive(NULL, 0, false, target, request_id, - YASL_TRANSFER_FAILED, c->ud); + YASL_PRIVATE_TRANSFER_FAILED, c->ud); return true; } if (wl_display_flush(c->display) < 0 && errno != EAGAIN) |
