aboutsummaryrefslogtreecommitdiff
path: root/selection.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-10-30 16:31:44 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-10-30 16:31:44 +0000
commitad0f8a02d56709bd59211ff6a5d485a380d708f0 (patch)
treecfabf659cbb1cf2219b982842f5d7b1249034f78 /selection.c
parentscrollback: regression: fix rendering of scrollback diffs less than a screen (diff)
parentslave: rename slave_spawn() -> slave_exec() (diff)
Merge branch 'fdm'
Diffstat (limited to 'selection.c')
-rw-r--r--selection.c65
1 files changed, 31 insertions, 34 deletions
diff --git a/selection.c b/selection.c
index d5b89dba..d2ed7354 100644
--- a/selection.c
+++ b/selection.c
@@ -22,7 +22,7 @@ selection_enabled(const struct terminal *term)
{
return
term->mouse_tracking == MOUSE_NONE ||
- term->kbd.shift ||
+ term->wl->kbd.shift ||
term->is_searching;
}
@@ -319,7 +319,7 @@ static void
send(void *data, struct wl_data_source *wl_data_source, const char *mime_type,
int32_t fd)
{
- const struct clipboard *clipboard
+ const struct wl_clipboard *clipboard
= wl_data_source_get_user_data(wl_data_source);
assert(clipboard != NULL);
@@ -346,7 +346,7 @@ send(void *data, struct wl_data_source *wl_data_source, const char *mime_type,
static void
cancelled(void *data, struct wl_data_source *wl_data_source)
{
- struct clipboard *clipboard = wl_data_source_get_user_data(wl_data_source);
+ struct wl_clipboard *clipboard = wl_data_source_get_user_data(wl_data_source);
assert(clipboard->data_source == wl_data_source);
wl_data_source_destroy(clipboard->data_source);
@@ -386,7 +386,7 @@ primary_send(void *data,
struct zwp_primary_selection_source_v1 *zwp_primary_selection_source_v1,
const char *mime_type, int32_t fd)
{
- const struct primary *primary
+ const struct wl_primary *primary
= zwp_primary_selection_source_v1_get_user_data(zwp_primary_selection_source_v1);
assert(primary != NULL);
@@ -414,7 +414,7 @@ static void
primary_cancelled(void *data,
struct zwp_primary_selection_source_v1 *zwp_primary_selection_source_v1)
{
- struct primary *primary = zwp_primary_selection_source_v1_get_user_data(
+ struct wl_primary *primary = zwp_primary_selection_source_v1_get_user_data(
zwp_primary_selection_source_v1);
//assert(primary->data_source == zwp_primary_selection_source_v1);
@@ -434,12 +434,12 @@ static const struct zwp_primary_selection_source_v1_listener primary_selection_s
bool
text_to_clipboard(struct terminal *term, char *text, uint32_t serial)
{
- if (term->selection.clipboard.data_source != NULL) {
- /* Kill previous data source */
- struct clipboard *clipboard = &term->selection.clipboard;
+ struct wl_clipboard *clipboard = &term->wl->clipboard;
+ if (term->wl->clipboard.data_source != NULL) {
+ /* Kill previous data source */
assert(clipboard->serial != 0);
- wl_data_device_set_selection(term->wl.data_device, NULL, clipboard->serial);
+ wl_data_device_set_selection(term->wl->data_device, NULL, clipboard->serial);
wl_data_source_destroy(clipboard->data_source);
free(clipboard->text);
@@ -447,10 +447,8 @@ text_to_clipboard(struct terminal *term, char *text, uint32_t serial)
clipboard->serial = 0;
}
- struct clipboard *clipboard = &term->selection.clipboard;
-
clipboard->data_source
- = wl_data_device_manager_create_data_source(term->wl.data_device_manager);
+ = wl_data_device_manager_create_data_source(term->wl->data_device_manager);
if (clipboard->data_source == NULL) {
LOG_ERR("failed to create clipboard data source");
@@ -462,7 +460,7 @@ text_to_clipboard(struct terminal *term, char *text, uint32_t serial)
/* Configure source */
wl_data_source_offer(clipboard->data_source, "text/plain;charset=utf-8");
wl_data_source_add_listener(clipboard->data_source, &data_source_listener, term);
- wl_data_device_set_selection(term->wl.data_device, clipboard->data_source, serial);
+ wl_data_device_set_selection(term->wl->data_device, clipboard->data_source, serial);
wl_data_source_set_user_data(clipboard->data_source, clipboard);
/* Needed when sending the selection to other client */
@@ -484,7 +482,7 @@ text_from_clipboard(struct terminal *term, uint32_t serial,
void (*cb)(const char *data, size_t size, void *user),
void *user)
{
- struct clipboard *clipboard = &term->selection.clipboard;
+ struct wl_clipboard *clipboard = &term->wl->clipboard;
if (clipboard->data_offer == NULL)
return;
@@ -501,7 +499,7 @@ text_from_clipboard(struct terminal *term, uint32_t serial,
/* Give write-end of pipe to other client */
wl_data_offer_receive(
clipboard->data_offer, "text/plain;charset=utf-8", write_fd);
- wl_display_roundtrip(term->wl.display);
+ wl_display_roundtrip(term->wl->display);
/* Don't keep our copy of the write-end open (or we'll never get EOF) */
close(write_fd);
@@ -541,7 +539,7 @@ from_clipboard_cb(const char *data, size_t size, void *user)
void
selection_from_clipboard(struct terminal *term, uint32_t serial)
{
- struct clipboard *clipboard = &term->selection.clipboard;
+ struct wl_clipboard *clipboard = &term->wl->clipboard;
if (clipboard->data_offer == NULL)
return;
@@ -557,17 +555,18 @@ 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)
+ if (term->wl->primary_selection_device_manager == NULL)
return false;
+ struct wl_primary *primary = &term->wl->primary;
+
/* TODO: somehow share code with the clipboard equivalent */
- if (term->selection.primary.data_source != NULL) {
+ if (term->wl->primary.data_source != NULL) {
/* Kill previous data source */
- struct primary *primary = &term->selection.primary;
assert(primary->serial != 0);
zwp_primary_selection_device_v1_set_selection(
- term->wl.primary_selection_device, NULL, primary->serial);
+ term->wl->primary_selection_device, NULL, primary->serial);
zwp_primary_selection_source_v1_destroy(primary->data_source);
free(primary->text);
@@ -575,11 +574,9 @@ text_to_primary(struct terminal *term, char *text, uint32_t serial)
primary->serial = 0;
}
- struct primary *primary = &term->selection.primary;
-
primary->data_source
= zwp_primary_selection_device_manager_v1_create_source(
- term->wl.primary_selection_device_manager);
+ term->wl->primary_selection_device_manager);
if (primary->data_source == NULL) {
LOG_ERR("failed to create clipboard data source");
@@ -592,7 +589,7 @@ text_to_primary(struct terminal *term, char *text, uint32_t serial)
/* Configure source */
zwp_primary_selection_source_v1_offer(primary->data_source, "text/plain;charset=utf-8");
zwp_primary_selection_source_v1_add_listener(primary->data_source, &primary_selection_source_listener, term);
- zwp_primary_selection_device_v1_set_selection(term->wl.primary_selection_device, primary->data_source, serial);
+ zwp_primary_selection_device_v1_set_selection(term->wl->primary_selection_device, primary->data_source, serial);
zwp_primary_selection_source_v1_set_user_data(primary->data_source, primary);
/* Needed when sending the selection to other client */
@@ -603,7 +600,7 @@ 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)
+ if (term->wl->primary_selection_device_manager == NULL)
return;
/* Get selection as a string */
@@ -617,10 +614,10 @@ 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)
+ if (term->wl->primary_selection_device_manager == NULL)
return;
- struct primary *primary = &term->selection.primary;
+ struct wl_primary *primary = &term->wl->primary;
if (primary->data_offer == NULL)
return;
@@ -637,7 +634,7 @@ text_from_primary(
/* Give write-end of pipe to other client */
zwp_primary_selection_offer_v1_receive(
primary->data_offer, "text/plain;charset=utf-8", write_fd);
- wl_display_roundtrip(term->wl.display);
+ wl_display_roundtrip(term->wl->display);
/* Don't keep our copy of the write-end open (or we'll never get EOF) */
close(write_fd);
@@ -670,10 +667,10 @@ text_from_primary(
void
selection_from_primary(struct terminal *term)
{
- if (term->wl.primary_selection_device_manager == NULL)
+ if (term->wl->primary_selection_device_manager == NULL)
return;
- struct clipboard *clipboard = &term->selection.clipboard;
+ struct wl_clipboard *clipboard = &term->wl->clipboard;
if (clipboard->data_offer == NULL)
return;
@@ -745,8 +742,8 @@ selection(void *data, struct wl_data_device *wl_data_device,
{
/* Selection offer from other client */
- struct terminal *term = data;
- struct clipboard *clipboard = &term->selection.clipboard;
+ struct wayland *wayl = data;
+ struct wl_clipboard *clipboard = &wayl->clipboard;
if (clipboard->data_offer != NULL)
wl_data_offer_destroy(clipboard->data_offer);
@@ -794,8 +791,8 @@ primary_selection(void *data,
{
/* Selection offer from other client, for primary */
- struct terminal *term = data;
- struct primary *primary = &term->selection.primary;
+ struct wayland *wayl = data;
+ struct wl_primary *primary = &wayl->primary;
if (primary->data_offer != NULL)
zwp_primary_selection_offer_v1_destroy(primary->data_offer);