summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2012-06-25 22:36:23 (GMT)
committerSung-Jin Park <sj76.park@samsung.com>2013-09-03 03:32:31 (GMT)
commitdbcf0699fa27c6966029939fc18490edfcf5eaff (patch)
tree5fb50aafdf89172eb32833409e5fb5836aeb22b7
parent6b29a729cdf90bd19afb94a9551c9274e334c718 (diff)
downloadxev-dbcf0699fa27c6966029939fc18490edfcf5eaff.zip
xev-dbcf0699fa27c6966029939fc18490edfcf5eaff.tar.gz
xev-dbcf0699fa27c6966029939fc18490edfcf5eaff.tar.bz2
Add a -event parameter to control the event maskrefs/changes/07/9207/1
It's annoying to have to sift through a lot of unrelated events if all you care about is one specific class of events (e.g. RandR events). Add a -event parameter that can be used to tune which events to select. When not specified, all events are selected. Change-Id: I36b0b36cc532d5e512d7469abd43a936afccbef5 Signed-off-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Andy Ritger <aritger@nvidia.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--man/xev.man9
-rw-r--r--xev.c112
2 files changed, 103 insertions, 18 deletions
diff --git a/man/xev.man b/man/xev.man
index d13f022..ca38d56 100644
--- a/man/xev.man
+++ b/man/xev.man
@@ -52,6 +52,15 @@ This option specifies the name to assign to the created window.
.TP 8
.B \-rv
This option specifies that the window should be in reverse video.
+.TP 8
+.B \-event \fIevent_mask\fP
+Select which events to display.
+The
+.B \-event
+option can be specified multiple times to select multiple types of events.
+When not specified, all events are selected.
+Available event masks: keyboard mouse expose visibility structure substructure
+focus property colormap owner_grab_button randr
.SH "SEE ALSO"
X(__miscmansuffix__), xwininfo(__appmansuffix__), xdpyinfo(__appmansuffix__), Xlib Programmers Manual, X Protocol
Specification
diff --git a/xev.c b/xev.c
index 9f9111a..b130b2f 100644
--- a/xev.c
+++ b/xev.c
@@ -75,6 +75,12 @@ Atom wm_protocols;
Bool have_rr;
int rr_event_base, rr_error_base;
+enum EventMaskIndex {
+ EVENT_MASK_INDEX_CORE,
+ EVENT_MASK_INDEX_RANDR,
+ NUM_EVENT_MASKS
+};
+
static void usage (void) _X_NORETURN;
static void
@@ -878,6 +884,12 @@ usage (void)
" -s set save-unders attribute",
" -name string window name",
" -rv reverse video",
+" -event event_mask select 'event_mask' events",
+" Supported event masks: keyboard mouse expose visibility structure",
+" substructure focus property colormap",
+" owner_grab_button randr",
+" This option can be specified multiple times to select multiple",
+" event masks.",
"",
NULL};
const char **cpp;
@@ -909,6 +921,66 @@ parse_backing_store (char *s)
usage ();
}
+static Bool
+parse_event_mask (const char *s, long event_masks[])
+{
+ const struct {
+ const char *name;
+ enum EventMaskIndex mask_index;
+ long mask;
+ } events[] = {
+ { "keyboard",
+ EVENT_MASK_INDEX_CORE,
+ KeyPressMask | KeyReleaseMask | KeymapStateMask },
+ { "mouse",
+ EVENT_MASK_INDEX_CORE,
+ ButtonPressMask | ButtonReleaseMask | EnterWindowMask |
+ LeaveWindowMask | PointerMotionMask | Button1MotionMask |
+ Button2MotionMask | Button3MotionMask | Button4MotionMask |
+ Button5MotionMask | ButtonMotionMask },
+ { "expose",
+ EVENT_MASK_INDEX_CORE,
+ ExposureMask },
+ { "visibility",
+ EVENT_MASK_INDEX_CORE,
+ VisibilityChangeMask },
+ { "structure",
+ EVENT_MASK_INDEX_CORE,
+ StructureNotifyMask },
+ { "substructure",
+ EVENT_MASK_INDEX_CORE,
+ SubstructureNotifyMask | SubstructureRedirectMask },
+ { "focus",
+ EVENT_MASK_INDEX_CORE,
+ FocusChangeMask },
+ { "property",
+ EVENT_MASK_INDEX_CORE,
+ PropertyChangeMask },
+ { "colormap",
+ EVENT_MASK_INDEX_CORE,
+ ColormapChangeMask },
+ { "owner_grab_button",
+ EVENT_MASK_INDEX_CORE,
+ OwnerGrabButtonMask },
+ { "randr",
+ EVENT_MASK_INDEX_RANDR,
+ RRScreenChangeNotifyMask | RRCrtcChangeNotifyMask |
+ RROutputChangeNotifyMask | RROutputPropertyNotifyMask },
+ { NULL, 0, 0 }
+ };
+ int i;
+
+ for (i = 0; events[i].name; i++) {
+ if (!s || !strcmp(s, events[i].name)) {
+ event_masks[events[i].mask_index] |= events[i].mask;
+ if (s)
+ return True;
+ }
+ }
+
+ return False;
+}
+
int
main (int argc, char **argv)
{
@@ -931,6 +1003,8 @@ main (int argc, char **argv)
XIMStyle xim_style = 0;
char *modifiers;
char *imvalret;
+ long event_masks[NUM_EVENT_MASKS];
+ Bool event_mask_specified = False;
ProgramName = argv[0];
@@ -939,6 +1013,8 @@ main (int argc, char **argv)
ProgramName);
}
+ memset(event_masks, 0, sizeof(event_masks));
+
w = 0;
for (i = 1; i < argc; i++) {
char *arg = argv[i];
@@ -995,6 +1071,12 @@ main (int argc, char **argv)
attr.save_under = True;
mask |= CWSaveUnder;
continue;
+ case 'e': /* -event */
+ if (++i >= argc) usage ();
+ if (!parse_event_mask (argv[i], event_masks))
+ usage ();
+ event_mask_specified = True;
+ continue;
default:
usage ();
} /* end switch on - */
@@ -1002,6 +1084,10 @@ main (int argc, char **argv)
usage ();
} /* end for over argc */
+ /* if no -event options were specified, pretend all of them were */
+ if (!event_mask_specified)
+ parse_event_mask (NULL, event_masks);
+
dpy = XOpenDisplay (displayname);
if (!dpy) {
fprintf (stderr, "%s: unable to open display '%s'\n",
@@ -1046,19 +1132,7 @@ main (int argc, char **argv)
screen = DefaultScreen (dpy);
- /* select for all events */
- attr.event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask |
- ButtonReleaseMask | EnterWindowMask |
- LeaveWindowMask | PointerMotionMask |
- Button1MotionMask |
- Button2MotionMask | Button3MotionMask |
- Button4MotionMask | Button5MotionMask |
- ButtonMotionMask | KeymapStateMask |
- ExposureMask | VisibilityChangeMask |
- StructureNotifyMask | /* ResizeRedirectMask | */
- SubstructureNotifyMask | SubstructureRedirectMask |
- FocusChangeMask | PropertyChangeMask |
- ColormapChangeMask | OwnerGrabButtonMask;
+ attr.event_mask = event_masks[EVENT_MASK_INDEX_CORE];
if (use_root)
w = RootWindow(dpy, screen);
@@ -1126,12 +1200,14 @@ main (int argc, char **argv)
int rr_major, rr_minor;
if (XRRQueryVersion (dpy, &rr_major, &rr_minor)) {
- int rr_mask = RRScreenChangeNotifyMask;
+ int rr_mask = event_masks[EVENT_MASK_INDEX_RANDR];
+
+ if (rr_major == 1 && rr_minor <= 1) {
+ rr_mask &= ~(RRCrtcChangeNotifyMask |
+ RROutputChangeNotifyMask |
+ RROutputPropertyNotifyMask);
+ }
- if (rr_major > 1
- || (rr_major == 1 && rr_minor >= 2))
- rr_mask |= RRCrtcChangeNotifyMask | RROutputChangeNotifyMask |
- RROutputPropertyNotifyMask;
XRRSelectInput (dpy, w, rr_mask);
}
}