spacing, declaration lineup to be consistent throughout cwm,

readability, and a bit of knf.

ok oga@
This commit is contained in:
okan 2008-07-11 14:21:28 +00:00
parent 734f45ab4b
commit b23fad3987
17 changed files with 293 additions and 264 deletions

View File

@ -44,16 +44,14 @@ struct conf Conf;
#define gray_height 2 #define gray_height 2
static char gray_bits[] = {0x02, 0x01}; static char gray_bits[] = {0x02, 0x01};
static void _sigchld_cb(int); static void _sigchld_cb(int);
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
int ch;
const char *conf_file = NULL; const char *conf_file = NULL;
char *display_name = NULL; char *display_name = NULL;
int ch;
while ((ch = getopt(argc, argv, "c:d:")) != -1) { while ((ch = getopt(argc, argv, "c:d:")) != -1) {
switch (ch) { switch (ch) {
@ -110,8 +108,8 @@ main(int argc, char **argv)
void void
x_setup(char *display_name) x_setup(char *display_name)
{ {
int i;
struct screen_ctx *sc; struct screen_ctx *sc;
int i;
TAILQ_INIT(&Screenq); TAILQ_INIT(&Screenq);
@ -143,10 +141,10 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
XColor tmp; XColor tmp;
XGCValues gv; XGCValues gv;
Window *wins, w0, w1; Window *wins, w0, w1;
u_int nwins, i = 0;
XWindowAttributes winattr; XWindowAttributes winattr;
XSetWindowAttributes rootattr; XSetWindowAttributes rootattr;
struct keybinding *kb; struct keybinding *kb;
u_int nwins, i;
Curscreen = sc; Curscreen = sc;

View File

@ -49,11 +49,11 @@ struct client_ctx *
client_new(Window win, struct screen_ctx *sc, int mapped) client_new(Window win, struct screen_ctx *sc, int mapped)
{ {
struct client_ctx *cc; struct client_ctx *cc;
long tmp;
XSetWindowAttributes pxattr; XSetWindowAttributes pxattr;
XWindowAttributes wattr; XWindowAttributes wattr;
int x, y, height, width, state;
XWMHints *wmhints; XWMHints *wmhints;
long tmp;
int x, y, height, width, state;
if (win == None) if (win == None)
return (NULL); return (NULL);
@ -127,7 +127,6 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
width += (cc->bwidth)*2; width += (cc->bwidth)*2;
height += (cc->bwidth)*2; height += (cc->bwidth)*2;
} }
pxattr.override_redirect = True; pxattr.override_redirect = True;
pxattr.background_pixel = sc->bgcolor.pixel; pxattr.background_pixel = sc->bgcolor.pixel;
pxattr.event_mask = ChildMask | ButtonPressMask | ButtonReleaseMask | pxattr.event_mask = ChildMask | ButtonPressMask | ButtonReleaseMask |
@ -203,8 +202,8 @@ client_delete(struct client_ctx *cc, int sendevent, int ignorewindow)
return (1); return (1);
group_client_delete(cc); group_client_delete(cc);
XGrabServer(X_Dpy);
XGrabServer(X_Dpy);
xu_setstate(cc, WithdrawnState); xu_setstate(cc, WithdrawnState);
XRemoveFromSaveSet(X_Dpy, cc->win); XRemoveFromSaveSet(X_Dpy, cc->win);
@ -251,8 +250,8 @@ client_leave(struct client_ctx *cc)
cc = _curcc; cc = _curcc;
if (cc == NULL) if (cc == NULL)
return; return;
sc = CCTOSC(cc);
sc = CCTOSC(cc);
xu_btn_ungrab(sc->rootwin, AnyModifier, Button1); xu_btn_ungrab(sc->rootwin, AnyModifier, Button1);
} }
@ -546,8 +545,8 @@ client_send_delete(struct client_ctx *cc)
void void
client_setname(struct client_ctx *cc) client_setname(struct client_ctx *cc)
{ {
char *newname;
struct winname *wn; struct winname *wn;
char *newname;
XFetchName(X_Dpy, cc->win, &newname); XFetchName(X_Dpy, cc->win, &newname);
if (newname == NULL) if (newname == NULL)
@ -586,10 +585,13 @@ match:
struct client_ctx * struct client_ctx *
client_cycle(int reverse) client_cycle(int reverse)
{ {
struct client_ctx *oldcc = client_current(), *newcc; struct client_ctx *oldcc, *newcc;
struct screen_ctx *sc = screen_current(); struct screen_ctx *sc;
int again = 1; int again = 1;
oldcc = client_current();
sc = screen_current();
/* If no windows then you cant cycle */ /* If no windows then you cant cycle */
if (TAILQ_EMPTY(&sc->mruq)) if (TAILQ_EMPTY(&sc->mruq))
return (NULL); return (NULL);
@ -701,7 +703,9 @@ client_vertmaximize(struct client_ctx *cc)
cc->geom = cc->savegeom; cc->geom = cc->savegeom;
} else { } else {
struct screen_ctx *sc = CCTOSC(cc); struct screen_ctx *sc = CCTOSC(cc);
int display_height = DisplayHeight(X_Dpy, sc->which) - int display_height;
display_height = DisplayHeight(X_Dpy, sc->which) -
cc->bwidth * 2; cc->bwidth * 2;
if (!(cc->flags & CLIENT_MAXIMIZED)) if (!(cc->flags & CLIENT_MAXIMIZED))
@ -758,8 +762,7 @@ client_gethints(struct client_ctx *cc)
if (XGetCommand(X_Dpy, cc->win, &argv, &argc)) { if (XGetCommand(X_Dpy, cc->win, &argv, &argc)) {
#define MAX_ARGLEN 512 #define MAX_ARGLEN 512
#define ARG_SEP_ " " #define ARG_SEP_ " "
int len = MAX_ARGLEN; int i, o, len = MAX_ARGLEN;
int i, o;
char *buf; char *buf;
buf = xmalloc(len); buf = xmalloc(len);

9
conf.c
View File

@ -53,7 +53,9 @@ conf_cmd_add(struct conf *c, char *image, char *label, int flags)
void void
conf_font(struct conf *c) 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->DefaultFont = font_make(sc, Conf.DefaultFontName);
c->FontHeight = font_ascent() + font_descent() + 1; c->FontHeight = font_ascent() + font_descent() + 1;
@ -310,9 +312,9 @@ struct {
void void
conf_bindname(struct conf *c, char *name, char *binding) conf_bindname(struct conf *c, char *name, char *binding)
{ {
int iter;
struct keybinding *current_binding; struct keybinding *current_binding;
char *substring; char *substring;
int iter;
XCALLOC(current_binding, struct keybinding); XCALLOC(current_binding, struct keybinding);
@ -417,10 +419,10 @@ struct {
void void
conf_mousebind(struct conf *c, char *name, char *binding) conf_mousebind(struct conf *c, char *name, char *binding)
{ {
int iter;
struct mousebinding *current_binding; struct mousebinding *current_binding;
char *substring; char *substring;
const char *errstr; const char *errstr;
int iter;
XCALLOC(current_binding, struct mousebinding); XCALLOC(current_binding, struct mousebinding);
@ -493,7 +495,6 @@ conf_grab_mouse(struct client_ctx *cc)
struct mousebinding *mb; struct mousebinding *mb;
int button; int button;
TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) { TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) {
if (mb->context != MOUSEBIND_CTX_WIN) if (mb->context != MOUSEBIND_CTX_WIN)
continue; continue;

1
font.c
View File

@ -44,6 +44,7 @@ int
font_width(const char *text, int len) font_width(const char *text, int len)
{ {
XGlyphInfo extents; XGlyphInfo extents;
XftTextExtents8(X_Dpy, Conf.DefaultFont, (const XftChar8*)text, XftTextExtents8(X_Dpy, Conf.DefaultFont, (const XftChar8*)text,
len, &extents); len, &extents);

27
grab.c
View File

@ -30,9 +30,9 @@ void
grab_sweep_draw(struct client_ctx *cc, int dx, int dy) grab_sweep_draw(struct client_ctx *cc, int dx, int dy)
{ {
struct screen_ctx *sc = CCTOSC(cc); struct screen_ctx *sc = CCTOSC(cc);
int x0 = cc->geom.x, y0 = cc->geom.y;
char asize[10]; /* fits "nnnnxnnnn\0" */ char asize[10]; /* fits "nnnnxnnnn\0" */
int wide, height, wide_size, wide_name; int wide, height, wide_size, wide_name;
int x = cc->geom.x, y = cc->geom.y;
snprintf(asize, sizeof(asize), "%dx%d", snprintf(asize, sizeof(asize), "%dx%d",
ADJUST_WIDTH(cc, dx), ADJUST_HEIGHT(cc, dy)); ADJUST_WIDTH(cc, dx), ADJUST_HEIGHT(cc, dy));
@ -41,7 +41,7 @@ grab_sweep_draw(struct client_ctx *cc, int dx, int dy)
wide = MAX(wide_size, wide_name); wide = MAX(wide_size, wide_name);
height = font_ascent() + font_descent() + 1; 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); XMapWindow(X_Dpy, sc->menuwin);
XReparentWindow(X_Dpy, sc->menuwin, cc->win, 0, 0); XReparentWindow(X_Dpy, sc->menuwin, cc->win, 0, 0);
XClearWindow(X_Dpy, sc->menuwin); XClearWindow(X_Dpy, sc->menuwin);
@ -56,8 +56,7 @@ grab_sweep(struct client_ctx *cc)
{ {
XEvent ev; XEvent ev;
struct screen_ctx *sc = CCTOSC(cc); struct screen_ctx *sc = CCTOSC(cc);
int x0 = cc->geom.x, y0 = cc->geom.y; int x = cc->geom.x, y = cc->geom.y, dx, dy;
int dx, dy;
dx = MAX(1, cc->size->width_inc); dx = MAX(1, cc->size->width_inc);
dy = MAX(1, cc->size->height_inc); dy = MAX(1, cc->size->height_inc);
@ -80,7 +79,7 @@ grab_sweep(struct client_ctx *cc)
client_draw_border(cc); client_draw_border(cc);
break; break;
case MotionNotify: 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 */ /* Recompute window output */
grab_sweep_draw(cc, dx, dy); grab_sweep_draw(cc, dx, dy);
@ -116,9 +115,9 @@ grab_sweep(struct client_ctx *cc)
void void
grab_drag(struct client_ctx *cc) 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); client_raise(cc);
@ -135,8 +134,8 @@ grab_drag(struct client_ctx *cc)
client_draw_border(cc); client_draw_border(cc);
break; break;
case MotionNotify: case MotionNotify:
cc->geom.x = x0 + (ev.xmotion.x - xm); cc->geom.x = x + (ev.xmotion.x - xm);
cc->geom.y = y0 + (ev.xmotion.y - ym); cc->geom.y = y + (ev.xmotion.y - ym);
XMoveWindow(X_Dpy, cc->pwin, XMoveWindow(X_Dpy, cc->pwin,
cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth); cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth);
@ -151,15 +150,15 @@ grab_drag(struct client_ctx *cc)
} }
static int 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; width = cc->geom.width;
height = cc->geom.height; height = cc->geom.height;
cc->geom.width = abs(x0 - motionx); cc->geom.width = abs(x - motionx);
cc->geom.height = abs(y0 - motiony); cc->geom.height = abs(y - motiony);
if (cc->size->flags & PResizeInc) { if (cc->size->flags & PResizeInc) {
cc->geom.width -= 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.height = MIN(cc->geom.height, cc->size->max_height);
} }
cc->geom.x = x0 <= motionx ? x0 : x0 - cc->geom.width; cc->geom.x = x <= motionx ? x : x - cc->geom.width;
cc->geom.y = y0 <= motiony ? y0 : y0 - cc->geom.height; cc->geom.y = y <= motiony ? y : y - cc->geom.height;
return (width != cc->geom.width || height != cc->geom.height); return (width != cc->geom.width || height != cc->geom.height);
} }

11
group.c
View File

@ -133,7 +133,9 @@ group_init(void)
void void
group_sticky_toggle_enter(struct client_ctx *cc) 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) { if (gc == cc->group) {
_group_remove(cc); _group_remove(cc);
@ -205,7 +207,6 @@ group_cycle(int reverse)
assert(Group_active != NULL); assert(Group_active != NULL);
gc = Group_active;
for (;;) { for (;;) {
gc = reverse ? TAILQ_PREV(gc, group_ctx_q, entry) : gc = reverse ? TAILQ_PREV(gc, group_ctx_q, entry) :
TAILQ_NEXT(gc, entry); TAILQ_NEXT(gc, entry);
@ -246,10 +247,10 @@ group_client_delete(struct client_ctx *cc)
void void
group_menu(XButtonEvent *e) group_menu(XButtonEvent *e)
{ {
struct menu_q menuq;
struct menu *mi;
int i;
struct group_ctx *gc; struct group_ctx *gc;
struct menu *mi;
struct menu_q menuq;
int i;
TAILQ_INIT(&menuq); TAILQ_INIT(&menuq);

View File

@ -46,10 +46,11 @@ kbfunc_client_raise(struct client_ctx *cc, void *arg)
void void
kbfunc_moveresize(struct client_ctx *cc, void *arg) kbfunc_moveresize(struct client_ctx *cc, void *arg)
{ {
struct screen_ctx *sc = screen_current(); struct screen_ctx *sc;
int x, y, flags, amt; int x, y, flags, amt;
u_int mx, my; u_int mx, my;
sc = screen_current();
mx = my = 0; mx = my = 0;
flags = (int)arg; flags = (int)arg;
@ -121,15 +122,16 @@ kbfunc_moveresize(struct client_ctx *cc, void *arg)
default: default:
warnx("invalid flags passed to kbfunc_client_moveresize"); warnx("invalid flags passed to kbfunc_client_moveresize");
} }
} }
void void
kbfunc_client_search(struct client_ctx *scratch, void *arg) kbfunc_client_search(struct client_ctx *scratch, void *arg)
{ {
struct menu_q menuq; struct client_ctx *cc, *old_cc;
struct client_ctx *cc, *old_cc = client_current();
struct menu *mi; struct menu *mi;
struct menu_q menuq;
old_cc = client_current();
TAILQ_INIT(&menuq); TAILQ_INIT(&menuq);
@ -160,9 +162,9 @@ kbfunc_client_search(struct client_ctx *scratch, void *arg)
void void
kbfunc_menu_search(struct client_ctx *scratch, void *arg) kbfunc_menu_search(struct client_ctx *scratch, void *arg)
{ {
struct menu_q menuq;
struct menu *mi;
struct cmd *cmd; struct cmd *cmd;
struct menu *mi;
struct menu_q menuq;
TAILQ_INIT(&menuq); TAILQ_INIT(&menuq);
@ -187,7 +189,9 @@ kbfunc_menu_search(struct client_ctx *scratch, void *arg)
void void
kbfunc_client_cycle(struct client_ctx *scratch, void *arg) 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 */ /* XXX for X apps that ignore events */
XGrabKeyboard(X_Dpy, sc->rootwin, True, XGrabKeyboard(X_Dpy, sc->rootwin, True,
@ -226,16 +230,16 @@ void
kbfunc_exec(struct client_ctx *scratch, void *arg) kbfunc_exec(struct client_ctx *scratch, void *arg)
{ {
#define NPATHS 256 #define NPATHS 256
char **ap, *paths[NPATHS], *path, *pathcpy, tpath[MAXPATHLEN]; char **ap, *paths[NPATHS], *path, *pathcpy, *label;
char tpath[MAXPATHLEN];
int l, i, j, ngroups; int l, i, j, ngroups;
gid_t mygroups[NGROUPS_MAX]; gid_t mygroups[NGROUPS_MAX];
uid_t ruid, euid, suid; uid_t ruid, euid, suid;
DIR *dirp; DIR *dirp;
struct dirent *dp; struct dirent *dp;
struct stat sb;
struct menu_q menuq;
struct menu *mi; struct menu *mi;
char *label; struct menu_q menuq;
struct stat sb;
int cmd = (int)arg; int cmd = (int)arg;
switch (cmd) { switch (cmd) {
@ -339,13 +343,14 @@ kbfunc_exec(struct client_ctx *scratch, void *arg)
void void
kbfunc_ssh(struct client_ctx *scratch, void *arg) kbfunc_ssh(struct client_ctx *scratch, void *arg)
{ {
struct menu_q menuq;
struct menu *mi; struct menu *mi;
struct menu_q menuq;
FILE *fp; FILE *fp;
size_t len;
char *buf, *lbuf, *p, *home; char *buf, *lbuf, *p, *home;
char hostbuf[MAXHOSTNAMELEN], filename[MAXPATHLEN], cmd[256]; char hostbuf[MAXHOSTNAMELEN], filename[MAXPATHLEN];
char cmd[256];
int l; int l;
size_t len;
if ((home = getenv("HOME")) == NULL) if ((home = getenv("HOME")) == NULL)
return; return;
@ -386,7 +391,6 @@ kbfunc_ssh(struct client_ctx *scratch, void *arg)
xfree(lbuf); xfree(lbuf);
fclose(fp); fclose(fp);
if ((mi = menu_filter(&menuq, "ssh", NULL, 1, if ((mi = menu_filter(&menuq, "ssh", NULL, 1,
search_match_exec, NULL)) != NULL) { search_match_exec, NULL)) != NULL) {
conf_reload(&Conf); conf_reload(&Conf);
@ -408,8 +412,8 @@ void
kbfunc_client_label(struct client_ctx *cc, void *arg) kbfunc_client_label(struct client_ctx *cc, void *arg)
{ {
struct menu *mi; struct menu *mi;
char *current;
struct menu_q menuq; struct menu_q menuq;
char *current;
TAILQ_INIT(&menuq); TAILQ_INIT(&menuq);

13
menu.c
View File

@ -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 (*match)(struct menu_q *, struct menu_q *, char *),
void (*print)(struct menu *, int)) void (*print)(struct menu *, int))
{ {
struct screen_ctx *sc = screen_current(); struct screen_ctx *sc;
struct menu_ctx mc; struct menu_ctx mc;
struct menu_q resultq; struct menu_q resultq;
struct menu *mi = NULL; struct menu *mi = NULL;
@ -75,6 +75,8 @@ menu_filter(struct menu_q *menuq, char *prompt, char *initial, int dummy,
Window focuswin; Window focuswin;
int Mask, focusrevert; int Mask, focusrevert;
sc = screen_current();
TAILQ_INIT(&resultq); TAILQ_INIT(&resultq);
bzero(&mc, sizeof(mc)); 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_q *resultq)
{ {
struct menu *mi; struct menu *mi;
int n = 0; int n, dy, xsave, ysave;
int dy;
int xsave, ysave;
int warp;
if (mc->list) { if (mc->list) {
if (TAILQ_EMPTY(resultq) && mc->list) { if (TAILQ_EMPTY(resultq) && mc->list) {
@ -388,7 +387,9 @@ menu_handle_release(XEvent *e, struct menu_ctx *mc, struct screen_ctx *sc,
static int static int
menu_calc_entry(struct screen_ctx *sc, struct menu_ctx *mc, int x, int y) 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? */ /* 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 ||

View File

@ -63,10 +63,12 @@ mousefunc_menu_group(struct client_ctx *cc, void *arg)
void void
mousefunc_menu_unhide(struct client_ctx *cc, void *arg) mousefunc_menu_unhide(struct client_ctx *cc, void *arg)
{ {
struct client_ctx *old_cc;
struct menu *mi; struct menu *mi;
struct menu_q menuq; struct menu_q menuq;
char *wname; char *wname;
struct client_ctx *old_cc = client_current();
old_cc = client_current();
TAILQ_INIT(&menuq); TAILQ_INIT(&menuq);
TAILQ_FOREACH(cc, &Clientq, entry) TAILQ_FOREACH(cc, &Clientq, entry)
@ -96,12 +98,13 @@ mousefunc_menu_unhide(struct client_ctx *cc, void *arg)
if (old_cc != NULL) if (old_cc != NULL)
client_ptrsave(old_cc); client_ptrsave(old_cc);
client_ptrwarp(cc); client_ptrwarp(cc);
} else } else {
while ((mi = TAILQ_FIRST(&menuq)) != NULL) { while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
TAILQ_REMOVE(&menuq, mi, entry); TAILQ_REMOVE(&menuq, mi, entry);
xfree(mi); xfree(mi);
} }
} }
}
void void
mousefunc_menu_cmd(struct client_ctx *cc, void *arg) mousefunc_menu_cmd(struct client_ctx *cc, void *arg)
@ -109,6 +112,7 @@ mousefunc_menu_cmd(struct client_ctx *cc, void *arg)
struct menu *mi; struct menu *mi;
struct menu_q menuq; struct menu_q menuq;
struct cmd *cmd; struct cmd *cmd;
conf_reload(&Conf); conf_reload(&Conf);
TAILQ_INIT(&menuq); TAILQ_INIT(&menuq);

View File

@ -47,9 +47,11 @@ void
screen_updatestackingorder(void) screen_updatestackingorder(void)
{ {
Window *wins, w0, w1; Window *wins, w0, w1;
struct screen_ctx *sc = screen_current(); struct screen_ctx *sc;
u_int nwins, i, s;
struct client_ctx *cc; struct client_ctx *cc;
u_int nwins, i, s;
sc = screen_current();
if (!XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins)) if (!XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins))
return; return;

View File

@ -33,7 +33,9 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
{ {
struct winname *wn; struct winname *wn;
struct menu *mi, *tierp[4], *before = NULL; struct menu *mi, *tierp[4], *before = NULL;
int ntiers = sizeof(tierp)/sizeof(tierp[0]); int ntiers;
ntiers = sizeof(tierp) / sizeof(tierp[0]);
TAILQ_INIT(resultq); TAILQ_INIT(resultq);
@ -119,9 +121,11 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
void void
search_print_client(struct menu *mi, int list) search_print_client(struct menu *mi, int list)
{ {
struct client_ctx *cc = mi->ctx; struct client_ctx *cc;
char flag = ' '; char flag = ' ';
cc = mi->ctx;
if (cc == client_current()) if (cc == client_current())
flag = '!'; flag = '!';
else if (cc->flags & CLIENT_HIDDEN) else if (cc->flags & CLIENT_HIDDEN)
@ -134,9 +138,11 @@ search_print_client(struct menu *mi, int list)
if (!list && cc->matchname != cc->name && if (!list && cc->matchname != cc->name &&
strlen(mi->print) < sizeof(mi->print) - 1) { strlen(mi->print) < sizeof(mi->print) - 1) {
int diff = sizeof(mi->print) - 1 - strlen(mi->print);
const char *marker = ""; const char *marker = "";
char buf[MENU_MAXENTRY + 1]; char buf[MENU_MAXENTRY + 1];
int diff;
diff = sizeof(mi->print) - 1 - strlen(mi->print);
/* One for the ':' */ /* One for the ':' */
diff -= 1; diff -= 1;
@ -197,6 +203,7 @@ _strsubmatch(char *sub, char *str, int zeroidx)
flen = len - sublen; flen = len - sublen;
else else
flen = 0; flen = 0;
for (n = 0; n <= flen; n++) for (n = 0; n <= flen; n++)
if (strncasecmp(sub, str + n, sublen) == 0) if (strncasecmp(sub, str + n, sublen) == 0)
return (1); return (1);

3
util.c
View File

@ -45,8 +45,7 @@ void
u_exec(char *argstr) u_exec(char *argstr)
{ {
char *args[MAXARGLEN], **ap = args; char *args[MAXARGLEN], **ap = args;
char **end = &args[MAXARGLEN - 1]; char **end = &args[MAXARGLEN - 1], *tmp;
char *tmp;
while (ap < end && (*ap = strsep(&argstr, " \t")) != NULL) { while (ap < end && (*ap = strsep(&argstr, " \t")) != NULL) {
if (**ap == '\0') if (**ap == '\0')

View File

@ -36,14 +36,15 @@ void
xev_handle_maprequest(struct xevent *xev, XEvent *ee) xev_handle_maprequest(struct xevent *xev, XEvent *ee)
{ {
XMapRequestEvent *e = &ee->xmaprequest; XMapRequestEvent *e = &ee->xmaprequest;
struct client_ctx *cc = NULL, *old_cc = client_current();
XWindowAttributes xattr; XWindowAttributes xattr;
struct client_ctx *cc = NULL, *old_cc;
struct screen_ctx *sc; struct screen_ctx *sc;
#ifdef notyet #ifdef notyet
int state; int state;
#endif #endif
if (old_cc != NULL) if ((old_cc = client_current()) != NULL)
client_ptrsave(old_cc); client_ptrsave(old_cc);
if ((cc = client_find(e->window)) == NULL) { if ((cc = client_find(e->window)) == NULL) {
@ -222,10 +223,11 @@ xev_handle_buttonpress(struct xevent *xev, XEvent *ee)
{ {
XButtonEvent *e = &ee->xbutton; XButtonEvent *e = &ee->xbutton;
struct client_ctx *cc; struct client_ctx *cc;
struct screen_ctx *sc = screen_fromroot(e->root); struct screen_ctx *sc;
struct mousebinding *mb; struct mousebinding *mb;
char *wname; char *wname;
sc = screen_fromroot(e->root);
cc = client_find(e->window); cc = client_find(e->window);
/* Ignore caps lock and numlock */ /* Ignore caps lock and numlock */
@ -256,9 +258,9 @@ out:
void void
xev_handle_buttonrelease(struct xevent *xev, XEvent *ee) 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); group_sticky_toggle_exit(cc);
xev_register(xev); xev_register(xev);
@ -268,7 +270,7 @@ void
xev_handle_keypress(struct xevent *xev, XEvent *ee) xev_handle_keypress(struct xevent *xev, XEvent *ee)
{ {
XKeyEvent *e = &ee->xkey; XKeyEvent *e = &ee->xkey;
struct client_ctx *cc = NULL; /* Make gcc happy. */ struct client_ctx *cc = NULL;
struct keybinding *kb; struct keybinding *kb;
KeySym keysym, skeysym; KeySym keysym, skeysym;
int modshift; int modshift;
@ -316,10 +318,13 @@ void
xev_handle_keyrelease(struct xevent *xev, XEvent *ee) xev_handle_keyrelease(struct xevent *xev, XEvent *ee)
{ {
XKeyEvent *e = &ee->xkey; XKeyEvent *e = &ee->xkey;
struct screen_ctx *sc = screen_fromroot(e->root); struct screen_ctx *sc;
struct client_ctx *cc = client_current(); struct client_ctx *cc;
int keysym; int keysym;
sc = screen_fromroot(e->root);
cc = client_current();
keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0); keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0);
if (keysym != XK_Alt_L && keysym != XK_Alt_R) if (keysym != XK_Alt_L && keysym != XK_Alt_R)
goto out; goto out;
@ -345,10 +350,12 @@ void
xev_handle_clientmessage(struct xevent *xev, XEvent *ee) xev_handle_clientmessage(struct xevent *xev, XEvent *ee)
{ {
XClientMessageEvent *e = &ee->xclient; XClientMessageEvent *e = &ee->xclient;
struct client_ctx *cc = client_find(e->window); Atom xa_wm_change_state;
Atom xa_wm_change_state = XInternAtom(X_Dpy, "WM_CHANGE_STATE", False); 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; goto out;
if (e->message_type == xa_wm_change_state && e->format == 32 && if (e->message_type == xa_wm_change_state && e->format == 32 &&
@ -446,9 +453,9 @@ void
xev_loop(void) xev_loop(void)
{ {
Window win, root; Window win, root;
int type;
XEvent e; XEvent e;
struct xevent *xev, *nextxev; struct xevent *xev = NULL, *nextxev;
int type;
while (_xev_quit == 0) { while (_xev_quit == 0) {
#ifdef DIAGNOSTIC #ifdef DIAGNOSTIC

View File

@ -65,9 +65,9 @@ xu_btn_ungrab(Window win, int mask, u_int btn)
void void
xu_ptr_getpos(Window rootwin, int *x, int *y) xu_ptr_getpos(Window rootwin, int *x, int *y)
{ {
Window w0, w1;
int tmp0, tmp1; int tmp0, tmp1;
u_int tmp2; u_int tmp2;
Window w0, w1;
XQueryPointer(X_Dpy, rootwin, &w0, &w1, &tmp0, &tmp1, x, y, &tmp2); XQueryPointer(X_Dpy, rootwin, &w0, &w1, &tmp0, &tmp1, x, y, &tmp2);
} }
@ -131,9 +131,11 @@ xu_getprop(struct client_ctx *cc, Atom atm, Atom type, long len, u_char **p)
int int
xu_getstate(struct client_ctx *cc, int *state) xu_getstate(struct client_ctx *cc, int *state)
{ {
Atom wm_state = XInternAtom(X_Dpy, "WM_STATE", False); Atom wm_state;
long *p = NULL; long *p = NULL;
wm_state = XInternAtom(X_Dpy, "WM_STATE", False);
if (xu_getprop(cc, wm_state, wm_state, 2L, (u_char **)&p) <= 0) if (xu_getprop(cc, wm_state, wm_state, 2L, (u_char **)&p) <= 0)
return (-1); return (-1);
@ -146,8 +148,8 @@ xu_getstate(struct client_ctx *cc, int *state)
void void
xu_setstate(struct client_ctx *cc, int state) xu_setstate(struct client_ctx *cc, int state)
{ {
long dat[2];
Atom wm_state; Atom wm_state;
long dat[2];
/* XXX cache */ /* XXX cache */
wm_state = XInternAtom(X_Dpy, "WM_STATE", False); wm_state = XInternAtom(X_Dpy, "WM_STATE", False);