set *handler as local to main, not global/extern, and set handler functions no-static

This commit is contained in:
Julien Danjou 2007-09-07 12:29:54 +02:00
parent a4449818f3
commit 1d25e8897a
3 changed files with 44 additions and 36 deletions

47
event.c
View File

@ -22,7 +22,6 @@ extern Cursor cursor[CurLast];
extern Client *clients, *sel; /* global client list */ extern Client *clients, *sel; /* global client list */
extern Bool selscreen; extern Bool selscreen;
extern Atom netatom[NetLast]; extern Atom netatom[NetLast];
void (*handler[LASTEvent]) (XEvent *, jdwm_config *); /* event handler */
#define CLEANMASK(mask) (mask & ~(jdwmconf->numlockmask | LockMask)) #define CLEANMASK(mask) (mask & ~(jdwmconf->numlockmask | LockMask))
#define MOUSEMASK (BUTTONMASK | PointerMotionMask) #define MOUSEMASK (BUTTONMASK | PointerMotionMask)
@ -61,7 +60,7 @@ movemouse(Client * c, jdwm_config *jdwmconf)
case ConfigureRequest: case ConfigureRequest:
case Expose: case Expose:
case MapRequest: case MapRequest:
handler[ev.type] (&ev, jdwmconf); handle_event_maprequest(&ev, jdwmconf);
break; break;
case MotionNotify: case MotionNotify:
XSync(c->display, False); XSync(c->display, False);
@ -108,7 +107,7 @@ resizemouse(Client * c, jdwm_config *jdwmconf)
case ConfigureRequest: case ConfigureRequest:
case Expose: case Expose:
case MapRequest: case MapRequest:
handler[ev.type] (&ev, jdwmconf); handle_event_maprequest(&ev, jdwmconf);
break; break;
case MotionNotify: case MotionNotify:
XSync(c->display, False); XSync(c->display, False);
@ -122,7 +121,7 @@ resizemouse(Client * c, jdwm_config *jdwmconf)
} }
} }
static void void
handle_event_buttonpress(XEvent * e, jdwm_config *jdwmconf) handle_event_buttonpress(XEvent * e, jdwm_config *jdwmconf)
{ {
int i, x; int i, x;
@ -184,7 +183,7 @@ handle_event_buttonpress(XEvent * e, jdwm_config *jdwmconf)
} }
} }
static void void
handle_event_configurerequest(XEvent * e, jdwm_config *jdwmconf __attribute__ ((unused))) handle_event_configurerequest(XEvent * e, jdwm_config *jdwmconf __attribute__ ((unused)))
{ {
Client *c; Client *c;
@ -232,7 +231,7 @@ handle_event_configurerequest(XEvent * e, jdwm_config *jdwmconf __attribute__ ((
XSync(e->xany.display, False); XSync(e->xany.display, False);
} }
static void void
handle_event_configurenotify(XEvent * e, jdwm_config *jdwmconf) handle_event_configurenotify(XEvent * e, jdwm_config *jdwmconf)
{ {
XConfigureEvent *ev = &e->xconfigure; XConfigureEvent *ev = &e->xconfigure;
@ -249,7 +248,7 @@ handle_event_configurenotify(XEvent * e, jdwm_config *jdwmconf)
} }
} }
static void void
handle_event_destroynotify(XEvent * e, jdwm_config *jdwmconf) handle_event_destroynotify(XEvent * e, jdwm_config *jdwmconf)
{ {
Client *c; Client *c;
@ -259,7 +258,7 @@ handle_event_destroynotify(XEvent * e, jdwm_config *jdwmconf)
unmanage(c, &dc, WithdrawnState, jdwmconf); unmanage(c, &dc, WithdrawnState, jdwmconf);
} }
static void void
handle_event_enternotify(XEvent * e, jdwm_config *jdwmconf) handle_event_enternotify(XEvent * e, jdwm_config *jdwmconf)
{ {
Client *c; Client *c;
@ -276,7 +275,7 @@ handle_event_enternotify(XEvent * e, jdwm_config *jdwmconf)
} }
} }
static void void
handle_event_expose(XEvent * e, jdwm_config *jdwmconf) handle_event_expose(XEvent * e, jdwm_config *jdwmconf)
{ {
XExposeEvent *ev = &e->xexpose; XExposeEvent *ev = &e->xexpose;
@ -285,7 +284,7 @@ handle_event_expose(XEvent * e, jdwm_config *jdwmconf)
drawstatus(e->xany.display, jdwmconf); drawstatus(e->xany.display, jdwmconf);
} }
static void void
handle_event_keypress(XEvent * e, jdwm_config *jdwmconf) handle_event_keypress(XEvent * e, jdwm_config *jdwmconf)
{ {
int i; int i;
@ -299,7 +298,7 @@ handle_event_keypress(XEvent * e, jdwm_config *jdwmconf)
jdwmconf->keys[i].func(e->xany.display, jdwmconf, jdwmconf->keys[i].arg); jdwmconf->keys[i].func(e->xany.display, jdwmconf, jdwmconf->keys[i].arg);
} }
static void void
handle_event_leavenotify(XEvent * e, jdwm_config *jdwmconf) handle_event_leavenotify(XEvent * e, jdwm_config *jdwmconf)
{ {
XCrossingEvent *ev = &e->xcrossing; XCrossingEvent *ev = &e->xcrossing;
@ -311,7 +310,7 @@ handle_event_leavenotify(XEvent * e, jdwm_config *jdwmconf)
} }
} }
static void void
handle_event_mappingnotify(XEvent * e, jdwm_config *jdwmconf) handle_event_mappingnotify(XEvent * e, jdwm_config *jdwmconf)
{ {
XMappingEvent *ev = &e->xmapping; XMappingEvent *ev = &e->xmapping;
@ -321,7 +320,7 @@ handle_event_mappingnotify(XEvent * e, jdwm_config *jdwmconf)
grabkeys(e->xany.display, jdwmconf); grabkeys(e->xany.display, jdwmconf);
} }
static void void
handle_event_maprequest(XEvent * e, jdwm_config *jdwmconf) handle_event_maprequest(XEvent * e, jdwm_config *jdwmconf)
{ {
static XWindowAttributes wa; static XWindowAttributes wa;
@ -335,7 +334,7 @@ handle_event_maprequest(XEvent * e, jdwm_config *jdwmconf)
manage(e->xany.display, &dc, ev->window, &wa, jdwmconf); manage(e->xany.display, &dc, ev->window, &wa, jdwmconf);
} }
static void void
handle_event_propertynotify(XEvent * e, jdwm_config *jdwmconf) handle_event_propertynotify(XEvent * e, jdwm_config *jdwmconf)
{ {
Client *c; Client *c;
@ -368,7 +367,7 @@ handle_event_propertynotify(XEvent * e, jdwm_config *jdwmconf)
} }
} }
static void void
handle_event_unmapnotify(XEvent * e, jdwm_config *jdwmconf) handle_event_unmapnotify(XEvent * e, jdwm_config *jdwmconf)
{ {
Client *c; Client *c;
@ -378,24 +377,6 @@ handle_event_unmapnotify(XEvent * e, jdwm_config *jdwmconf)
unmanage(c, &dc, WithdrawnState, jdwmconf); unmanage(c, &dc, WithdrawnState, jdwmconf);
} }
/* extern */
void (*handler[LASTEvent]) (XEvent *, jdwm_config *) =
{
[ButtonPress] = handle_event_buttonpress,
[ConfigureRequest] = handle_event_configurerequest,
[ConfigureNotify] = handle_event_configurenotify,
[DestroyNotify] = handle_event_destroynotify,
[EnterNotify] = handle_event_enternotify,
[LeaveNotify] = handle_event_leavenotify,
[Expose] = handle_event_expose,
[KeyPress] = handle_event_keypress,
[MappingNotify] = handle_event_mappingnotify,
[MapRequest] = handle_event_maprequest,
[PropertyNotify] = handle_event_propertynotify,
[UnmapNotify] = handle_event_unmapnotify
};
void void
grabkeys(Display *disp, jdwm_config *jdwmconf) grabkeys(Display *disp, jdwm_config *jdwmconf)
{ {

13
event.h
View File

@ -7,4 +7,17 @@
void grabkeys(Display *, jdwm_config *); /* grab all keys defined in config */ void grabkeys(Display *, jdwm_config *); /* grab all keys defined in config */
void handle_event_buttonpress(XEvent *, jdwm_config *);
void handle_event_configurerequest(XEvent *, jdwm_config *);
void handle_event_configurenotify(XEvent *, jdwm_config *);
void handle_event_destroynotify(XEvent *, jdwm_config *);
void handle_event_enternotify(XEvent *, jdwm_config *);
void handle_event_expose(XEvent *, jdwm_config *);
void handle_event_keypress(XEvent *, jdwm_config *);
void handle_event_leavenotify(XEvent *, jdwm_config *);
void handle_event_mappingnotify(XEvent *, jdwm_config *);
void handle_event_maprequest(XEvent *, jdwm_config *);
void handle_event_propertynotify(XEvent *, jdwm_config *);
void handle_event_unmapnotify(XEvent *, jdwm_config *);
#endif #endif

20
jdwm.c
View File

@ -18,9 +18,6 @@
#include "layout.h" #include "layout.h"
#include "tag.h" #include "tag.h"
/* extern */
extern void (*handler[LASTEvent]) (XEvent *, jdwm_config *); /* event handler */
int screen, sx, sy, sw, sh, wax, way, waw, wah; int screen, sx, sy, sw, sh, wax, way, waw, wah;
int bh; int bh;
Atom jdwmprops, wmatom[WMLast], netatom[NetLast]; Atom jdwmprops, wmatom[WMLast], netatom[NetLast];
@ -320,6 +317,23 @@ main(int argc, char *argv[])
scan(dpy, &jdwmconf); scan(dpy, &jdwmconf);
XSync(dpy, False); XSync(dpy, False);
void (*handler[LASTEvent]) (XEvent *, jdwm_config *) =
{
[ButtonPress] = handle_event_buttonpress,
[ConfigureRequest] = handle_event_configurerequest,
[ConfigureNotify] = handle_event_configurenotify,
[DestroyNotify] = handle_event_destroynotify,
[EnterNotify] = handle_event_enternotify,
[LeaveNotify] = handle_event_leavenotify,
[Expose] = handle_event_expose,
[KeyPress] = handle_event_keypress,
[MappingNotify] = handle_event_mappingnotify,
[MapRequest] = handle_event_maprequest,
[PropertyNotify] = handle_event_propertynotify,
[UnmapNotify] = handle_event_unmapnotify
};
/* main event loop, also reads status text from stdin */ /* main event loop, also reads status text from stdin */
while(running) while(running)
{ {