changeset: 2138:9addd4c171b4
user: Kris Maglione <jg_AT_suckless.org>
date: Thu May 24 17:23:36 2007 -0400
summary: Explicitly prototype (void) functions.
diff -r 27c0bf99dd16 -r 9addd4c171b4 DISTRIBUTERS
--- a/DISTRIBUTERS Thu May 24 16:49:45 2007 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-The following conditions apply to any distribution which
-uses the name wmii. These conditions apply only to wmii
-name, and not to its source code or any other materials.
-
-When in doubt about any of these conditions or other matters
-of packaging or distrobution, , please contact the wmii
-mailing lists <wmii-hackers_AT_suckless.org> or
-<wmii_AT_suckless.org>, or Kris Maglione <fbsdaemon_AT_gmail.com>.
-
-Any binary distribution of wmii MUST have a properly set
-version string. This string may normally be set in
-'mk/wmii.mk', and is set automatically to the Mercurial
-revision number for builds from a Mercurial tree, so long as
-the 'hg' command is present and properly functioning.
-
-Any version which not an official release or snapshot MUST
-be contain the hg revision number in its version string.
-This SHOULD be formated as hgXXXX, where XXXX is the decimal
-revision number.
-
-The version string of any snapshot release MUST contain the
-date of the snapshot in the form YYYYMMDD, and SHOULD
-contain the word snap or snapshot. The version string of a
-snapshot MAY contain the version of a full release that the
-snapshot is expected to lead to, but it MUST be either
-directly preceded, or directly followed by, the word 'pre',
-optionally separated by a non-alphanumeric character,
-including -~_,./, the version.
-
-Any binary distribution which is modified in any non-trivial
-way MUST signify the modifications in its name or version
-string. This includes patches to use Xft for font display,
-but does NOT include minor patches to improve consistency
-with the rest of the system, including changing the default
-terminal emulator or changing any build flags as set in
-config.mk.
-
-Source form distribution MAY include non-trivial patches
-without such modifications, provided that the user is made
-clearly aware of them at build time and/or prompted in some
-way to enable or disable them.
-
diff -r 27c0bf99dd16 -r 9addd4c171b4 cmd/wmii/area.c
--- a/cmd/wmii/area.c Thu May 24 16:49:45 2007 -0400
+++ b/cmd/wmii/area.c Thu May 24 17:23:36 2007 -0400
@@ -246,11 +246,11 @@ detach_from_area(Frame *f) {
static void
bit_set(uint *field, uint width, uint x, uint y, Bool set) {
- enum { devisor = sizeof(uint) * 8 };
+ enum { divisor = sizeof(uint) * 8 };
uint bx, mask;
- bx = x / devisor;
- mask = 1 << x % devisor;
+ bx = x / divisor;
+ mask = 1 << x % divisor;
if(set)
field[y*width + bx] |= mask;
else
@@ -259,18 +259,18 @@ bit_set(uint *field, uint width, uint x,
static Bool
bit_get(uint *field, uint width, uint x, uint y) {
- enum { devisor = sizeof(uint) * 8 };
+ enum { divisor = sizeof(uint) * 8 };
uint bx, mask;
- bx = x / devisor;
- mask = 1 << x % devisor;
+ bx = x / divisor;
+ mask = 1 << x % divisor;
return (field[y*width + bx] & mask) != 0;
}
static void
place_frame(Frame *f) {
- enum { devisor = sizeof(uint) * 8 };
+ enum { divisor = sizeof(uint) * 8 };
enum { dx = 8, dy = 8 };
static uint mwidth, mx, my;
@@ -301,7 +301,7 @@ place_frame(Frame *f) {
if(!field) {
mx = Dx(screen->r) / dx;
my = Dy(screen->r) / dy;
- mwidth = ceil((float)mx / devisor);
+ mwidth = ceil((float)mx / divisor);
field = emallocz(sizeof(uint) * mwidth * my);
}
diff -r 27c0bf99dd16 -r 9addd4c171b4 cmd/wmii/client.c
--- a/cmd/wmii/client.c Thu May 24 16:49:45 2007 -0400
+++ b/cmd/wmii/client.c Thu May 24 17:23:36 2007 -0400
@@ -2,6 +2,7 @@
* Copyright ©2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
* See LICENSE file for license details.
*/
+#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -9,6 +10,8 @@
#include <util.h>
#include "dat.h"
#include "fns.h"
+
+#define Mbsearch(k, l, cmp) bsearch(k, l, nelem(l), sizeof(*l), cmp)
static Handlers handlers;
@@ -186,7 +189,7 @@ destroy_client(Client *c) {
/* Convenience functions */
Client *
-selclient() {
+selclient(void) {
if(screen->sel->sel->sel)
return screen->sel->sel->sel->client;
return nil;
@@ -325,7 +328,7 @@ focus_client(Client *c) {
Debug fprintf(stderr, "focus_client(%p[%x]) => %s\n", c, clientwin(c), clientname(c));
- if(screen->focus != c) {
+ if((c == nil || !c->noinput) && screen->focus != c) {
Debug fprintf(stderr, "\t%s => %s\n", clientname(screen->focus), clientname(c));
if(c)
@@ -566,6 +569,7 @@ prop_client(Client *c, Atom a) {
case XA_WM_HINTS:
wmh = XGetWMHints(display, c->w.w);
if(wmh) {
+ c->noinput = !((wmh->flags&InputFocus) && wmh->input);
set_urgent(c, (wmh->flags & XUrgencyHint) != 0, False);
XFree(wmh);
}
@@ -798,9 +802,20 @@ update_client_views(Client *c, char **ta
}
static int
-compare_tags(const void *a, const void *b) {
+bsstrcmp(const void *a, const void *b) {
+ return strcmp((char*)a, (char*)b);
+}
+
+static int
+strpcmp(const void *a, const void *b) {
return strcmp(*(char **)a, *(char **)b);
}
+
+static char *badtags[] = {
+ ".",
+ "..",
+ "sel",
+};
void
apply_tags(Client *c, const char *tags) {
@@ -810,8 +825,10 @@ apply_tags(Client *c, const char *tags)
char *toks[32], *cur;
buf[0] = 0;
+
for(n = 0; tags[n]; n++)
- if(tags[n] != ' ' && tags[n] != '\t') break;
+ if(!isspace(tags[n]))
+ break;
if(tags[n] == '+' || tags[n] == '-')
strncpy(buf, c->tags, sizeof(c->tags));
@@ -820,7 +837,6 @@ apply_tags(Client *c, const char *tags)
trim(buf, " \t/");
n = 0;
- j = 0;
add = True;
if(buf[0] == '+')
n++;
@@ -828,6 +844,8 @@ apply_tags(Client *c, const char *tags)
n++;
add = False;
}
+
+ j = 0;
while(buf[n] && n < sizeof(buf) && j < 32) {
for(i = n; i < sizeof(buf) - 1; i++)
if(buf[i] == '+' || buf[i] == '-' || buf[i] == '\0')
@@ -836,14 +854,12 @@ apply_tags(Client *c, const char *tags)
buf[i] = '\0';
cur = nil;
- if(!strncmp(&buf[n], "~", 2))
+ if(!strcmp(buf+n, "~"))
c->floating = add;
- else if(!strncmp(&buf[n], "!", 2))
- cur = view ? screen->sel->name : "nil";
- else if(strcmp(&buf[n], "sel")
- && strcmp(&buf[n], ".")
- && strcmp(&buf[n], ".."))
- cur = &buf[n];
+ else if(!strcmp(buf+n, "!"))
+ cur = screen->sel->name;
+ else if(!Mbsearch(buf+n, badtags, bsstrcmp))
+ cur = buf+n;
n = i + 1;
if(cur) {
@@ -870,14 +886,15 @@ apply_tags(Client *c, const char *tags)
}
}
- c->tags[0] = '\0';
if(!j)
return;
- qsort(toks, j, sizeof(char *), compare_tags);
-
+
+ qsort(toks, j, sizeof(char *), strpcmp);
+
+ c->tags[0] = '\0';
for(i=0, n=0; i < j; i++)
- if(!n || strcmp(toks[i], toks[n-1])) {
- if(i)
+ if(n == 0 || strcmp(toks[i], toks[n-1])) {
+ if(i > 0)
strlcat(c->tags, "+", sizeof(c->tags));
strlcat(c->tags, toks[i], sizeof(c->tags));
toks[n++] = toks[i];
@@ -893,16 +910,17 @@ apply_rules(Client *c) {
apply_rules(Client *c) {
Rule *r;
regmatch_t rm;
-
+
if(strlen(c->tags))
return;
+
if(def.tagrules.string)
for(r=def.tagrules.rule; r; r=r->next)
if(!regexec(&r->regex, c->props, 1, &rm, 0)) {
apply_tags(c, r->value);
- if(strlen(c->tags) && strcmp(c->tags, "nil"))
+ if(strcmp(c->tags, "nil"))
break;
}
- if(!strlen(c->tags))
+ if(c->tags[0] == '\0')
apply_tags(c, "nil");
}
diff -r 27c0bf99dd16 -r 9addd4c171b4 cmd/wmii/column.c
--- a/cmd/wmii/column.c Thu May 24 16:49:45 2007 -0400
+++ b/cmd/wmii/column.c Thu May 24 17:23:36 2007 -0400
@@ -104,7 +104,7 @@ drawdiv(Divide *d) {
}
void
-update_imgs() {
+update_imgs(void) {
Divide *d;
int w, h;
@@ -133,7 +133,7 @@ update_imgs() {
}
void
-update_divs() {
+update_divs(void) {
Divide **dp, *d;
Area *a;
View *v;
diff -r 27c0bf99dd16 -r 9addd4c171b4 cmd/wmii/dat.h
--- a/cmd/wmii/dat.h Thu May 24 16:49:45 2007 -0400
+++ b/cmd/wmii/dat.h Thu May 24 17:23:36 2007 -0400
@@ -131,6 +131,7 @@ struct Client {
Bool urgent;
Bool borderless;
Bool titleless;
+ Bool noinput;
int unmapped;
Window w;
XWindow trans;
diff -r 27c0bf99dd16 -r 9addd4c171b4 cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Thu May 24 16:49:45 2007 -0400
+++ b/cmd/wmii/fns.h Thu May 24 17:23:36 2007 -0400
@@ -17,7 +17,7 @@ Bar *create_bar(Bar **b_link, char *name
Bar *create_bar(Bar **b_link, char *name);
void destroy_bar(Bar **b_link, Bar*);
void draw_bar(WMScreen *s);
-void resize_bar();
+void resize_bar(WMScreen *s);
Bar *bar_of_name(Bar *b_link, const char *name);
/* client.c */
@@ -43,7 +43,7 @@ void apply_sizehints(Client*, Rectangle*
void apply_sizehints(Client*, Rectangle*, Bool floating, Bool frame, Align sticky);
void move_client(Client*, char *arg);
void size_client(Client*, char *arg);
-Client *selclient();
+Client *selclient(void);
Client *win2client(XWindow);
uint clientwin(Client *c);
char *clientname(Client*);
@@ -51,7 +51,7 @@ void apply_tags(Client*, const char*);
void apply_tags(Client*, const char*);
/* column.c */
-void update_divs();
+void update_divs(void);
void draw_div(Divide*);
void setdiv(Divide*, int x);
void arrange_column(Area*, Bool dirty);
@@ -74,13 +74,13 @@ Bool frame_to_top(Frame *f);
Bool frame_to_top(Frame *f);
void set_frame_cursor(Frame*, Point);
void swap_frames(Frame*, Frame*);
-int frame_delta_h();
+int frame_delta_h(void);
Rectangle frame_hints(Frame*, Rectangle, Align);
Rectangle frame2client(Frame*, Rectangle);
Rectangle client2frame(Frame*, Rectangle);
int ingrabbox(Frame*, int x, int y);
void draw_frame(Frame*);
-void draw_frames();
+void draw_frames(void);
void update_frame_widget_colors(Frame*);
Rectangle constrain(Rectangle);
@@ -106,8 +106,8 @@ Align get_sticky(Rectangle src, Rectangl
/* key.c */
void kpress(XWindow, ulong mod, KeyCode);
-void update_keys();
-void init_lock_keys();
+void update_keys(void);
+void init_lock_keys(void);
ulong str2modmask(char*);
/* map.c */
@@ -122,7 +122,7 @@ char * message_view(View*, Message*);
char * message_view(View*, Message*);
char * parse_colors(Message*, CTuple*);
char * message_root(void*, Message*);
-char * read_root_ctl();
+char * read_root_ctl(void);
char * message_client(Client*, Message*);
char *select_area(Area*, Message*);
char *send_client(View*, Message*, Bool swap);
@@ -156,7 +156,7 @@ void restack_view(View*);
void restack_view(View*);
uchar *view_index(View*);
void destroy_view(View*);
-void update_views();
+void update_views(void);
uint newcolw(View*, int i);
/* wm.c */
@@ -172,7 +172,7 @@ Rectangle insetrect(Rectangle, int);
Rectangle insetrect(Rectangle, int);
Rectangle rectaddpt(Rectangle, Point);
Rectangle rectsubpt(Rectangle, Point);
-void initdisplay();
+void initdisplay(void);
Image * allocimage(int w, int h, int depth);
void freeimage(Image *);
Window *createwindow(Window *parent, Rectangle, int depth, uint class, WinAttr*, int valuemask);
@@ -214,7 +214,7 @@ void warppointer(Point);
void warppointer(Point);
Point translate(Window*, Window*, Point);
int grabpointer(Window*, Window *confine, Cursor, int mask);
-void ungrabpointer();
+void ungrabpointer(void);
Rectangle gravitate(Rectangle dst, Rectangle src, Point grav);
Rectangle sizehint(WinHints*, Rectangle);
void sethints(Window*);
diff -r 27c0bf99dd16 -r 9addd4c171b4 cmd/wmii/frame.c
--- a/cmd/wmii/frame.c Thu May 24 16:49:45 2007 -0400
+++ b/cmd/wmii/frame.c Thu May 24 17:23:36 2007 -0400
@@ -285,9 +285,9 @@ resize_frame(Frame *f, Rectangle r) {
}
pt = ZP;
- if(!f->client->borderless)
+ if(!f->client->borderless || !f->area->floating)
pt.y += 1;
- if(!f->client->titleless)
+ if(!f->client->titleless || !f->area->floating)
pt.y += labelh(def.font) - 1;
if(f->area->floating) {
@@ -324,7 +324,7 @@ swap_frames(Frame *fa, Frame *fb) {
Client *c;
if(fa == fb) return;
-
+
for(fp = &fa->client->frame; *fp; fp = &(*fp)->cnext)
if(*fp == fa) break;
*fp = (*fp)->cnext;
@@ -378,7 +378,7 @@ focus_frame(Frame *f, Bool restack) {
}
int
-frame_delta_h() {
+frame_delta_h(void) {
return def.border + labelh(def.font);
}
@@ -438,7 +438,7 @@ draw_frame(Frame *f) {
}
void
-draw_frames() {
+draw_frames(void) {
Client *c;
for(c=client; c; c=c->next)
diff -r 27c0bf99dd16 -r 9addd4c171b4 cmd/wmii/fs.c
--- a/cmd/wmii/fs.c Thu May 24 16:49:45 2007 -0400
+++ b/cmd/wmii/fs.c Thu May 24 17:23:36 2007 -0400
@@ -135,7 +135,7 @@ static Dirtab *dirtab[] = {
/* Utility Functions */
static FileId *
-get_file() {
+get_file(void) {
FileId *temp;
if(!free_fileid) {
uint i = 15;
diff -r 27c0bf99dd16 -r 9addd4c171b4 cmd/wmii/geom.c
--- a/cmd/wmii/geom.c Thu May 24 16:49:45 2007 -0400
+++ b/cmd/wmii/geom.c Thu May 24 17:23:36 2007 -0400
@@ -1,4 +1,4 @@
-/* Copyright ©2004-2006 Anselm R. Garbe <garbeam at gmail dot com>
+/* Copyright ©2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
* See LICENSE file for license details.
*/
#include <stdio.h>
diff -r 27c0bf99dd16 -r 9addd4c171b4 cmd/wmii/key.c
--- a/cmd/wmii/key.c Thu May 24 16:49:45 2007 -0400
+++ b/cmd/wmii/key.c Thu May 24 17:23:36 2007 -0400
@@ -9,7 +9,7 @@
#include "fns.h"
void
-init_lock_keys() {
+init_lock_keys(void) {
XModifierKeymap *modmap;
KeyCode num_lock;
static int masks[] = {
@@ -213,7 +213,7 @@ kpress(XWindow w, ulong mod, KeyCode key
}
void
-update_keys() {
+update_keys(void) {
Key *k, *n;
char *l, *p;
diff -r 27c0bf99dd16 -r 9addd4c171b4 cmd/wmii/main.c
--- a/cmd/wmii/main.c Thu May 24 16:49:45 2007 -0400
+++ b/cmd/wmii/main.c Thu May 24 17:23:36 2007 -0400
@@ -29,12 +29,12 @@ static int sleeperfd, sock, exitsignal;
static int sleeperfd, sock, exitsignal;
static void
-usage() {
+usage(void) {
fatal("usage: wmii [-a <address>] [-r <wmiirc>] [-v]\n");
}
static void
-scan_wins() {
+scan_wins(void) {
int i;
uint num;
XWindow *wins;
@@ -63,7 +63,7 @@ scan_wins() {
}
static char*
-ns_display() {
+ns_display(void) {
char *s, *disp;
disp = getenv("DISPLAY");
@@ -102,7 +102,7 @@ rmkdir(char *path, int mode) {
}
static void
-init_ns() {
+init_ns(void) {
struct stat st;
char *s;
@@ -131,7 +131,7 @@ init_ns() {
}
static void
-init_environment() {
+init_environment(void) {
init_ns();
if(address == nil) {
@@ -144,7 +144,7 @@ init_environment() {
}
static void
-init_atoms() {
+init_atoms(void) {
Atom net[] = { xatom("_NET_SUPPORTED"), xatom("_NET_WM_NAME") };
changeprop(&scr.root, "_NET_SUPPORTED", "ATOM", net, nelem(net));
@@ -156,7 +156,7 @@ create_cursor(int ident, uint shape) {
}
static void
-init_cursors() {
+init_cursors(void) {
Pixmap pix;
XColor black, dummy;
@@ -218,7 +218,7 @@ init_screen(WMScreen *screen) {
}
static void
-cleanup() {
+cleanup(void) {
while(client)
destroy_client(client);
ixp_server_close(&srv);
@@ -282,7 +282,7 @@ cleanup_handler(int signal) {
}
static void
-init_traps() {
+init_traps(void) {
char buf[1];
int fd[2];
diff -r 27c0bf99dd16 -r 9addd4c171b4 cmd/wmii/message.c
--- a/cmd/wmii/message.c Thu May 24 16:49:45 2007 -0400
+++ b/cmd/wmii/message.c Thu May 24 17:23:36 2007 -0400
@@ -324,7 +324,7 @@ message_root(void *p, Message *m) {
}
char *
-read_root_ctl() {
+read_root_ctl(void) {
uint i = 0;
i += snprintf(&buffer[i], (sizeof(buffer) - i), "view %s\n", screen->sel->name);
i += snprintf(&buffer[i], (sizeof(buffer) - i), "focuscolors %s\n", def.focuscolor.colstr);
diff -r 27c0bf99dd16 -r 9addd4c171b4 cmd/wmii/mouse.c
--- a/cmd/wmii/mouse.c Thu May 24 16:49:45 2007 -0400
+++ b/cmd/wmii/mouse.c Thu May 24 17:23:36 2007 -0400
@@ -245,7 +245,7 @@ do_managed_move(Client *c) {
pt2.x = f->area->r.min.x;
pt2.y = pt.y;
fw = framewin(f, pt2, OHoriz, Dx(f->area->r));
-
+
r = screen->r;
r.min.y += fw->gb.min.y + Dy(fw->gb)/2;
r.max.y = r.min.y + 1;
@@ -415,7 +415,7 @@ mouse_resizecolframe(Frame *f, Align ali
}
}
if(align&WEST) {
- if(a->prev) {
+ if(a->prev != v->area) {
r.min.x = a->prev->r.min.x + min.x;
r.max.x = a->r.max.x - min.x;
}else {
@@ -446,7 +446,7 @@ mouse_resizecolframe(Frame *f, Align ali
if(!grabpointer(&scr.root, cwin, cursor[CurSizing], MouseMask))
goto done;
-
+
pt.x = ((align&WEST) ? f->r.min.x : f->r.max.x);
pt.y = ((align&NORTH) ? f->r.min.y : f->r.max.y);
warppointer(pt);
diff -r 27c0bf99dd16 -r 9addd4c171b4 cmd/wmii/printevent.c
--- a/cmd/wmii/printevent.c Thu May 24 16:49:45 2007 -0400
+++ b/cmd/wmii/printevent.c Thu May 24 17:23:36 2007 -0400
@@ -1,49 +1,47 @@
/*
* Original code posted to comp.sources.x
* Modifications by Russ Cox <rsc_AT_swtch.com>.
+ * Further modifications by Kris Maglione <fbsdaemon_AT_gmail.com>
*/
/*
-Path: uunet!wyse!mikew
-From: mikew_AT_wyse.wyse.com (Mike Wexler)
-Newsgroups: comp.sources.x
-Subject: v02i056: subroutine to print events in human readable form, Part01/01
-Message-ID: <1935_AT_wyse.wyse.com>
-Date: 22 Dec 88 19:28:25 GMT
-Organization: Wyse Technology, San Jose
-Lines: 1093
-Approved: mikew_AT_wyse.com
-
-Submitted-by: richsun!darkstar!ken
-Posting-number: Volume 2, Issue 56
-Archive-name: showevent/part01
-
-
-There are times during debugging when it would be real useful to be able to
-print the fields of an event in a human readable form. Too many times I found
-myself scrounging around in section 8 of the Xlib manual looking for the valid
-fields for the events I wanted to see, then adding printf's to display the
-numeric values of the fields, and then scanning through X.h trying to decode
-the cryptic detail and state fields. After playing with xev, I decided to
-write a couple of standard functions that I could keep in a library and call
-on whenever I needed a little debugging verbosity. The first function,
-GetType(), is useful for returning the string representation of the type of
-an event. The second function, ShowEvent(), is used to display all the fields
-of an event in a readable format. The functions are not complicated, in fact,
-they are mind-numbingly boring - but that's just the point nobody wants to
-spend the time writing functions like this, they just want to have them when
-they need them.
-
-A simple, sample program is included which does little else but to demonstrate
-the use of these two functions. These functions have saved me many an hour
-during debugging and I hope you find some benefit to these. If you have any
-comments, suggestions, improvements, or if you find any blithering errors you
-can get it touch with me at the following location:
-
- ken_AT_richsun.UUCP
-*/
-
+ * Path: uunet!wyse!mikew From: mikew_AT_wyse.wyse.com (Mike Wexler) Newsgroups:
+ * comp.sources.x Subject: v02i056: subroutine to print events in human
+ * readable form, Part01/01 Message-ID: <1935_AT_wyse.wyse.com> Date: 22 Dec 88
+ * 19:28:25 GMT Organization: Wyse Technology, San Jose Lines: 1093 Approved:
+ * mikew_AT_wyse.com
+ *
+ * Submitted-by: richsun!darkstar!ken Posting-number: Volume 2, Issue 56
+ * Archive-name: showevent/part01
+ *
+ *
+ * There are times during debugging when it would be real useful to be able to
+ * print the fields of an event in a human readable form. Too many times I
+ * found myself scrounging around in section 8 of the Xlib manual looking for
+ * the valid fields for the events I wanted to see, then adding printf's to
+ * display the numeric values of the fields, and then scanning through X.h
+ * trying to decode the cryptic detail and state fields. After playing with
+ * xev, I decided to write a couple of standard functions that I could keep
+ * in a library and call on whenever I needed a little debugging verbosity.
+ * The first function, GetType(), is useful for returning the string
+ * representation of the type of an event. The second function, ShowEvent(),
+ * is used to display all the fields of an event in a readable format. The
+ * functions are not complicated, in fact, they are mind-numbingly boring -
+ * but that's just the point nobody wants to spend the time writing functions
+ * like this, they just want to have them when they need them.
+ *
+ * A simple, sample program is included which does little else but to
+ * demonstrate the use of these two functions. These functions have saved me
+ * many an hour during debugging and I hope you find some benefit to these.
+ * If you have any comments, suggestions, improvements, or if you find any
+ * blithering errors you can get it touch with me at the following location:
+ *
+ * ken_AT_richsun.UUCP
+ */
+
+#include <stdarg.h>
#include <stdio.h>
+#include <stdlib.h>
#include <X11/Intrinsic.h>
#include <X11/Xproto.h>
#include <util.h>
@@ -51,413 +49,511 @@ can get it touch with me at the followin
//#include "fns.h"
#include "printevent.h"
+#define nil ((void*)0)
+
+typedef struct Pair Pair;
+
+struct Pair {
+ int key;
+ char *val;
+};
+
static char* sep = " ";
+
+char *
+search(Pair *lst, int key, char *(*def)(int)) {
+ for(; lst->val; lst++)
+ if(lst->key == key)
+ return lst->val;
+ return def(key);
+}
+
+static char buffer[512];
+
+char *
+unmask(Pair * list, uint val)
+{
+ Pair *p;
+ char *s, *end;
+ Boolean first = True;
+
+ buffer[0] = '\0';
+ end = buffer + sizeof buffer;
+ s = buffer;
+
+ s += strlcat(s, "(", end - s);
+
+ for (p = list; p->val; p++)
+ if (val & p->key) {
+ if (!first)
+ s += strlcat(s, "|", end - s);
+ first = False;
+ s += strlcat(s, p->val, end - s);
+ }
+
+ s += strlcat(s, ")", end - s);
+
+ return buffer;
+}
+
+static char *
+strhex(int key) {
+ sprintf(buffer, "0x%x", key);
+ return buffer;
+}
+
+static char *
+strdec(int key) {
+ sprintf(buffer, "%d", key);
+ return buffer;
+}
+
+static char *
+strign(int key) {
+ return "?";
+}
/******************************************************************************/
/**** Miscellaneous routines to convert values to their string equivalents ****/
/******************************************************************************/
+static char *
+Self(char *str)
+{
+ strncpy(buffer, str, sizeof buffer);
+ free(str);
+ return buffer;
+}
+
+/* Returns the string equivalent of a timestamp */
+static char *
+ServerTime(Time time)
+{
+ ulong msec;
+ ulong sec;
+ ulong min;
+ ulong hr;
+ ulong day;
+
+ msec = time % 1000;
+ time /= 1000;
+ sec = time % 60;
+ time /= 60;
+ min = time % 60;
+ time /= 60;
+ hr = time % 24;
+ time /= 24;
+ day = time;
+
+ if (0)
+ sprintf(buffer, "%lu day%s %02lu:%02lu:%02lu.%03lu",
+ day, day == 1 ? "" : "(s)", hr, min, sec, msec);
+
+ sprintf(buffer, "%lud%luh%lum%lu.%03lds", day, hr, min, sec, msec);
+ return buffer;
+}
+
/* Returns the string equivalent of a boolean parameter */
-static char*
-TorF(int bool)
-{
- switch (bool) {
- case True:
- return ("True");
-
- case False:
- return ("False");
-
- default:
- return ("?");
- }
+static char *
+TorF(int key)
+{
+ static Pair list[] = {
+ {True, "True"},
+ {False, "False"},
+ {0, nil},
+ };
+
+ return search(list, key, strign);
}
/* Returns the string equivalent of a property notify state */
-static char*
-PropertyState(int state)
-{
- switch (state) {
- case PropertyNewValue:
- return ("PropertyNewValue");
-
- case PropertyDelete:
- return ("PropertyDelete");
-
- default:
- return ("?");
- }
+static char *
+PropertyState(int key)
+{
+ static Pair list[] = {
+ {PropertyNewValue, "PropertyNewValue"},
+ {PropertyDelete, "PropertyDelete"},
+ {0, nil},
+ };
+
+ return search(list, key, strign);
}
/* Returns the string equivalent of a visibility notify state */
-static char*
-VisibilityState(int state)
-{
- switch (state) {
- case VisibilityUnobscured:
- return ("VisibilityUnobscured");
-
- case VisibilityPartiallyObscured:
- return ("VisibilityPartiallyObscured");
-
- case VisibilityFullyObscured:
- return ("VisibilityFullyObscured");
-
- default:
- return ("?");
- }
-}
-
-/* Returns the string equivalent of a timestamp */
-static char*
-ServerTime(Time time)
-{
- ulong msec;
- ulong sec;
- ulong min;
- ulong hr;
- ulong day;
- static char buffer[32];
-
- msec = time % 1000;
- time /= 1000;
- sec = time % 60;
- time /= 60;
- min = time % 60;
- time /= 60;
- hr = time % 24;
- time /= 24;
- day = time;
-
-if(0)
- sprintf(buffer, "%lu day%s %02lu:%02lu:%02lu.%03lu",
- day, day == 1 ? "" : "(s)", hr, min, sec, msec);
-
- sprintf(buffer, "%lud%luh%lum%lu.%03lds", day, hr, min, sec, msec);
- return (buffer);
-}
-
-/* Simple structure to ease the interpretation of masks */
-typedef struct MaskType MaskType;
-struct MaskType
-{
- uint value;
- char *string;
-};
+static char *
+VisibilityState(int key)
+{
+ static Pair list[] = {
+ {VisibilityUnobscured, "VisibilityUnobscured"},
+ {VisibilityPartiallyObscured, "VisibilityPartiallyObscured"},
+ {VisibilityFullyObscured, "VisibilityFullyObscured"},
+ {0, nil},
+ };
+
+ return search(list, key, strign);
+}
/* Returns the string equivalent of a mask of buttons and/or modifier keys */
-static char*
+static char *
ButtonAndOrModifierState(uint state)
{
- static char buffer[256];
- static MaskType masks[] = {
- {Button1Mask, "Button1Mask"},
- {Button2Mask, "Button2Mask"},
- {Button3Mask, "Button3Mask"},
- {Button4Mask, "Button4Mask"},
- {Button5Mask, "Button5Mask"},
- {ShiftMask, "ShiftMask"},
- {LockMask, "LockMask"},
- {ControlMask, "ControlMask"},
- {Mod1Mask, "Mod1Mask"},
- {Mod2Mask, "Mod2Mask"},
- {Mod3Mask, "Mod3Mask"},
- {Mod4Mask, "Mod4Mask"},
- {Mod5Mask, "Mod5Mask"},
- };
- int num_masks = sizeof(masks) / sizeof(MaskType);
- int i;
- Boolean first = True;
-
- buffer[0] = 0;
-
- for (i = 0; i < num_masks; i++)
- if (state & masks[i].value) {
- if (first) {
- first = False;
- strcpy(buffer, masks[i].string);
- } else {
- strcat(buffer, " | ");
- strcat(buffer, masks[i].string);
- }
- }
- return (buffer);
+ static Pair list[] = {
+ {Button1Mask, "Button1Mask"},
+ {Button2Mask, "Button2Mask"},
+ {Button3Mask, "Button3Mask"},
+ {Button4Mask, "Button4Mask"},
+ {Button5Mask, "Button5Mask"},
+ {ShiftMask, "ShiftMask"},
+ {LockMask, "LockMask"},
+ {ControlMask, "ControlMask"},
+ {Mod1Mask, "Mod1Mask"},
+ {Mod2Mask, "Mod2Mask"},
+ {Mod3Mask, "Mod3Mask"},
+ {Mod4Mask, "Mod4Mask"},
+ {Mod5Mask, "Mod5Mask"},
+ {0, nil},
+ };
+
+ return unmask(list, state);
}
/* Returns the string equivalent of a mask of configure window values */
-static char*
+static char *
ConfigureValueMask(uint valuemask)
{
- static char buffer[256];
- static MaskType masks[] = {
- {CWX, "CWX"},
- {CWY, "CWY"},
- {CWWidth, "CWWidth"},
- {CWHeight, "CWHeight"},
- {CWBorderWidth, "CWBorderWidth"},
- {CWSibling, "CWSibling"},
- {CWStackMode, "CWStackMode"},
- };
- int num_masks = sizeof(masks) / sizeof(MaskType);
- int i;
- Boolean first = True;
-
- buffer[0] = 0;
-
- for (i = 0; i < num_masks; i++)
- if (valuemask & masks[i].value) {
- if (first) {
- first = False;
- strcpy(buffer, masks[i].string);
- } else {
- strcat(buffer, " | ");
- strcat(buffer, masks[i].string);
- }
- }
-
- return (buffer);
+ static Pair list[] = {
+ {CWX, "CWX"},
+ {CWY, "CWY"},
+ {CWWidth, "CWWidth"},
+ {CWHeight, "CWHeight"},
+ {CWBorderWidth, "CWBorderWidth"},
+ {CWSibling, "CWSibling"},
+ {CWStackMode, "CWStackMode"},
+ {0, nil},
+ };
+
+ return unmask(list, valuemask);
}
/* Returns the string equivalent of a motion hint */
-static char*
-IsHint(char is_hint)
-{
- switch (is_hint) {
- case NotifyNormal:
- return ("NotifyNormal");
-
- case NotifyHint:
- return ("NotifyHint");
-
- default:
- return ("?");
- }
-}
+#if 0
+static char *
+IsHint(char key)
+{
+ static Pair list[] = {
+ {NotifyNormal, "NotifyNormal"},
+ {NotifyHint, "NotifyHint"},
+ {0, nil},
+ };
+
+ return search(list, key, strign);
+}
+#endif
/* Returns the string equivalent of an id or the value "None" */
-static char*
-MaybeNone(int value)
-{
- static char buffer[16];
-
- if (value == None)
- return ("None");
- else {
- sprintf(buffer, "0x%x", value);
- return (buffer);
- }
+static char *
+MaybeNone(int key)
+{
+ static Pair list[] = {
+ {None, "None"},
+ {0, nil},
+ };
+
+ return search(list, key, strhex);
}
/* Returns the string equivalent of a colormap state */
-static char*
-ColormapState(int state)
-{
- switch (state) {
- case ColormapInstalled:
- return ("ColormapInstalled");
-
- case ColormapUninstalled:
- return ("ColormapUninstalled");
-
- default:
- return ("?");
- }
+static char *
+ColormapState(int key)
+{
+ static Pair list[] = {
+ {ColormapInstalled, "ColormapInstalled"},
+ {ColormapUninstalled, "ColormapUninstalled"},
+ {0, nil},
+ };
+
+ return search(list, key, strign);
}
/* Returns the string equivalent of a crossing detail */
-static char*
-CrossingDetail(int detail)
-{
- switch (detail) {
- case NotifyAncestor:
- return ("NotifyAncestor");
-
- case NotifyInferior:
- return ("NotifyInferior");
-
- case NotifyVirtual:
- return ("NotifyVirtual");
-
- case NotifyNonlinear:
- return ("NotifyNonlinear");
-
- case NotifyNonlinearVirtual:
- return ("NotifyNonlinearVirtual");
-
- default:
- return ("?");
- }
+static char *
+CrossingDetail(int key)
+{
+ static Pair list[] = {
+ {NotifyAncestor, "NotifyAncestor"},
+ {NotifyInferior, "NotifyInferior"},
+ {NotifyVirtual, "NotifyVirtual"},
+ {NotifyNonlinear, "NotifyNonlinear"},
+ {NotifyNonlinearVirtual, "NotifyNonlinearVirtual"},
+ {0, nil},
+ };
+
+ return search(list, key, strign);
}
/* Returns the string equivalent of a focus change detail */
-static char*
-FocusChangeDetail(int detail)
-{
- switch (detail) {
- case NotifyAncestor:
- return ("NotifyAncestor");
-
- case NotifyInferior:
- return ("NotifyInferior");
-
- case NotifyVirtual:
- return ("NotifyVirtual");
-
- case NotifyNonlinear:
- return ("NotifyNonlinear");
-
- case NotifyNonlinearVirtual:
- return ("NotifyNonlinearVirtual");
-
- case NotifyPointer:
- return ("NotifyPointer");
-
- case NotifyPointerRoot:
- return ("NotifyPointerRoot");
-
- case NotifyDetailNone:
- return ("NotifyDetailNone");
-
- default:
- return ("?");
- }
+static char *
+FocusChangeDetail(int key)
+{
+ static Pair list[] = {
+ {NotifyAncestor, "NotifyAncestor"},
+ {NotifyInferior, "NotifyInferior"},
+ {NotifyVirtual, "NotifyVirtual"},
+ {NotifyNonlinear, "NotifyNonlinear"},
+ {NotifyNonlinearVirtual, "NotifyNonlinearVirtual"},
+ {NotifyPointer, "NotifyPointer"},
+ {NotifyPointerRoot, "NotifyPointerRoot"},
+ {NotifyDetailNone, "NotifyDetailNone"},
+ {0, nil},
+ };
+
+ return search(list, key, strign);
}
/* Returns the string equivalent of a configure detail */
-static char*
-ConfigureDetail(int detail)
-{
- switch (detail) {
- case Above:
- return ("Above");
-
- case Below:
- return ("Below");
-
- case TopIf:
- return ("TopIf");
-
- case BottomIf:
- return ("BottomIf");
-
- case Opposite:
- return ("Opposite");
-
- default:
- return ("?");
- }
+static char *
+ConfigureDetail(int key)
+{
+ static Pair list[] = {
+ {Above, "Above"},
+ {Below, "Below"},
+ {TopIf, "TopIf"},
+ {BottomIf, "BottomIf"},
+ {Opposite, "Opposite"},
+ {0, nil},
+ };
+
+ return search(list, key, strign);
}
/* Returns the string equivalent of a grab mode */
-static char*
-GrabMode(int mode)
-{
- switch (mode) {
- case NotifyNormal:
- return ("NotifyNormal");
-
- case NotifyGrab:
- return ("NotifyGrab");
-
- case NotifyUngrab:
- return ("NotifyUngrab");
-
- case NotifyWhileGrabbed:
- return ("NotifyWhileGrabbed");
-
- default:
- return ("?");
- }
+static char *
+GrabMode(int key)
+{
+ static Pair list[] = {
+ {NotifyNormal, "NotifyNormal"},
+ {NotifyGrab, "NotifyGrab"},
+ {NotifyUngrab, "NotifyUngrab"},
+ {NotifyWhileGrabbed, "NotifyWhileGrabbed"},
+ {0, nil},
+ };
+
+ return search(list, key, strign);
}
/* Returns the string equivalent of a mapping request */
-static char*
-MappingRequest(int request)
-{
- switch (request) {
- case MappingModifier:
- return ("MappingModifier");
-
- case MappingKeyboard:
- return ("MappingKeyboard");
-
- case MappingPointer:
- return ("MappingPointer");
-
- default:
- return ("?");
- }
+static char *
+MappingRequest(int key)
+{
+ static Pair list[] = {
+ {MappingModifier, "MappingModifier"},
+ {MappingKeyboard, "MappingKeyboard"},
+ {MappingPointer, "MappingPointer"},
+ {0, nil},
+ };
+
+ return search(list, key, strign);
}
/* Returns the string equivalent of a stacking order place */
-static char*
-Place(int place)
-{
- switch (place) {
- case PlaceOnTop:
- return ("PlaceOnTop");
-
- case PlaceOnBottom:
- return ("PlaceOnBottom");
-
- default:
- return ("?");
- }
+static char *
+Place(int key)
+{
+ static Pair list[] = {
+ {PlaceOnTop, "PlaceOnTop"},
+ {PlaceOnBottom, "PlaceOnBottom"},
+ {0, nil},
+ };
+
+ return search(list, key, strign);
}
/* Returns the string equivalent of a major code */
-static char*
-MajorCode(int code)
-{
- static char buffer[32];
-
- switch (code) {
- case X_CopyArea:
- return ("X_CopyArea");
-
- case X_CopyPlane:
- return ("X_CopyPlane");
-
- default:
- sprintf(buffer, "0x%x", code);
- return (buffer);
- }
-}
-
+static char *
+MajorCode(int key)
+{
+ static Pair list[] = {
+ {X_CopyArea, "X_CopyArea"},
+ {X_CopyPlane, "X_CopyPlane"},
+ {0, nil},
+ };
+
+ return search(list, key, strhex);
+}
+
+static char *
+eventtype(int key)
+{
+ static Pair list[] = {
+ {ButtonPress, "ButtonPress"},
+ {ButtonRelease, "ButtonRelease"},
+ {CirculateNotify, "CirculateNotify"},
+ {CirculateRequest, "CirculateRequest"},
+ {ClientMessage, "ClientMessage"},
+ {ColormapNotify, "ColormapNotify"},
+ {ConfigureNotify, "ConfigureNotify"},
+ {ConfigureRequest, "ConfigureRequest"},
+ {CreateNotify, "CreateNotify"},
+ {DestroyNotify, "DestroyNotify"},
+ {EnterNotify, "EnterNotify"},
+ {Expose, "Expose"},
+ {FocusIn, "FocusIn"},
+ {FocusOut, "FocusOut"},
+ {GraphicsExpose, "GraphicsExpose"},
+ {GravityNotify, "GravityNotify"},
+ {KeyPress, "KeyPress"},
+ {KeyRelease, "KeyRelease"},
+ {KeymapNotify, "KeymapNotify"},
+ {LeaveNotify, "LeaveNotify"},
+ {MapNotify, "MapNotify"},
+ {MapRequest, "MapRequest"},
+ {MappingNotify, "MappingNotify"},
+ {MotionNotify, "MotionNotify"},
+ {NoExpose, "NoExpose"},
+ {PropertyNotify, "PropertyNotify"},
+ {ReparentNotify, "ReparentNotify"},
+ {ResizeRequest, "ResizeRequest"},
+ {SelectionClear, "SelectionClear"},
+ {SelectionNotify, "SelectionNotify"},
+ {SelectionRequest, "SelectionRequest"},
+ {UnmapNotify, "UnmapNotify"},
+ {VisibilityNotify, "VisibilityNotify"},
+ {0, nil},
+ };
+
+ return search(list, key, strdec);
+}
/* Returns the string equivalent the keycode contained in the key event */
static char*
-Keycode(XKeyEvent *ev)
-{
- static char buffer[256];
- KeySym keysym_str;
- char *keysym_name;
- char string[256];
-
- XLookupString(ev, string, 64, &keysym_str, NULL);
-
- if (keysym_str == NoSymbol)
- keysym_name = "NoSymbol";
- else if (!(keysym_name = XKeysymToString(keysym_str)))
- keysym_name = "(no name)";
- sprintf(buffer, "%u (keysym 0x%x \"%s\")",
- (int)ev->keycode, (int)keysym_str, keysym_name);
- return (buffer);
-}
-
-/* Returns the string equivalent of an atom or "None"*/
-static char*
-AtomName(Display *dpy, Atom atom)
-{
- static char buffer[256];
- char *atom_name;
-
- if (atom == None)
- return ("None");
-
- atom_name = XGetAtomName(dpy, atom);
- strncpy(buffer, atom_name, 256);
- XFree(atom_name);
- return (buffer);
+Keycode(XKeyEvent * ev)
+{
+ KeySym keysym_str;
+ char *keysym_name;
+
+ XLookupString(ev, buffer, sizeof buffer, &keysym_str, NULL);
+
+ if (keysym_str == NoSymbol)
+ keysym_name = "NoSymbol";
+ else
+ keysym_name = XKeysymToString(keysym_str);
+ if(keysym_name == nil)
+ keysym_name = "(no name)";
+
+ snprintf(buffer, sizeof buffer, "%u (keysym 0x%x \"%s\")",
+ (int)ev->keycode, (int)keysym_str, keysym_name);
+ return buffer;
+}
+
+/* Returns the string equivalent of an atom or "None" */
+static char *
+AtomName(Atom atom)
+{
+ extern Display *display;
+ char *atom_name;
+
+ if (atom == None)
+ return "None";
+
+ atom_name = XGetAtomName(display, atom);
+ strncpy(buffer, atom_name, sizeof buffer);
+ XFree(atom_name);
+
+ return buffer;
+}
+
+#define _(m) #m, ev->m
+
+enum {
+ TEnd,
+ TAtom,
+ TBool,
+ TColMap,
+ TConfDetail,
+ TConfMask,
+ TFocus,
+ TGrabMode,
+ TInt,
+ TIntNone,
+ TMajor,
+ TMapping,
+ TModState,
+ TPlace,
+ TPropState,
+ TString,
+ TTime,
+ TVis,
+ TWindow,
+ TXing,
+};
+
+typedef struct TypeTab TypeTab;
+
+struct TypeTab {
+ int size;
+ char *(*fn)();
+} ttab[] = {
+ [TEnd] = {0, nil},
+ [TAtom] = {sizeof(Atom), AtomName},
+ [TBool] = {sizeof(Bool), TorF},
+ [TColMap] = {sizeof(int), ColormapState},
+ [TConfDetail] = {sizeof(int), ConfigureDetail},
+ [TConfMask] = {sizeof(int), ConfigureValueMask},
+ [TFocus] = {sizeof(int), FocusChangeDetail},
+ [TGrabMode] = {sizeof(int), GrabMode},
+ [TIntNone] = {sizeof(int), MaybeNone},
+ [TInt] = {sizeof(int), strdec},
+ [TMajor] = {sizeof(int), MajorCode},
+ [TMapping] = {sizeof(int), MappingRequest},
+ [TModState] = {sizeof(int), ButtonAndOrModifierState},
+ [TPlace] = {sizeof(int), Place},
+ [TPropState] = {sizeof(int), PropertyState},
+ [TString] = {sizeof(char*), Self},
+ [TTime] = {sizeof(Time), ServerTime},
+ [TVis] = {sizeof(int), VisibilityState},
+ [TWindow] = {sizeof(Window), strhex},
+ [TXing] = {sizeof(int), CrossingDetail},
+};
+
+static void
+pevent(void *ev, ...) {
+ static char buf[4096];
+ static char *bend = buf + sizeof(buf);
+ va_list ap;
+ TypeTab *t;
+ char *p, *key, *val;
+ int n, type, valint;
+
+ va_start(ap, ev);
+
+ p = buf;
+ *p = '\0';
+ n = 0;
+ for(;;) {
+ type = va_arg(ap, int);
+ if(type == TEnd)
+ break;
+ t = &ttab[type];
+
+ key = va_arg(ap, char*);
+ switch(t->size) {
+ default:
+ break; /* Can't continue */
+ case sizeof(int):
+ valint = va_arg(ap, int);
+ val = t->fn(valint);
+ break;
+ }
+
+ if(n++ != 0)
+ p += strlcat(p, sep, bend-p);
+ p += snprintf(p, bend-p, "%s=%s", key, val);
+
+ if(p >= bend)
+ break;
+ }
+ fprintf(stderr, "%s\n", buf);
+
+ va_end(ap);
}
/******************************************************************************/
@@ -467,534 +563,448 @@ static void
static void
VerbMotion(XMotionEvent *ev)
{
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "root=0x%x%s", (int)ev->root, sep);
- fprintf(stderr, "subwindow=0x%x%s", (int)ev->subwindow, sep);
- fprintf(stderr, "time=%s%s", ServerTime(ev->time), sep);
- fprintf(stderr, "x=%d y=%d%s", ev->x, ev->y, sep);
- fprintf(stderr, "x_root=%d y_root=%d%s", ev->x_root, ev->y_root, sep);
- fprintf(stderr, "state=%s%s", ButtonAndOrModifierState(ev->state), sep);
- fprintf(stderr, "is_hint=%s%s", IsHint(ev->is_hint), sep);
- fprintf(stderr, "same_screen=%s\n", TorF(ev->same_screen));
+ pevent(ev,
+ TWindow, _(window),
+ TWindow, _(root),
+ TWindow, _(subwindow),
+ TTime, _(time),
+ TInt, _(x), TInt, _(y),
+ TInt, _(x_root), TInt, _(y_root),
+ TModState, _(state),
+ TBool, _(same_screen),
+ TEnd
+ );
+ //fprintf(stderr, "is_hint=%s%s", IsHint(ev->is_hint), sep);
}
static void
VerbButton(XButtonEvent *ev)
{
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "root=0x%x%s", (int)ev->root, sep);
- fprintf(stderr, "subwindow=0x%x%s", (int)ev->subwindow, sep);
- fprintf(stderr, "time=%s%s", ServerTime(ev->time), sep);
- fprintf(stderr, "x=%d y=%d%s", ev->x, ev->y, sep);
- fprintf(stderr, "x_root=%d y_root=%d%s", ev->x_root, ev->y_root, sep);
- fprintf(stderr, "state=%s%s", ButtonAndOrModifierState(ev->state), sep);
- fprintf(stderr, "button=%s%s", ButtonAndOrModifierState(ev->button), sep);
- fprintf(stderr, "same_screen=%s\n", TorF(ev->same_screen));
+ pevent(ev,
+ TWindow, _(window),
+ TWindow, _(root),
+ TWindow, _(subwindow),
+ TTime, _(time),
+ TInt, _(x), TInt, _(y),
+ TInt, _(x_root), TInt, _(y_root),
+ TModState, _(state),
+ TModState, _(button),
+ TBool, _(same_screen),
+ TEnd
+ );
}
static void
VerbColormap(XColormapEvent *ev)
{
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "colormap=%s%s", MaybeNone(ev->colormap), sep);
- fprintf(stderr, "new=%s%s", TorF(ev->new), sep);
- fprintf(stderr, "state=%s\n", ColormapState(ev->state));
+ pevent(ev,
+ TWindow, _(window),
+ TIntNone, _(colormap),
+ TBool, _(new),
+ TColMap, _(state),
+ TEnd
+ );
}
static void
VerbCrossing(XCrossingEvent *ev)
{
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "root=0x%x%s", (int)ev->root, sep);
- fprintf(stderr, "subwindow=0x%x%s", (int)ev->subwindow, sep);
- fprintf(stderr, "time=%s%s", ServerTime(ev->time), sep);
- fprintf(stderr, "x=%d y=%d%s", ev->x, ev->y, sep);
- fprintf(stderr, "x_root=%d y_root=%d%s", ev->x_root, ev->y_root, sep);
- fprintf(stderr, "mode=%s%s", GrabMode(ev->mode), sep);
- fprintf(stderr, "detail=%s%s", CrossingDetail(ev->detail), sep);
- fprintf(stderr, "same_screen=%s%s", TorF(ev->same_screen), sep);
- fprintf(stderr, "focus=%s%s", TorF(ev->focus), sep);
- fprintf(stderr, "state=%s\n", ButtonAndOrModifierState(ev->state));
+ pevent(ev,
+ TWindow, _(window),
+ TWindow, _(root),
+ TWindow, _(subwindow),
+ TTime, _(time),
+ TInt, _(x), TInt, _(y),
+ TInt, _(x_root), TInt, _(y_root),
+ TGrabMode, _(mode),
+ TXing, _(detail),
+ TBool, _(same_screen),
+ TBool, _(focus),
+ TModState, _(state),
+ TEnd
+ );
}
static void
VerbExpose(XExposeEvent *ev)
{
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "x=%d y=%d%s", ev->x, ev->y, sep);
- fprintf(stderr, "width=%d height=%d%s", ev->width, ev->height, sep);
- fprintf(stderr, "count=%d\n", ev->count);
+ pevent(ev,
+ TWindow, _(window),
+ TInt, _(x), TInt, _(y),
+ TInt, _(width), TInt, _(height),
+ TInt, _(count),
+ TEnd
+ );
}
static void
VerbGraphicsExpose(XGraphicsExposeEvent *ev)
{
- fprintf(stderr, "drawable=0x%x%s", (int)ev->drawable, sep);
- fprintf(stderr, "x=%d y=%d%s", ev->x, ev->y, sep);
- fprintf(stderr, "width=%d height=%d%s", ev->width, ev->height, sep);
- fprintf(stderr, "major_code=%s%s", MajorCode(ev->major_code), sep);
- fprintf(stderr, "minor_code=%d\n", ev->minor_code);
+ pevent(ev,
+ TWindow, _(drawable),
+ TInt, _(x), TInt, _(y),
+ TInt, _(width), TInt, _(height),
+ TMajor, _(major_code),
+ TInt, _(minor_code),
+ TEnd
+ );
}
static void
VerbNoExpose(XNoExposeEvent *ev)
{
- fprintf(stderr, "drawable=0x%x%s", (int)ev->drawable, sep);
- fprintf(stderr, "major_code=%s%s", MajorCode(ev->major_code), sep);
- fprintf(stderr, "minor_code=%d\n", ev->minor_code);
+ pevent(ev,
+ TWindow, _(drawable),
+ TMajor, _(major_code),
+ TInt, _(minor_code),
+ TEnd
+ );
}
static void
VerbFocus(XFocusChangeEvent *ev)
{
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "mode=%s%s", GrabMode(ev->mode), sep);
- fprintf(stderr, "detail=%s\n", FocusChangeDetail(ev->detail));
-}
-
-static void
-VerbKeymap(XKeymapEvent *ev)
-{
- int i;
-
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "key_vector=");
- for (i = 0; i < 32; i++)
- fprintf(stderr, "%02x", ev->key_vector[i]);
- fprintf(stderr, "\n");
+ pevent(ev,
+ TWindow, _(window),
+ TGrabMode, _(mode),
+ TFocus, _(detail),
+ TEnd
+ );
+}
+
+static void
+VerbKeymap(XKeymapEvent * ev)
+{
+ int i;
+
+ fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
+ fprintf(stderr, "key_vector=");
+ for (i = 0; i < 32; i++)
+ fprintf(stderr, "%02x", ev->key_vector[i]);
+ fprintf(stderr, "\n");
}
static void
VerbKey(XKeyEvent *ev)
{
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "root=0x%x%s", (int)ev->root, sep);
- if(ev->subwindow)
- fprintf(stderr, "subwindow=0x%x%s", (int)ev->subwindow, sep);
- fprintf(stderr, "time=%s%s", ServerTime(ev->time), sep);
- fprintf(stderr, "[%d,%d]%s", ev->x, ev->y, sep);
- fprintf(stderr, "root=[%d,%d]%s", ev->x_root, ev->y_root, sep);
- if(ev->state)
- fprintf(stderr, "state=%s%s", ButtonAndOrModifierState(ev->state), sep);
- fprintf(stderr, "keycode=%s%s", Keycode(ev), sep);
- if(!ev->same_screen)
- fprintf(stderr, "!same_screen");
- fprintf(stderr, "\n");
- return;
-
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "root=0x%x%s", (int)ev->root, sep);
- fprintf(stderr, "subwindow=0x%x%s", (int)ev->subwindow, sep);
- fprintf(stderr, "time=%s%s", ServerTime(ev->time), sep);
- fprintf(stderr, "x=%d y=%d%s", ev->x, ev->y, sep);
- fprintf(stderr, "x_root=%d y_root=%d%s", ev->x_root, ev->y_root, sep);
- fprintf(stderr, "state=%s%s", ButtonAndOrModifierState(ev->state), sep);
- fprintf(stderr, "keycode=%s%s", Keycode(ev), sep);
- fprintf(stderr, "same_screen=%s\n", TorF(ev->same_screen));
+ pevent(ev,
+ TWindow, _(window),
+ TWindow, _(root),
+ TWindow, _(subwindow),
+ TTime, _(time),
+ TInt, _(x), TInt, _(y),
+ TInt, _(x_root), TInt, _(y_root),
+ TModState, _(state),
+ TString, "keycode", estrdup(Keycode(ev)),
+ TBool, _(same_screen),
+ TEnd
+ );
}
static void
VerbProperty(XPropertyEvent *ev)
{
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "atom=%s%s", AtomName(ev->display, ev->atom), sep);
- fprintf(stderr, "time=%s%s", ServerTime(ev->time), sep);
- fprintf(stderr, "state=%s\n", PropertyState(ev->state));
+ pevent(ev,
+ TWindow, _(window),
+ TAtom, _(atom),
+ TTime, _(time),
+ TPropState, _(state),
+ TEnd
+ );
}
static void
VerbResizeRequest(XResizeRequestEvent *ev)
{
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "width=%d height=%d\n", ev->width, ev->height);
+ pevent(ev,
+ TWindow, _(window),
+ TInt, _(width), TInt, _(height),
+ TEnd
+ );
}
static void
VerbCirculate(XCirculateEvent *ev)
{
- fprintf(stderr, "event=0x%x%s", (int)ev->event, sep);
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "place=%s\n", Place(ev->place));
+ pevent(ev,
+ TWindow, _(event),
+ TWindow, _(window),
+ TPlace, _(place),
+ TEnd
+ );
}
static void
VerbConfigure(XConfigureEvent *ev)
{
- fprintf(stderr, "event=0x%x%s", (int)ev->event, sep);
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "x=%d y=%d%s", ev->x, ev->y, sep);
- fprintf(stderr, "width=%d height=%d%s", ev->width, ev->height, sep);
- fprintf(stderr, "border_width=%d%s", ev->border_width, sep);
- fprintf(stderr, "above=%s%s", MaybeNone(ev->above), sep);
- fprintf(stderr, "override_redirect=%s\n", TorF(ev->override_redirect));
+ pevent(ev,
+ TWindow, _(event),
+ TWindow, _(window),
+ TInt, _(x), TInt, _(y),
+ TInt, _(width), TInt, _(height),
+ TInt, _(border_width),
+ TIntNone, _(above),
+ TBool, _(override_redirect),
+ TEnd
+ );
}
static void
VerbCreateWindow(XCreateWindowEvent *ev)
{
- fprintf(stderr, "parent=0x%x%s", (int)ev->parent, sep);
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "x=%d y=%d%s", ev->x, ev->y, sep);
- fprintf(stderr, "width=%d height=%d%s", ev->width, ev->height, sep);
- fprintf(stderr, "border_width=%d%s", ev->border_width, sep);
- fprintf(stderr, "override_redirect=%s\n", TorF(ev->override_redirect));
+ pevent(ev,
+ TWindow, _(parent),
+ TWindow, _(window),
+ TInt, _(x), TInt, _(y),
+ TInt, _(width), TInt, _(height),
+ TInt, _(border_width),
+ TBool, _(override_redirect),
+ TEnd
+ );
}
static void
VerbDestroyWindow(XDestroyWindowEvent *ev)
{
- fprintf(stderr, "event=0x%x%s", (int)ev->event, sep);
- fprintf(stderr, "window=0x%x\n", (int)ev->window);
+ pevent(ev,
+ TWindow, _(event),
+ TWindow, _(window),
+ TEnd
+ );
}
static void
VerbGravity(XGravityEvent *ev)
{
- fprintf(stderr, "event=0x%x%s", (int)ev->event, sep);
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "x=%d y=%d\n", ev->x, ev->y);
+ pevent(ev,
+ TWindow, _(event),
+ TWindow, _(window),
+ TInt, _(x), TInt, _(y),
+ TEnd
+ );
}
static void
VerbMap(XMapEvent *ev)
{
- fprintf(stderr, "event=0x%x%s", (int)ev->event, sep);
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "override_redirect=%s\n", TorF(ev->override_redirect));
+ pevent(ev,
+ TWindow, _(event),
+ TWindow, _(window),
+ TBool, _(override_redirect),
+ TEnd
+ );
}
static void
VerbReparent(XReparentEvent *ev)
{
- fprintf(stderr, "event=0x%x%s", (int)ev->event, sep);
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "parent=0x%x%s", (int)ev->parent, sep);
- fprintf(stderr, "x=%d y=%d%s", ev->x, ev->y, sep);
- fprintf(stderr, "override_redirect=%s\n", TorF(ev->override_redirect));
+ pevent(ev,
+ TWindow, _(event),
+ TWindow, _(window),
+ TWindow, _(parent),
+ TInt, _(x), TInt, _(y),
+ TBool, _(override_redirect),
+ TEnd
+ );
}
static void
VerbUnmap(XUnmapEvent *ev)
{
- fprintf(stderr, "event=0x%x%s", (int)ev->event, sep);
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "from_configure=%s\n", TorF(ev->from_configure));
+ pevent(ev,
+ TWindow, _(event),
+ TWindow, _(window),
+ TBool, _(from_configure),
+ TEnd
+ );
}
static void
VerbCirculateRequest(XCirculateRequestEvent *ev)
{
- fprintf(stderr, "parent=0x%x%s", (int)ev->parent, sep);
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "place=%s\n", Place(ev->place));
+ pevent(ev,
+ TWindow, _(parent),
+ TWindow, _(window),
+ TPlace, _(place),
+ TEnd
+ );
}
static void
VerbConfigureRequest(XConfigureRequestEvent *ev)
{
- fprintf(stderr, "parent=0x%x%s", (int)ev->parent, sep);
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "x=%d y=%d%s", ev->x, ev->y, sep);
- fprintf(stderr, "width=%d height=%d%s", ev->width, ev->height, sep);
- fprintf(stderr, "border_width=%d%s", ev->border_width, sep);
- fprintf(stderr, "above=%s%s", MaybeNone(ev->above), sep);
- fprintf(stderr, "detail=%s%s", ConfigureDetail(ev->detail), sep);
- fprintf(stderr, "value_mask=%s\n", ConfigureValueMask(ev->value_mask));
+ pevent(ev,
+ TWindow, _(parent),
+ TWindow, _(window),
+ TInt, _(x), TInt, _(y),
+ TInt, _(width), TInt, _(height),
+ TInt, _(border_width),
+ TIntNone, _(above),
+ TConfDetail, _(detail),
+ TConfMask, _(value_mask),
+ TEnd
+ );
}
static void
VerbMapRequest(XMapRequestEvent *ev)
{
- fprintf(stderr, "parent=0x%x%s", (int)ev->parent, sep);
- fprintf(stderr, "window=0x%x\n", (int)ev->window);
-}
-
-static void
-VerbClient(XClientMessageEvent *ev)
-{
- int i;
-
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "message_type=%s%s", AtomName(ev->display, ev->message_type), sep);
- fprintf(stderr, "format=%d\n", ev->format);
- fprintf(stderr, "data (shown as longs)=");
- for (i = 0; i < 5; i++)
- fprintf(stderr, " 0x%08lx", ev->data.l[i]);
- fprintf(stderr, "\n");
+ pevent(ev,
+ TWindow, _(parent),
+ TWindow, _(window),
+ TEnd
+ );
+}
+
+static void
+VerbClient(XClientMessageEvent * ev)
+{
+ int i;
+
+ fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
+ fprintf(stderr, "message_type=%s%s", AtomName(ev->message_type), sep);
+ fprintf(stderr, "format=%d\n", ev->format);
+ fprintf(stderr, "data (shown as longs)=");
+ for (i = 0; i < 5; i++)
+ fprintf(stderr, " 0x%08lx", ev->data.l[i]);
+ fprintf(stderr, "\n");
}
static void
VerbMapping(XMappingEvent *ev)
{
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "request=%s%s", MappingRequest(ev->request), sep);
- fprintf(stderr, "first_keycode=0x%x%s", ev->first_keycode, sep);
- fprintf(stderr, "count=0x%x\n", ev->count);
+ pevent(ev,
+ TWindow, _(window),
+ TMapping, _(request),
+ TWindow, _(first_keycode),
+ TWindow, _(count),
+ TEnd
+ );
}
static void
VerbSelectionClear(XSelectionClearEvent *ev)
{
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "selection=%s%s", AtomName(ev->display, ev->selection), sep);
- fprintf(stderr, "time=%s\n", ServerTime(ev->time));
+ pevent(ev,
+ TWindow, _(window),
+ TAtom, _(selection),
+ TTime, _(time),
+ TEnd
+ );
}
static void
VerbSelection(XSelectionEvent *ev)
{
- fprintf(stderr, "requestor=0x%x%s", (int)ev->requestor, sep);
- fprintf(stderr, "selection=%s%s", AtomName(ev->display, ev->selection), sep);
- fprintf(stderr, "target=%s%s", AtomName(ev->display, ev->target), sep);
- fprintf(stderr, "property=%s%s", AtomName(ev->display, ev->property), sep);
- fprintf(stderr, "time=%s\n", ServerTime(ev->time));
+ pevent(ev,
+ TWindow, _(requestor),
+ TAtom, _(selection),
+ TAtom, _(target),
+ TAtom, _(property),
+ TTime, _(time),
+ TEnd
+ );
}
static void
VerbSelectionRequest(XSelectionRequestEvent *ev)
{
- fprintf(stderr, "owner=0x%x%s", (int)ev->owner, sep);
- fprintf(stderr, "requestor=0x%x%s", (int)ev->requestor, sep);
- fprintf(stderr, "selection=%s%s", AtomName(ev->display, ev->selection), sep);
- fprintf(stderr, "target=%s%s", AtomName(ev->display, ev->target), sep);
- fprintf(stderr, "property=%s%s", AtomName(ev->display, ev->property), sep);
- fprintf(stderr, "time=%s\n", ServerTime(ev->time));
+ pevent(ev,
+ TWindow, _(owner),
+ TWindow, _(requestor),
+ TAtom, _(selection),
+ TAtom, _(target),
+ TAtom, _(property),
+ TTime, _(time),
+ TEnd
+ );
}
static void
VerbVisibility(XVisibilityEvent *ev)
{
- fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
- fprintf(stderr, "state=%s\n", VisibilityState(ev->state));
-}
-
-/******************************************************************************/
-/************ Return the string representation for type of an event ***********/
-/******************************************************************************/
-
-char *eventtype(XEvent *ev)
-{
- static char buffer[20];
-
- switch (ev->type) {
- case KeyPress:
- return ("KeyPress");
- case KeyRelease:
- return ("KeyRelease");
- case ButtonPress:
- return ("ButtonPress");
- case ButtonRelease:
- return ("ButtonRelease");
- case MotionNotify:
- return ("MotionNotify");
- case EnterNotify:
- return ("EnterNotify");
- case LeaveNotify:
- return ("LeaveNotify");
- case FocusIn:
- return ("FocusIn");
- case FocusOut:
- return ("FocusOut");
- case KeymapNotify:
- return ("KeymapNotify");
- case Expose:
- return ("Expose");
- case GraphicsExpose:
- return ("GraphicsExpose");
- case NoExpose:
- return ("NoExpose");
- case VisibilityNotify:
- return ("VisibilityNotify");
- case CreateNotify:
- return ("CreateNotify");
- case DestroyNotify:
- return ("DestroyNotify");
- case UnmapNotify:
- return ("UnmapNotify");
- case MapNotify:
- return ("MapNotify");
- case MapRequest:
- return ("MapRequest");
- case ReparentNotify:
- return ("ReparentNotify");
- case ConfigureNotify:
- return ("ConfigureNotify");
- case ConfigureRequest:
- return ("ConfigureRequest");
- case GravityNotify:
- return ("GravityNotify");
- case ResizeRequest:
- return ("ResizeRequest");
- case CirculateNotify:
- return ("CirculateNotify");
- case CirculateRequest:
- return ("CirculateRequest");
- case PropertyNotify:
- return ("PropertyNotify");
- case SelectionClear:
- return ("SelectionClear");
- case SelectionRequest:
- return ("SelectionRequest");
- case SelectionNotify:
- return ("SelectionNotify");
- case ColormapNotify:
- return ("ColormapNotify");
- case ClientMessage:
- return ("ClientMessage");
- case MappingNotify:
- return ("MappingNotify");
- }
- sprintf(buffer, "%d", ev->type);
- return buffer;
+ pevent(ev,
+ TWindow, _(window),
+ TVis, _(state),
+ TEnd
+ );
}
/******************************************************************************/
/**************** Print the values of all fields for any event ****************/
/******************************************************************************/
-void printevent(XEvent *e)
-{
- extern Display* display;
- XAnyEvent *ev = (void*)e;
- char *name;
-
- if(ev->window) {
- XFetchName(display, ev->window, &name);
- if(name) {
- fprintf(stderr, "\ttitle=%s\n", name);
- XFree(name);
- }
- }
- fprintf(stderr, "%3ld %-20s ", ev->serial, eventtype(e));
- if(ev->send_event)
- fprintf(stderr, "(sendevent) ");
- if(0){
- fprintf(stderr, "type=%s%s", eventtype(e), sep);
- fprintf(stderr, "serial=%lu%s", ev->serial, sep);
- fprintf(stderr, "send_event=%s%s", TorF(ev->send_event), sep);
- fprintf(stderr, "display=0x%p%s", ev->display, sep);
- }
-
- switch (ev->type) {
- case MotionNotify:
- VerbMotion((void*)ev);
- break;
-
- case ButtonPress:
- case ButtonRelease:
- VerbButton((void*)ev);
- break;
-
- case ColormapNotify:
- VerbColormap((void*)ev);
- break;
-
- case EnterNotify:
- case LeaveNotify:
- VerbCrossing((void*)ev);
- break;
-
- case Expose:
- VerbExpose((void*)ev);
- break;
-
- case GraphicsExpose:
- VerbGraphicsExpose((void*)ev);
- break;
-
- case NoExpose:
- VerbNoExpose((void*)ev);
- break;
-
- case FocusIn:
- case FocusOut:
- VerbFocus((void*)ev);
- break;
-
- case KeymapNotify:
- VerbKeymap((void*)ev);
- break;
-
- case KeyPress:
- case KeyRelease:
- VerbKey((void*)ev);
- break;
-
- case PropertyNotify:
- VerbProperty((void*)ev);
- break;
-
- case ResizeRequest:
- VerbResizeRequest((void*)ev);
- break;
-
- case CirculateNotify:
- VerbCirculate((void*)ev);
- break;
-
- case ConfigureNotify:
- VerbConfigure((void*)ev);
- break;
-
- case CreateNotify:
- VerbCreateWindow((void*)ev);
- break;
-
- case DestroyNotify:
- VerbDestroyWindow((void*)ev);
- break;
-
- case GravityNotify:
- VerbGravity((void*)ev);
- break;
-
- case MapNotify:
- VerbMap((void*)ev);
- break;
-
- case ReparentNotify:
- VerbReparent((void*)ev);
- break;
-
- case UnmapNotify:
- VerbUnmap((void*)ev);
- break;
-
- case CirculateRequest:
- VerbCirculateRequest((void*)ev);
- break;
-
- case ConfigureRequest:
- VerbConfigureRequest((void*)ev);
- break;
-
- case MapRequest:
- VerbMapRequest((void*)ev);
- break;
-
- case ClientMessage:
- VerbClient((void*)ev);
- break;
-
- case MappingNotify:
- VerbMapping((void*)ev);
- break;
-
- case SelectionClear:
- VerbSelectionClear((void*)ev);
- break;
-
- case SelectionNotify:
- VerbSelection((void*)ev);
- break;
-
- case SelectionRequest:
- VerbSelectionRequest((void*)ev);
- break;
-
- case VisibilityNotify:
- VerbVisibility((void*)ev);
- break;
- }
-}
-
+typedef struct Handler Handler;
+
+struct Handler {
+ int key;
+ void (*fn)();
+};
+
+void
+printevent(XEvent * e)
+{
+ extern Display *display;
+ XAnyEvent *ev = (void *)e;
+ char *name;
+
+ if (ev->window) {
+ XFetchName(display, ev->window, &name);
+ if (name)
+ fprintf(stderr, "\ttitle=%s\n", name);
+ XFree(name);
+ }
+
+ fprintf(stderr, "%3ld %-20s ", ev->serial, eventtype(e->xany.type));
+ if (ev->send_event)
+ fprintf(stderr, "(sendevent) ");
+ if (0) {
+ fprintf(stderr, "type=%s%s", eventtype(e->xany.type), sep);
+ fprintf(stderr, "serial=%lu%s", ev->serial, sep);
+ fprintf(stderr, "send_event=%s%s", TorF(ev->send_event), sep);
+ fprintf(stderr, "display=0x%p%s", ev->display, sep);
+ }
+ static Handler fns[] = {
+ {MotionNotify, VerbMotion},
+ {ButtonPress, VerbButton},
+ {ButtonRelease, VerbButton},
+ {ColormapNotify, VerbColormap},
+ {EnterNotify, VerbCrossing},
+ {LeaveNotify, VerbCrossing},
+ {Expose, VerbExpose},
+ {GraphicsExpose, VerbGraphicsExpose},
+ {NoExpose, VerbNoExpose},
+ {FocusIn, VerbFocus},
+ {FocusOut, VerbFocus},
+ {KeymapNotify, VerbKeymap},
+ {KeyPress, VerbKey},
+ {KeyRelease, VerbKey},
+ {PropertyNotify, VerbProperty},
+ {ResizeRequest, VerbResizeRequest},
+ {CirculateNotify, VerbCirculate},
+ {ConfigureNotify, VerbConfigure},
+ {CreateNotify, VerbCreateWindow},
+ {DestroyNotify, VerbDestroyWindow},
+ {GravityNotify, VerbGravity},
+ {MapNotify, VerbMap},
+ {ReparentNotify, VerbReparent},
+ {UnmapNotify, VerbUnmap},
+ {CirculateRequest, VerbCirculateRequest},
+ {ConfigureRequest, VerbConfigureRequest},
+ {MapRequest, VerbMapRequest},
+ {ClientMessage, VerbClient},
+ {MappingNotify, VerbMapping},
+ {SelectionClear, VerbSelectionClear},
+ {SelectionNotify, VerbSelection},
+ {SelectionRequest, VerbSelectionRequest},
+ {VisibilityNotify, VerbVisibility},
+ {0, nil},
+ };
+ Handler *p;
+
+ for (p = fns; p->fn; p++)
+ if (p->key == ev->type)
+ break;
+ if (p->fn)
+ p->fn(ev);
+}
diff -r 27c0bf99dd16 -r 9addd4c171b4 cmd/wmii/printevent.h
--- a/cmd/wmii/printevent.h Thu May 24 16:49:45 2007 -0400
+++ b/cmd/wmii/printevent.h Thu May 24 17:23:36 2007 -0400
@@ -1,2 +1,1 @@ char *eventtype(XEvent*);
-char *eventtype(XEvent*);
void printevent(XEvent*);
diff -r 27c0bf99dd16 -r 9addd4c171b4 cmd/wmii/view.c
--- a/cmd/wmii/view.c Thu May 24 16:49:45 2007 -0400
+++ b/cmd/wmii/view.c Thu May 24 17:23:36 2007 -0400
@@ -371,7 +371,7 @@ view_index(View *v) {
}
void
-update_views() {
+update_views(void) {
View *n, *v, *old;
Bool found;
diff -r 27c0bf99dd16 -r 9addd4c171b4 cmd/wmii/x11.c
--- a/cmd/wmii/x11.c Thu May 24 16:49:45 2007 -0400
+++ b/cmd/wmii/x11.c Thu May 24 17:23:36 2007 -0400
@@ -96,7 +96,7 @@ rectsubpt(Rectangle r, Point p) {
/* Init */
void
-initdisplay() {
+initdisplay(void) {
display = XOpenDisplay(nil);
scr.screen = DefaultScreen(display);
scr.colormap = DefaultColormap(display, scr.screen);
@@ -654,7 +654,7 @@ grabpointer(Window *w, Window *confine,
}
void
-ungrabpointer() {
+ungrabpointer(void) {
XUngrabPointer(display, CurrentTime);
}
Received on Fri Jun 01 2007 - 03:10:37 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:57:13 UTC