summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xi/Makefile.am2
-rw-r--r--Xi/extinit.c5
-rw-r--r--Xi/setcptr.c105
-rw-r--r--Xi/setcptr.h39
-rw-r--r--dix/cursor.c1
-rw-r--r--dix/events.c72
-rw-r--r--include/dix.h10
7 files changed, 170 insertions, 64 deletions
diff --git a/Xi/Makefile.am b/Xi/Makefile.am
index e77c8a382..16d0e8d3f 100644
--- a/Xi/Makefile.am
+++ b/Xi/Makefile.am
@@ -76,6 +76,8 @@ libXi_la_SOURCES = \
sendexev.h \
setbmap.c \
setbmap.h \
+ setcptr.c \
+ setcptr.h \
setdval.c \
setdval.h \
setfocus.c \
diff --git a/Xi/extinit.c b/Xi/extinit.c
index 598348e13..ff6e4ac0e 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -110,6 +110,7 @@ SOFTWARE.
#include "sendexev.h"
#include "chgkmap.h"
#include "setbmap.h"
+#include "setcptr.h"
#include "setdval.h"
#include "setfocus.h"
#include "setmmap.h"
@@ -367,6 +368,8 @@ ProcIDispatch(register ClientPtr client)
return (ProcXChangeWindowAccess(client));
else if (stuff->data == X_QueryWindowAccess)
return ProcXQueryWindowAccess(client);
+ else if (stuff->data == X_SetClientPointer)
+ return ProcXSetClientPointer(client);
else {
SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest);
}
@@ -472,6 +475,8 @@ SProcIDispatch(register ClientPtr client)
return (SProcXChangeWindowAccess(client));
else if (stuff->data == X_QueryWindowAccess)
return SProcXQueryWindowAccess(client);
+ else if (stuff->data == X_SetClientPointer)
+ return SProcXSetClientPointer(client);
else {
SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest);
}
diff --git a/Xi/setcptr.c b/Xi/setcptr.c
new file mode 100644
index 000000000..25874f0a5
--- /dev/null
+++ b/Xi/setcptr.c
@@ -0,0 +1,105 @@
+/*
+
+Copyright 2007 Peter Hutterer <peter@cs.unisa.edu.au>
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the author shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the author.
+
+*/
+
+/***********************************************************************
+ *
+ * Request to set the client pointer for the owner of the given window.
+ * All subsequent calls that are ambiguous will choose the client pointer as
+ * default value.
+ */
+
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h> /* for inputstr.h */
+#include <X11/Xproto.h> /* Request macro */
+#include "inputstr.h" /* DeviceIntPtr */
+#include "windowstr.h" /* window structure */
+#include "scrnintstr.h" /* screen structure */
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "extnsionst.h"
+#include "extinit.h" /* LookupDeviceIntRec */
+#include "exevents.h"
+#include "exglobals.h"
+
+#include "setcptr.h"
+
+int
+SProcXSetClientPointer(ClientPtr client)
+{
+ char n;
+
+ REQUEST(xSetClientPointerReq);
+ swaps(&stuff->length, n);
+ REQUEST_SIZE_MATCH(xSetClientPointerReq);
+ return (ProcXSetClientPointer(client));
+}
+
+int
+ProcXSetClientPointer(ClientPtr client)
+{
+ DeviceIntPtr pDev;
+ WindowPtr pWin;
+ int err;
+
+ REQUEST(xSetClientPointerReq);
+ REQUEST_SIZE_MATCH(xSetClientPointerReq);
+
+
+ pDev = LookupDeviceIntRec(stuff->deviceid);
+ if (pDev == NULL || !IsPointerDevice(pDev))
+ {
+ SendErrorToClient(client, IReqCode, X_SetClientPointer, 0,
+ BadDevice);
+ return Success;
+ }
+
+ if (stuff->win != None)
+ {
+ err = dixLookupWindow(&pWin, stuff->win, client, DixReadWriteAccess);
+ if (err != Success)
+ {
+ SendErrorToClient(client, IReqCode, X_SetClientPointer,
+ stuff->win, err);
+ return Success;
+ }
+ }
+
+ if (!SetClientPointer(wClient(pWin), client, pDev))
+ {
+ SendErrorToClient(client, IReqCode, X_SetClientPointer,
+ stuff->win, BadAccess);
+ return Success;
+ }
+ return Success;
+}
diff --git a/Xi/setcptr.h b/Xi/setcptr.h
new file mode 100644
index 000000000..0c24fd4dd
--- /dev/null
+++ b/Xi/setcptr.h
@@ -0,0 +1,39 @@
+/*
+
+Copyright 2007 Peter Hutterer <peter@cs.unisa.edu.au>
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the author shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the author.
+
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifndef SETCPTR_H
+#define SETCPTR_H 1
+
+int SProcXSetClientPointer(ClientPtr /* client */);
+int ProcXSetClientPointer(ClientPtr /* client */);
+
+#endif /* SETCPTR_H */
diff --git a/dix/cursor.c b/dix/cursor.c
index 23a2cc916..e44a5efb0 100644
--- a/dix/cursor.c
+++ b/dix/cursor.c
@@ -131,6 +131,7 @@ FreeCursor(pointer value, XID cid)
}
FreeCursorBits(pCurs->bits);
xfree( pCurs);
+ MPXDBG("freeing memory for cursor\n");
return(Success);
}
diff --git a/dix/events.c b/dix/events.c
index f6d643846..4e77577a8 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1706,12 +1706,6 @@ DeliverEventsToWindow(DeviceIntPtr pDev, register WindowPtr pWin, xEvent
if (filter != CantBeFiltered &&
!((wOtherEventMasks(pWin)|pWin->eventMask) & filter))
return 0;
-
- /* core event? check for grab interference */
- if (!(type & EXTENSION_EVENT_BASE) &&
- IsInterferingGrab(wClient(pWin), pDev, pEvents))
- return 0;
-
if ( (attempt = TryClientEvents(wClient(pWin), pEvents, count,
pWin->eventMask, filter, grab)) )
{
@@ -1740,11 +1734,6 @@ DeliverEventsToWindow(DeviceIntPtr pDev, register WindowPtr pWin, xEvent
other = (InputClients *)wOtherClients(pWin);
for (; other; other = other->next)
{
- /* core event? check for grab interference */
- if (!(type & EXTENSION_EVENT_BASE) &&
- IsInterferingGrab(rClient(other), pDev, pEvents))
- continue;
-
if ( (attempt = TryClientEvents(rClient(other), pEvents, count,
other->mask[mskidx], filter, grab)) )
{
@@ -4861,11 +4850,22 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
}
}
+/*
+ * Set the client pointer for the given client. Second parameter setter could
+ * be used in the future to determine access rights. Unused for now.
+ */
+_X_EXPORT Bool
+SetClientPointer(ClientPtr client, ClientPtr setter, DeviceIntPtr device)
+{
+ client->clientPtr = device;
+ return TRUE;
+}
+
/* PickPointer will pick an appropriate pointer for the given client.
*
* If a client pointer is set, it will pick the client pointer, otherwise the
* first available pointer in the list. If no physical device is attached, it
- * will pick the core pointer.
+ * will pick the core pointer, but will not store it on the client.
*/
_X_EXPORT DeviceIntPtr
PickPointer(ClientPtr client)
@@ -4887,7 +4887,7 @@ PickPointer(ClientPtr client)
if (!it)
{
ErrorF("Picking VCP\n");
- client->clientPtr = inputInfo.pointer;
+ return inputInfo.pointer;
}
}
return client->clientPtr;
@@ -4916,49 +4916,3 @@ PickKeyboard(ClientPtr client)
return inputInfo.keyboard;
}
-/* A client that has one or more core grabs does not get core events from
- * devices it does not have a grab on. Legacy applications behave bad
- * otherwise because they are not used to it and the events interfere.
- * Only applies for core events.
- *
- * Return true if a core event from the device would interfere and should not
- * be delivered.
- */
-Bool
-IsInterferingGrab(ClientPtr client, DeviceIntPtr dev, xEvent* event)
-{
- DeviceIntPtr it = inputInfo.devices;
-
- if (dev->coreGrab.grab && SameClient(dev->coreGrab.grab, client))
- return FALSE;
-
- switch(event->u.u.type)
- {
- case KeyPress:
- case KeyRelease:
- case ButtonPress:
- case ButtonRelease:
- case MotionNotify:
- case EnterNotify:
- case LeaveNotify:
- break;
- default:
- return FALSE;
- }
-
- while(it)
- {
- if (it != dev)
- {
- if (it->coreGrab.grab && SameClient(it->coreGrab.grab, client))
- {
- return TRUE;
-
- }
- }
- it = it->next;
- }
-
- return FALSE;
-}
-
diff --git a/include/dix.h b/include/dix.h
index 56d2f1712..06dafbb70 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -603,17 +603,17 @@ extern int TryClientEvents(
extern void WindowsRestructured(void);
+extern Bool SetClientPointer(
+ ClientPtr /* client */,
+ ClientPtr /* setter */,
+ DeviceIntPtr /* device */);
+
extern DeviceIntPtr PickPointer(
ClientPtr /* client */);
extern DeviceIntPtr PickKeyboard(
ClientPtr /* client */);
-extern Bool IsInterferingGrab(
- ClientPtr /* client */,
- DeviceIntPtr /* dev */,
- xEvent* /* events */);
-
#ifdef PANORAMIX
extern void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff);
#endif