diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-10-27 15:15:32 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-10-27 15:15:32 +0000 |
| commit | 5ca1ee701bc4297180fa9c248d9f8810ef82550c (patch) | |
| tree | 89eed45b45ca6b0233bde223d5cb852ca7f7fe64 /selection.c | |
| parent | wayland: implement wayl_win_destroy() (diff) | |
wayland: move clipboard/primary structs into the wayland struct
These are application global and very wayland specific
Diffstat (limited to 'selection.c')
| -rw-r--r-- | selection.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/selection.c b/selection.c index d5b89dba..e53ace8b 100644 --- a/selection.c +++ b/selection.c @@ -319,7 +319,7 @@ static void send(void *data, struct wl_data_source *wl_data_source, const char *mime_type, int32_t fd) { - const struct clipboard *clipboard + const struct wl_clipboard *clipboard = wl_data_source_get_user_data(wl_data_source); assert(clipboard != NULL); @@ -346,7 +346,7 @@ send(void *data, struct wl_data_source *wl_data_source, const char *mime_type, static void cancelled(void *data, struct wl_data_source *wl_data_source) { - struct clipboard *clipboard = wl_data_source_get_user_data(wl_data_source); + struct wl_clipboard *clipboard = wl_data_source_get_user_data(wl_data_source); assert(clipboard->data_source == wl_data_source); wl_data_source_destroy(clipboard->data_source); @@ -386,7 +386,7 @@ primary_send(void *data, struct zwp_primary_selection_source_v1 *zwp_primary_selection_source_v1, const char *mime_type, int32_t fd) { - const struct primary *primary + const struct wl_primary *primary = zwp_primary_selection_source_v1_get_user_data(zwp_primary_selection_source_v1); assert(primary != NULL); @@ -414,7 +414,7 @@ static void primary_cancelled(void *data, struct zwp_primary_selection_source_v1 *zwp_primary_selection_source_v1) { - struct primary *primary = zwp_primary_selection_source_v1_get_user_data( + struct wl_primary *primary = zwp_primary_selection_source_v1_get_user_data( zwp_primary_selection_source_v1); //assert(primary->data_source == zwp_primary_selection_source_v1); @@ -434,10 +434,10 @@ static const struct zwp_primary_selection_source_v1_listener primary_selection_s bool text_to_clipboard(struct terminal *term, char *text, uint32_t serial) { - if (term->selection.clipboard.data_source != NULL) { - /* Kill previous data source */ - struct clipboard *clipboard = &term->selection.clipboard; + struct wl_clipboard *clipboard = &term->wl.clipboard; + if (term->wl.clipboard.data_source != NULL) { + /* Kill previous data source */ assert(clipboard->serial != 0); wl_data_device_set_selection(term->wl.data_device, NULL, clipboard->serial); wl_data_source_destroy(clipboard->data_source); @@ -447,8 +447,6 @@ text_to_clipboard(struct terminal *term, char *text, uint32_t serial) clipboard->serial = 0; } - struct clipboard *clipboard = &term->selection.clipboard; - clipboard->data_source = wl_data_device_manager_create_data_source(term->wl.data_device_manager); @@ -484,7 +482,7 @@ text_from_clipboard(struct terminal *term, uint32_t serial, void (*cb)(const char *data, size_t size, void *user), void *user) { - struct clipboard *clipboard = &term->selection.clipboard; + struct wl_clipboard *clipboard = &term->wl.clipboard; if (clipboard->data_offer == NULL) return; @@ -541,7 +539,7 @@ from_clipboard_cb(const char *data, size_t size, void *user) void selection_from_clipboard(struct terminal *term, uint32_t serial) { - struct clipboard *clipboard = &term->selection.clipboard; + struct wl_clipboard *clipboard = &term->wl.clipboard; if (clipboard->data_offer == NULL) return; @@ -560,10 +558,11 @@ text_to_primary(struct terminal *term, char *text, uint32_t serial) if (term->wl.primary_selection_device_manager == NULL) return false; + struct wl_primary *primary = &term->wl.primary; + /* TODO: somehow share code with the clipboard equivalent */ - if (term->selection.primary.data_source != NULL) { + if (term->wl.primary.data_source != NULL) { /* Kill previous data source */ - struct primary *primary = &term->selection.primary; assert(primary->serial != 0); zwp_primary_selection_device_v1_set_selection( @@ -575,8 +574,6 @@ text_to_primary(struct terminal *term, char *text, uint32_t serial) primary->serial = 0; } - struct primary *primary = &term->selection.primary; - primary->data_source = zwp_primary_selection_device_manager_v1_create_source( term->wl.primary_selection_device_manager); @@ -620,7 +617,7 @@ text_from_primary( if (term->wl.primary_selection_device_manager == NULL) return; - struct primary *primary = &term->selection.primary; + struct wl_primary *primary = &term->wl.primary; if (primary->data_offer == NULL) return; @@ -673,7 +670,7 @@ selection_from_primary(struct terminal *term) if (term->wl.primary_selection_device_manager == NULL) return; - struct clipboard *clipboard = &term->selection.clipboard; + struct wl_clipboard *clipboard = &term->wl.clipboard; if (clipboard->data_offer == NULL) return; @@ -746,7 +743,7 @@ selection(void *data, struct wl_data_device *wl_data_device, /* Selection offer from other client */ struct terminal *term = data; - struct clipboard *clipboard = &term->selection.clipboard; + struct wl_clipboard *clipboard = &term->wl.clipboard; if (clipboard->data_offer != NULL) wl_data_offer_destroy(clipboard->data_offer); @@ -795,7 +792,7 @@ primary_selection(void *data, /* Selection offer from other client, for primary */ struct terminal *term = data; - struct primary *primary = &term->selection.primary; + struct wl_primary *primary = &term->wl.primary; if (primary->data_offer != NULL) zwp_primary_selection_offer_v1_destroy(primary->data_offer); |
