To: xbugs@expo.lcs.mit.edu xpert@expo.lcs.mit.edu Subject: xev: additional code for selection or omission of particular events VERSION: R5, public-patch-13 CLIENT MACHINE and OPERATING SYSTEM: DISPLAY TYPE: WINDOW MANAGER: COMPILER: AREA: mit/demos/xev SYNOPSIS: diffs permitting use of xev to select or filter out particular events DESCRIPTION: I often use xev to check for particular events but don't need all the output the tool puts out and want to select for only particular events (e.g. xev -focus -crossing); or I need to check for most events but am not interested in a particular set which I want to have ignored (e.g. xev -omit -keyboard -pointer). REPEAT BY: SAMPLE FIX: Here's the set of changes that I'm using: Bugs: - one of my goals was adding as little code as possible; there are doubtless better ways to specify the events wanted to be selected or filtered out (e.g. -omit keyboard pointer, etc.) - the set of events which can be selected as "categories" isn't complete David B. Lewis Yet another new address!: david%craft@uunet.uu.net "This is a war of engines and octanes. I drink to the American auto industry and the American oil industry." -- Joseph Stalin, sometime during WWII. *** xev.c.orig Sat May 4 23:15:19 1991 --- xev.c Mon Jul 27 05:45:02 1992 *************** *** 61,66 **** --- 61,71 ---- " -s set save-unders attribute", " -name string window name", " -rv reverse video", + " -keyboard select keyboard events", + " -pointer select pointer events", + " -focus select input focus events", + " -crossing select window crossing events", + " -omit omit rather than use selected events", "", NULL}; char **cpp; *************** *** 109,114 **** --- 114,121 ---- char *name = "Event Tester"; Bool reverse = False; unsigned long back, fore; + long selectedMask = 0L; + Bool omitFlag = False; w = 0; ProgramName = argv[0]; *************** *** 158,163 **** --- 165,190 ---- attr.save_under = True; mask |= CWSaveUnder; continue; + /* selection for specific event categories follows */ + case 'k': /* -keyboard */ + selectedMask |= KeyPressMask | KeyReleaseMask; + continue; + case 'p': /* -pointer */ + selectedMask |= ButtonPressMask | ButtonReleaseMask | + PointerMotionMask | ButtonMotionMask | + Button1MotionMask | + Button2MotionMask | Button3MotionMask | + Button4MotionMask | Button5MotionMask; + continue; + case 'f': /* -focus */ + selectedMask |= FocusChangeMask; + continue; + case 'c': /* -crossing */ + selectedMask |= EnterWindowMask | LeaveWindowMask; + continue; + case 'o': /* -omit */ + omitFlag = True; + continue; default: usage (); } /* end switch on - */ *************** *** 187,192 **** --- 214,228 ---- SubstructureNotifyMask | SubstructureRedirectMask | FocusChangeMask | PropertyChangeMask | ColormapChangeMask | OwnerGrabButtonMask; + + if (0L != selectedMask) + { + if (omitFlag) + attr.event_mask &= ~selectedMask; + else + /* use just the reduced set */ + attr.event_mask = selectedMask; + } if (w) { XGetWindowAttributes(dpy, w, &wattr); *** xev.man.orig Sat Jul 27 18:26:57 1991 --- xev.man Sun Jul 26 14:41:46 1992 *************** *** 6,11 **** --- 6,12 ---- [\-display \fIdisplayname\fP] [\-geometry \fIgeom\fP] [\-bw \fIpixels\fP] [\-bs \fI{NotUseful,WhenMapped,Always}\fP] [\-id \fIwindowid\fP] [\-s] [\-name \fIstring\fP] [\-rv] + [[\-keyboard] [\-pointer] [\-focus] [\-crossing] [-omit]] .SH DESCRIPTION .PP \fIXev\fP creates a window and then asks the X server to send it *************** *** 13,18 **** --- 14,21 ---- resized, typed in, clicked in, etc.). You can also attach it to an existing window. It is useful for seeing what causes events to occur and to display the information that they contain. + You can also select for one or more specific event categories or choose to + have events in those categories ignored. .SH OPTIONS .TP 8 .B \-display \fIdisplay\fP *************** *** 40,45 **** --- 43,66 ---- .TP 8 .B \-rv This option specifies that the window should be in reverse video. + .TP 8 + .B \-keyboard + Rather than select for all events, add keyboard events to the selection set. + .TP 8 + .B \-pointer + Rather than select for all events, add pointer and motion events to + the selection set. + .TP 8 + .B \-focus + Rather than select for all events, add input focus events to the selection set. + .TP 8 + .B \-crossing + Rather than select for all events, add window crossing events to the + selection set. + .TP 8 + .B \-omit + Rather than select for the categories explicitly added to the selected set, + instead strip them out from the set of all events. .SH "SEE ALSO" X(1), xwininfo(1), xdpyinfo(1), Xlib Programmers Manual, X Protocol Specification