mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-16 05:34:00 -04:00
selection: primary: don't require compositor to implement it
This commit is contained in:
parent
5340204cbc
commit
16f15d1a36
2 changed files with 20 additions and 8 deletions
16
main.c
16
main.c
|
|
@ -735,10 +735,8 @@ main(int argc, char *const *argv)
|
||||||
"(wl_data_device_manager not implemented by server)");
|
"(wl_data_device_manager not implemented by server)");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (term.wl.primary_selection_device_manager == NULL) {
|
if (term.wl.primary_selection_device_manager == NULL)
|
||||||
LOG_ERR("no primary selection available");
|
LOG_WARN("no primary selection available");
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
tll_foreach(term.wl.monitors, it) {
|
tll_foreach(term.wl.monitors, it) {
|
||||||
LOG_INFO("%s: %dx%d+%dx%d (scale=%d, refresh=%.2fHz)",
|
LOG_INFO("%s: %dx%d+%dx%d (scale=%d, refresh=%.2fHz)",
|
||||||
|
|
@ -752,10 +750,12 @@ main(int argc, char *const *argv)
|
||||||
wl_data_device_add_listener(term.wl.data_device, &data_device_listener, &term);
|
wl_data_device_add_listener(term.wl.data_device, &data_device_listener, &term);
|
||||||
|
|
||||||
/* Primary selection */
|
/* Primary selection */
|
||||||
term.wl.primary_selection_device = zwp_primary_selection_device_manager_v1_get_device(
|
if (term.wl.primary_selection_device_manager != NULL) {
|
||||||
term.wl.primary_selection_device_manager, term.wl.seat);
|
term.wl.primary_selection_device = zwp_primary_selection_device_manager_v1_get_device(
|
||||||
zwp_primary_selection_device_v1_add_listener(
|
term.wl.primary_selection_device_manager, term.wl.seat);
|
||||||
term.wl.primary_selection_device, &primary_selection_device_listener, &term);
|
zwp_primary_selection_device_v1_add_listener(
|
||||||
|
term.wl.primary_selection_device, &primary_selection_device_listener, &term);
|
||||||
|
}
|
||||||
|
|
||||||
/* Cursor */
|
/* Cursor */
|
||||||
unsigned cursor_size = 24;
|
unsigned cursor_size = 24;
|
||||||
|
|
|
||||||
12
selection.c
12
selection.c
|
|
@ -549,6 +549,9 @@ selection_from_clipboard(struct terminal *term, uint32_t serial)
|
||||||
bool
|
bool
|
||||||
text_to_primary(struct terminal *term, char *text, uint32_t serial)
|
text_to_primary(struct terminal *term, char *text, uint32_t serial)
|
||||||
{
|
{
|
||||||
|
if (term->wl.primary_selection_device_manager == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
/* TODO: somehow share code with the clipboard equivalent */
|
/* TODO: somehow share code with the clipboard equivalent */
|
||||||
if (term->selection.primary.data_source != NULL) {
|
if (term->selection.primary.data_source != NULL) {
|
||||||
/* Kill previous data source */
|
/* Kill previous data source */
|
||||||
|
|
@ -592,6 +595,9 @@ text_to_primary(struct terminal *term, char *text, uint32_t serial)
|
||||||
void
|
void
|
||||||
selection_to_primary(struct terminal *term, uint32_t serial)
|
selection_to_primary(struct terminal *term, uint32_t serial)
|
||||||
{
|
{
|
||||||
|
if (term->wl.primary_selection_device_manager == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Get selection as a string */
|
/* Get selection as a string */
|
||||||
char *text = extract_selection(term);
|
char *text = extract_selection(term);
|
||||||
if (!text_to_primary(term, text, serial))
|
if (!text_to_primary(term, text, serial))
|
||||||
|
|
@ -603,6 +609,9 @@ text_from_primary(
|
||||||
struct terminal *term, void (*cb)(const char *data, size_t size, void *user),
|
struct terminal *term, void (*cb)(const char *data, size_t size, void *user),
|
||||||
void *user)
|
void *user)
|
||||||
{
|
{
|
||||||
|
if (term->wl.primary_selection_device_manager == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
struct primary *primary = &term->selection.primary;
|
struct primary *primary = &term->selection.primary;
|
||||||
if (primary->data_offer == NULL)
|
if (primary->data_offer == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
@ -645,6 +654,9 @@ text_from_primary(
|
||||||
void
|
void
|
||||||
selection_from_primary(struct terminal *term)
|
selection_from_primary(struct terminal *term)
|
||||||
{
|
{
|
||||||
|
if (term->wl.primary_selection_device_manager == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
struct clipboard *clipboard = &term->selection.clipboard;
|
struct clipboard *clipboard = &term->selection.clipboard;
|
||||||
if (clipboard->data_offer == NULL)
|
if (clipboard->data_offer == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue