dwm-meillo

changeset 452:026aba558fdf

added some comments
author Anselm R. Garbe <arg@10kloc.org>
date Mon, 11 Sep 2006 07:40:41 +0200
parents d358f2daa8ba
children f30f937f9e52
files client.c dwm.h
diffstat 2 files changed, 72 insertions(+), 75 deletions(-) [+]
line diff
     1.1 --- a/client.c	Fri Sep 08 08:32:08 2006 +0200
     1.2 +++ b/client.c	Mon Sep 11 07:40:41 2006 +0200
     1.3 @@ -19,11 +19,11 @@
     1.4  }
     1.5  
     1.6  static void
     1.7 -grabbuttons(Client *c, Bool focus)
     1.8 +grabbuttons(Client *c, Bool focused)
     1.9  {
    1.10  	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
    1.11  
    1.12 -	if(focus) {
    1.13 +	if(focused) {
    1.14  		XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
    1.15  				GrabModeAsync, GrabModeSync, None, None);
    1.16  		XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK,
    1.17 @@ -304,7 +304,7 @@
    1.18  		wc.border_width = 0;
    1.19  	else
    1.20  		wc.border_width = 1;
    1.21 -	XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
    1.22 +	XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
    1.23  	XSync(dpy, False);
    1.24  }
    1.25  
     2.1 --- a/dwm.h	Fri Sep 08 08:32:08 2006 +0200
     2.2 +++ b/dwm.h	Mon Sep 11 07:40:41 2006 +0200
     2.3 @@ -11,23 +11,19 @@
     2.4  #define MOUSEMASK		(BUTTONMASK | PointerMotionMask)
     2.5  #define PROTODELWIN		1
     2.6  
     2.7 +enum { NetSupported, NetWMName, NetLast };		/* EWMH atoms */
     2.8 +enum { WMProtocols, WMDelete, WMLast };			/* default atoms */
     2.9 +enum { CurNormal, CurResize, CurMove, CurLast };	/* cursor */
    2.10 +enum { ColFG, ColBG, ColLast };				/* color */
    2.11 +
    2.12 +typedef enum {
    2.13 +	TopLeft, TopRight, BotLeft, BotRight
    2.14 +} Corner; /* window corners */
    2.15 +
    2.16  typedef union {
    2.17  	const char *cmd;
    2.18  	int i;
    2.19 -} Arg;
    2.20 -
    2.21 -/* atoms */
    2.22 -enum { NetSupported, NetWMName, NetLast };
    2.23 -enum { WMProtocols, WMDelete, WMLast };
    2.24 -
    2.25 -/* cursor */
    2.26 -enum { CurNormal, CurResize, CurMove, CurLast };
    2.27 -
    2.28 -/* color */
    2.29 -enum { ColFG, ColBG, ColLast };
    2.30 -
    2.31 -/* window corners */
    2.32 -typedef enum { TopLeft, TopRight, BotLeft, BotRight } Corner;
    2.33 +} Arg; /* argument type */
    2.34  
    2.35  typedef struct {
    2.36  	int ascent;
    2.37 @@ -37,7 +33,7 @@
    2.38  	XFontStruct *xfont;
    2.39  } Fnt;
    2.40  
    2.41 -typedef struct { /* draw context */
    2.42 +typedef struct {
    2.43  	int x, y, w, h;
    2.44  	unsigned long norm[ColLast];
    2.45  	unsigned long sel[ColLast];
    2.46 @@ -45,7 +41,7 @@
    2.47  	Drawable drawable;
    2.48  	Fnt font;
    2.49  	GC gc;
    2.50 -} DC;
    2.51 +} DC; /* draw context */
    2.52  
    2.53  typedef struct Client Client;
    2.54  struct Client {
    2.55 @@ -66,77 +62,78 @@
    2.56  	Window twin;
    2.57  };
    2.58  
    2.59 -extern const char *tags[];
    2.60 -extern char stext[1024];
    2.61 -extern int bx, by, bw, bh, bmw, mw, screen, sx, sy, sw, sh;
    2.62 -extern unsigned int ntags, numlockmask;
    2.63 -extern void (*handler[LASTEvent])(XEvent *);
    2.64 -extern void (*arrange)(Arg *);
    2.65 +extern const char *tags[];			/* all tags */
    2.66 +extern char stext[1024];			/* status text */
    2.67 +extern int bx, by, bw, bh, bmw;			/* bar geometry, bar mode label width */
    2.68 +extern int mw, screen, sx, sy, sw, sh;		/* screen geometry, master width */
    2.69 +extern unsigned int ntags, numlockmask;		/* number of tags, and dynamic lock mask */
    2.70 +extern void (*handler[LASTEvent])(XEvent *);	/* event handler */
    2.71 +extern void (*arrange)(Arg *);			/* arrange function, indicates mode  */
    2.72  extern Atom wmatom[WMLast], netatom[NetLast];
    2.73 -extern Bool running, issel, maximized, *seltag;
    2.74 -extern Client *clients, *sel, *stack;
    2.75 +extern Bool running, issel, maximized, *seltag;	/* seltag is array of Bool */
    2.76 +extern Client *clients, *sel, *stack;		/* Client containers */
    2.77  extern Cursor cursor[CurLast];
    2.78 -extern DC dc;
    2.79 +extern DC dc;					/* draw context for everything */
    2.80  extern Display *dpy;
    2.81  extern Window root, barwin;
    2.82  
    2.83  /* client.c */
    2.84 -extern void ban(Client *c);
    2.85 -extern void focus(Client *c);
    2.86 -extern Client *getclient(Window w);
    2.87 -extern Client *getctitle(Window w);
    2.88 -extern void gravitate(Client *c, Bool invert);
    2.89 -extern void killclient(Arg *arg);
    2.90 -extern void manage(Window w, XWindowAttributes *wa);
    2.91 -extern void resize(Client *c, Bool sizehints, Corner sticky);
    2.92 -extern void setsize(Client *c);
    2.93 -extern void settitle(Client *c);
    2.94 -extern void togglemax(Arg *arg);
    2.95 -extern void unmanage(Client *c);
    2.96 +extern void ban(Client *c);			/* ban client from screen */
    2.97 +extern void focus(Client *c);			/* focus c, c may be NULL */
    2.98 +extern Client *getclient(Window w);		/* return client of w */
    2.99 +extern Client *getctitle(Window w);		/* return client of title window */
   2.100 +extern void gravitate(Client *c, Bool invert);	/* gravitate c */
   2.101 +extern void killclient(Arg *arg);		/* kill c nicely */
   2.102 +extern void manage(Window w, XWindowAttributes *wa);	/* manage new client */
   2.103 +extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize c*/
   2.104 +extern void setsize(Client *c);			/* set the size structs of c */
   2.105 +extern void settitle(Client *c);		/* set the name of c */
   2.106 +extern void togglemax(Arg *arg);		/* (un)maximize c */
   2.107 +extern void unmanage(Client *c);		/* destroy c */
   2.108  
   2.109  /* draw.c */
   2.110 -extern void drawall();
   2.111 -extern void drawstatus();
   2.112 -extern void drawtitle(Client *c);
   2.113 -extern unsigned long getcolor(const char *colstr);
   2.114 -extern void setfont(const char *fontstr);
   2.115 -extern unsigned int textw(const char *text);
   2.116 +extern void drawall();				/* draw all visible client titles and the bar */
   2.117 +extern void drawstatus();			/* draw the bar */
   2.118 +extern void drawtitle(Client *c);		/* draw title of c */
   2.119 +extern unsigned long getcolor(const char *colstr);	/* return color of colstr */
   2.120 +extern void setfont(const char *fontstr);	/* set the font for DC */
   2.121 +extern unsigned int textw(const char *text);	/* return the text width of text */
   2.122  
   2.123  /* event.c */
   2.124 -extern void grabkeys();
   2.125 -extern void procevent();
   2.126 +extern void grabkeys();				/* grab all keys defined in config.h */
   2.127 +extern void procevent();			/* process pending X events */
   2.128  
   2.129  /* main.c */
   2.130 -extern int getproto(Window w);
   2.131 -extern void quit(Arg *arg);
   2.132 -extern void sendevent(Window w, Atom a, long value);
   2.133 -extern int xerror(Display *dsply, XErrorEvent *ee);
   2.134 +extern int getproto(Window w);			/* return protocol mask of WMProtocols property of w */
   2.135 +extern void quit(Arg *arg);			/* quit dwm nicely */
   2.136 +extern void sendevent(Window w, Atom a, long value);	/* send synthetic event to w */
   2.137 +extern int xerror(Display *dsply, XErrorEvent *ee);	/* dwm's X error handler */
   2.138  
   2.139  /* tag.c */
   2.140 -extern void initrregs();
   2.141 -extern Client *getnext(Client *c);
   2.142 -extern Client *getprev(Client *c);
   2.143 -extern void settags(Client *c, Client *trans);
   2.144 -extern void tag(Arg *arg);
   2.145 -extern void toggletag(Arg *arg);
   2.146 +extern void initrregs();			/* initialize regexps of rules defined in config.h */
   2.147 +extern Client *getnext(Client *c);		/* returns next visible client */
   2.148 +extern Client *getprev(Client *c);		/* returns previous visible client */
   2.149 +extern void settags(Client *c, Client *trans);	/* updates tags of c */
   2.150 +extern void tag(Arg *arg);			/* tags c accordingly to arg's index */
   2.151 +extern void toggletag(Arg *arg);		/* toggles c tags accordingly to arg's index */
   2.152  
   2.153  /* util.c */
   2.154 -extern void *emallocz(unsigned int size);
   2.155 -extern void eprint(const char *errstr, ...);
   2.156 -extern void *erealloc(void *ptr, unsigned int size);
   2.157 -extern void spawn(Arg *arg);
   2.158 +extern void *emallocz(unsigned int size);	/* allocates zero-initialized memory, exits on error */
   2.159 +extern void eprint(const char *errstr, ...);	/* prints error string and exits with return code 1 */
   2.160 +extern void *erealloc(void *ptr, unsigned int size);	/* reallocates memory, exits on error */
   2.161 +extern void spawn(Arg *arg)			/* forks a new subprocess accordingly to arg's cmd */
   2.162  
   2.163  /* view.c */
   2.164 -extern void detach(Client *c);
   2.165 -extern void dofloat(Arg *arg);
   2.166 -extern void dotile(Arg *arg);
   2.167 -extern void focusnext(Arg *arg);
   2.168 -extern void focusprev(Arg *arg);
   2.169 -extern Bool isvisible(Client *c);
   2.170 -extern void resizecol(Arg *arg);
   2.171 -extern void restack();
   2.172 -extern void togglemode(Arg *arg);
   2.173 -extern void toggleview(Arg *arg);
   2.174 -extern void view(Arg *arg);
   2.175 -extern void viewall(Arg *arg);
   2.176 -extern void zoom(Arg *arg);
   2.177 +extern void detach(Client *c);			/* detaches c from global client list */
   2.178 +extern void dofloat(Arg *arg);			/* arranges all windows in a floating way, arg is ignored */
   2.179 +extern void dotile(Arg *arg);			/* arranges all windows in a tiled way, arg is ignored */
   2.180 +extern void focusnext(Arg *arg);		/* focuses next visible client, arg is ignored  */
   2.181 +extern void focusprev(Arg *arg);		/* focuses previous visible client, arg is ignored */
   2.182 +extern Bool isvisible(Client *c);		/* returns True if client is visible */
   2.183 +extern void resizecol(Arg *arg);		/* resizes the master width accordingly to arg's index value */
   2.184 +extern void restack();				/* restores z layers of all clients */
   2.185 +extern void togglemode(Arg *arg);		/* toggles global arrange mode (between dotile and dofloat) */
   2.186 +extern void toggleview(Arg *arg);		/* makes the tag accordingly to arg's index (in)visible */
   2.187 +extern void view(Arg *arg);			/* makes the tag accordingly to arg's index visible */
   2.188 +extern void viewall(Arg *arg);			/* makes all tags visible, arg is ignored */
   2.189 +extern void zoom(Arg *arg);			/* zooms the focused client to master column, arg is ignored */