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