mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-21 05:33:45 -04:00
selection: add support for pasting *from* primary
This commit is contained in:
parent
e56066feef
commit
703aeecb95
5 changed files with 124 additions and 6 deletions
29
main.c
29
main.c
|
|
@ -131,6 +131,11 @@ handle_global(void *data, struct wl_registry *registry,
|
|||
term->wl.data_device_manager = wl_registry_bind(
|
||||
term->wl.registry, name, &wl_data_device_manager_interface, 1);
|
||||
}
|
||||
|
||||
else if (strcmp(interface, zwp_primary_selection_device_manager_v1_interface.name) == 0) {
|
||||
term->wl.primary_selection_device_manager = wl_registry_bind(
|
||||
term->wl.registry, name, &zwp_primary_selection_device_manager_v1_interface, 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -403,12 +408,22 @@ main(int argc, char *const *argv)
|
|||
"(wl_data_device_manager not implemented by server)");
|
||||
goto out;
|
||||
}
|
||||
if (term.wl.primary_selection_device_manager == NULL) {
|
||||
LOG_ERR("no primary selection available");
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Clipboard */
|
||||
term.wl.data_device = wl_data_device_manager_get_data_device(
|
||||
term.wl.data_device_manager, term.wl.seat);
|
||||
wl_data_device_add_listener(term.wl.data_device, &data_device_listener, &term);
|
||||
|
||||
/* Primary selection */
|
||||
term.wl.primary_selection_device = zwp_primary_selection_device_manager_v1_get_device(
|
||||
term.wl.primary_selection_device_manager, term.wl.seat);
|
||||
zwp_primary_selection_device_v1_add_listener(
|
||||
term.wl.primary_selection_device, &primary_selection_device_listener, &term);
|
||||
|
||||
/* Cursor */
|
||||
term.wl.pointer.surface = wl_compositor_create_surface(term.wl.compositor);
|
||||
if (term.wl.pointer.surface == NULL) {
|
||||
|
|
@ -623,11 +638,6 @@ out:
|
|||
wl_surface_destroy(term.wl.pointer.surface);
|
||||
if (term.wl.keyboard != NULL)
|
||||
wl_keyboard_destroy(term.wl.keyboard);
|
||||
if (term.selection.primary.data_source != NULL)
|
||||
wl_data_source_destroy(term.selection.primary.data_source);
|
||||
if (term.selection.primary.data_offer != NULL)
|
||||
wl_data_offer_destroy(term.selection.primary.data_offer);
|
||||
free(term.selection.primary.text);
|
||||
if (term.selection.clipboard.data_source != NULL)
|
||||
wl_data_source_destroy(term.selection.clipboard.data_source);
|
||||
if (term.selection.clipboard.data_offer != NULL)
|
||||
|
|
@ -637,6 +647,15 @@ out:
|
|||
wl_data_device_destroy(term.wl.data_device);
|
||||
if (term.wl.data_device_manager != NULL)
|
||||
wl_data_device_manager_destroy(term.wl.data_device_manager);
|
||||
if (term.selection.primary.data_source != NULL)
|
||||
zwp_primary_selection_source_v1_destroy(term.selection.primary.data_source);
|
||||
if (term.selection.primary.data_offer != NULL)
|
||||
zwp_primary_selection_offer_v1_destroy(term.selection.primary.data_offer);
|
||||
free(term.selection.primary.text);
|
||||
if (term.wl.primary_selection_device != NULL)
|
||||
zwp_primary_selection_device_v1_destroy(term.wl.primary_selection_device);
|
||||
if (term.wl.primary_selection_device_manager != NULL)
|
||||
zwp_primary_selection_device_manager_v1_destroy(term.wl.primary_selection_device_manager);
|
||||
if (term.wl.seat != NULL)
|
||||
wl_seat_destroy(term.wl.seat);
|
||||
if (term.wl.surface != NULL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue