mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-05-02 06:46:32 -04:00
selection: add selection_<type>_unset()
These functions clear the current selection.
This commit is contained in:
parent
99023cae99
commit
c3cacb4704
2 changed files with 44 additions and 0 deletions
41
selection.c
41
selection.c
|
|
@ -661,6 +661,47 @@ selection_cancel(struct terminal *term)
|
||||||
term->selection.ongoing = false;
|
term->selection.ongoing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
selection_clipboard_unset(struct seat *seat)
|
||||||
|
{
|
||||||
|
struct wl_clipboard *clipboard = &seat->clipboard;
|
||||||
|
|
||||||
|
if (clipboard->data_source == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Kill previous data source */
|
||||||
|
assert(clipboard->serial != 0);
|
||||||
|
wl_data_device_set_selection(seat->data_device, NULL, clipboard->serial);
|
||||||
|
wl_data_source_destroy(clipboard->data_source);
|
||||||
|
|
||||||
|
clipboard->data_source = NULL;
|
||||||
|
clipboard->serial = 0;
|
||||||
|
|
||||||
|
free(clipboard->text);
|
||||||
|
clipboard->text = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
selection_primary_unset(struct seat *seat)
|
||||||
|
{
|
||||||
|
struct wl_primary *primary = &seat->primary;
|
||||||
|
|
||||||
|
if (primary->data_source == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
assert(primary->serial != 0);
|
||||||
|
zwp_primary_selection_device_v1_set_selection(
|
||||||
|
seat->primary_selection_device, NULL, primary->serial);
|
||||||
|
zwp_primary_selection_source_v1_destroy(primary->data_source);
|
||||||
|
free(primary->text);
|
||||||
|
|
||||||
|
primary->data_source = NULL;
|
||||||
|
primary->serial = 0;
|
||||||
|
|
||||||
|
free(primary->text);
|
||||||
|
primary->text = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
selection_mark_word(struct seat *seat, struct terminal *term, int col, int row,
|
selection_mark_word(struct seat *seat, struct terminal *term, int col, int row,
|
||||||
bool spaces_only, uint32_t serial)
|
bool spaces_only, uint32_t serial)
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,9 @@ void selection_mark_word(
|
||||||
void selection_mark_row(
|
void selection_mark_row(
|
||||||
struct seat *seat, struct terminal *term, int row, uint32_t serial);
|
struct seat *seat, struct terminal *term, int row, uint32_t serial);
|
||||||
|
|
||||||
|
void selection_clipboard_unset(struct seat *seat);
|
||||||
|
void selection_primary_unset(struct seat *seat);
|
||||||
|
|
||||||
char *selection_to_text(const struct terminal *term);
|
char *selection_to_text(const struct terminal *term);
|
||||||
void selection_to_clipboard(
|
void selection_to_clipboard(
|
||||||
struct seat *seat, struct terminal *term, uint32_t serial);
|
struct seat *seat, struct terminal *term, uint32_t serial);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue