Commit 6fa56701 authored by Jeremy White's avatar Jeremy White

Only watch the uinput channel when an agent is connected.

Otherwise, you constantly spin loop, getting a return code of 0,
and pegging CPU usage at 100%.
parent 6e588d2a
......@@ -20,6 +20,7 @@
static const char *uinput_filename;
static int uinput_fd;
static SpiceWatch *uinput_watch;
static struct input_event inp_event;
static int offset;
......@@ -121,6 +122,17 @@ void spiceqxl_uinput_init(qxl_screen_t *qxl)
uinput_filename, strerror(errno));
return;
}
qxl->core->watch_add(uinput_fd, SPICE_WATCH_EVENT_READ, spiceqxl_uinput_read_cb, qxl);
spice_server_set_agent_mouse(qxl->spice_server, 1);
}
void spiceqxl_uinput_watch(qxl_screen_t *qxl, Bool on)
{
if (uinput_watch) {
qxl->core->watch_remove(uinput_watch);
uinput_watch = NULL;
}
if (on)
uinput_watch = qxl->core->watch_add(uinput_fd, SPICE_WATCH_EVENT_READ,
spiceqxl_uinput_read_cb, qxl);
}
......@@ -4,5 +4,6 @@
#include "qxl.h"
void spiceqxl_uinput_init(qxl_screen_t *qxl);
void spiceqxl_uinput_watch(qxl_screen_t *qxl, Bool on);
#endif
......@@ -62,6 +62,7 @@ static int vmc_read(SpiceCharDeviceInstance *sin, uint8_t *buf, int len)
vdagent_sin.qxl->core->watch_remove(virtio_client_watch);
virtio_client_watch = NULL;
spice_server_remove_interface(&vdagent_sin.base.base);
spiceqxl_uinput_watch(vdagent_sin.qxl, FALSE);
}
return nbytes;
}
......@@ -123,6 +124,7 @@ static void on_accept(int fd, int event, void *opaque)
/* TODO - SPICE_WATCH_EVENT_WRITE */, on_read_available, qxl);
spice_server_add_interface(qxl->spice_server, &vdagent_sin.base.base);
spiceqxl_uinput_watch(qxl, TRUE);
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment