LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Zephaniah E. Hull" <warp@aehallh.com>
To: Dmitry Torokhov <dtor@insightbb.com>
Cc: linux-input@atrey.karlin.mff.cuni.cz, linux-kernel@vger.kernel.org
Subject: [PATCH] Input: Support for a less exclusive grab.
Date: Sat, 9 Jun 2007 04:48:01 -0400	[thread overview]
Message-ID: <20070609084800.GR6362@aehallh.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2683 bytes --]

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@aehallh.com>

---
 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@aehallh.com>
	   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 #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

             reply	other threads:[~2007-06-09  9:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-09  8:48 Zephaniah E. Hull [this message]
2007-06-12  5:07 ` Dmitry Torokhov
2007-06-12  5:12   ` Zephaniah E. Hull
2007-06-12  5:19     ` Dmitry Torokhov
2007-06-12  5:23       ` Zephaniah E. Hull
2007-06-12  5:35         ` Dmitry Torokhov
2007-06-12  5:40           ` Zephaniah E. Hull
2007-07-02 15:20             ` Vojtech Pavlik
2007-07-03 16:45               ` Zephaniah E. Hull
2007-07-03 22:15                 ` Vojtech Pavlik
2007-09-29  3:05                 ` Ryan Lortie
2007-10-23 13:21                   ` Dmitry Torokhov
2007-10-23 15:57                     ` Ryan Lortie
2007-10-23 18:10                       ` Dmitry Torokhov
2007-10-24  1:58                         ` Ryan Lortie
2007-10-24  3:33                           ` Dmitry Torokhov
2007-10-24 15:35                             ` Zephaniah E. Hull
2007-10-25  5:37                               ` Ryan Lortie
2007-10-26 16:44                                 ` Zephaniah E. Hull
2007-10-26 17:16                                   ` Ryan Lortie
2007-10-26 17:58                                     ` Zephaniah E. Hull
2007-10-26 17:29                                   ` Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070609084800.GR6362@aehallh.com \
    --to=warp@aehallh.com \
    --cc=dtor@insightbb.com \
    --cc=linux-input@atrey.karlin.mff.cuni.cz \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH] Input: Support for a less exclusive grab.' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).