forked from mirror/dwm
sanitized names
This commit is contained in:
parent
29355bd382
commit
c0705eeb65
7 changed files with 72 additions and 72 deletions
28
client.c
28
client.c
|
@ -17,14 +17,14 @@ static Rule rule[] = {
|
|||
};
|
||||
|
||||
Client *
|
||||
next(Client *c)
|
||||
getnext(Client *c)
|
||||
{
|
||||
for(; c && !c->tags[tsel]; c = c->next);
|
||||
return c;
|
||||
}
|
||||
|
||||
void
|
||||
ban_client(Client *c)
|
||||
ban(Client *c)
|
||||
{
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty);
|
||||
|
@ -48,7 +48,7 @@ resize_title(Client *c)
|
|||
}
|
||||
|
||||
void
|
||||
update_name(Client *c)
|
||||
settitle(Client *c)
|
||||
{
|
||||
XTextProperty name;
|
||||
int n;
|
||||
|
@ -76,7 +76,7 @@ update_name(Client *c)
|
|||
}
|
||||
|
||||
void
|
||||
update_size(Client *c)
|
||||
setsize(Client *c)
|
||||
{
|
||||
XSizeHints size;
|
||||
long msize;
|
||||
|
@ -114,7 +114,7 @@ update_size(Client *c)
|
|||
}
|
||||
|
||||
void
|
||||
craise(Client *c)
|
||||
higher(Client *c)
|
||||
{
|
||||
XRaiseWindow(dpy, c->win);
|
||||
XRaiseWindow(dpy, c->title);
|
||||
|
@ -136,8 +136,8 @@ focus(Client *c)
|
|||
XFlush(dpy);
|
||||
sel = c;
|
||||
if(old && old != c)
|
||||
draw_client(old);
|
||||
draw_client(c);
|
||||
drawtitle(old);
|
||||
drawtitle(c);
|
||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||
XFlush(dpy);
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
|
@ -196,8 +196,8 @@ manage(Window w, XWindowAttributes *wa)
|
|||
c->h = wa->height;
|
||||
c->th = bh;
|
||||
c->border = 1;
|
||||
c->proto = win_proto(c->win);
|
||||
update_size(c);
|
||||
c->proto = proto(c->win);
|
||||
setsize(c);
|
||||
XSelectInput(dpy, c->win,
|
||||
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
||||
XGetTransientForHint(dpy, c->win, &trans);
|
||||
|
@ -210,7 +210,7 @@ manage(Window w, XWindowAttributes *wa)
|
|||
DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
||||
|
||||
update_name(c);
|
||||
settitle(c);
|
||||
init_tags(c);
|
||||
|
||||
for(l = &clients; *l; l = &(*l)->next);
|
||||
|
@ -236,7 +236,7 @@ manage(Window w, XWindowAttributes *wa)
|
|||
focus(c);
|
||||
}
|
||||
else {
|
||||
ban_client(c);
|
||||
ban(c);
|
||||
XMapRaised(dpy, c->win);
|
||||
XMapRaised(dpy, c->title);
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ resize(Client *c, Bool inc)
|
|||
}
|
||||
|
||||
static int
|
||||
dummy_error_handler(Display *dsply, XErrorEvent *err)
|
||||
dummy_xerror(Display *dsply, XErrorEvent *err)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ unmanage(Client *c)
|
|||
Client **l;
|
||||
|
||||
XGrabServer(dpy);
|
||||
XSetErrorHandler(dummy_error_handler);
|
||||
XSetErrorHandler(dummy_xerror);
|
||||
|
||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||
XDestroyWindow(dpy, c->title);
|
||||
|
@ -366,7 +366,7 @@ unmanage(Client *c)
|
|||
free(c);
|
||||
|
||||
XFlush(dpy);
|
||||
XSetErrorHandler(error_handler);
|
||||
XSetErrorHandler(xerror);
|
||||
XUngrabServer(dpy);
|
||||
arrange(NULL);
|
||||
if(sel)
|
||||
|
|
10
draw.c
10
draw.c
|
@ -11,7 +11,7 @@
|
|||
#include "dwm.h"
|
||||
|
||||
void
|
||||
draw_bar()
|
||||
drawstatus()
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -44,11 +44,11 @@ draw_bar()
|
|||
}
|
||||
|
||||
void
|
||||
draw_client(Client *c)
|
||||
drawtitle(Client *c)
|
||||
{
|
||||
int i;
|
||||
if(c == sel) {
|
||||
draw_bar();
|
||||
drawstatus();
|
||||
XUnmapWindow(dpy, c->title);
|
||||
XSetWindowBorder(dpy, c->win, dc.fg);
|
||||
return;
|
||||
|
@ -145,7 +145,7 @@ drawtext(const char *text, Bool invert, Bool border)
|
|||
}
|
||||
|
||||
unsigned long
|
||||
initcolor(const char *colstr)
|
||||
getcolor(const char *colstr)
|
||||
{
|
||||
XColor color;
|
||||
Colormap cmap = DefaultColormap(dpy, screen);
|
||||
|
@ -172,7 +172,7 @@ textw(char *text)
|
|||
}
|
||||
|
||||
void
|
||||
initfont(const char *fontstr)
|
||||
setfont(const char *fontstr)
|
||||
{
|
||||
char **missing, *def;
|
||||
int i, n;
|
||||
|
|
24
dwm.h
24
dwm.h
|
@ -107,22 +107,22 @@ extern void manage(Window w, XWindowAttributes *wa);
|
|||
extern void unmanage(Client *c);
|
||||
extern Client *getclient(Window w);
|
||||
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 update_size(Client *c);
|
||||
extern void setsize(Client *c);
|
||||
extern Client *gettitle(Window w);
|
||||
extern void craise(Client *c);
|
||||
extern void higher(Client *c);
|
||||
extern void lower(Client *c);
|
||||
extern void gravitate(Client *c, Bool invert);
|
||||
extern void ban_client(Client *c);
|
||||
extern Client *next(Client *c);
|
||||
extern void ban(Client *c);
|
||||
extern Client *getnext(Client *c);
|
||||
|
||||
/* draw.c */
|
||||
extern void draw_bar();
|
||||
extern void draw_client(Client *c);
|
||||
extern void drawstatus();
|
||||
extern void drawtitle(Client *c);
|
||||
extern void drawtext(const char *text, Bool invert, Bool border);
|
||||
extern unsigned long initcolor(const char *colstr);
|
||||
extern void initfont(const char *fontstr);
|
||||
extern unsigned long getcolor(const char *colstr);
|
||||
extern void setfont(const char *fontstr);
|
||||
extern unsigned int textnw(char *text, unsigned int len);
|
||||
extern unsigned int textw(char *text);
|
||||
extern unsigned int texth(void);
|
||||
|
@ -132,9 +132,9 @@ extern void grabkeys();
|
|||
extern void keypress(XEvent *e);
|
||||
|
||||
/* main.c */
|
||||
extern int error_handler(Display *dsply, XErrorEvent *e);
|
||||
extern void send_message(Window w, Atom a, long value);
|
||||
extern int win_proto(Window w);
|
||||
extern int xerror(Display *dsply, XErrorEvent *e);
|
||||
extern void sendevent(Window w, Atom a, long value);
|
||||
extern int proto(Window w);
|
||||
extern void quit(Arg *arg);
|
||||
|
||||
/* screen.c */
|
||||
|
|
14
event.c
14
event.c
|
@ -129,7 +129,7 @@ buttonpress(XEvent *e)
|
|||
else if((c = getclient(ev->window))) {
|
||||
if(arrange == tiling && !c->floating)
|
||||
return;
|
||||
craise(c);
|
||||
higher(c);
|
||||
switch(ev->button) {
|
||||
default:
|
||||
break;
|
||||
|
@ -225,9 +225,9 @@ expose(XEvent *e)
|
|||
|
||||
if(ev->count == 0) {
|
||||
if(barwin == ev->window)
|
||||
draw_bar();
|
||||
drawstatus();
|
||||
else if((c = gettitle(ev->window)))
|
||||
draw_client(c);
|
||||
drawtitle(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,7 +262,7 @@ propertynotify(XEvent *e)
|
|||
|
||||
if((c = getclient(ev->window))) {
|
||||
if(ev->atom == wm_atom[WMProtocols]) {
|
||||
c->proto = win_proto(c->win);
|
||||
c->proto = proto(c->win);
|
||||
return;
|
||||
}
|
||||
switch (ev->atom) {
|
||||
|
@ -273,12 +273,12 @@ propertynotify(XEvent *e)
|
|||
arrange(NULL);
|
||||
break;
|
||||
case XA_WM_NORMAL_HINTS:
|
||||
update_size(c);
|
||||
setsize(c);
|
||||
break;
|
||||
}
|
||||
if(ev->atom == XA_WM_NAME || ev->atom == net_atom[NetWMName]) {
|
||||
update_name(c);
|
||||
draw_client(c);
|
||||
settitle(c);
|
||||
drawtitle(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
16
key.c
16
key.c
|
@ -99,8 +99,8 @@ zoom(Arg *arg)
|
|||
if(!sel)
|
||||
return;
|
||||
|
||||
if(sel == next(clients) && sel->next) {
|
||||
if((c = next(sel->next)))
|
||||
if(sel == getnext(clients) && sel->next) {
|
||||
if((c = getnext(sel->next)))
|
||||
sel = c;
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ max(Arg *arg)
|
|||
sel->y = sy + bh;
|
||||
sel->w = sw - 2 * sel->border;
|
||||
sel->h = sh - 2 * sel->border - bh;
|
||||
craise(sel);
|
||||
higher(sel);
|
||||
resize(sel, False);
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ prevc(Arg *arg)
|
|||
return;
|
||||
|
||||
if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) {
|
||||
craise(c);
|
||||
higher(c);
|
||||
focus(c);
|
||||
}
|
||||
}
|
||||
|
@ -170,10 +170,10 @@ nextc(Arg *arg)
|
|||
if(!sel)
|
||||
return;
|
||||
|
||||
if(!(c = next(sel->next)))
|
||||
c = next(clients);
|
||||
if(!(c = getnext(sel->next)))
|
||||
c = getnext(clients);
|
||||
if(c) {
|
||||
craise(c);
|
||||
higher(c);
|
||||
c->revert = sel;
|
||||
focus(c);
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ ckill(Arg *arg)
|
|||
if(!sel)
|
||||
return;
|
||||
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
|
||||
XKillClient(dpy, sel->win);
|
||||
}
|
||||
|
|
28
main.c
28
main.c
|
@ -46,7 +46,7 @@ Client *sel = NULL;
|
|||
static Bool other_wm_running;
|
||||
static const char version[] =
|
||||
"dwm-" VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
|
||||
static int (*x_error_handler) (Display *, XErrorEvent *);
|
||||
static int (*x_xerror) (Display *, XErrorEvent *);
|
||||
|
||||
static void
|
||||
usage() { error("usage: dwm [-v]\n"); }
|
||||
|
@ -94,7 +94,7 @@ win_property(Window w, Atom a, Atom t, long l, unsigned char **prop)
|
|||
}
|
||||
|
||||
int
|
||||
win_proto(Window w)
|
||||
proto(Window w)
|
||||
{
|
||||
unsigned char *protocols;
|
||||
long res;
|
||||
|
@ -114,7 +114,7 @@ win_proto(Window w)
|
|||
}
|
||||
|
||||
void
|
||||
send_message(Window w, Atom a, long value)
|
||||
sendevent(Window w, Atom a, long value)
|
||||
{
|
||||
XEvent e;
|
||||
|
||||
|
@ -135,7 +135,7 @@ send_message(Window w, Atom a, long value)
|
|||
* calls exit().
|
||||
*/
|
||||
int
|
||||
error_handler(Display *dpy, XErrorEvent *error)
|
||||
xerror(Display *dpy, XErrorEvent *error)
|
||||
{
|
||||
if(error->error_code == BadWindow
|
||||
|| (error->request_code == X_SetInputFocus
|
||||
|
@ -153,7 +153,7 @@ error_handler(Display *dpy, XErrorEvent *error)
|
|||
return 0;
|
||||
fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
|
||||
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.
|
||||
*/
|
||||
static int
|
||||
startup_error_handler(Display *dpy, XErrorEvent *error)
|
||||
startup_xerror(Display *dpy, XErrorEvent *error)
|
||||
{
|
||||
other_wm_running = True;
|
||||
return -1;
|
||||
|
@ -215,7 +215,7 @@ main(int argc, char *argv[])
|
|||
|
||||
/* check if another WM is already running */
|
||||
other_wm_running = False;
|
||||
XSetErrorHandler(startup_error_handler);
|
||||
XSetErrorHandler(startup_xerror);
|
||||
/* this causes an error if some other WM is running */
|
||||
XSelectInput(dpy, root, SubstructureRedirectMask);
|
||||
XFlush(dpy);
|
||||
|
@ -224,7 +224,7 @@ main(int argc, char *argv[])
|
|||
error("dwm: another window manager is already running\n");
|
||||
|
||||
XSetErrorHandler(0);
|
||||
x_error_handler = XSetErrorHandler(error_handler);
|
||||
x_xerror = XSetErrorHandler(xerror);
|
||||
|
||||
/* init atoms */
|
||||
wm_atom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
|
||||
|
@ -242,10 +242,10 @@ main(int argc, char *argv[])
|
|||
grabkeys();
|
||||
|
||||
/* style */
|
||||
dc.bg = initcolor(BGCOLOR);
|
||||
dc.fg = initcolor(FGCOLOR);
|
||||
dc.border = initcolor(BORDERCOLOR);
|
||||
initfont(FONT);
|
||||
dc.bg = getcolor(BGCOLOR);
|
||||
dc.fg = getcolor(FGCOLOR);
|
||||
dc.border = getcolor(BORDERCOLOR);
|
||||
setfont(FONT);
|
||||
|
||||
sx = sy = 0;
|
||||
sw = DisplayWidth(dpy, screen);
|
||||
|
@ -267,7 +267,7 @@ main(int argc, char *argv[])
|
|||
|
||||
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
|
||||
dc.gc = XCreateGC(dpy, root, 0, 0);
|
||||
draw_bar();
|
||||
drawstatus();
|
||||
|
||||
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
||||
|
||||
|
@ -315,7 +315,7 @@ Mainloop:
|
|||
stext[n++] = i;
|
||||
}
|
||||
stext[n] = 0;
|
||||
draw_bar();
|
||||
drawstatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
24
screen.c
24
screen.c
|
@ -15,9 +15,9 @@ view(Arg *arg)
|
|||
tsel = arg->i;
|
||||
arrange(NULL);
|
||||
|
||||
for(c = clients; c; c = next(c->next))
|
||||
draw_client(c);
|
||||
draw_bar();
|
||||
for(c = clients; c; c = getnext(c->next))
|
||||
drawtitle(c);
|
||||
drawstatus();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -30,15 +30,15 @@ floating(Arg *arg)
|
|||
if(c->tags[tsel])
|
||||
resize(c, True);
|
||||
else
|
||||
ban_client(c);
|
||||
ban(c);
|
||||
}
|
||||
if(sel && !sel->tags[tsel]) {
|
||||
if((sel = next(clients))) {
|
||||
craise(sel);
|
||||
if((sel = getnext(clients))) {
|
||||
higher(sel);
|
||||
focus(sel);
|
||||
}
|
||||
}
|
||||
draw_bar();
|
||||
drawstatus();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -61,7 +61,7 @@ tiling(Arg *arg)
|
|||
for(i = 0, c = clients; c; c = c->next) {
|
||||
if(c->tags[tsel]) {
|
||||
if(c->floating) {
|
||||
craise(c);
|
||||
higher(c);
|
||||
resize(c, True);
|
||||
continue;
|
||||
}
|
||||
|
@ -87,14 +87,14 @@ tiling(Arg *arg)
|
|||
i++;
|
||||
}
|
||||
else
|
||||
ban_client(c);
|
||||
ban(c);
|
||||
}
|
||||
if(!sel || (sel && !sel->tags[tsel])) {
|
||||
if((sel = next(clients))) {
|
||||
craise(sel);
|
||||
if((sel = getnext(clients))) {
|
||||
higher(sel);
|
||||
focus(sel);
|
||||
}
|
||||
}
|
||||
draw_bar();
|
||||
drawstatus();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue