summaryrefslogtreecommitdiff
path: root/clients
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2011-01-21 16:23:09 -0500
committerKristian Høgsberg <krh@bitplanet.net>2011-01-21 16:26:28 -0500
commit6bccebee2334aae4926cb17f479ce51a2d6a4574 (patch)
tree9ec473a15317933ad3c7e29570abd55d8f155b9c /clients
parent31cce0533faa1032f065d730cab3dd1c4fa31d81 (diff)
terminal: Just send the pty master fd to receive the selection.
LOL!!1
Diffstat (limited to 'clients')
-rw-r--r--clients/terminal.c37
-rw-r--r--clients/window.c11
-rw-r--r--clients/window.h4
3 files changed, 10 insertions, 42 deletions
diff --git a/clients/terminal.c b/clients/terminal.c
index 1b36ba9..9254907 100644
--- a/clients/terminal.c
+++ b/clients/terminal.c
@@ -391,7 +391,6 @@ struct terminal {
cairo_font_extents_t extents;
cairo_scaled_font_t *font_normal, *font_bold;
- uint32_t tag;
struct wl_selection *selection;
struct wl_selection_offer *selection_offer;
uint32_t selection_offer_has_text;
@@ -1978,34 +1977,11 @@ static const struct wl_selection_listener selection_listener = {
selection_listener_cancelled
};
-static gboolean
-selection_io_func(GIOChannel *source, GIOCondition condition, gpointer data)
-{
- struct terminal *terminal = data;
- char buffer[256];
- unsigned int len;
- int fd;
-
- fd = g_io_channel_unix_get_fd(source);
- len = read(fd, buffer, sizeof buffer);
-
- write(terminal->master, buffer, len);
-
- close(fd);
- g_source_remove(terminal->tag);
-
- g_io_channel_unref(source);
-
- return TRUE;
-}
-
static int
handle_bound_key(struct terminal *terminal,
struct input *input, uint32_t sym, uint32_t time)
{
struct wl_shell *shell;
- GIOChannel *channel;
- int fd;
switch (sym) {
case XK_C:
@@ -2019,14 +1995,11 @@ handle_bound_key(struct terminal *terminal,
return 1;
case XK_V:
- if (input_offers_mime_type(input, "text/plain")) {
- fd = input_receive_mime_type(input, "text/plain");
- channel = g_io_channel_unix_new(fd);
- terminal->tag = g_io_add_watch(channel, G_IO_IN,
- selection_io_func,
- terminal);
- }
-
+ /* Just pass the master fd of the pty to receive the
+ * selection. */
+ if (input_offers_mime_type(input, "text/plain"))
+ input_receive_mime_type(input, "text/plain",
+ terminal->master);
return 1;
case XK_X:
/* cut selection; terminal doesn't do cut */
diff --git a/clients/window.c b/clients/window.c
index f598bcd..e2e59d1 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -1323,23 +1323,18 @@ input_offers_mime_type(struct input *input, const char *type)
return 0;
}
-int
-input_receive_mime_type(struct input *input, const char *type)
+void
+input_receive_mime_type(struct input *input, const char *type, int fd)
{
struct selection_offer *offer = input->offer;
- int p[2];
- pipe(p);
/* FIXME: A number of things can go wrong here: the object may
* not be the current selection offer any more (which could
* still work, but the source may have gone away or just
* destroyed its wl_selection) or the offer may not have the
* requested type after all (programmer/client error,
* typically) */
- wl_selection_offer_receive(offer->offer, type, p[1]);
- close(p[1]);
-
- return p[0];
+ wl_selection_offer_receive(offer->offer, type, fd);
}
static void
diff --git a/clients/window.h b/clients/window.h
index 7d6afdc..27811f3 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -232,8 +232,8 @@ input_get_input_device(struct input *input);
int
input_offers_mime_type(struct input *input, const char *type);
-int
-input_receive_mime_type(struct input *input, const char *type);
+void
+input_receive_mime_type(struct input *input, const char *type, int fd);
#endif