mirror of
git://git.suckless.org/dwm
synced 2025-07-26 09:42:11 -07:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
fbce733532 | ||
|
e7572804fa | ||
|
ed1bef1241 | ||
|
2b047e460b | ||
|
5f74dc5e78 | ||
|
ea8a4ca46a | ||
|
4883a06221 | ||
|
4dea5324c0 |
2
.hgtags
2
.hgtags
@@ -55,3 +55,5 @@ d6d3085307d8d98b8b012b669e858fd787befeb1 4.7
|
||||
22c669b2dd3673785c3476b9976da21e8783f745 4.9
|
||||
06eb9644e2dad7667d97495eb7d7bc62aa0429e8 5.0
|
||||
ce355cea9bb89e162f61913737a46908cdfa7e45 5.1
|
||||
e4bcaca8e6ef13d2c3b81f1218ad15e5da4d68bd 5.2
|
||||
4004d61160355d869a7d2672561caad440751ba0 5.3
|
||||
|
@@ -13,6 +13,8 @@ static unsigned int snap = 32; /* snap pixel */
|
||||
static Bool showbar = True; /* False means no bar */
|
||||
static Bool topbar = True; /* False means bottom bar */
|
||||
static Bool readin = True; /* False means do not read stdin */
|
||||
static Bool usegrab = False; /* True means grabbing the X server
|
||||
during mouse-based resizals */
|
||||
|
||||
/* tagging */
|
||||
static const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
|
@@ -1,5 +1,5 @@
|
||||
# dwm version
|
||||
VERSION = 5.2
|
||||
VERSION = 5.3
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
@@ -10,9 +10,9 @@ MANPREFIX = ${PREFIX}/share/man
|
||||
X11INC = /usr/X11R6/include
|
||||
X11LIB = /usr/X11R6/lib
|
||||
|
||||
# Xinerama, comment if you don't want it
|
||||
XINERAMALIBS = -L${X11LIB} -lXinerama
|
||||
XINERAMAFLAGS = -DXINERAMA
|
||||
# Xinerama, un-comment if you want it
|
||||
#XINERAMALIBS = -L${X11LIB} -lXinerama
|
||||
#XINERAMAFLAGS = -DXINERAMA
|
||||
|
||||
# includes and libs
|
||||
INCS = -I. -I/usr/include -I${X11INC}
|
||||
|
64
dwm.c
64
dwm.c
@@ -15,7 +15,7 @@
|
||||
*
|
||||
* Each child of the root window is called a client, except windows which have
|
||||
* set the override_redirect flag. Clients are organized in a global
|
||||
* doubly-linked client list, the focus history is remembered through a global
|
||||
* linked client list, the focus history is remembered through a global
|
||||
* stack list. Each client contains a bit array to indicate the tags of a
|
||||
* client.
|
||||
*
|
||||
@@ -53,7 +53,8 @@
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define MAXTAGLEN 16
|
||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||
#define NOBORDER(x) ((x) - 2 * c->bw)
|
||||
#define WIDTH(x) ((x)->w + 2 * (x)->bw)
|
||||
#define HEIGHT(x) ((x)->h + 2 * (x)->bw)
|
||||
#define TAGMASK ((int)((1LL << LENGTH(tags)) - 1))
|
||||
#define TEXTW(x) (textnw(x, strlen(x)) + dc.font.height)
|
||||
|
||||
@@ -137,7 +138,7 @@ static void attachstack(Client *c);
|
||||
static void buttonpress(XEvent *e);
|
||||
static void checkotherwm(void);
|
||||
static void cleanup(void);
|
||||
static void clearurgent(void);
|
||||
static void clearurgent(Client *c);
|
||||
static void configure(Client *c);
|
||||
static void configurenotify(XEvent *e);
|
||||
static void configurerequest(XEvent *e);
|
||||
@@ -364,21 +365,16 @@ cleanup(void) {
|
||||
}
|
||||
|
||||
void
|
||||
clearurgent(void) {
|
||||
clearurgent(Client *c) {
|
||||
XWMHints *wmh;
|
||||
Client *c;
|
||||
|
||||
for(c = clients; c; c = c->next)
|
||||
if(ISVISIBLE(c) && c->isurgent) {
|
||||
c->isurgent = False;
|
||||
if(!(wmh = XGetWMHints(dpy, c->win)))
|
||||
continue;
|
||||
|
||||
return;
|
||||
wmh->flags &= ~XUrgencyHint;
|
||||
XSetWMHints(dpy, c->win, wmh);
|
||||
XFree(wmh);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
configure(Client *c) {
|
||||
@@ -616,6 +612,8 @@ focus(Client *c) {
|
||||
XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
|
||||
}
|
||||
if(c) {
|
||||
if(c->isurgent)
|
||||
clearurgent(c);
|
||||
detachstack(c);
|
||||
attachstack(c);
|
||||
grabbuttons(c, True);
|
||||
@@ -868,10 +866,10 @@ manage(Window w, XWindowAttributes *wa) {
|
||||
c->bw = 0;
|
||||
}
|
||||
else {
|
||||
if(c->x + c->w + 2 * c->bw > sx + sw)
|
||||
c->x = sx + sw - NOBORDER(c->w);
|
||||
if(c->y + c->h + 2 * c->bw > sy + sh)
|
||||
c->y = sy + sh - NOBORDER(c->h);
|
||||
if(c->x + WIDTH(c) > sx + sw)
|
||||
c->x = sx + sw - WIDTH(c);
|
||||
if(c->y + HEIGHT(c) > sy + sh)
|
||||
c->y = sy + sh - HEIGHT(c);
|
||||
c->x = MAX(c->x, sx);
|
||||
/* only fix client y-offset, if the client center might cover the bar */
|
||||
c->y = MAX(c->y, ((by == 0) && (c->x + (c->w / 2) >= wx) && (c->x + (c->w / 2) < wx + ww)) ? bh : sy);
|
||||
@@ -931,7 +929,7 @@ monocle(void) {
|
||||
Client *c;
|
||||
|
||||
for(c = nexttiled(clients); c; c = nexttiled(c->next))
|
||||
resize(c, wx, wy, NOBORDER(ww), NOBORDER(wh), resizehints);
|
||||
resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, resizehints);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -951,6 +949,8 @@ movemouse(const Arg *arg) {
|
||||
None, cursor[CurMove], CurrentTime) != GrabSuccess)
|
||||
return;
|
||||
XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui);
|
||||
if(usegrab)
|
||||
XGrabServer(dpy);
|
||||
do {
|
||||
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
|
||||
switch (ev.type) {
|
||||
@@ -960,19 +960,18 @@ movemouse(const Arg *arg) {
|
||||
handler[ev.type](&ev);
|
||||
break;
|
||||
case MotionNotify:
|
||||
XSync(dpy, False);
|
||||
nx = ocx + (ev.xmotion.x - x);
|
||||
ny = ocy + (ev.xmotion.y - y);
|
||||
if(snap && nx >= wx && nx <= wx + ww
|
||||
&& ny >= wy && ny <= wy + wh) {
|
||||
if(abs(wx - nx) < snap)
|
||||
nx = wx;
|
||||
else if(abs((wx + ww) - (nx + c->w + 2 * c->bw)) < snap)
|
||||
nx = wx + ww - NOBORDER(c->w);
|
||||
else if(abs((wx + ww) - (nx + WIDTH(c))) < snap)
|
||||
nx = wx + ww - WIDTH(c);
|
||||
if(abs(wy - ny) < snap)
|
||||
ny = wy;
|
||||
else if(abs((wy + wh) - (ny + c->h + 2 * c->bw)) < snap)
|
||||
ny = wy + wh - NOBORDER(c->h);
|
||||
else if(abs((wy + wh) - (ny + HEIGHT(c))) < snap)
|
||||
ny = wy + wh - HEIGHT(c);
|
||||
if(!c->isfloating && lt[sellt]->arrange && (abs(nx - c->x) > snap || abs(ny - c->y) > snap))
|
||||
togglefloating(NULL);
|
||||
}
|
||||
@@ -982,6 +981,8 @@ movemouse(const Arg *arg) {
|
||||
}
|
||||
}
|
||||
while(ev.type != ButtonRelease);
|
||||
if(usegrab)
|
||||
XUngrabServer(dpy);
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
}
|
||||
|
||||
@@ -1080,9 +1081,9 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
|
||||
if(w <= 0 || h <= 0)
|
||||
return;
|
||||
if(x > sx + sw)
|
||||
x = sw - NOBORDER(w);
|
||||
x = sw - WIDTH(c);
|
||||
if(y > sy + sh)
|
||||
y = sh - NOBORDER(h);
|
||||
y = sh - HEIGHT(c);
|
||||
if(x + w + 2 * c->bw < sx)
|
||||
x = sx;
|
||||
if(y + h + 2 * c->bw < sy)
|
||||
@@ -1120,6 +1121,8 @@ resizemouse(const Arg *arg) {
|
||||
None, cursor[CurResize], CurrentTime) != GrabSuccess)
|
||||
return;
|
||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
|
||||
if(usegrab)
|
||||
XGrabServer(dpy);
|
||||
do {
|
||||
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
|
||||
switch(ev.type) {
|
||||
@@ -1129,9 +1132,8 @@ resizemouse(const Arg *arg) {
|
||||
handler[ev.type](&ev);
|
||||
break;
|
||||
case MotionNotify:
|
||||
XSync(dpy, False);
|
||||
nw = MAX(ev.xmotion.x - NOBORDER(ocx) + 1, 1);
|
||||
nh = MAX(ev.xmotion.y - NOBORDER(ocy) + 1, 1);
|
||||
nw = MAX(ev.xmotion.x - ocx - 2*c->bw + 1, 1);
|
||||
nh = MAX(ev.xmotion.y - ocy - 2*c->bw + 1, 1);
|
||||
|
||||
if(snap && nw >= wx && nw <= wx + ww
|
||||
&& nh >= wy && nh <= wy + wh) {
|
||||
@@ -1145,6 +1147,8 @@ resizemouse(const Arg *arg) {
|
||||
}
|
||||
}
|
||||
while(ev.type != ButtonRelease);
|
||||
if(usegrab)
|
||||
XUngrabServer(dpy);
|
||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
@@ -1434,7 +1438,7 @@ tile(void) {
|
||||
/* master */
|
||||
c = nexttiled(clients);
|
||||
mw = mfact * ww;
|
||||
resize(c, wx, wy, NOBORDER(n == 1 ? ww : mw), NOBORDER(wh), resizehints);
|
||||
resize(c, wx, wy, (n == 1 ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints);
|
||||
|
||||
if(--n == 0)
|
||||
return;
|
||||
@@ -1448,10 +1452,10 @@ tile(void) {
|
||||
h = wh;
|
||||
|
||||
for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
|
||||
resize(c, x, y, NOBORDER(w), /* remainder */ ((i + 1 == n)
|
||||
? NOBORDER(wy + wh) - y : h), resizehints);
|
||||
resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
|
||||
? wy + wh - y - 2 * c->bw : h - 2 * c->bw), resizehints);
|
||||
if(h != wh)
|
||||
y = c->y + c->h + 2 * c->bw;
|
||||
y = c->y + HEIGHT(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1493,7 +1497,6 @@ toggleview(const Arg *arg) {
|
||||
|
||||
if(mask) {
|
||||
tagset[seltags] = mask;
|
||||
clearurgent();
|
||||
arrange();
|
||||
}
|
||||
}
|
||||
@@ -1666,7 +1669,6 @@ view(const Arg *arg) {
|
||||
seltags ^= 1; /* toggle sel tagset */
|
||||
if(arg->ui & TAGMASK)
|
||||
tagset[seltags] = arg->ui & TAGMASK;
|
||||
clearurgent();
|
||||
arrange();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user