diff options
author | Okan Demirmen <okan@cvs.openbsd.org> | 2008-07-11 14:21:29 +0000 |
---|---|---|
committer | Okan Demirmen <okan@cvs.openbsd.org> | 2008-07-11 14:21:29 +0000 |
commit | 7bd488e7c78e06de5f445f4f2669397298dbfb9c (patch) | |
tree | 0684416aa66987b30b47fcde37d467d0ae4a7422 /app | |
parent | b8d1b4702426abb5c0ce0b5ea49d5874e1fd1e47 (diff) |
spacing, declaration lineup to be consistent throughout cwm,
readability, and a bit of knf.
ok oga@
Diffstat (limited to 'app')
-rw-r--r-- | app/cwm/calmwm.c | 40 | ||||
-rw-r--r-- | app/cwm/calmwm.h | 6 | ||||
-rw-r--r-- | app/cwm/client.c | 117 | ||||
-rw-r--r-- | app/cwm/conf.c | 35 | ||||
-rw-r--r-- | app/cwm/font.c | 11 | ||||
-rw-r--r-- | app/cwm/grab.c | 45 | ||||
-rw-r--r-- | app/cwm/group.c | 39 | ||||
-rw-r--r-- | app/cwm/input.c | 4 | ||||
-rw-r--r-- | app/cwm/kbfunc.c | 60 | ||||
-rw-r--r-- | app/cwm/menu.c | 15 | ||||
-rw-r--r-- | app/cwm/mousefunc.c | 22 | ||||
-rw-r--r-- | app/cwm/screen.c | 14 | ||||
-rw-r--r-- | app/cwm/search.c | 33 | ||||
-rw-r--r-- | app/cwm/util.c | 7 | ||||
-rw-r--r-- | app/cwm/xevents.c | 99 | ||||
-rw-r--r-- | app/cwm/xmalloc.c | 8 | ||||
-rw-r--r-- | app/cwm/xutil.c | 30 |
17 files changed, 307 insertions, 278 deletions
diff --git a/app/cwm/calmwm.c b/app/cwm/calmwm.c index bbd045e93..fe9d4252d 100644 --- a/app/cwm/calmwm.c +++ b/app/cwm/calmwm.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: calmwm.c,v 1.22 2008/06/25 01:09:09 oga Exp $ + * $Id: calmwm.c,v 1.23 2008/07/11 14:21:28 okan Exp $ */ #include "headers.h" @@ -44,16 +44,14 @@ struct conf Conf; #define gray_height 2 static char gray_bits[] = {0x02, 0x01}; - static void _sigchld_cb(int); int main(int argc, char **argv) { - int ch; - const char *conf_file = NULL; - - char *display_name = NULL; + const char *conf_file = NULL; + char *display_name = NULL; + int ch; while ((ch = getopt(argc, argv, "c:d:")) != -1) { switch (ch) { @@ -110,8 +108,8 @@ main(int argc, char **argv) void x_setup(char *display_name) { - int i; - struct screen_ctx *sc; + struct screen_ctx *sc; + int i; TAILQ_INIT(&Screenq); @@ -140,13 +138,13 @@ x_setup(char *display_name) void x_setupscreen(struct screen_ctx *sc, u_int which) { - XColor tmp; - XGCValues gv; - Window *wins, w0, w1; - u_int nwins, i = 0; - XWindowAttributes winattr; - XSetWindowAttributes rootattr; - struct keybinding *kb; + XColor tmp; + XGCValues gv; + Window *wins, w0, w1; + XWindowAttributes winattr; + XSetWindowAttributes rootattr; + struct keybinding *kb; + u_int nwins, i; Curscreen = sc; @@ -247,8 +245,8 @@ x_setupscreen(struct screen_ctx *sc, u_int which) char * x_screenname(int which) { - char *cp, *dstr, *sn; - size_t snlen; + char *cp, *dstr, *sn; + size_t snlen; if (which > 9) errx(1, "Can't handle more than 9 screens. If you need it, " @@ -298,9 +296,9 @@ x_errorhandler(Display *dpy, XErrorEvent *e) static void _sigchld_cb(int which) { - pid_t pid; - int save_errno = errno; - int status; + pid_t pid; + int save_errno = errno; + int status; /* Collect dead children. */ while ((pid = waitpid(-1, &status, WNOHANG)) > 0 || @@ -313,7 +311,7 @@ _sigchld_cb(int which) __dead void usage(void) { - extern char *__progname; + extern char *__progname; fprintf(stderr, "usage: %s [-c file] [-d display]\n", __progname); exit(1); diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index fa73b58fc..de70f55aa 100644 --- a/app/cwm/calmwm.h +++ b/app/cwm/calmwm.h @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: calmwm.h,v 1.57 2008/06/25 22:44:42 oga Exp $ + * $Id: calmwm.h,v 1.58 2008/07/11 14:21:28 okan Exp $ */ #ifndef _CALMWM_H_ @@ -83,8 +83,8 @@ TAILQ_HEAD(screen_ctx_q, screen_ctx); struct winname { - TAILQ_ENTRY(winname) entry; - char *name; + TAILQ_ENTRY(winname) entry; + char *name; }; TAILQ_HEAD(winname_q, winname); diff --git a/app/cwm/client.c b/app/cwm/client.c index fdc81e660..c54a7e695 100644 --- a/app/cwm/client.c +++ b/app/cwm/client.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: client.c,v 1.33 2008/06/30 17:52:37 okan Exp $ + * $Id: client.c,v 1.34 2008/07/11 14:21:28 okan Exp $ */ #include "headers.h" @@ -36,7 +36,7 @@ client_setup(void) struct client_ctx * client_find(Window win) { - struct client_ctx *cc; + struct client_ctx *cc; TAILQ_FOREACH(cc, &Clientq, entry) if (cc->pwin == win || cc->win == win) @@ -48,12 +48,12 @@ client_find(Window win) struct client_ctx * client_new(Window win, struct screen_ctx *sc, int mapped) { - struct client_ctx *cc; - long tmp; - XSetWindowAttributes pxattr; - XWindowAttributes wattr; - int x, y, height, width, state; - XWMHints *wmhints; + struct client_ctx *cc; + XSetWindowAttributes pxattr; + XWindowAttributes wattr; + XWMHints *wmhints; + long tmp; + int x, y, height, width, state; if (win == None) return (NULL); @@ -127,7 +127,6 @@ client_new(Window win, struct screen_ctx *sc, int mapped) width += (cc->bwidth)*2; height += (cc->bwidth)*2; } - pxattr.override_redirect = True; pxattr.background_pixel = sc->bgcolor.pixel; pxattr.event_mask = ChildMask | ButtonPressMask | ButtonReleaseMask | @@ -176,8 +175,8 @@ void client_do_shape(struct client_ctx *cc) { /* Windows not rectangular require more effort */ - XRectangle *r; - int n, tmp; + XRectangle *r; + int n, tmp; if (Doshape) { XShapeSelectInput(X_Dpy, cc->win, ShapeNotifyMask); @@ -196,15 +195,15 @@ client_do_shape(struct client_ctx *cc) int client_delete(struct client_ctx *cc, int sendevent, int ignorewindow) { - struct screen_ctx *sc = CCTOSC(cc); - struct winname *wn; + struct screen_ctx *sc = CCTOSC(cc); + struct winname *wn; if (cc->state == IconicState && !sendevent) return (1); group_client_delete(cc); - XGrabServer(X_Dpy); + XGrabServer(X_Dpy); xu_setstate(cc, WithdrawnState); XRemoveFromSaveSet(X_Dpy, cc->win); @@ -245,21 +244,21 @@ client_delete(struct client_ctx *cc, int sendevent, int ignorewindow) void client_leave(struct client_ctx *cc) { - struct screen_ctx *sc; + struct screen_ctx *sc; if (cc == NULL) cc = _curcc; if (cc == NULL) return; - sc = CCTOSC(cc); + sc = CCTOSC(cc); xu_btn_ungrab(sc->rootwin, AnyModifier, Button1); } void client_setactive(struct client_ctx *cc, int fg) { - struct screen_ctx* sc; + struct screen_ctx *sc; if (cc == NULL) cc = _curcc; @@ -300,9 +299,9 @@ client_current(void) void client_gravitate(struct client_ctx *cc, int yes) { - int dx = 0, dy = 0, mult = yes ? 1 : -1; - int gravity = (cc->size->flags & PWinGravity) ? - cc->size->win_gravity : NorthWestGravity; + int dx = 0, dy = 0, mult = yes ? 1 : -1; + int gravity = (cc->size->flags & PWinGravity) ? + cc->size->win_gravity : NorthWestGravity; switch (gravity) { case NorthWestGravity: @@ -315,8 +314,8 @@ client_gravitate(struct client_ctx *cc, int yes) break; } - cc->geom.x += mult*dx; - cc->geom.y += mult*dy; + cc->geom.x += mult * dx; + cc->geom.y += mult * dy; } void @@ -388,7 +387,7 @@ client_raise(struct client_ctx *cc) void client_ptrwarp(struct client_ctx *cc) { - int x = cc->ptr.x, y = cc->ptr.y; + int x = cc->ptr.x, y = cc->ptr.y; if (x == -1 || y == -1) { x = cc->geom.width / 2; @@ -406,7 +405,7 @@ client_ptrwarp(struct client_ctx *cc) void client_ptrsave(struct client_ctx *cc) { - int x, y; + int x, y; xu_ptr_getpos(cc->pwin, &x, &y); if (_inwindowbounds(cc, x, y)) { @@ -442,7 +441,7 @@ client_unhide(struct client_ctx *cc) void client_draw_border(struct client_ctx *cc) { - struct screen_ctx *sc = CCTOSC(cc); + struct screen_ctx *sc = CCTOSC(cc); if (cc->active) { XSetWindowBackground(X_Dpy, cc->pwin, client_bg_pixel(cc)); @@ -464,8 +463,8 @@ client_draw_border(struct client_ctx *cc) u_long client_bg_pixel(struct client_ctx *cc) { - struct screen_ctx *sc = CCTOSC(cc); - u_long pixl; + struct screen_ctx *sc = CCTOSC(cc); + u_long pixl; switch (cc->highlight) { case CLIENT_HIGHLIGHT_BLUE: @@ -485,8 +484,8 @@ client_bg_pixel(struct client_ctx *cc) Pixmap client_bg_pixmap(struct client_ctx *cc) { - struct screen_ctx *sc = CCTOSC(cc); - Pixmap pix; + struct screen_ctx *sc = CCTOSC(cc); + Pixmap pix; switch (cc->highlight) { case CLIENT_HIGHLIGHT_BLUE: @@ -506,9 +505,9 @@ client_bg_pixmap(struct client_ctx *cc) void client_update(struct client_ctx *cc) { - Atom *p, wm_delete, wm_protocols, wm_take_focus; - int i; - long n; + Atom *p, wm_delete, wm_protocols, wm_take_focus; + int i; + long n; /* XXX cache these. */ wm_delete = XInternAtom(X_Dpy, "WM_DELETE_WINDOW", False); @@ -531,7 +530,7 @@ client_update(struct client_ctx *cc) void client_send_delete(struct client_ctx *cc) { - Atom wm_delete, wm_protocols; + Atom wm_delete, wm_protocols; /* XXX - cache */ wm_delete = XInternAtom(X_Dpy, "WM_DELETE_WINDOW", False); @@ -546,8 +545,8 @@ client_send_delete(struct client_ctx *cc) void client_setname(struct client_ctx *cc) { - char *newname; - struct winname *wn; + struct winname *wn; + char *newname; XFetchName(X_Dpy, cc->win, &newname); if (newname == NULL) @@ -586,10 +585,13 @@ match: struct client_ctx * client_cycle(int reverse) { - struct client_ctx *oldcc = client_current(), *newcc; - struct screen_ctx *sc = screen_current(); + struct client_ctx *oldcc, *newcc; + struct screen_ctx *sc; int again = 1; + oldcc = client_current(); + sc = screen_current(); + /* If no windows then you cant cycle */ if (TAILQ_EMPTY(&sc->mruq)) return (NULL); @@ -629,8 +631,8 @@ client_cycle(int reverse) struct client_ctx * client_mrunext(struct client_ctx *cc) { - struct screen_ctx *sc = CCTOSC(cc); - struct client_ctx *ccc; + struct screen_ctx *sc = CCTOSC(cc); + struct client_ctx *ccc; return ((ccc = TAILQ_NEXT(cc, mru_entry)) != NULL ? ccc : TAILQ_FIRST(&sc->mruq)); @@ -639,8 +641,8 @@ client_mrunext(struct client_ctx *cc) struct client_ctx * client_mruprev(struct client_ctx *cc) { - struct screen_ctx *sc = CCTOSC(cc); - struct client_ctx *ccc; + struct screen_ctx *sc = CCTOSC(cc); + struct client_ctx *ccc; return ((ccc = TAILQ_PREV(cc, cycle_entry_q, mru_entry)) != NULL ? ccc : TAILQ_LAST(&sc->mruq, cycle_entry_q)); @@ -649,16 +651,16 @@ client_mruprev(struct client_ctx *cc) void client_placecalc(struct client_ctx *cc) { - struct screen_ctx *sc = CCTOSC(cc); - int yslack, xslack, xmouse, ymouse; + struct screen_ctx *sc = CCTOSC(cc); + int yslack, xslack, xmouse, ymouse; yslack = sc->ymax - cc->geom.height - cc->bwidth; xslack = sc->xmax - cc->geom.width - cc->bwidth; xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse); - xmouse = MAX(xmouse, cc->bwidth) - cc->geom.width/2; - ymouse = MAX(ymouse, cc->bwidth) - cc->geom.height/2; + xmouse = MAX(xmouse, cc->bwidth) - cc->geom.width / 2; + ymouse = MAX(ymouse, cc->bwidth) - cc->geom.height / 2; xmouse = MAX(xmouse, (int)cc->bwidth); ymouse = MAX(ymouse, (int)cc->bwidth); @@ -700,9 +702,11 @@ client_vertmaximize(struct client_ctx *cc) if (cc->flags & CLIENT_VMAXIMIZED) { cc->geom = cc->savegeom; } else { - struct screen_ctx *sc = CCTOSC(cc); - int display_height = DisplayHeight(X_Dpy, sc->which) - - cc->bwidth*2; + struct screen_ctx *sc = CCTOSC(cc); + int display_height; + + display_height = DisplayHeight(X_Dpy, sc->which) - + cc->bwidth * 2; if (!(cc->flags & CLIENT_MAXIMIZED)) cc->savegeom = cc->geom; @@ -718,7 +722,7 @@ client_vertmaximize(struct client_ctx *cc) void client_mtf(struct client_ctx *cc) { - struct screen_ctx *sc; + struct screen_ctx *sc; if (cc == NULL) cc = _curcc; @@ -735,11 +739,11 @@ client_mtf(struct client_ctx *cc) void client_gethints(struct client_ctx *cc) { - XClassHint xch; - int argc; - char **argv; - Atom mha; - struct mwm_hints *mwmh; + XClassHint xch; + int argc; + char **argv; + Atom mha; + struct mwm_hints *mwmh; if (XGetClassHint(X_Dpy, cc->win, &xch)) { if (xch.res_name != NULL) @@ -758,9 +762,8 @@ client_gethints(struct client_ctx *cc) if (XGetCommand(X_Dpy, cc->win, &argv, &argc)) { #define MAX_ARGLEN 512 #define ARG_SEP_ " " - int len = MAX_ARGLEN; - int i, o; - char *buf; + int i, o, len = MAX_ARGLEN; + char *buf; buf = xmalloc(len); buf[0] = '\0'; diff --git a/app/cwm/conf.c b/app/cwm/conf.c index c10a18299..88609544f 100644 --- a/app/cwm/conf.c +++ b/app/cwm/conf.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: conf.c,v 1.46 2008/06/25 22:44:42 oga Exp $ + * $Id: conf.c,v 1.47 2008/07/11 14:21:28 okan Exp $ */ #include "headers.h" @@ -53,7 +53,9 @@ conf_cmd_add(struct conf *c, char *image, char *label, int flags) void conf_font(struct conf *c) { - struct screen_ctx *sc = screen_current(); + struct screen_ctx *sc; + + sc = screen_current(); c->DefaultFont = font_make(sc, Conf.DefaultFontName); c->FontHeight = font_ascent() + font_descent() + 1; @@ -62,9 +64,9 @@ conf_font(struct conf *c) int conf_changed(char *path) { - static struct timespec old_ts; - struct stat sb; - int changed; + static struct timespec old_ts; + struct stat sb; + int changed; /* If the file does not exist we pretend that nothing changed */ if (stat(path, &sb) == -1 || !(sb.st_mode & S_IFREG)) @@ -178,7 +180,7 @@ conf_init(struct conf *c) void conf_setup(struct conf *c, const char *conf_file) { - struct stat sb; + struct stat sb; if (conf_file == NULL) { char *home = getenv("HOME"); @@ -310,9 +312,9 @@ struct { void conf_bindname(struct conf *c, char *name, char *binding) { - int iter; - struct keybinding *current_binding; - char *substring; + struct keybinding *current_binding; + char *substring; + int iter; XCALLOC(current_binding, struct keybinding); @@ -356,7 +358,7 @@ conf_bindname(struct conf *c, char *name, char *binding) /* We now have the correct binding, remove duplicates. */ conf_unbind(c, current_binding); - if (strcmp("unmap",binding) == 0) + if (strcmp("unmap", binding) == 0) return; for (iter = 0; name_to_kbfunc[iter].tag != NULL; iter++) { @@ -379,7 +381,7 @@ conf_bindname(struct conf *c, char *name, char *binding) void conf_unbind(struct conf *c, struct keybinding *unbind) { - struct keybinding *key = NULL, *keynxt; + struct keybinding *key = NULL, *keynxt; for (key = TAILQ_FIRST(&c->keybindingq); key != TAILQ_END(&c->keybindingq); key = keynxt) { @@ -417,10 +419,10 @@ struct { void conf_mousebind(struct conf *c, char *name, char *binding) { - int iter; - struct mousebinding *current_binding; - char *substring; - const char *errstr; + struct mousebinding *current_binding; + char *substring; + const char *errstr; + int iter; XCALLOC(current_binding, struct mousebinding); @@ -468,7 +470,7 @@ conf_mousebind(struct conf *c, char *name, char *binding) void conf_mouseunbind(struct conf *c, struct mousebinding *unbind) { - struct mousebinding *mb = NULL, *mbnxt; + struct mousebinding *mb = NULL, *mbnxt; for (mb = TAILQ_FIRST(&c->mousebindingq); mb != TAILQ_END(&c->mousebindingq); mb = mbnxt) { @@ -492,7 +494,6 @@ conf_grab_mouse(struct client_ctx *cc) { struct mousebinding *mb; int button; - TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) { if (mb->context != MOUSEBIND_CTX_WIN) diff --git a/app/cwm/font.c b/app/cwm/font.c index 85f54e597..ea200e55e 100644 --- a/app/cwm/font.c +++ b/app/cwm/font.c @@ -22,7 +22,7 @@ void font_init(struct screen_ctx *sc) { - XColor xcolor, tmp; + XColor xcolor, tmp; sc->xftdraw = XftDrawCreate(X_Dpy, sc->rootwin, DefaultVisual(X_Dpy, sc->which), DefaultColormap(X_Dpy, sc->which)); @@ -43,7 +43,8 @@ font_init(struct screen_ctx *sc) int font_width(const char *text, int len) { - XGlyphInfo extents; + XGlyphInfo extents; + XftTextExtents8(X_Dpy, Conf.DefaultFont, (const XftChar8*)text, len, &extents); @@ -63,9 +64,9 @@ font_draw(struct screen_ctx *sc, const char *text, int len, XftFont * font_make(struct screen_ctx *sc, const char *name) { - XftFont *fn = NULL; - FcPattern *pat, *patx; - XftResult res; + XftFont *fn = NULL; + FcPattern *pat, *patx; + XftResult res; if ((pat = FcNameParse(name)) == NULL) return (NULL); diff --git a/app/cwm/grab.c b/app/cwm/grab.c index 1c5ef2d70..12f55c936 100644 --- a/app/cwm/grab.c +++ b/app/cwm/grab.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: grab.c,v 1.19 2008/06/15 02:47:46 oga Exp $ + * $Id: grab.c,v 1.20 2008/07/11 14:21:28 okan Exp $ */ #include "headers.h" @@ -29,10 +29,10 @@ static int _sweepcalc(struct client_ctx *, int, int, int, int); void grab_sweep_draw(struct client_ctx *cc, int dx, int dy) { - struct screen_ctx *sc = CCTOSC(cc); - int x0 = cc->geom.x, y0 = cc->geom.y; - char asize[10]; /* fits "nnnnxnnnn\0" */ - int wide, height, wide_size, wide_name; + struct screen_ctx *sc = CCTOSC(cc); + char asize[10]; /* fits "nnnnxnnnn\0" */ + int wide, height, wide_size, wide_name; + int x = cc->geom.x, y = cc->geom.y; snprintf(asize, sizeof(asize), "%dx%d", ADJUST_WIDTH(cc, dx), ADJUST_HEIGHT(cc, dy)); @@ -41,23 +41,22 @@ grab_sweep_draw(struct client_ctx *cc, int dx, int dy) wide = MAX(wide_size, wide_name); height = font_ascent() + font_descent() + 1; - XMoveResizeWindow(X_Dpy, sc->menuwin, x0, y0, wide, height * 2); + XMoveResizeWindow(X_Dpy, sc->menuwin, x, y, wide, height * 2); XMapWindow(X_Dpy, sc->menuwin); XReparentWindow(X_Dpy, sc->menuwin, cc->win, 0, 0); XClearWindow(X_Dpy, sc->menuwin); font_draw(sc, cc->name, strlen(cc->name), sc->menuwin, 2, font_ascent() + 1); font_draw(sc, asize, strlen(asize), sc->menuwin, - wide/2 - wide_size/2, height + font_ascent() + 1); + wide / 2 - wide_size / 2, height + font_ascent() + 1); } void grab_sweep(struct client_ctx *cc) { - XEvent ev; - struct screen_ctx *sc = CCTOSC(cc); - int x0 = cc->geom.x, y0 = cc->geom.y; - int dx, dy; + XEvent ev; + struct screen_ctx *sc = CCTOSC(cc); + int x = cc->geom.x, y = cc->geom.y, dx, dy; dx = MAX(1, cc->size->width_inc); dy = MAX(1, cc->size->height_inc); @@ -80,7 +79,7 @@ grab_sweep(struct client_ctx *cc) client_draw_border(cc); break; case MotionNotify: - if (_sweepcalc(cc, x0, y0, ev.xmotion.x, ev.xmotion.y)) + if (_sweepcalc(cc, x, y, ev.xmotion.x, ev.xmotion.y)) /* Recompute window output */ grab_sweep_draw(cc, dx, dy); @@ -116,9 +115,9 @@ grab_sweep(struct client_ctx *cc) void grab_drag(struct client_ctx *cc) { - int x0 = cc->geom.x, y0 = cc->geom.y, xm, ym; - struct screen_ctx *sc = CCTOSC(cc); - XEvent ev; + XEvent ev; + struct screen_ctx *sc = CCTOSC(cc); + int x = cc->geom.x, y = cc->geom.y, xm, ym; client_raise(cc); @@ -135,8 +134,8 @@ grab_drag(struct client_ctx *cc) client_draw_border(cc); break; case MotionNotify: - cc->geom.x = x0 + (ev.xmotion.x - xm); - cc->geom.y = y0 + (ev.xmotion.y - ym); + cc->geom.x = x + (ev.xmotion.x - xm); + cc->geom.y = y + (ev.xmotion.y - ym); XMoveWindow(X_Dpy, cc->pwin, cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth); @@ -151,15 +150,15 @@ grab_drag(struct client_ctx *cc) } static int -_sweepcalc(struct client_ctx *cc, int x0, int y0, int motionx, int motiony) +_sweepcalc(struct client_ctx *cc, int x, int y, int motionx, int motiony) { - int width, height; + int width, height; width = cc->geom.width; height = cc->geom.height; - cc->geom.width = abs(x0 - motionx); - cc->geom.height = abs(y0 - motiony); + cc->geom.width = abs(x - motionx); + cc->geom.height = abs(y - motiony); if (cc->size->flags & PResizeInc) { cc->geom.width -= @@ -178,8 +177,8 @@ _sweepcalc(struct client_ctx *cc, int x0, int y0, int motionx, int motiony) cc->geom.height = MIN(cc->geom.height, cc->size->max_height); } - cc->geom.x = x0 <= motionx ? x0 : x0 - cc->geom.width; - cc->geom.y = y0 <= motiony ? y0 : y0 - cc->geom.height; + cc->geom.x = x <= motionx ? x : x - cc->geom.width; + cc->geom.y = y <= motiony ? y : y - cc->geom.height; return (width != cc->geom.width || height != cc->geom.height); } diff --git a/app/cwm/group.c b/app/cwm/group.c index 1be7cd1ab..1950b0cbb 100644 --- a/app/cwm/group.c +++ b/app/cwm/group.c @@ -16,7 +16,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: group.c,v 1.17 2008/05/21 14:11:19 oga Exp $ + * $Id: group.c,v 1.18 2008/07/11 14:21:28 okan Exp $ */ #include "headers.h" @@ -58,7 +58,7 @@ _group_remove(struct client_ctx *cc) static void _group_hide(struct group_ctx *gc) { - struct client_ctx *cc; + struct client_ctx *cc; screen_updatestackingorder(); @@ -76,10 +76,10 @@ _group_hide(struct group_ctx *gc) static void _group_show(struct group_ctx *gc) { - struct client_ctx *cc; - Window *winlist; - u_int i; - int lastempty = -1; + struct client_ctx *cc; + Window *winlist; + u_int i; + int lastempty = -1; winlist = (Window *) xcalloc(sizeof(*winlist), (gc->highstack + 1)); @@ -113,7 +113,7 @@ _group_show(struct group_ctx *gc) void group_init(void) { - int i; + int i; TAILQ_INIT(&Groupq); @@ -133,7 +133,9 @@ group_init(void) void group_sticky_toggle_enter(struct client_ctx *cc) { - struct group_ctx *gc = Group_active; + struct group_ctx *gc; + + gc = Group_active; if (gc == cc->group) { _group_remove(cc); @@ -162,8 +164,8 @@ group_sticky_toggle_exit(struct client_ctx *cc) void _group_fix_hidden_state(struct group_ctx *gc) { - struct client_ctx *cc; - int same = 0; + struct client_ctx *cc; + int same = 0; TAILQ_FOREACH(cc, &gc->clients, group_entry) { if (gc->hidden == ((cc->flags & CLIENT_HIDDEN) ? 1 : 0)) @@ -177,7 +179,7 @@ _group_fix_hidden_state(struct group_ctx *gc) void group_hidetoggle(int idx) { - struct group_ctx *gc; + struct group_ctx *gc; if (idx < 0 || idx >= CALMWM_NGROUPS) err(1, "group_hidetoggle: index out of range (%d)", idx); @@ -201,11 +203,10 @@ group_hidetoggle(int idx) void group_cycle(int reverse) { - struct group_ctx *gc, *showgroup = NULL; + struct group_ctx *gc, *showgroup = NULL; assert(Group_active != NULL); - gc = Group_active; for (;;) { gc = reverse ? TAILQ_PREV(gc, group_ctx_q, entry) : TAILQ_NEXT(gc, entry); @@ -246,10 +247,10 @@ group_client_delete(struct client_ctx *cc) void group_menu(XButtonEvent *e) { - struct menu_q menuq; + struct group_ctx *gc; struct menu *mi; + struct menu_q menuq; int i; - struct group_ctx *gc; TAILQ_INIT(&menuq); @@ -295,7 +296,7 @@ cleanup: void group_alltoggle(void) { - int i; + int i; for (i = 0; i < CALMWM_NGROUPS; i++) { if (Grouphideall) @@ -313,9 +314,9 @@ group_alltoggle(void) void group_autogroup(struct client_ctx *cc) { - struct autogroupwin *aw; - struct group_ctx *gc; - char group[CALMWM_MAXNAMELEN]; + struct autogroupwin *aw; + struct group_ctx *gc; + char group[CALMWM_MAXNAMELEN]; if (cc->app_class == NULL || cc->app_name == NULL) return; diff --git a/app/cwm/input.c b/app/cwm/input.c index 5cfae4e26..cb0884791 100644 --- a/app/cwm/input.c +++ b/app/cwm/input.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: input.c,v 1.6 2008/05/19 18:07:53 okan Exp $ + * $Id: input.c,v 1.7 2008/07/11 14:21:28 okan Exp $ */ #include "headers.h" @@ -24,7 +24,7 @@ int input_keycodetrans(KeyCode kc, u_int state, enum ctltype *ctl, char *chr) { - int ks; + int ks; *ctl = CTL_NONE; *chr = '\0'; diff --git a/app/cwm/kbfunc.c b/app/cwm/kbfunc.c index 73744a20b..e9f6f0791 100644 --- a/app/cwm/kbfunc.c +++ b/app/cwm/kbfunc.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: kbfunc.c,v 1.30 2008/06/25 00:52:47 oga Exp $ + * $Id: kbfunc.c,v 1.31 2008/07/11 14:21:28 okan Exp $ */ #include <paths.h> @@ -46,10 +46,11 @@ kbfunc_client_raise(struct client_ctx *cc, void *arg) void kbfunc_moveresize(struct client_ctx *cc, void *arg) { - struct screen_ctx *sc = screen_current(); + struct screen_ctx *sc; int x, y, flags, amt; u_int mx, my; + sc = screen_current(); mx = my = 0; flags = (int)arg; @@ -121,15 +122,16 @@ kbfunc_moveresize(struct client_ctx *cc, void *arg) default: warnx("invalid flags passed to kbfunc_client_moveresize"); } - } void kbfunc_client_search(struct client_ctx *scratch, void *arg) { - struct menu_q menuq; - struct client_ctx *cc, *old_cc = client_current(); + struct client_ctx *cc, *old_cc; struct menu *mi; + struct menu_q menuq; + + old_cc = client_current(); TAILQ_INIT(&menuq); @@ -160,9 +162,9 @@ kbfunc_client_search(struct client_ctx *scratch, void *arg) void kbfunc_menu_search(struct client_ctx *scratch, void *arg) { - struct menu_q menuq; - struct menu *mi; struct cmd *cmd; + struct menu *mi; + struct menu_q menuq; TAILQ_INIT(&menuq); @@ -187,7 +189,9 @@ kbfunc_menu_search(struct client_ctx *scratch, void *arg) void kbfunc_client_cycle(struct client_ctx *scratch, void *arg) { - struct screen_ctx *sc = screen_current(); + struct screen_ctx *sc; + + sc = screen_current(); /* XXX for X apps that ignore events */ XGrabKeyboard(X_Dpy, sc->rootwin, True, @@ -226,16 +230,16 @@ void kbfunc_exec(struct client_ctx *scratch, void *arg) { #define NPATHS 256 - char **ap, *paths[NPATHS], *path, *pathcpy, tpath[MAXPATHLEN]; - int l, i, j, ngroups; - gid_t mygroups[NGROUPS_MAX]; - uid_t ruid, euid, suid; - DIR *dirp; - struct dirent *dp; - struct stat sb; - struct menu_q menuq; - struct menu *mi; - char *label; + char **ap, *paths[NPATHS], *path, *pathcpy, *label; + char tpath[MAXPATHLEN]; + int l, i, j, ngroups; + gid_t mygroups[NGROUPS_MAX]; + uid_t ruid, euid, suid; + DIR *dirp; + struct dirent *dp; + struct menu *mi; + struct menu_q menuq; + struct stat sb; int cmd = (int)arg; switch (cmd) { @@ -308,7 +312,7 @@ kbfunc_exec(struct client_ctx *scratch, void *arg) strlcpy(mi->text, dp->d_name, sizeof(mi->text)); TAILQ_INSERT_TAIL(&menuq, mi, entry); } - (void) closedir(dirp); + (void)closedir(dirp); } xfree(path); @@ -339,13 +343,14 @@ kbfunc_exec(struct client_ctx *scratch, void *arg) void kbfunc_ssh(struct client_ctx *scratch, void *arg) { - struct menu_q menuq; - struct menu *mi; - FILE *fp; - size_t len; - char *buf, *lbuf, *p, *home; - char hostbuf[MAXHOSTNAMELEN], filename[MAXPATHLEN], cmd[256]; - int l; + struct menu *mi; + struct menu_q menuq; + FILE *fp; + char *buf, *lbuf, *p, *home; + char hostbuf[MAXHOSTNAMELEN], filename[MAXPATHLEN]; + char cmd[256]; + int l; + size_t len; if ((home = getenv("HOME")) == NULL) return; @@ -386,7 +391,6 @@ kbfunc_ssh(struct client_ctx *scratch, void *arg) xfree(lbuf); fclose(fp); - if ((mi = menu_filter(&menuq, "ssh", NULL, 1, search_match_exec, NULL)) != NULL) { conf_reload(&Conf); @@ -408,8 +412,8 @@ void kbfunc_client_label(struct client_ctx *cc, void *arg) { struct menu *mi; - char *current; struct menu_q menuq; + char *current; TAILQ_INIT(&menuq); diff --git a/app/cwm/menu.c b/app/cwm/menu.c index 6db9a535f..5b60b674a 100644 --- a/app/cwm/menu.c +++ b/app/cwm/menu.c @@ -67,7 +67,7 @@ menu_filter(struct menu_q *menuq, char *prompt, char *initial, int dummy, void (*match)(struct menu_q *, struct menu_q *, char *), void (*print)(struct menu *, int)) { - struct screen_ctx *sc = screen_current(); + struct screen_ctx *sc; struct menu_ctx mc; struct menu_q resultq; struct menu *mi = NULL; @@ -75,6 +75,8 @@ menu_filter(struct menu_q *menuq, char *prompt, char *initial, int dummy, Window focuswin; int Mask, focusrevert; + sc = screen_current(); + TAILQ_INIT(&resultq); bzero(&mc, sizeof(mc)); @@ -255,10 +257,7 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq) { struct menu *mi; - int n = 0; - int dy; - int xsave, ysave; - int warp; + int n, dy, xsave, ysave; if (mc->list) { if (TAILQ_EMPTY(resultq) && mc->list) { @@ -388,10 +387,12 @@ menu_handle_release(XEvent *e, struct menu_ctx *mc, struct screen_ctx *sc, static int menu_calc_entry(struct screen_ctx *sc, struct menu_ctx *mc, int x, int y) { - int entry = y / font_height(); + int entry; + + entry = y / font_height(); /* in bounds? */ - if (x < 0 || x > mc->width || y < 0 || y > font_height()*mc->num || + if (x < 0 || x > mc->width || y < 0 || y > font_height() * mc->num || entry < 0 || entry >= mc->num) entry = -1; diff --git a/app/cwm/mousefunc.c b/app/cwm/mousefunc.c index e4e8e9b07..e0b6b575d 100644 --- a/app/cwm/mousefunc.c +++ b/app/cwm/mousefunc.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: mousefunc.c,v 1.2 2008/06/25 22:44:42 oga Exp $ + * $Id: mousefunc.c,v 1.3 2008/07/11 14:21:28 okan Exp $ */ #include "headers.h" @@ -63,10 +63,12 @@ mousefunc_menu_group(struct client_ctx *cc, void *arg) void mousefunc_menu_unhide(struct client_ctx *cc, void *arg) { - struct menu *mi; - struct menu_q menuq; - char *wname; - struct client_ctx *old_cc = client_current(); + struct client_ctx *old_cc; + struct menu *mi; + struct menu_q menuq; + char *wname; + + old_cc = client_current(); TAILQ_INIT(&menuq); TAILQ_FOREACH(cc, &Clientq, entry) @@ -96,19 +98,21 @@ mousefunc_menu_unhide(struct client_ctx *cc, void *arg) if (old_cc != NULL) client_ptrsave(old_cc); client_ptrwarp(cc); - } else + } else { while ((mi = TAILQ_FIRST(&menuq)) != NULL) { TAILQ_REMOVE(&menuq, mi, entry); xfree(mi); } + } } void mousefunc_menu_cmd(struct client_ctx *cc, void *arg) { - struct menu *mi; - struct menu_q menuq; - struct cmd *cmd; + struct menu *mi; + struct menu_q menuq; + struct cmd *cmd; + conf_reload(&Conf); TAILQ_INIT(&menuq); diff --git a/app/cwm/screen.c b/app/cwm/screen.c index 76cc8439f..9ecf699b3 100644 --- a/app/cwm/screen.c +++ b/app/cwm/screen.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: screen.c,v 1.6 2008/05/01 18:01:13 oga Exp $ + * $Id: screen.c,v 1.7 2008/07/11 14:21:28 okan Exp $ */ #include "headers.h" @@ -27,7 +27,7 @@ extern struct screen_ctx *Curscreen; struct screen_ctx * screen_fromroot(Window rootwin) { - struct screen_ctx *sc; + struct screen_ctx *sc; TAILQ_FOREACH(sc, &Screenq, entry) if (sc->rootwin == rootwin) @@ -46,10 +46,12 @@ screen_current(void) void screen_updatestackingorder(void) { - Window *wins, w0, w1; - struct screen_ctx *sc = screen_current(); - u_int nwins, i, s; - struct client_ctx *cc; + Window *wins, w0, w1; + struct screen_ctx *sc; + struct client_ctx *cc; + u_int nwins, i, s; + + sc = screen_current(); if (!XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins)) return; diff --git a/app/cwm/search.c b/app/cwm/search.c index 697c4d9a4..93d60195b 100644 --- a/app/cwm/search.c +++ b/app/cwm/search.c @@ -14,7 +14,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: search.c,v 1.11 2008/05/20 14:50:51 oga Exp $ + * $Id: search.c,v 1.12 2008/07/11 14:21:28 okan Exp $ */ #include "headers.h" @@ -31,9 +31,11 @@ static int _strsubmatch(char *, char *, int); void search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search) { - struct winname *wn; - struct menu *mi, *tierp[4], *before = NULL; - int ntiers = sizeof(tierp)/sizeof(tierp[0]); + struct winname *wn; + struct menu *mi, *tierp[4], *before = NULL; + int ntiers; + + ntiers = sizeof(tierp) / sizeof(tierp[0]); TAILQ_INIT(resultq); @@ -119,8 +121,10 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search) void search_print_client(struct menu *mi, int list) { - struct client_ctx *cc = mi->ctx; - char flag = ' '; + struct client_ctx *cc; + char flag = ' '; + + cc = mi->ctx; if (cc == client_current()) flag = '!'; @@ -134,9 +138,11 @@ search_print_client(struct menu *mi, int list) if (!list && cc->matchname != cc->name && strlen(mi->print) < sizeof(mi->print) - 1) { - int diff = sizeof(mi->print) - 1 - strlen(mi->print); - const char *marker = ""; - char buf[MENU_MAXENTRY + 1]; + const char *marker = ""; + char buf[MENU_MAXENTRY + 1]; + int diff; + + diff = sizeof(mi->print) - 1 - strlen(mi->print); /* One for the ':' */ diff -= 1; @@ -157,7 +163,7 @@ search_print_client(struct menu *mi, int list) void search_match_text(struct menu_q *menuq, struct menu_q *resultq, char *search) { - struct menu *mi; + struct menu *mi; TAILQ_INIT(resultq); @@ -169,7 +175,7 @@ search_match_text(struct menu_q *menuq, struct menu_q *resultq, char *search) void search_match_exec(struct menu_q *menuq, struct menu_q *resultq, char *search) { - struct menu *mi; + struct menu *mi; TAILQ_INIT(resultq); @@ -181,8 +187,8 @@ search_match_exec(struct menu_q *menuq, struct menu_q *resultq, char *search) static int _strsubmatch(char *sub, char *str, int zeroidx) { - size_t len, sublen; - u_int n, flen; + size_t len, sublen; + u_int n, flen; if (sub == NULL || str == NULL) return (0); @@ -197,6 +203,7 @@ _strsubmatch(char *sub, char *str, int zeroidx) flen = len - sublen; else flen = 0; + for (n = 0; n <= flen; n++) if (strncasecmp(sub, str + n, sublen) == 0) return (1); diff --git a/app/cwm/util.c b/app/cwm/util.c index 4c55924d0..e9c0591d1 100644 --- a/app/cwm/util.c +++ b/app/cwm/util.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: util.c,v 1.9 2008/05/15 22:18:00 oga Exp $ + * $Id: util.c,v 1.10 2008/07/11 14:21:28 okan Exp $ */ #include "headers.h" @@ -44,9 +44,8 @@ u_spawn(char *argstr) void u_exec(char *argstr) { - char *args[MAXARGLEN], **ap = args; - char **end = &args[MAXARGLEN - 1]; - char *tmp; + char *args[MAXARGLEN], **ap = args; + char **end = &args[MAXARGLEN - 1], *tmp; while (ap < end && (*ap = strsep(&argstr, " \t")) != NULL) { if (**ap == '\0') diff --git a/app/cwm/xevents.c b/app/cwm/xevents.c index 1db01ae76..3efb3ba18 100644 --- a/app/cwm/xevents.c +++ b/app/cwm/xevents.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: xevents.c,v 1.24 2008/06/18 19:09:12 oga Exp $ + * $Id: xevents.c,v 1.25 2008/07/11 14:21:28 okan Exp $ */ /* @@ -35,15 +35,16 @@ void xev_handle_maprequest(struct xevent *xev, XEvent *ee) { - XMapRequestEvent *e = &ee->xmaprequest; - struct client_ctx *cc = NULL, *old_cc = client_current(); - XWindowAttributes xattr; - struct screen_ctx *sc; + XMapRequestEvent *e = &ee->xmaprequest; + XWindowAttributes xattr; + struct client_ctx *cc = NULL, *old_cc; + struct screen_ctx *sc; + #ifdef notyet int state; #endif - if (old_cc != NULL) + if ((old_cc = client_current()) != NULL) client_ptrsave(old_cc); if ((cc = client_find(e->window)) == NULL) { @@ -66,8 +67,8 @@ xev_handle_maprequest(struct xevent *xev, XEvent *ee) void xev_handle_unmapnotify(struct xevent *xev, XEvent *ee) { - XUnmapEvent *e = &ee->xunmap; - struct client_ctx *cc; + XUnmapEvent *e = &ee->xunmap; + struct client_ctx *cc; if ((cc = client_find(e->window)) != NULL) client_delete(cc, e->send_event, 0); @@ -78,8 +79,8 @@ xev_handle_unmapnotify(struct xevent *xev, XEvent *ee) void xev_handle_destroynotify(struct xevent *xev, XEvent *ee) { - XDestroyWindowEvent *e = &ee->xdestroywindow; - struct client_ctx *cc; + XDestroyWindowEvent *e = &ee->xdestroywindow; + struct client_ctx *cc; if ((cc = client_find(e->window)) != NULL) client_delete(cc, 1, 1); @@ -90,10 +91,10 @@ xev_handle_destroynotify(struct xevent *xev, XEvent *ee) void xev_handle_configurerequest(struct xevent *xev, XEvent *ee) { - XConfigureRequestEvent *e = &ee->xconfigurerequest; - struct client_ctx *cc; - struct screen_ctx *sc; - XWindowChanges wc; + XConfigureRequestEvent *e = &ee->xconfigurerequest; + struct client_ctx *cc; + struct screen_ctx *sc; + XWindowChanges wc; if ((cc = client_find(e->window)) != NULL) { sc = CCTOSC(cc); @@ -146,9 +147,9 @@ xev_handle_configurerequest(struct xevent *xev, XEvent *ee) void xev_handle_propertynotify(struct xevent *xev, XEvent *ee) { - XPropertyEvent *e = &ee->xproperty; - struct client_ctx *cc; - long tmp; + XPropertyEvent *e = &ee->xproperty; + struct client_ctx *cc; + long tmp; if ((cc = client_find(e->window)) != NULL) { switch (e->atom) { @@ -170,7 +171,7 @@ xev_handle_propertynotify(struct xevent *xev, XEvent *ee) void xev_reconfig(struct client_ctx *cc) { - XConfigureEvent ce; + XConfigureEvent ce; ce.type = ConfigureNotify; ce.event = cc->win; @@ -189,8 +190,8 @@ xev_reconfig(struct client_ctx *cc) void xev_handle_enternotify(struct xevent *xev, XEvent *ee) { - XCrossingEvent *e = &ee->xcrossing; - struct client_ctx *cc; + XCrossingEvent *e = &ee->xcrossing; + struct client_ctx *cc; if ((cc = client_find(e->window)) == NULL) { /* @@ -222,10 +223,11 @@ xev_handle_buttonpress(struct xevent *xev, XEvent *ee) { XButtonEvent *e = &ee->xbutton; struct client_ctx *cc; - struct screen_ctx *sc = screen_fromroot(e->root); + struct screen_ctx *sc; struct mousebinding *mb; char *wname; + sc = screen_fromroot(e->root); cc = client_find(e->window); /* Ignore caps lock and numlock */ @@ -256,9 +258,9 @@ out: void xev_handle_buttonrelease(struct xevent *xev, XEvent *ee) { - struct client_ctx *cc = client_current(); + struct client_ctx *cc; - if (cc != NULL) + if ((cc = client_current()) != NULL) group_sticky_toggle_exit(cc); xev_register(xev); @@ -267,11 +269,11 @@ xev_handle_buttonrelease(struct xevent *xev, XEvent *ee) void xev_handle_keypress(struct xevent *xev, XEvent *ee) { - XKeyEvent *e = &ee->xkey; - struct client_ctx *cc = NULL; /* Make gcc happy. */ - struct keybinding *kb; - KeySym keysym, skeysym; - int modshift; + XKeyEvent *e = &ee->xkey; + struct client_ctx *cc = NULL; + struct keybinding *kb; + KeySym keysym, skeysym; + int modshift; keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0); skeysym = XKeycodeToKeysym(X_Dpy, e->keycode, 1); @@ -315,10 +317,13 @@ out: void xev_handle_keyrelease(struct xevent *xev, XEvent *ee) { - XKeyEvent *e = &ee->xkey; - struct screen_ctx *sc = screen_fromroot(e->root); - struct client_ctx *cc = client_current(); - int keysym; + XKeyEvent *e = &ee->xkey; + struct screen_ctx *sc; + struct client_ctx *cc; + int keysym; + + sc = screen_fromroot(e->root); + cc = client_current(); keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0); if (keysym != XK_Alt_L && keysym != XK_Alt_R) @@ -344,11 +349,13 @@ out: void xev_handle_clientmessage(struct xevent *xev, XEvent *ee) { - XClientMessageEvent *e = &ee->xclient; - struct client_ctx *cc = client_find(e->window); - Atom xa_wm_change_state = XInternAtom(X_Dpy, "WM_CHANGE_STATE", False); + XClientMessageEvent *e = &ee->xclient; + Atom xa_wm_change_state; + struct client_ctx *cc; - if (cc == NULL) + xa_wm_change_state = XInternAtom(X_Dpy, "WM_CHANGE_STATE", False); + + if ((cc = client_find(e->window)) == NULL) goto out; if (e->message_type == xa_wm_change_state && e->format == 32 && @@ -361,8 +368,8 @@ out: void xev_handle_shape(struct xevent *xev, XEvent *ee) { - XShapeEvent *sev = (XShapeEvent *) ee; - struct client_ctx *cc; + XShapeEvent *sev = (XShapeEvent *) ee; + struct client_ctx *cc; if ((cc = client_find(sev->window)) != NULL) client_do_shape(cc); @@ -387,7 +394,7 @@ struct xevent * xev_new(Window *win, Window *root, int type, void (*cb)(struct xevent *, XEvent *), void *arg) { - struct xevent *xev; + struct xevent *xev; XMALLOC(xev, struct xevent); xev->xev_win = win; @@ -402,7 +409,7 @@ xev_new(Window *win, Window *root, void xev_register(struct xevent *xev) { - struct xevent_q *xq; + struct xevent_q *xq; xq = _xev_q_lock ? &_xevq_putaway : &_xevq; TAILQ_INSERT_TAIL(xq, xev, entry); @@ -411,7 +418,7 @@ xev_register(struct xevent *xev) void _xev_reincorporate(void) { - struct xevent *xev; + struct xevent *xev; while ((xev = TAILQ_FIRST(&_xevq_putaway)) != NULL) { TAILQ_REMOVE(&_xevq_putaway, xev, entry); @@ -422,8 +429,8 @@ _xev_reincorporate(void) void xev_handle_expose(struct xevent *xev, XEvent *ee) { - XExposeEvent *e = &ee->xexpose; - struct client_ctx *cc; + XExposeEvent *e = &ee->xexpose; + struct client_ctx *cc; if ((cc = client_find(e->window)) != NULL && e->count == 0) { client_draw_border(cc); @@ -445,10 +452,10 @@ xev_handle_expose(struct xevent *xev, XEvent *ee) void xev_loop(void) { - Window win, root; + Window win, root; + XEvent e; + struct xevent *xev = NULL, *nextxev; int type; - XEvent e; - struct xevent *xev, *nextxev; while (_xev_quit == 0) { #ifdef DIAGNOSTIC diff --git a/app/cwm/xmalloc.c b/app/cwm/xmalloc.c index e454c24b7..22ff56c3c 100644 --- a/app/cwm/xmalloc.c +++ b/app/cwm/xmalloc.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: xmalloc.c,v 1.3 2008/04/16 13:38:09 oga Exp $ + * $Id: xmalloc.c,v 1.4 2008/07/11 14:21:28 okan Exp $ */ #include "headers.h" @@ -24,7 +24,7 @@ void * xmalloc(size_t siz) { - void *p; + void *p; if ((p = malloc(siz)) == NULL) err(1, "malloc"); @@ -35,7 +35,7 @@ xmalloc(size_t siz) void * xcalloc(size_t no, size_t siz) { - void *p; + void *p; if ((p = calloc(no, siz)) == NULL) err(1, "calloc"); @@ -52,7 +52,7 @@ xfree(void *p) char * xstrdup(const char *str) { - char *p; + char *p; if ((p = strdup(str)) == NULL) err(1, "strdup"); diff --git a/app/cwm/xutil.c b/app/cwm/xutil.c index a76d5c060..f6553f155 100644 --- a/app/cwm/xutil.c +++ b/app/cwm/xutil.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: xutil.c,v 1.7 2008/06/17 23:40:33 oga Exp $ + * $Id: xutil.c,v 1.8 2008/07/11 14:21:28 okan Exp $ */ #include "headers.h" @@ -65,9 +65,9 @@ xu_btn_ungrab(Window win, int mask, u_int btn) void xu_ptr_getpos(Window rootwin, int *x, int *y) { - int tmp0, tmp1; - u_int tmp2; - Window w0, w1; + Window w0, w1; + int tmp0, tmp1; + u_int tmp2; XQueryPointer(X_Dpy, rootwin, &w0, &w1, &tmp0, &tmp1, x, y, &tmp2); } @@ -81,8 +81,8 @@ xu_ptr_setpos(Window win, int x, int y) void xu_key_grab(Window win, int mask, int keysym) { - KeyCode code; - int i; + KeyCode code; + int i; code = XKeysymToKeycode(X_Dpy, keysym); if ((XKeycodeToKeysym(X_Dpy, code, 0) != keysym) && @@ -98,7 +98,7 @@ xu_key_grab(Window win, int mask, int keysym) void xu_sendmsg(struct client_ctx *cc, Atom atm, long val) { - XEvent e; + XEvent e; memset(&e, 0, sizeof(e)); e.xclient.type = ClientMessage; @@ -114,9 +114,9 @@ xu_sendmsg(struct client_ctx *cc, Atom atm, long val) int xu_getprop(struct client_ctx *cc, Atom atm, Atom type, long len, u_char **p) { - Atom realtype; - u_long n, extra; - int format; + Atom realtype; + u_long n, extra; + int format; if (XGetWindowProperty(X_Dpy, cc->win, atm, 0L, len, False, type, &realtype, &format, &n, &extra, p) != Success || *p == NULL) @@ -131,8 +131,10 @@ xu_getprop(struct client_ctx *cc, Atom atm, Atom type, long len, u_char **p) int xu_getstate(struct client_ctx *cc, int *state) { - Atom wm_state = XInternAtom(X_Dpy, "WM_STATE", False); - long *p = NULL; + Atom wm_state; + long *p = NULL; + + wm_state = XInternAtom(X_Dpy, "WM_STATE", False); if (xu_getprop(cc, wm_state, wm_state, 2L, (u_char **)&p) <= 0) return (-1); @@ -146,8 +148,8 @@ xu_getstate(struct client_ctx *cc, int *state) void xu_setstate(struct client_ctx *cc, int state) { - long dat[2]; - Atom wm_state; + Atom wm_state; + long dat[2]; /* XXX cache */ wm_state = XInternAtom(X_Dpy, "WM_STATE", False); |