Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1 | From b9b2b8d1af283a13cdccea55562cf332de48dcb9 Mon Sep 17 00:00:00 2001 |
| 2 | From: Ross Burton <ross@openedhand.com> |
| 3 | Date: Wed, 28 Mar 2007 16:10:50 +0000 |
| 4 | Subject: [PATCH] Add xev |
| 5 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6 | Upstream-Status: Inappropriate [disable feature] |
| 7 | |
| 8 | --- |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 9 | xev.c | 64 +---------------------------------------------------------- |
| 10 | 1 file changed, 1 insertion(+), 63 deletions(-) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 12 | diff --git a/xev.c b/xev.c |
| 13 | index ea69234..6d5eb30 100644 |
| 14 | --- a/xev.c |
| 15 | +++ b/xev.c |
| 16 | @@ -175,17 +175,6 @@ do_KeyPress(XEvent *eventp) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 17 | nbytes = XLookupString(e, str, 256, &ks, NULL); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 18 | |
| 19 | /* not supposed to call XmbLookupString on a key release event */ |
| 20 | - if (e->type == KeyPress && xic) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 21 | - do { |
| 22 | - nmbbytes = XmbLookupString(xic, e, buf, bsize - 1, &ks, &status); |
| 23 | - buf[nmbbytes] = '\0'; |
| 24 | - |
| 25 | - if (status == XBufferOverflow) { |
| 26 | - bsize = nmbbytes + 1; |
| 27 | - buf = realloc(buf, bsize); |
| 28 | - } |
| 29 | - } while (status == XBufferOverflow); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 30 | - } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 31 | |
| 32 | if (ks == NoSymbol) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 33 | ksname = "NoSymbol"; |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 34 | @@ -220,16 +209,6 @@ do_KeyPress(XEvent *eventp) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | /* not supposed to call XmbLookupString on a key release event */ |
| 38 | - if (e->type == KeyPress && xic) { |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 39 | - output(Indent, "XmbLookupString gives %d bytes: ", nmbbytes); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 40 | - if (nmbbytes > 0) { |
| 41 | - dump(buf, nmbbytes); |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 42 | - output(NewLine, " \"%s\"", buf); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 43 | - } |
| 44 | - else { |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 45 | - output_new_line(); |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 46 | - } |
| 47 | - } |
| 48 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 49 | output(Indent | NewLine, "XFilterEvent returns: %s", |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 50 | XFilterEvent(eventp, e->window) ? "True" : "False"); |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 51 | @@ -1211,7 +1190,7 @@ parse_event_mask(const char *s, long event_masks[]) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 52 | if (s) |
| 53 | return True; |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 54 | } |
| 55 | - } |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 56 | + } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 57 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 58 | if (s != NULL) |
| 59 | fprintf(stderr, "%s: unrecognized event mask '%s'\n", ProgramName, s); |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 60 | @@ -1361,37 +1340,6 @@ main(int argc, char **argv) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 61 | fprintf(stderr, "%s: XSetLocaleModifiers failed\n", ProgramName); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 62 | } |
| 63 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 64 | - xim = XOpenIM(dpy, NULL, NULL, NULL); |
| 65 | - if (xim == NULL) { |
| 66 | - fprintf(stderr, "%s: XOpenIM failed\n", ProgramName); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 67 | - } |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 68 | - |
| 69 | - if (xim) { |
| 70 | - imvalret = XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL); |
| 71 | - if (imvalret != NULL || xim_styles == NULL) { |
| 72 | - fprintf(stderr, "%s: input method doesn't support any styles\n", |
| 73 | - ProgramName); |
| 74 | - } |
| 75 | - |
| 76 | - if (xim_styles) { |
| 77 | - xim_style = 0; |
| 78 | - for (i = 0; i < xim_styles->count_styles; i++) { |
| 79 | - if (xim_styles->supported_styles[i] == |
| 80 | - (XIMPreeditNothing | XIMStatusNothing)) { |
| 81 | - xim_style = xim_styles->supported_styles[i]; |
| 82 | - break; |
| 83 | - } |
| 84 | - } |
| 85 | - |
| 86 | - if (xim_style == 0) { |
| 87 | - fprintf(stderr, |
| 88 | - "%s: input method doesn't support the style we support\n", |
| 89 | - ProgramName); |
| 90 | - } |
| 91 | - XFree(xim_styles); |
| 92 | - } |
| 93 | - } |
| 94 | - |
| 95 | screen = DefaultScreen(dpy); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 96 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 97 | attr.event_mask = event_masks[EVENT_MASK_INDEX_CORE]; |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 98 | @@ -1446,16 +1394,6 @@ main(int argc, char **argv) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 99 | printf("Outer window is 0x%lx, inner window is 0x%lx\n", w, subw); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | - if (xim && xim_style) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 103 | - xic = XCreateIC(xim, |
| 104 | - XNInputStyle, xim_style, |
| 105 | - XNClientWindow, w, XNFocusWindow, w, NULL); |
| 106 | - |
| 107 | - if (xic == NULL) { |
| 108 | - fprintf(stderr, "XCreateIC failed\n"); |
| 109 | - } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 110 | - } |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 111 | - |
| 112 | have_rr = XRRQueryExtension(dpy, &rr_event_base, &rr_error_base); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 113 | if (have_rr) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 114 | int rr_major, rr_minor; |