sanitized names

new_dwm
Anselm R. Garbe 19 years ago
parent 29355bd382
commit c0705eeb65

@ -17,14 +17,14 @@ static Rule rule[] = {
}; };
Client * Client *
next(Client *c) getnext(Client *c)
{ {
for(; c && !c->tags[tsel]; c = c->next); for(; c && !c->tags[tsel]; c = c->next);
return c; return c;
} }
void void
ban_client(Client *c) ban(Client *c)
{ {
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty); XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty);
@ -48,7 +48,7 @@ resize_title(Client *c)
} }
void void
update_name(Client *c) settitle(Client *c)
{ {
XTextProperty name; XTextProperty name;
int n; int n;
@ -76,7 +76,7 @@ update_name(Client *c)
} }
void void
update_size(Client *c) setsize(Client *c)
{ {
XSizeHints size; XSizeHints size;
long msize; long msize;
@ -114,7 +114,7 @@ update_size(Client *c)
} }
void void
craise(Client *c) higher(Client *c)
{ {
XRaiseWindow(dpy, c->win); XRaiseWindow(dpy, c->win);
XRaiseWindow(dpy, c->title); XRaiseWindow(dpy, c->title);
@ -136,8 +136,8 @@ focus(Client *c)
XFlush(dpy); XFlush(dpy);
sel = c; sel = c;
if(old && old != c) if(old && old != c)
draw_client(old); drawtitle(old);
draw_client(c); drawtitle(c);
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
XFlush(dpy); XFlush(dpy);
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
@ -196,8 +196,8 @@ manage(Window w, XWindowAttributes *wa)
c->h = wa->height; c->h = wa->height;
c->th = bh; c->th = bh;
c->border = 1; c->border = 1;
c->proto = win_proto(c->win); c->proto = proto(c->win);
update_size(c); setsize(c);
XSelectInput(dpy, c->win, XSelectInput(dpy, c->win,
StructureNotifyMask | PropertyChangeMask | EnterWindowMask); StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
XGetTransientForHint(dpy, c->win, &trans); XGetTransientForHint(dpy, c->win, &trans);
@ -210,7 +210,7 @@ manage(Window w, XWindowAttributes *wa)
DefaultVisual(dpy, screen), DefaultVisual(dpy, screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
update_name(c); settitle(c);
init_tags(c); init_tags(c);
for(l = &clients; *l; l = &(*l)->next); for(l = &clients; *l; l = &(*l)->next);
@ -236,7 +236,7 @@ manage(Window w, XWindowAttributes *wa)
focus(c); focus(c);
} }
else { else {
ban_client(c); ban(c);
XMapRaised(dpy, c->win); XMapRaised(dpy, c->win);
XMapRaised(dpy, c->title); XMapRaised(dpy, c->title);
} }
@ -339,7 +339,7 @@ resize(Client *c, Bool inc)
} }
static int static int
dummy_error_handler(Display *dsply, XErrorEvent *err) dummy_xerror(Display *dsply, XErrorEvent *err)
{ {
return 0; return 0;
} }
@ -350,7 +350,7 @@ unmanage(Client *c)
Client **l; Client **l;
XGrabServer(dpy); XGrabServer(dpy);
XSetErrorHandler(dummy_error_handler); XSetErrorHandler(dummy_xerror);
XUngrabButton(dpy, AnyButton, AnyModifier, c->win); XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
XDestroyWindow(dpy, c->title); XDestroyWindow(dpy, c->title);
@ -366,7 +366,7 @@ unmanage(Client *c)
free(c); free(c);
XFlush(dpy); XFlush(dpy);
XSetErrorHandler(error_handler); XSetErrorHandler(xerror);
XUngrabServer(dpy); XUngrabServer(dpy);
arrange(NULL); arrange(NULL);
if(sel) if(sel)

@ -11,7 +11,7 @@
#include "dwm.h" #include "dwm.h"
void void
draw_bar() drawstatus()
{ {
int i; int i;
@ -44,11 +44,11 @@ draw_bar()
} }
void void
draw_client(Client *c) drawtitle(Client *c)
{ {
int i; int i;
if(c == sel) { if(c == sel) {
draw_bar(); drawstatus();
XUnmapWindow(dpy, c->title); XUnmapWindow(dpy, c->title);
XSetWindowBorder(dpy, c->win, dc.fg); XSetWindowBorder(dpy, c->win, dc.fg);
return; return;
@ -145,7 +145,7 @@ drawtext(const char *text, Bool invert, Bool border)
} }
unsigned long unsigned long
initcolor(const char *colstr) getcolor(const char *colstr)
{ {
XColor color; XColor color;
Colormap cmap = DefaultColormap(dpy, screen); Colormap cmap = DefaultColormap(dpy, screen);
@ -172,7 +172,7 @@ textw(char *text)
} }
void void
initfont(const char *fontstr) setfont(const char *fontstr)
{ {
char **missing, *def; char **missing, *def;
int i, n; int i, n;

24
dwm.h

@ -107,22 +107,22 @@ extern void manage(Window w, XWindowAttributes *wa);
extern void unmanage(Client *c); extern void unmanage(Client *c);
extern Client *getclient(Window w); extern Client *getclient(Window w);
extern void focus(Client *c); extern void focus(Client *c);
extern void update_name(Client *c); extern void settitle(Client *c);
extern void resize(Client *c, Bool inc); extern void resize(Client *c, Bool inc);
extern void update_size(Client *c); extern void setsize(Client *c);
extern Client *gettitle(Window w); extern Client *gettitle(Window w);
extern void craise(Client *c); extern void higher(Client *c);
extern void lower(Client *c); extern void lower(Client *c);
extern void gravitate(Client *c, Bool invert); extern void gravitate(Client *c, Bool invert);
extern void ban_client(Client *c); extern void ban(Client *c);
extern Client *next(Client *c); extern Client *getnext(Client *c);
/* draw.c */ /* draw.c */
extern void draw_bar(); extern void drawstatus();
extern void draw_client(Client *c); extern void drawtitle(Client *c);
extern void drawtext(const char *text, Bool invert, Bool border); extern void drawtext(const char *text, Bool invert, Bool border);
extern unsigned long initcolor(const char *colstr); extern unsigned long getcolor(const char *colstr);
extern void initfont(const char *fontstr); extern void setfont(const char *fontstr);
extern unsigned int textnw(char *text, unsigned int len); extern unsigned int textnw(char *text, unsigned int len);
extern unsigned int textw(char *text); extern unsigned int textw(char *text);
extern unsigned int texth(void); extern unsigned int texth(void);
@ -132,9 +132,9 @@ extern void grabkeys();
extern void keypress(XEvent *e); extern void keypress(XEvent *e);
/* main.c */ /* main.c */
extern int error_handler(Display *dsply, XErrorEvent *e); extern int xerror(Display *dsply, XErrorEvent *e);
extern void send_message(Window w, Atom a, long value); extern void sendevent(Window w, Atom a, long value);
extern int win_proto(Window w); extern int proto(Window w);
extern void quit(Arg *arg); extern void quit(Arg *arg);
/* screen.c */ /* screen.c */

@ -129,7 +129,7 @@ buttonpress(XEvent *e)
else if((c = getclient(ev->window))) { else if((c = getclient(ev->window))) {
if(arrange == tiling && !c->floating) if(arrange == tiling && !c->floating)
return; return;
craise(c); higher(c);
switch(ev->button) { switch(ev->button) {
default: default:
break; break;
@ -225,9 +225,9 @@ expose(XEvent *e)
if(ev->count == 0) { if(ev->count == 0) {
if(barwin == ev->window) if(barwin == ev->window)
draw_bar(); drawstatus();
else if((c = gettitle(ev->window))) else if((c = gettitle(ev->window)))
draw_client(c); drawtitle(c);
} }
} }
@ -262,7 +262,7 @@ propertynotify(XEvent *e)
if((c = getclient(ev->window))) { if((c = getclient(ev->window))) {
if(ev->atom == wm_atom[WMProtocols]) { if(ev->atom == wm_atom[WMProtocols]) {
c->proto = win_proto(c->win); c->proto = proto(c->win);
return; return;
} }
switch (ev->atom) { switch (ev->atom) {
@ -273,12 +273,12 @@ propertynotify(XEvent *e)
arrange(NULL); arrange(NULL);
break; break;
case XA_WM_NORMAL_HINTS: case XA_WM_NORMAL_HINTS:
update_size(c); setsize(c);
break; break;
} }
if(ev->atom == XA_WM_NAME || ev->atom == net_atom[NetWMName]) { if(ev->atom == XA_WM_NAME || ev->atom == net_atom[NetWMName]) {
update_name(c); settitle(c);
draw_client(c); drawtitle(c);
} }
} }
} }

16
key.c

@ -99,8 +99,8 @@ zoom(Arg *arg)
if(!sel) if(!sel)
return; return;
if(sel == next(clients) && sel->next) { if(sel == getnext(clients) && sel->next) {
if((c = next(sel->next))) if((c = getnext(sel->next)))
sel = c; sel = c;
} }
@ -122,7 +122,7 @@ max(Arg *arg)
sel->y = sy + bh; sel->y = sy + bh;
sel->w = sw - 2 * sel->border; sel->w = sw - 2 * sel->border;
sel->h = sh - 2 * sel->border - bh; sel->h = sh - 2 * sel->border - bh;
craise(sel); higher(sel);
resize(sel, False); resize(sel, False);
} }
@ -157,7 +157,7 @@ prevc(Arg *arg)
return; return;
if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) { if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) {
craise(c); higher(c);
focus(c); focus(c);
} }
} }
@ -170,10 +170,10 @@ nextc(Arg *arg)
if(!sel) if(!sel)
return; return;
if(!(c = next(sel->next))) if(!(c = getnext(sel->next)))
c = next(clients); c = getnext(clients);
if(c) { if(c) {
craise(c); higher(c);
c->revert = sel; c->revert = sel;
focus(c); focus(c);
} }
@ -185,7 +185,7 @@ ckill(Arg *arg)
if(!sel) if(!sel)
return; return;
if(sel->proto & WM_PROTOCOL_DELWIN) if(sel->proto & WM_PROTOCOL_DELWIN)
send_message(sel->win, wm_atom[WMProtocols], wm_atom[WMDelete]); sendevent(sel->win, wm_atom[WMProtocols], wm_atom[WMDelete]);
else else
XKillClient(dpy, sel->win); XKillClient(dpy, sel->win);
} }

@ -46,7 +46,7 @@ Client *sel = NULL;
static Bool other_wm_running; static Bool other_wm_running;
static const char version[] = static const char version[] =
"dwm-" VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; "dwm-" VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
static int (*x_error_handler) (Display *, XErrorEvent *); static int (*x_xerror) (Display *, XErrorEvent *);
static void static void
usage() { error("usage: dwm [-v]\n"); } usage() { error("usage: dwm [-v]\n"); }
@ -94,7 +94,7 @@ win_property(Window w, Atom a, Atom t, long l, unsigned char **prop)
} }
int int
win_proto(Window w) proto(Window w)
{ {
unsigned char *protocols; unsigned char *protocols;
long res; long res;
@ -114,7 +114,7 @@ win_proto(Window w)
} }
void void
send_message(Window w, Atom a, long value) sendevent(Window w, Atom a, long value)
{ {
XEvent e; XEvent e;
@ -135,7 +135,7 @@ send_message(Window w, Atom a, long value)
* calls exit(). * calls exit().
*/ */
int int
error_handler(Display *dpy, XErrorEvent *error) xerror(Display *dpy, XErrorEvent *error)
{ {
if(error->error_code == BadWindow if(error->error_code == BadWindow
|| (error->request_code == X_SetInputFocus || (error->request_code == X_SetInputFocus
@ -153,7 +153,7 @@ error_handler(Display *dpy, XErrorEvent *error)
return 0; return 0;
fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n", fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
error->request_code, error->error_code); error->request_code, error->error_code);
return x_error_handler(dpy, error); /* may call exit() */ return x_xerror(dpy, error); /* may call exit() */
} }
/* /*
@ -161,7 +161,7 @@ error_handler(Display *dpy, XErrorEvent *error)
* is already running. * is already running.
*/ */
static int static int
startup_error_handler(Display *dpy, XErrorEvent *error) startup_xerror(Display *dpy, XErrorEvent *error)
{ {
other_wm_running = True; other_wm_running = True;
return -1; return -1;
@ -215,7 +215,7 @@ main(int argc, char *argv[])
/* check if another WM is already running */ /* check if another WM is already running */
other_wm_running = False; other_wm_running = False;
XSetErrorHandler(startup_error_handler); XSetErrorHandler(startup_xerror);
/* this causes an error if some other WM is running */ /* this causes an error if some other WM is running */
XSelectInput(dpy, root, SubstructureRedirectMask); XSelectInput(dpy, root, SubstructureRedirectMask);
XFlush(dpy); XFlush(dpy);
@ -224,7 +224,7 @@ main(int argc, char *argv[])
error("dwm: another window manager is already running\n"); error("dwm: another window manager is already running\n");
XSetErrorHandler(0); XSetErrorHandler(0);
x_error_handler = XSetErrorHandler(error_handler); x_xerror = XSetErrorHandler(xerror);
/* init atoms */ /* init atoms */
wm_atom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); wm_atom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
@ -242,10 +242,10 @@ main(int argc, char *argv[])
grabkeys(); grabkeys();
/* style */ /* style */
dc.bg = initcolor(BGCOLOR); dc.bg = getcolor(BGCOLOR);
dc.fg = initcolor(FGCOLOR); dc.fg = getcolor(FGCOLOR);
dc.border = initcolor(BORDERCOLOR); dc.border = getcolor(BORDERCOLOR);
initfont(FONT); setfont(FONT);
sx = sy = 0; sx = sy = 0;
sw = DisplayWidth(dpy, screen); sw = DisplayWidth(dpy, screen);
@ -267,7 +267,7 @@ main(int argc, char *argv[])
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
dc.gc = XCreateGC(dpy, root, 0, 0); dc.gc = XCreateGC(dpy, root, 0, 0);
draw_bar(); drawstatus();
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
@ -315,7 +315,7 @@ Mainloop:
stext[n++] = i; stext[n++] = i;
} }
stext[n] = 0; stext[n] = 0;
draw_bar(); drawstatus();
} }
} }
} }

@ -15,9 +15,9 @@ view(Arg *arg)
tsel = arg->i; tsel = arg->i;
arrange(NULL); arrange(NULL);
for(c = clients; c; c = next(c->next)) for(c = clients; c; c = getnext(c->next))
draw_client(c); drawtitle(c);
draw_bar(); drawstatus();
} }
void void
@ -30,15 +30,15 @@ floating(Arg *arg)
if(c->tags[tsel]) if(c->tags[tsel])
resize(c, True); resize(c, True);
else else
ban_client(c); ban(c);
} }
if(sel && !sel->tags[tsel]) { if(sel && !sel->tags[tsel]) {
if((sel = next(clients))) { if((sel = getnext(clients))) {
craise(sel); higher(sel);
focus(sel); focus(sel);
} }
} }
draw_bar(); drawstatus();
} }
void void
@ -61,7 +61,7 @@ tiling(Arg *arg)
for(i = 0, c = clients; c; c = c->next) { for(i = 0, c = clients; c; c = c->next) {
if(c->tags[tsel]) { if(c->tags[tsel]) {
if(c->floating) { if(c->floating) {
craise(c); higher(c);
resize(c, True); resize(c, True);
continue; continue;
} }
@ -87,14 +87,14 @@ tiling(Arg *arg)
i++; i++;
} }
else else
ban_client(c); ban(c);
} }
if(!sel || (sel && !sel->tags[tsel])) { if(!sel || (sel && !sel->tags[tsel])) {
if((sel = next(clients))) { if((sel = getnext(clients))) {
craise(sel); higher(sel);
focus(sel); focus(sel);
} }
} }
draw_bar(); drawstatus();
} }

Loading…
Cancel
Save