diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-07-11 06:30:47 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-07-11 06:30:47 +0000 |
| commit | ed0cb06b485e83a914cb7a5888369a213dc5577c (patch) | |
| tree | 0597f7aafd9bb304012dbdd71273b14960396432 /osc.c | |
| parent | meson/PKGBUILD: bump fcft requirement to 2.2.0 (diff) | |
| parent | wayland: destroy cursor theme when removing pointer capability (diff) | |
Merge branch 'multi-seat'
Closes #32
Diffstat (limited to 'osc.c')
| -rw-r--r-- | osc.c | 41 |
1 files changed, 35 insertions, 6 deletions
@@ -52,15 +52,29 @@ osc_to_clipboard(struct terminal *term, const char *target, } } + /* Find a seat in which the terminal has focus */ + struct seat *seat = NULL; + tll_foreach(term->wl->seats, it) { + if (it->item.kbd_focus == term) { + seat = &it->item; + break; + } + } + + if (seat == NULL) { + LOG_WARN("OSC52: client tried to write to clipboard data while window was unfocused"); + return; + } + if (to_clipboard) { char *copy = strdup(decoded); - if (!text_to_clipboard(term, copy, term->wl->input_serial)) + if (!text_to_clipboard(seat, term, copy, seat->kbd.serial)) free(copy); } if (to_primary) { char *copy = strdup(decoded); - if (!text_to_primary(term, copy, term->wl->input_serial)) + if (!text_to_primary(seat, term, copy, seat->kbd.serial)) free(copy); } @@ -68,6 +82,7 @@ osc_to_clipboard(struct terminal *term, const char *target, } struct clip_context { + struct seat *seat; struct terminal *term; uint8_t buf[3]; int idx; @@ -151,23 +166,37 @@ osc_from_clipboard(struct terminal *term, const char *source) if (src == 0) return; + /* Find a seat in which the terminal has focus */ + struct seat *seat = NULL; + tll_foreach(term->wl->seats, it) { + if (it->item.kbd_focus == term) { + seat = &it->item; + break; + } + } + + if (seat == NULL) { + LOG_WARN("OSC52: client tried to read clipboard data while window was unfocused"); + return; + } + term_to_slave(term, "\033]52;", 5); term_to_slave(term, &src, 1); term_to_slave(term, ";", 1); struct clip_context *ctx = malloc(sizeof(*ctx)); - *ctx = (struct clip_context) {.term = term}; + *ctx = (struct clip_context) {.seat = seat, .term = term}; switch (src) { case 'c': text_from_clipboard( - term, term->wl->input_serial, - &from_clipboard_cb, &from_clipboard_done, ctx); + seat, term, &from_clipboard_cb, &from_clipboard_done, ctx); break; case 's': case 'p': - text_from_primary(term, &from_clipboard_cb, &from_clipboard_done, ctx); + text_from_primary( + seat, term, &from_clipboard_cb, &from_clipboard_done, ctx); break; } } |
