mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
spacing, declaration lineup to be consistent throughout cwm,
readability, and a bit of knf. ok oga@
This commit is contained in:
parent
734f45ab4b
commit
b23fad3987
8
calmwm.c
8
calmwm.c
@ -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;
|
||||
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;
|
||||
int i;
|
||||
|
||||
TAILQ_INIT(&Screenq);
|
||||
|
||||
@ -143,10 +141,10 @@ 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;
|
||||
u_int nwins, i;
|
||||
|
||||
Curscreen = sc;
|
||||
|
||||
|
37
client.c
37
client.c
@ -49,11 +49,11 @@ 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;
|
||||
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 |
|
||||
@ -203,8 +202,8 @@ client_delete(struct client_ctx *cc, int sendevent, int ignorewindow)
|
||||
return (1);
|
||||
|
||||
group_client_delete(cc);
|
||||
XGrabServer(X_Dpy);
|
||||
|
||||
XGrabServer(X_Dpy);
|
||||
xu_setstate(cc, WithdrawnState);
|
||||
XRemoveFromSaveSet(X_Dpy, cc->win);
|
||||
|
||||
@ -251,15 +250,15 @@ client_leave(struct client_ctx *cc)
|
||||
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;
|
||||
@ -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
|
||||
@ -546,8 +545,8 @@ client_send_delete(struct client_ctx *cc)
|
||||
void
|
||||
client_setname(struct client_ctx *cc)
|
||||
{
|
||||
char *newname;
|
||||
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);
|
||||
@ -657,8 +659,8 @@ client_placecalc(struct client_ctx *cc)
|
||||
|
||||
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);
|
||||
@ -701,8 +703,10 @@ client_vertmaximize(struct client_ctx *cc)
|
||||
cc->geom = cc->savegeom;
|
||||
} else {
|
||||
struct screen_ctx *sc = CCTOSC(cc);
|
||||
int display_height = DisplayHeight(X_Dpy, sc->which) -
|
||||
cc->bwidth*2;
|
||||
int display_height;
|
||||
|
||||
display_height = DisplayHeight(X_Dpy, sc->which) -
|
||||
cc->bwidth * 2;
|
||||
|
||||
if (!(cc->flags & CLIENT_MAXIMIZED))
|
||||
cc->savegeom = cc->geom;
|
||||
@ -758,8 +762,7 @@ 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;
|
||||
int i, o, len = MAX_ARGLEN;
|
||||
char *buf;
|
||||
|
||||
buf = xmalloc(len);
|
||||
|
11
conf.c
11
conf.c
@ -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;
|
||||
@ -310,9 +312,9 @@ struct {
|
||||
void
|
||||
conf_bindname(struct conf *c, char *name, char *binding)
|
||||
{
|
||||
int iter;
|
||||
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++) {
|
||||
@ -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;
|
||||
int iter;
|
||||
|
||||
XCALLOC(current_binding, struct mousebinding);
|
||||
|
||||
@ -493,7 +495,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)
|
||||
continue;
|
||||
|
1
font.c
1
font.c
@ -44,6 +44,7 @@ int
|
||||
font_width(const char *text, int len)
|
||||
{
|
||||
XGlyphInfo extents;
|
||||
|
||||
XftTextExtents8(X_Dpy, Conf.DefaultFont, (const XftChar8*)text,
|
||||
len, &extents);
|
||||
|
||||
|
29
grab.c
29
grab.c
@ -30,9 +30,9 @@ 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;
|
||||
int x = cc->geom.x, y = cc->geom.y;
|
||||
|
||||
snprintf(asize, sizeof(asize), "%dx%d",
|
||||
ADJUST_WIDTH(cc, dx), ADJUST_HEIGHT(cc, dy));
|
||||
@ -41,14 +41,14 @@ 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
|
||||
@ -56,8 +56,7 @@ 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;
|
||||
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;
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
11
group.c
11
group.c
@ -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);
|
||||
@ -205,7 +207,6 @@ group_cycle(int reverse)
|
||||
|
||||
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 menu *mi;
|
||||
int i;
|
||||
struct group_ctx *gc;
|
||||
struct menu *mi;
|
||||
struct menu_q menuq;
|
||||
int i;
|
||||
|
||||
TAILQ_INIT(&menuq);
|
||||
|
||||
|
38
kbfunc.c
38
kbfunc.c
@ -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];
|
||||
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 stat sb;
|
||||
struct menu_q menuq;
|
||||
struct menu *mi;
|
||||
char *label;
|
||||
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;
|
||||
struct menu_q menuq;
|
||||
FILE *fp;
|
||||
size_t len;
|
||||
char *buf, *lbuf, *p, *home;
|
||||
char hostbuf[MAXHOSTNAMELEN], filename[MAXPATHLEN], cmd[256];
|
||||
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);
|
||||
|
||||
|
15
menu.c
15
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;
|
||||
|
||||
|
@ -63,10 +63,12 @@ mousefunc_menu_group(struct client_ctx *cc, void *arg)
|
||||
void
|
||||
mousefunc_menu_unhide(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
struct client_ctx *old_cc;
|
||||
struct menu *mi;
|
||||
struct menu_q menuq;
|
||||
char *wname;
|
||||
struct client_ctx *old_cc = client_current();
|
||||
|
||||
old_cc = client_current();
|
||||
|
||||
TAILQ_INIT(&menuq);
|
||||
TAILQ_FOREACH(cc, &Clientq, entry)
|
||||
@ -96,11 +98,12 @@ 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
|
||||
@ -109,6 +112,7 @@ mousefunc_menu_cmd(struct client_ctx *cc, void *arg)
|
||||
struct menu *mi;
|
||||
struct menu_q menuq;
|
||||
struct cmd *cmd;
|
||||
|
||||
conf_reload(&Conf);
|
||||
|
||||
TAILQ_INIT(&menuq);
|
||||
|
6
screen.c
6
screen.c
@ -47,9 +47,11 @@ void
|
||||
screen_updatestackingorder(void)
|
||||
{
|
||||
Window *wins, w0, w1;
|
||||
struct screen_ctx *sc = screen_current();
|
||||
u_int nwins, i, s;
|
||||
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;
|
||||
|
13
search.c
13
search.c
@ -33,7 +33,9 @@ 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]);
|
||||
int ntiers;
|
||||
|
||||
ntiers = sizeof(tierp) / sizeof(tierp[0]);
|
||||
|
||||
TAILQ_INIT(resultq);
|
||||
|
||||
@ -119,9 +121,11 @@ 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;
|
||||
struct client_ctx *cc;
|
||||
char flag = ' ';
|
||||
|
||||
cc = mi->ctx;
|
||||
|
||||
if (cc == client_current())
|
||||
flag = '!';
|
||||
else if (cc->flags & CLIENT_HIDDEN)
|
||||
@ -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];
|
||||
int diff;
|
||||
|
||||
diff = sizeof(mi->print) - 1 - strlen(mi->print);
|
||||
|
||||
/* One for the ':' */
|
||||
diff -= 1;
|
||||
@ -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);
|
||||
|
3
util.c
3
util.c
@ -45,8 +45,7 @@ void
|
||||
u_exec(char *argstr)
|
||||
{
|
||||
char *args[MAXARGLEN], **ap = args;
|
||||
char **end = &args[MAXARGLEN - 1];
|
||||
char *tmp;
|
||||
char **end = &args[MAXARGLEN - 1], *tmp;
|
||||
|
||||
while (ap < end && (*ap = strsep(&argstr, " \t")) != NULL) {
|
||||
if (**ap == '\0')
|
||||
|
33
xevents.c
33
xevents.c
@ -36,14 +36,15 @@ 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 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) {
|
||||
@ -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);
|
||||
@ -268,7 +270,7 @@ void
|
||||
xev_handle_keypress(struct xevent *xev, XEvent *ee)
|
||||
{
|
||||
XKeyEvent *e = &ee->xkey;
|
||||
struct client_ctx *cc = NULL; /* Make gcc happy. */
|
||||
struct client_ctx *cc = NULL;
|
||||
struct keybinding *kb;
|
||||
KeySym keysym, skeysym;
|
||||
int modshift;
|
||||
@ -316,10 +318,13 @@ 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();
|
||||
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)
|
||||
goto out;
|
||||
@ -345,10 +350,12 @@ 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);
|
||||
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 &&
|
||||
@ -446,9 +453,9 @@ void
|
||||
xev_loop(void)
|
||||
{
|
||||
Window win, root;
|
||||
int type;
|
||||
XEvent e;
|
||||
struct xevent *xev, *nextxev;
|
||||
struct xevent *xev = NULL, *nextxev;
|
||||
int type;
|
||||
|
||||
while (_xev_quit == 0) {
|
||||
#ifdef DIAGNOSTIC
|
||||
|
8
xutil.c
8
xutil.c
@ -65,9 +65,9 @@ xu_btn_ungrab(Window win, int mask, u_int btn)
|
||||
void
|
||||
xu_ptr_getpos(Window rootwin, int *x, int *y)
|
||||
{
|
||||
Window w0, w1;
|
||||
int tmp0, tmp1;
|
||||
u_int tmp2;
|
||||
Window w0, w1;
|
||||
|
||||
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
|
||||
xu_getstate(struct client_ctx *cc, int *state)
|
||||
{
|
||||
Atom wm_state = XInternAtom(X_Dpy, "WM_STATE", False);
|
||||
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;
|
||||
long dat[2];
|
||||
|
||||
/* XXX cache */
|
||||
wm_state = XInternAtom(X_Dpy, "WM_STATE", False);
|
||||
|
Loading…
Reference in New Issue
Block a user