From 74109dec517245ec9215454226792d72ae0912b0 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Tue, 15 Jun 2010 22:07:31 +0200 Subject: Control grabbing by parameter Add a parameter to control whether the underlying device should be grabbed or not. Default to yes. Signed-off-by: Henrik Rydberg --- src/mtouch.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/mtouch.c b/src/mtouch.c index 959783a..db75b6f 100644 --- a/src/mtouch.c +++ b/src/mtouch.c @@ -21,6 +21,8 @@ #include "mtouch.h" +static const int use_grab = 1; + int configure_mtouch(struct MTouch *mt, int fd) { int rc = read_capabilities(&mt->caps, fd); @@ -32,22 +34,28 @@ int configure_mtouch(struct MTouch *mt, int fd) int open_mtouch(struct MTouch *mt, int fd) { - int rc; mtdev_init(&mt->dev, &mt->caps); init_iobuf(&mt->buf); init_hwstate(&mt->hs, &mt->caps); init_mtstate(&mt->prev_state); init_mtstate(&mt->state); init_memory(&mt->mem); - SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)1)); - return rc; + if (use_grab) { + int rc; + SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)1)); + return rc; + } + return 0; } int close_mtouch(struct MTouch *mt, int fd) { - int rc; - SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)0)); - return rc; + if (use_grab) { + int rc; + SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)0)); + } + mtdev_destroy(&mt->dev); + return 0; } int parse_event(struct MTouch *mt, const struct input_event *ev) -- cgit v1.2.3