mirror of
git://git.suckless.org/dwm
synced 2025-07-26 01:32:08 -07:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
2b047e460b | ||
|
5f74dc5e78 | ||
|
ea8a4ca46a | ||
|
4883a06221 | ||
|
4dea5324c0 |
1
.hgtags
1
.hgtags
@@ -55,3 +55,4 @@ d6d3085307d8d98b8b012b669e858fd787befeb1 4.7
|
||||
22c669b2dd3673785c3476b9976da21e8783f745 4.9
|
||||
06eb9644e2dad7667d97495eb7d7bc62aa0429e8 5.0
|
||||
ce355cea9bb89e162f61913737a46908cdfa7e45 5.1
|
||||
e4bcaca8e6ef13d2c3b81f1218ad15e5da4d68bd 5.2
|
||||
|
@@ -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}
|
||||
|
74
dwm.c
74
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)
|
||||
|
||||
@@ -181,6 +182,7 @@ static void setlayout(const Arg *arg);
|
||||
static void setmfact(const Arg *arg);
|
||||
static void setup(void);
|
||||
static void showhide(Client *c);
|
||||
static void sigchld(int signal);
|
||||
static void spawn(const Arg *arg);
|
||||
static void tag(const Arg *arg);
|
||||
static int textnw(const char *text, unsigned int len);
|
||||
@@ -868,10 +870,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 +933,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 +953,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 +964,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 +985,8 @@ movemouse(const Arg *arg) {
|
||||
}
|
||||
}
|
||||
while(ev.type != ButtonRelease);
|
||||
if(usegrab)
|
||||
XUngrabServer(dpy);
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
}
|
||||
|
||||
@@ -1080,9 +1085,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 +1125,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 +1136,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 +1151,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));
|
||||
@@ -1384,22 +1392,24 @@ showhide(Client *c) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
sigchld(int signal) {
|
||||
while(0 < waitpid(-1, NULL, WNOHANG));
|
||||
}
|
||||
|
||||
void
|
||||
spawn(const Arg *arg) {
|
||||
/* The double-fork construct avoids zombie processes and keeps the code
|
||||
* clean from stupid signal handlers. */
|
||||
signal(SIGCHLD, sigchld);
|
||||
if(fork() == 0) {
|
||||
if(fork() == 0) {
|
||||
if(dpy)
|
||||
close(ConnectionNumber(dpy));
|
||||
setsid();
|
||||
execvp(((char **)arg->v)[0], (char **)arg->v);
|
||||
fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]);
|
||||
perror(" failed");
|
||||
}
|
||||
if(dpy)
|
||||
close(ConnectionNumber(dpy));
|
||||
setsid();
|
||||
execvp(((char **)arg->v)[0], (char **)arg->v);
|
||||
fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]);
|
||||
perror(" failed");
|
||||
exit(0);
|
||||
}
|
||||
wait(0);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1434,7 +1444,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 +1458,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user