Xinqi Bao's Git
projects
/
dwm.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
s/int/uint/ in config.h
[dwm.git]
/
dwm.c
diff --git
a/dwm.c
b/dwm.c
index
1f4b881
..
f46f069
100644
(file)
--- a/
dwm.c
+++ b/
dwm.c
@@
-60,6
+60,8
@@
enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
/* typedefs */
enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
/* typedefs */
+typedef unsigned int uint;
+typedef unsigned long ulong;
typedef struct Client Client;
struct Client {
char name[256];
typedef struct Client Client;
struct Client {
char name[256];
@@
-67,9
+69,9
@@
struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int minax, maxax, minay, maxay;
long flags;
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int minax, maxax, minay, maxay;
long flags;
-
unsigned
int bw, oldbw;
+ int bw, oldbw;
Bool isbanned, isfixed, isfloating, isurgent;
Bool isbanned, isfixed, isfloating, isurgent;
- u
nsigned
int tags;
+ uint tags;
Client *next;
Client *prev;
Client *snext;
Client *next;
Client *prev;
Client *snext;
@@
-78,8
+80,8
@@
struct Client {
typedef struct {
int x, y, w, h;
typedef struct {
int x, y, w, h;
- u
nsigned
long norm[ColLast];
- u
nsigned
long sel[ColLast];
+ ulong norm[ColLast];
+ ulong sel[ColLast];
Drawable drawable;
GC gc;
struct {
Drawable drawable;
GC gc;
struct {
@@
-92,7
+94,7
@@
typedef struct {
} DC; /* draw context */
typedef struct {
} DC; /* draw context */
typedef struct {
- u
nsigned long
mod;
+ u
int
mod;
KeySym keysym;
void (*func)(const void *arg);
const void *arg;
KeySym keysym;
void (*func)(const void *arg);
const void *arg;
@@
-108,7
+110,7
@@
typedef struct {
const char *class;
const char *instance;
const char *title;
const char *class;
const char *instance;
const char *title;
- u
nsigned
int tags;
+ uint tags;
Bool isfloating;
} Rule;
Bool isfloating;
} Rule;
@@
-128,9
+130,9
@@
void destroynotify(XEvent *e);
void detach(Client *c);
void detachstack(Client *c);
void drawbar(void);
void detach(Client *c);
void detachstack(Client *c);
void drawbar(void);
-void drawsquare(Bool filled, Bool empty, Bool invert, u
nsigned
long col[ColLast]);
-void drawtext(const char *text, u
nsigned
long col[ColLast], Bool invert);
-void *emallocz(u
nsigned
int size);
+void drawsquare(Bool filled, Bool empty, Bool invert, ulong col[ColLast]);
+void drawtext(const char *text, ulong col[ColLast], Bool invert);
+void *emallocz(uint size);
void enternotify(XEvent *e);
void eprint(const char *errstr, ...);
void expose(XEvent *e);
void enternotify(XEvent *e);
void eprint(const char *errstr, ...);
void expose(XEvent *e);
@@
-139,15
+141,15
@@
void focusin(XEvent *e);
void focusnext(const void *arg);
void focusprev(const void *arg);
Client *getclient(Window w);
void focusnext(const void *arg);
void focusprev(const void *arg);
Client *getclient(Window w);
-u
nsigned
long getcolor(const char *colstr);
+ulong getcolor(const char *colstr);
long getstate(Window w);
long getstate(Window w);
-Bool gettextprop(Window w, Atom atom, char *text, u
nsigned
int size);
+Bool gettextprop(Window w, Atom atom, char *text, uint size);
void grabbuttons(Client *c, Bool focused);
void grabkeys(void);
void initfont(const char *fontstr);
void grabbuttons(Client *c, Bool focused);
void grabkeys(void);
void initfont(const char *fontstr);
-Bool isoccupied(u
nsigned
int t);
+Bool isoccupied(uint t);
Bool isprotodel(Client *c);
Bool isprotodel(Client *c);
-Bool isurgent(u
nsigned
int t);
+Bool isurgent(uint t);
Bool isvisible(Client *c);
void keypress(XEvent *e);
void killclient(const void *arg);
Bool isvisible(Client *c);
void keypress(XEvent *e);
void killclient(const void *arg);
@@
-155,7
+157,7
@@
void manage(Window w, XWindowAttributes *wa);
void mappingnotify(XEvent *e);
void maprequest(XEvent *e);
void movemouse(Client *c);
void mappingnotify(XEvent *e);
void maprequest(XEvent *e);
void movemouse(Client *c);
-Client *next
unfloating
(Client *c);
+Client *next
tiled
(Client *c);
void propertynotify(XEvent *e);
void quit(const void *arg);
void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
void propertynotify(XEvent *e);
void quit(const void *arg);
void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
@@
-168,8
+170,8
@@
void setmfact(const void *arg);
void setup(void);
void spawn(const void *arg);
void tag(const void *arg);
void setup(void);
void spawn(const void *arg);
void tag(const void *arg);
-u
nsigned int textnw(const char *text, unsigned
int len);
-u
nsigned
int textw(const char *text);
+u
int textnw(const char *text, u
int len);
+uint textw(const char *text);
void tile(void);
void tileresize(Client *c, int x, int y, int w, int h);
void togglebar(const void *arg);
void tile(void);
void tileresize(Client *c, int x, int y, int w, int h);
void togglebar(const void *arg);
@@
-198,9
+200,9
@@
char stext[256];
int screen, sx, sy, sw, sh;
int bx, by, bw, bh, blw, wx, wy, ww, wh;
int mx, my, mw, mh, tx, ty, tw, th;
int screen, sx, sy, sw, sh;
int bx, by, bw, bh, blw, wx, wy, ww, wh;
int mx, my, mw, mh, tx, ty, tw, th;
-u
nsigned
int seltags = 0;
+uint seltags = 0;
int (*xerrorxlib)(Display *, XErrorEvent *);
int (*xerrorxlib)(Display *, XErrorEvent *);
-u
nsigned
int numlockmask = 0;
+uint numlockmask = 0;
void (*handler[LASTEvent]) (XEvent *) = {
[ButtonPress] = buttonpress,
[ConfigureRequest] = configurerequest,
void (*handler[LASTEvent]) (XEvent *) = {
[ButtonPress] = buttonpress,
[ConfigureRequest] = configurerequest,
@@
-218,7
+220,7
@@
void (*handler[LASTEvent]) (XEvent *) = {
Atom wmatom[WMLast], netatom[NetLast];
Bool otherwm, readin;
Bool running = True;
Atom wmatom[WMLast], netatom[NetLast];
Bool otherwm, readin;
Bool running = True;
-u
nsigned
int tagset[] = {1, 1}; /* after start, first tag is selected */
+uint tagset[] = {1, 1}; /* after start, first tag is selected */
Client *clients = NULL;
Client *sel = NULL;
Client *stack = NULL;
Client *clients = NULL;
Client *sel = NULL;
Client *stack = NULL;
@@
-232,14
+234,13
@@
Window root, barwin;
/* configuration, allows nested code to access above variables */
#include "config.h"
/* configuration, allows nested code to access above variables */
#include "config.h"
-/* c
heck if all tags will fit into a unsigned int bit
array. */
-st
atic char tags_is_a_sign_that_your_IQ[sizeof(int) * 8 < LENGTH(tags) ? -1 : 1]
;
+/* c
ompile-time check if all tags fit into an uint bit
array. */
+st
ruct NumTags { char limitexceeded[sizeof(uint) * 8 < LENGTH(tags) ? -1 : 1]; }
;
/* function implementations */
/* function implementations */
-
void
applyrules(Client *c) {
void
applyrules(Client *c) {
- u
nsigned
int i;
+ uint i;
Rule *r;
XClassHint ch = { 0 };
Rule *r;
XClassHint ch = { 0 };
@@
-305,7
+306,7
@@
ban(Client *c) {
void
buttonpress(XEvent *e) {
void
buttonpress(XEvent *e) {
- u
nsigned
int i, x, mask;
+ uint i, x, mask;
Client *c;
XButtonPressedEvent *ev = &e->xbutton;
Client *c;
XButtonPressedEvent *ev = &e->xbutton;
@@
-538,7
+539,7
@@
drawbar(void) {
}
void
}
void
-drawsquare(Bool filled, Bool empty, Bool invert, u
nsigned
long col[ColLast]) {
+drawsquare(Bool filled, Bool empty, Bool invert, ulong col[ColLast]) {
int x;
XGCValues gcv;
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
int x;
XGCValues gcv;
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
@@
-559,9
+560,9
@@
drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) {
}
void
}
void
-drawtext(const char *text, u
nsigned
long col[ColLast], Bool invert) {
+drawtext(const char *text, ulong col[ColLast], Bool invert) {
int x, y, w, h;
int x, y, w, h;
- u
nsigned
int len, olen;
+ uint len, olen;
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
char buf[256];
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
char buf[256];
@@
-596,7
+597,7
@@
drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
}
void *
}
void *
-emallocz(u
nsigned
int size) {
+emallocz(uint size) {
void *res = calloc(1, size);
if(!res)
void *res = calloc(1, size);
if(!res)
@@
-706,7
+707,7
@@
getclient(Window w) {
return c;
}
return c;
}
-u
nsigned
long
+ulong
getcolor(const char *colstr) {
Colormap cmap = DefaultColormap(dpy, screen);
XColor color;
getcolor(const char *colstr) {
Colormap cmap = DefaultColormap(dpy, screen);
XColor color;
@@
-721,7
+722,7
@@
getstate(Window w) {
int format, status;
long result = -1;
unsigned char *p = NULL;
int format, status;
long result = -1;
unsigned char *p = NULL;
- u
nsigned
long n, extra;
+ ulong n, extra;
Atom real;
status = XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState],
Atom real;
status = XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState],
@@
-735,7
+736,7
@@
getstate(Window w) {
}
Bool
}
Bool
-gettextprop(Window w, Atom atom, char *text, u
nsigned
int size) {
+gettextprop(Window w, Atom atom, char *text, uint size) {
char **list = NULL;
int n;
XTextProperty name;
char **list = NULL;
int n;
XTextProperty name;
@@
-763,8
+764,8
@@
gettextprop(Window w, Atom atom, char *text, unsigned int size) {
void
grabbuttons(Client *c, Bool focused) {
int i, j;
void
grabbuttons(Client *c, Bool focused) {
int i, j;
- u
nsigned
int buttons[] = { Button1, Button2, Button3 };
- u
nsigned
int modifiers[] = { MODKEY, MODKEY|LockMask, MODKEY|numlockmask,
+ uint buttons[] = { Button1, Button2, Button3 };
+ uint modifiers[] = { MODKEY, MODKEY|LockMask, MODKEY|numlockmask,
MODKEY|numlockmask|LockMask} ;
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
MODKEY|numlockmask|LockMask} ;
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
@@
-780,7
+781,7
@@
grabbuttons(Client *c, Bool focused) {
void
grabkeys(void) {
void
grabkeys(void) {
- u
nsigned
int i, j;
+ uint i, j;
KeyCode code;
XModifierKeymap *modmap;
KeyCode code;
XModifierKeymap *modmap;
@@
-848,7
+849,7
@@
initfont(const char *fontstr) {
}
Bool
}
Bool
-isoccupied(u
nsigned
int t) {
+isoccupied(uint t) {
Client *c;
for(c = clients; c; c = c->next)
Client *c;
for(c = clients; c; c = c->next)
@@
-873,7
+874,7
@@
isprotodel(Client *c) {
}
Bool
}
Bool
-isurgent(u
nsigned
int t) {
+isurgent(uint t) {
Client *c;
for(c = clients; c; c = c->next)
Client *c;
for(c = clients; c; c = c->next)
@@
-889,7
+890,7
@@
isvisible(Client *c) {
void
keypress(XEvent *e) {
void
keypress(XEvent *e) {
- u
nsigned
int i;
+ uint i;
KeySym keysym;
XKeyEvent *ev;
KeySym keysym;
XKeyEvent *ev;
@@
-1004,7
+1005,7
@@
maprequest(XEvent *e) {
void
movemouse(Client *c) {
int x1, y1, ocx, ocy, di, nx, ny;
void
movemouse(Client *c) {
int x1, y1, ocx, ocy, di, nx, ny;
- u
nsigned
int dui;
+ uint dui;
Window dummy;
XEvent ev;
Window dummy;
XEvent ev;
@@
-1050,7
+1051,7
@@
movemouse(Client *c) {
}
Client *
}
Client *
-next
unfloating
(Client *c) {
+next
tiled
(Client *c) {
for(; c && (c->isfloating || !isvisible(c)); c = c->next);
return c;
}
for(; c && (c->isfloating || !isvisible(c)); c = c->next);
return c;
}
@@
-1230,7
+1231,7
@@
run(void) {
char sbuf[sizeof stext];
fd_set rd;
int r, xfd;
char sbuf[sizeof stext];
fd_set rd;
int r, xfd;
- u
nsigned
int len, offset;
+ uint len, offset;
XEvent ev;
/* main event loop, also reads status text from stdin */
XEvent ev;
/* main event loop, also reads status text from stdin */
@@
-1286,7
+1287,7
@@
run(void) {
void
scan(void) {
void
scan(void) {
- u
nsigned
int i, num;
+ uint i, num;
Window *wins, d1, d2;
XWindowAttributes wa;
Window *wins, d1, d2;
XWindowAttributes wa;
@@
-1336,7
+1337,7
@@
setmfact(const void *arg) {
void
setup(void) {
void
setup(void) {
- u
nsigned
int i, w;
+ uint i, w;
XSetWindowAttributes wa;
/* init screen */
XSetWindowAttributes wa;
/* init screen */
@@
-1441,8
+1442,8
@@
tag(const void *arg) {
}
}
}
}
-u
nsigned
int
-textnw(const char *text, u
nsigned
int len) {
+uint
+textnw(const char *text, uint len) {
XRectangle r;
if(dc.font.set) {
XRectangle r;
if(dc.font.set) {
@@
-1452,7
+1453,7
@@
textnw(const char *text, unsigned int len) {
return XTextWidth(dc.font.xfont, text, len);
}
return XTextWidth(dc.font.xfont, text, len);
}
-u
nsigned
int
+uint
textw(const char *text) {
return textnw(text, strlen(text)) + dc.font.height;
}
textw(const char *text) {
return textnw(text, strlen(text)) + dc.font.height;
}
@@
-1460,15
+1461,15
@@
textw(const char *text) {
void
tile(void) {
int x, y, h, w;
void
tile(void) {
int x, y, h, w;
- u
nsigned
int i, n;
+ uint i, n;
Client *c;
Client *c;
- for(n = 0, c = next
unfloating(clients); c; c = nextunfloating
(c->next), n++);
+ for(n = 0, c = next
tiled(clients); c; c = nexttiled
(c->next), n++);
if(n == 0)
return;
/* master */
if(n == 0)
return;
/* master */
- c = next
unfloating
(clients);
+ c = next
tiled
(clients);
if(n == 1)
tileresize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw);
if(n == 1)
tileresize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw);
@@
-1486,7
+1487,7
@@
tile(void) {
if(h < bh)
h = th;
if(h < bh)
h = th;
- for(i = 0, c = next
unfloating(c->next); c; c = nextunfloating
(c->next), i++) {
+ for(i = 0, c = next
tiled(c->next); c; c = nexttiled
(c->next), i++) {
if(i + 1 == n) /* remainder */
tileresize(c, x, y, w - 2 * c->bw, (ty + th) - y - 2 * c->bw);
else
if(i + 1 == n) /* remainder */
tileresize(c, x, y, w - 2 * c->bw, (ty + th) - y - 2 * c->bw);
else
@@
-1524,7
+1525,7
@@
togglefloating(const void *arg) {
void
togglelayout(const void *arg) {
void
togglelayout(const void *arg) {
- u
nsigned
int i;
+ uint i;
if(!arg) {
if(++lt == &layouts[LENGTH(layouts)])
if(!arg) {
if(++lt == &layouts[LENGTH(layouts)])
@@
-1546,14
+1547,6
@@
togglelayout(const void *arg) {
void
toggletag(const void *arg) {
void
toggletag(const void *arg) {
- int i, m = *(int *)arg;
- for(i = 0; i < sizeof(int) * 8; i++)
- fputc(m & 1 << i ? '1' : '0', stdout);
- puts("");
- for(i = 0; i < sizeof(int) * 8; i++)
- fputc(TAGMASK & 1 << i ? '1' : '0', stdout);
- puts("aaa");
-
if(sel && (sel->tags ^ ((*(int *)arg) & TAGMASK))) {
sel->tags ^= (*(int *)arg) & TAGMASK;
arrange();
if(sel && (sel->tags ^ ((*(int *)arg) & TAGMASK))) {
sel->tags ^= (*(int *)arg) & TAGMASK;
arrange();
@@
-1788,14
+1781,14
@@
void
zoom(const void *arg) {
Client *c = sel;
zoom(const void *arg) {
Client *c = sel;
- if(c == nextunfloating(clients))
- if(!c || !(c = nextunfloating(c->next)))
+ if(!lt->arrange || sel->isfloating)
+ return;
+ if(c == nexttiled(clients))
+ if(!c || !(c = nexttiled(c->next)))
return;
return;
- if(lt->arrange == tile && !sel->isfloating) {
- detach(c);
- attach(c);
- focus(c);
- }
+ detach(c);
+ attach(c);
+ focus(c);
arrange();
}
arrange();
}