summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@google.com>2015-11-03 03:51:48 -0800
committerPeter Hutterer <peter.hutterer@who-t.net>2015-11-10 15:12:21 +1000
commita6cddb8c04ddc3c48aae3f3611ad9f336fecb09d (patch)
tree67a5935d78ed74064f985133985c9691a7c56176
parentf2ceb683c2da1ec08c8e07d7ec146f14864f2386 (diff)
Also dump passive grabs on XF86LogGrabInfo
Signed-off-by: Michael Stapelberg <stapelberg@google.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--dix/window.c126
-rw-r--r--hw/xfree86/dixmods/xkbPrivate.c2
-rw-r--r--include/window.h1
3 files changed, 129 insertions, 0 deletions
diff --git a/dix/window.c b/dix/window.c
index 69b5a7cf5..25d29ecd4 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -127,6 +127,7 @@ Equipment Corporation.
#include "compint.h"
#endif
#include "selection.h"
+#include "inpututils.h"
#include "privates.h"
#include "xace.h"
@@ -272,6 +273,131 @@ log_window_info(WindowPtr pWin, int depth)
ErrorF("\n");
}
+static const char*
+grab_grabtype_to_text(GrabPtr pGrab)
+{
+ switch (pGrab->grabtype) {
+ case XI2:
+ return "xi2";
+ case CORE:
+ return "core";
+ default:
+ return "xi1";
+ }
+}
+
+static const char*
+grab_type_to_text(GrabPtr pGrab)
+{
+ switch (pGrab->type) {
+ case ButtonPress:
+ return "ButtonPress";
+ case KeyPress:
+ return "KeyPress";
+ case XI_Enter:
+ return "XI_Enter";
+ case XI_FocusIn:
+ return "XI_FocusIn";
+ default:
+ return "unknown?!";
+ }
+}
+
+static void
+log_grab_info(void *value, XID id, void *cdata)
+{
+ int i, j;
+ GrabPtr pGrab = (GrabPtr)value;
+
+ ErrorF(" grab 0x%lx (%s), type '%s' on window 0x%lx\n",
+ (unsigned long) pGrab->resource,
+ grab_grabtype_to_text(pGrab),
+ grab_type_to_text(pGrab),
+ (unsigned long) pGrab->window->drawable.id);
+ ErrorF(" detail %d (mask %lu), modifiersDetail %d (mask %lu)\n",
+ pGrab->detail.exact,
+ pGrab->detail.pMask ? (unsigned long) *(pGrab->detail.pMask) : 0,
+ pGrab->modifiersDetail.exact,
+ pGrab->modifiersDetail.pMask ?
+ (unsigned long) *(pGrab->modifiersDetail.pMask) :
+ (unsigned long) 0);
+ ErrorF(" device '%s' (%d), modifierDevice '%s' (%d)\n",
+ pGrab->device->name, pGrab->device->id,
+ pGrab->modifierDevice->name, pGrab->modifierDevice->id);
+ if (pGrab->grabtype == CORE) {
+ ErrorF(" core event mask 0x%lx\n",
+ (unsigned long) pGrab->eventMask);
+ }
+ else if (pGrab->grabtype == XI) {
+ ErrorF(" xi1 event mask 0x%lx\n",
+ (unsigned long) pGrab->eventMask);
+ }
+ else if (pGrab->grabtype == XI2) {
+ for (i = 0; i < xi2mask_num_masks(pGrab->xi2mask); i++) {
+ const unsigned char *mask;
+ int print;
+
+ print = 0;
+ for (j = 0; j < XI2MASKSIZE; j++) {
+ mask = xi2mask_get_one_mask(pGrab->xi2mask, i);
+ if (mask[j]) {
+ print = 1;
+ break;
+ }
+ }
+ if (!print)
+ continue;
+ ErrorF(" xi2 event mask 0x");
+ for (j = 0; j < xi2mask_mask_size(pGrab->xi2mask); j++)
+ ErrorF("%x ", mask[j]);
+ ErrorF("\n");
+ }
+ }
+ ErrorF(" owner-events %s, kb %d ptr %d, confine 0x%lx, cursor 0x%lx\n",
+ pGrab->ownerEvents ? "true" : "false",
+ pGrab->keyboardMode, pGrab->pointerMode,
+ pGrab->confineTo ? (unsigned long) pGrab->confineTo->drawable.id : 0,
+ pGrab->cursor ? (unsigned long) pGrab->cursor->id : 0);
+}
+
+void
+PrintPassiveGrabs(void)
+{
+ int i;
+ LocalClientCredRec *lcc;
+ pid_t clientpid;
+ const char *cmdname;
+ const char *cmdargs;
+
+ ErrorF("Printing all currently registered grabs\n");
+
+ for (i = 1; i < currentMaxClients; i++) {
+ if (!clients[i] || clients[i]->clientState != ClientStateRunning)
+ continue;
+
+ clientpid = GetClientPid(clients[i]);
+ cmdname = GetClientCmdName(clients[i]);
+ cmdargs = GetClientCmdArgs(clients[i]);
+ if ((clientpid > 0) && (cmdname != NULL)) {
+ ErrorF(" Printing all registered grabs of client pid %ld %s %s\n",
+ (long) clientpid, cmdname, cmdargs ? cmdargs : "");
+ } else {
+ if (GetLocalClientCreds(clients[i], &lcc) == -1) {
+ ErrorF(" GetLocalClientCreds() failed\n");
+ continue;
+ }
+ ErrorF(" Printing all registered grabs of client pid %ld uid %ld gid %ld\n",
+ (lcc->fieldsSet & LCC_PID_SET) ? (long) lcc->pid : 0,
+ (lcc->fieldsSet & LCC_UID_SET) ? (long) lcc->euid : 0,
+ (lcc->fieldsSet & LCC_GID_SET) ? (long) lcc->egid : 0);
+ FreeLocalClientCreds(lcc);
+ }
+
+ FindClientResourcesByType(clients[i], RT_PASSIVEGRAB, log_grab_info, NULL);
+ }
+ ErrorF("End list of registered passive grabs\n");
+}
+
void
PrintWindowTree(void)
{
diff --git a/hw/xfree86/dixmods/xkbPrivate.c b/hw/xfree86/dixmods/xkbPrivate.c
index 574590f28..4b9ef3397 100644
--- a/hw/xfree86/dixmods/xkbPrivate.c
+++ b/hw/xfree86/dixmods/xkbPrivate.c
@@ -38,6 +38,8 @@ XkbDDXPrivate(DeviceIntPtr dev, KeyCode key, XkbAction *act)
if (tmp->deviceGrab.grab)
PrintDeviceGrabInfo(tmp);
xf86Msg(X_INFO, "End list of active device grabs\n");
+
+ PrintPassiveGrabs();
}
else if (strcasecmp(msgbuf, "ungrab") == 0)
UngrabAllDevices(FALSE);
diff --git a/include/window.h b/include/window.h
index 6daec8599..f13ed5115 100644
--- a/include/window.h
+++ b/include/window.h
@@ -223,6 +223,7 @@ extern _X_EXPORT RegionPtr CreateClipShape(WindowPtr /* pWin */ );
extern _X_EXPORT void SetRootClip(ScreenPtr pScreen, Bool enable);
extern _X_EXPORT void PrintWindowTree(void);
+extern _X_EXPORT void PrintPassiveGrabs(void);
extern _X_EXPORT VisualPtr WindowGetVisual(WindowPtr /*pWin*/);
#endif /* WINDOW_H */