summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2012-01-10 10:24:49 +0100
committerHans de Goede <hdegoede@redhat.com>2012-01-10 13:26:58 +0100
commita1c0042dd602651cbc6ef5d2670f2ad5f46b17f4 (patch)
tree339a8cb9b924f8f5c1ee695548cdb0819bc999ee
parentde2bf74160782810b06f1ebd643f92638f42215b (diff)
Add a --enable-static-uinput option
This makes spice-vdagentd create the tablet uinput device once and then keep it around forever. This is necessary for X-servers without hotplug support, such as the RHEL-5 X-server. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--configure.ac11
-rw-r--r--src/vdagentd-uinput.c16
-rw-r--r--src/vdagentd.c14
3 files changed, 41 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index b18e38d..93070b2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,20 +24,31 @@ AC_ARG_ENABLE([pciaccess],
[enable_pciaccess="$enableval"],
[enable_pciaccess="yes"])
+AC_ARG_ENABLE([static-uinput],
+ [AS_HELP_STRING([--enable-statis-uinput], [Enable use of a fixed, static uinput device for X-servers without hotplug support (default: no)])],
+ [enable_static_uinput="$enableval"],
+ [enable_static_uinput="yes"])
+
PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES(X, [xfixes xrandr xinerama x11])
PKG_CHECK_MODULES(SPICE, [spice-protocol >= 0.8.0])
+
if test x"$enable_console_kit" = "xyes" ; then
PKG_CHECK_MODULES(DBUS, [dbus-1])
AC_DEFINE([HAVE_CONSOLE_KIT], [1], [If defined, vdagentd will be compiled with ConsoleKit support] )
fi
AM_CONDITIONAL(HAVE_CONSOLE_KIT, test x"$enable_console_kit" = "xyes")
+
if test x"$enable_pciaccess" = "xyes" ; then
PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10])
AC_DEFINE([HAVE_PCIACCESS], [1], [If defined, vdagentd will be compiled with pciaccess support] )
fi
AM_CONDITIONAL(HAVE_PCIACCESS, test x"$enable_pciaccess" = "xyes")
+if test x"$enable_static_uinput" = "xyes" ; then
+ AC_DEFINE([WITH_STATIC_UINPUT], [1], [If defined, vdagentd will use a static uinput device] )
+fi
+
AC_CONFIG_FILES([
Makefile
])
diff --git a/src/vdagentd-uinput.c b/src/vdagentd-uinput.c
index d50dfe7..6cfe1c2 100644
--- a/src/vdagentd-uinput.c
+++ b/src/vdagentd-uinput.c
@@ -19,6 +19,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <stdlib.h>
#include <string.h>
@@ -85,8 +88,13 @@ void vdagentd_uinput_update_size(struct vdagentd_uinput **uinputp,
struct vdagentd_uinput *uinput = *uinputp;
struct uinput_user_dev device = {
.name = "spice vdagent tablet",
+#ifdef WITH_STATIC_UINPUT
+ .absmax [ ABS_X ] = 32767,
+ .absmax [ ABS_Y ] = 32767,
+#else
.absmax [ ABS_X ] = width,
.absmax [ ABS_Y ] = height,
+#endif
};
int rc;
@@ -100,7 +108,11 @@ void vdagentd_uinput_update_size(struct vdagentd_uinput **uinputp,
uinput->height = height;
if (uinput->fd != -1)
+#ifndef WITH_STATIC_UINPUT
close(uinput->fd);
+#else
+ return;
+#endif
uinput->fd = open(uinput->devname, O_RDWR);
if (uinput->fd == -1) {
@@ -188,6 +200,10 @@ void vdagentd_uinput_do_mouse(struct vdagentd_uinput **uinputp,
}
mouse->x += uinput->screen_info[mouse->display_id].x;
mouse->y += uinput->screen_info[mouse->display_id].y;
+#ifdef WITH_STATIC_UINPUT
+ mouse->x = mouse->x * 32767 / uinput->width;
+ mouse->y = mouse->y * 32767 / uinput->height;
+#endif
}
if (*uinputp && uinput->last.x != mouse->x) {
diff --git a/src/vdagentd.c b/src/vdagentd.c
index 1193567..8c0588f 100644
--- a/src/vdagentd.c
+++ b/src/vdagentd.c
@@ -437,7 +437,9 @@ static void check_xorg_resolution(void)
send_capabilities(virtio_port, 1);
}
} else {
+#ifndef WITH_STATIC_UINPUT
vdagentd_uinput_destroy(&uinput);
+#endif
if (virtio_port) {
vdagent_virtio_port_flush(&virtio_port);
vdagent_virtio_port_destroy(&virtio_port);
@@ -796,10 +798,22 @@ int main(int argc, char *argv[])
if (do_daemonize)
daemonize();
+#ifdef WITH_STATIC_UINPUT
+ uinput = vdagentd_uinput_create(uinput_device, 1024, 768, NULL, 0,
+ logfile, debug > 1);
+ if (!uinput) {
+ udscs_destroy_server(server);
+ if (logfile != stderr)
+ fclose(logfile);
+ return 1;
+ }
+#endif
+
#ifdef HAVE_CONSOLE_KIT
console_kit = console_kit_create(logfile);
if (!console_kit) {
fprintf(logfile, "Fatal could not connect to console kit\n");
+ vdagentd_uinput_destroy(&uinput);
udscs_destroy_server(server);
if (logfile != stderr)
fclose(logfile);