summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mtouch.c20
1 files 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 @@
21 21
22#include "mtouch.h" 22#include "mtouch.h"
23 23
24static const int use_grab = 1;
25
24int configure_mtouch(struct MTouch *mt, int fd) 26int configure_mtouch(struct MTouch *mt, int fd)
25{ 27{
26 int rc = read_capabilities(&mt->caps, fd); 28 int rc = read_capabilities(&mt->caps, fd);
@@ -32,22 +34,28 @@ int configure_mtouch(struct MTouch *mt, int fd)
32 34
33int open_mtouch(struct MTouch *mt, int fd) 35int open_mtouch(struct MTouch *mt, int fd)
34{ 36{
35 int rc;
36 mtdev_init(&mt->dev, &mt->caps); 37 mtdev_init(&mt->dev, &mt->caps);
37 init_iobuf(&mt->buf); 38 init_iobuf(&mt->buf);
38 init_hwstate(&mt->hs, &mt->caps); 39 init_hwstate(&mt->hs, &mt->caps);
39 init_mtstate(&mt->prev_state); 40 init_mtstate(&mt->prev_state);
40 init_mtstate(&mt->state); 41 init_mtstate(&mt->state);
41 init_memory(&mt->mem); 42 init_memory(&mt->mem);
42 SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)1)); 43 if (use_grab) {
43 return rc; 44 int rc;
45 SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)1));
46 return rc;
47 }
48 return 0;
44} 49}
45 50
46int close_mtouch(struct MTouch *mt, int fd) 51int close_mtouch(struct MTouch *mt, int fd)
47{ 52{
48 int rc; 53 if (use_grab) {
49 SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)0)); 54 int rc;
50 return rc; 55 SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)0));
56 }
57 mtdev_destroy(&mt->dev);
58 return 0;
51} 59}
52 60
53int parse_event(struct MTouch *mt, const struct input_event *ev) 61int parse_event(struct MTouch *mt, const struct input_event *ev)