aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-09-25 17:26:55 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-09-25 17:26:55 +0000
commit16f15d1a36a30e79e0ad42dd05746bb04bc0d7dd (patch)
tree2a056566c1b4e35e40baccbff1891855e541891c
parentmain: we prefer xdg-output-manager version 2, but get by with 1 (diff)
selection: primary: don't require compositor to implement it
-rw-r--r--main.c16
-rw-r--r--selection.c12
2 files changed, 20 insertions, 8 deletions
diff --git a/main.c b/main.c
index bfba5ce9..947e4b46 100644
--- a/main.c
+++ b/main.c
@@ -735,10 +735,8 @@ 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;
- }
+ if (term.wl.primary_selection_device_manager == NULL)
+ LOG_WARN("no primary selection available");
tll_foreach(term.wl.monitors, it) {
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);
/* 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);
+ if (term.wl.primary_selection_device_manager != NULL) {
+ 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 */
unsigned cursor_size = 24;
diff --git a/selection.c b/selection.c
index c4991906..72e56ec0 100644
--- a/selection.c
+++ b/selection.c
@@ -549,6 +549,9 @@ selection_from_clipboard(struct terminal *term, uint32_t serial)
bool
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 */
if (term->selection.primary.data_source != NULL) {
/* Kill previous data source */
@@ -592,6 +595,9 @@ text_to_primary(struct terminal *term, char *text, uint32_t serial)
void
selection_to_primary(struct terminal *term, uint32_t serial)
{
+ if (term->wl.primary_selection_device_manager == NULL)
+ return;
+
/* Get selection as a string */
char *text = extract_selection(term);
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),
void *user)
{
+ if (term->wl.primary_selection_device_manager == NULL)
+ return;
+
struct primary *primary = &term->selection.primary;
if (primary->data_offer == NULL)
return;
@@ -645,6 +654,9 @@ text_from_primary(
void
selection_from_primary(struct terminal *term)
{
+ if (term->wl.primary_selection_device_manager == NULL)
+ return;
+
struct clipboard *clipboard = &term->selection.clipboard;
if (clipboard->data_offer == NULL)
return;