[PATCH] Input: Support for a less exclusive grab.
From: Zephaniah E. Hull
Date: Sat Jun 09 2007 - 05:02:06 EST
EVIOCGRAB is nice and very useful, however over time I've gotten
multiple requests to make it possible for applications to get events
straight from the event device while xf86-input-evdev is getting events
from the same device.
Here is the least invasive patch I could think of, it changes the
behavior of EVIOCGRAB in some cases, specificly behavior is identical if
the argument is 0 or 1, however if the argument is true and != 1, then
it does a 'non exclusive grab', a better name might be handy.
What this does is allow the events to go to everything that's using
evdev to get events, but grabs it from anything else. About as close to
what people want as I can get, and fairly non-invasive.
Signed-off-by: Zephaniah E. Hull <warp@xxxxxxxxxxx>
---
drivers/input/evdev.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index be6b93c..385e856 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -29,6 +29,7 @@ struct evdev {
struct input_handle handle;
wait_queue_head_t wait;
struct evdev_client *grab;
+ int grab_exclusive;
struct list_head client_list;
};
@@ -48,7 +49,7 @@ static void evdev_event(struct input_handle *handle, unsigned int type, unsigned
struct evdev *evdev = handle->private;
struct evdev_client *client;
- if (evdev->grab) {
+ if (evdev->grab && evdev->grab_exclusive) {
client = evdev->grab;
do_gettimeofday(&client->buffer[client->head].time);
@@ -108,6 +109,7 @@ static int evdev_release(struct inode *inode, struct file *file)
if (evdev->grab == client) {
input_release_device(&evdev->handle);
evdev->grab = NULL;
+ evdev->grab_exclusive = 0;
}
evdev_fasync(-1, file, 0);
@@ -493,12 +495,14 @@ static long evdev_ioctl_handler(struct file *file, unsigned int cmd,
if (input_grab_device(&evdev->handle))
return -EBUSY;
evdev->grab = client;
+ evdev->grab_exclusive = ((long) p == 1);
return 0;
} else {
if (evdev->grab != client)
return -EINVAL;
input_release_device(&evdev->handle);
evdev->grab = NULL;
+ evdev->grab_exclusive = 0;
return 0;
}
--
1024D/E65A7801 Zephaniah E. Hull <warp@xxxxxxxxxxx>
92ED 94E4 B1E6 3624 226D 5727 4453 008B E65A 7801
CCs of replies from mailing lists are requested.
It was then I realized how dire my medical situation was. Here I was,
a network admin, unable to leave, and here was someone with a broken
network. And they didn't ask me to fix it. They didn't even try to
casually pry a hint out of me.
-- Ryan Tucker in the SDM.
Attachment:
signature.asc
Description: Digital signature