diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-12-15 07:21:38 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-12-21 12:38:36 +1000 |
commit | bb0af002dc9ad5b464dc6793aedb6d1ff65d001d (patch) | |
tree | a0ff683edcbccd8e5a705ef5696522b50c6ce5a3 | |
parent | 209b3d613a7bed126c81daedbad6461e4391e9e6 (diff) |
Xi: handle grab accept/reject requests
Consists mostly of generating an ownership event and processing it.
Co-authored-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
-rw-r--r-- | Xi/xiallowev.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/Xi/xiallowev.c b/Xi/xiallowev.c index 0d45b3654..a4b2f5782 100644 --- a/Xi/xiallowev.c +++ b/Xi/xiallowev.c @@ -35,6 +35,8 @@ #include "inputstr.h" /* DeviceIntPtr */ #include "windowstr.h" /* window structure */ +#include "mi.h" +#include "eventstr.h" #include <X11/extensions/XI2.h> #include <X11/extensions/XI2proto.h> @@ -49,10 +51,53 @@ SProcXIAllowEvents(ClientPtr client) swaps(&stuff->length); swaps(&stuff->deviceid); swapl(&stuff->time); + /* FIXME swap touchid */ + /* FIXME swap window */ return ProcXIAllowEvents(client); } +static int +AllowTouch(ClientPtr client, DeviceIntPtr dev, int mode, uint32_t touchid, XID *error) +{ + TouchPointInfoPtr ti; + int nev, i; + InternalEvent *events = InitEventList(GetMaximumEventsNum()); + + if (!events) + return BadAlloc; + + if (!dev->touch) + { + *error = dev->id; + return BadDevice; + } + + /* FIXME window is unhandled */ + + ti = TouchFindByClientID(dev, touchid); + if (!ti) + { + *error = touchid; + return BadValue; + } + + /* FIXME: Allow for early accept */ + if (ti->num_listeners == 0 || CLIENT_ID(ti->listeners[0].listener) != client->index) + return BadAccess; + + nev = GetTouchOwnershipEvents(events, dev, ti, mode, ti->listeners[0].listener, 0); + if (nev == 0) + return BadAlloc; + for (i = 0; i < nev; i++) + mieqProcessDeviceEvent(dev, events + i, NULL); + + ProcessInputEvents(); + + FreeEventList(events, GetMaximumEventsNum()); + return Success; +} + int ProcXIAllowEvents(ClientPtr client) { @@ -61,7 +106,7 @@ ProcXIAllowEvents(ClientPtr client) int ret = Success; REQUEST(xXIAllowEventsReq); - REQUEST_SIZE_MATCH(xXIAllowEventsReq); + /* FIXME: check request length, 12 for XI 2.0+, 20 for XI 2.2+ */ ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess); if (ret != Success) @@ -91,6 +136,12 @@ ProcXIAllowEvents(ClientPtr client) if (IsMaster(dev)) AllowSome(client, time, dev, THAWED_BOTH); break; + case XIRejectTouch: + case XIAcceptTouch: + ret = AllowTouch(client, dev, + stuff->mode, stuff->touchid, + &client->errorValue); + break; default: client->errorValue = stuff->mode; ret = BadValue; |