Compare commits

..

11 Commits
4.2 ... 4.3

7 changed files with 76 additions and 71 deletions

View File

@ -44,3 +44,4 @@ baee494346e520f8dee2cee9491b8350064770d2 3.7
55478328b2422c700c5404a774c85e77322f41a3 3.9 55478328b2422c700c5404a774c85e77322f41a3 3.9
018c3846842291cb6c009dc087e7fe2f0ef53bea 4.0 018c3846842291cb6c009dc087e7fe2f0ef53bea 4.0
00f4180df72b49aadb2933804fde4bfb33e5666d 4.1 00f4180df72b49aadb2933804fde4bfb33e5666d 4.1
c13cb8c6b7a56af74cc88346e71d2490470b546f 4.2

View File

@ -96,6 +96,14 @@ attach(Client *c) {
clients = c; clients = c;
} }
void
ban(Client *c) {
if (c->isbanned)
return;
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
c->isbanned = True;
}
void void
configure(Client *c) { configure(Client *c) {
XConfigureEvent ce; XConfigureEvent ce;
@ -216,8 +224,7 @@ manage(Window w, XWindowAttributes *wa) {
c->isfloating = (rettrans == Success) || c->isfixed; c->isfloating = (rettrans == Success) || c->isfixed;
attach(c); attach(c);
attachstack(c); attachstack(c);
c->isbanned = True; ban(c);
XMoveWindow(dpy, w, c->x + 2 * sw, c->y);
XMapWindow(dpy, w); XMapWindow(dpy, w);
setclientstate(c, NormalState); setclientstate(c, NormalState);
focus(c); focus(c);
@ -299,6 +306,37 @@ togglefloating(const char *arg) {
lt->arrange(); lt->arrange();
} }
void
unban(Client *c) {
if (!c->isbanned)
return;
XMoveWindow(dpy, c->win, c->x, c->y);
c->isbanned = False;
}
void
unmanage(Client *c) {
XWindowChanges wc;
wc.border_width = c->oldborder;
/* The server grab construct avoids race conditions. */
XGrabServer(dpy);
XSetErrorHandler(xerrordummy);
XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
detach(c);
detachstack(c);
if(sel == c)
focus(NULL);
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
setclientstate(c, WithdrawnState);
free(c->tags);
free(c);
XSync(dpy, False);
XSetErrorHandler(xerror);
XUngrabServer(dpy);
lt->arrange();
}
void void
updatesizehints(Client *c) { updatesizehints(Client *c) {
long msize; long msize;
@ -377,26 +415,3 @@ updatetitle(Client *c) {
c->name[sizeof c->name - 1] = '\0'; c->name[sizeof c->name - 1] = '\0';
XFree(name.value); XFree(name.value);
} }
void
unmanage(Client *c) {
XWindowChanges wc;
wc.border_width = c->oldborder;
/* The server grab construct avoids race conditions. */
XGrabServer(dpy);
XSetErrorHandler(xerrordummy);
XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
detach(c);
detachstack(c);
if(sel == c)
focus(NULL);
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
setclientstate(c, WithdrawnState);
free(c->tags);
free(c);
XSync(dpy, False);
XSetErrorHandler(xerror);
XUngrabServer(dpy);
lt->arrange();
}

View File

@ -3,7 +3,7 @@
/* appearance */ /* appearance */
#define BARPOS BarTop /* BarBot, BarOff */ #define BARPOS BarTop /* BarBot, BarOff */
#define BORDERPX 1 #define BORDERPX 1
#define FONT "-*-pixelcarnage monospace-*-r-*-*-14-*-*-*-*-*-*-*" #define FONT "-*-terminus-medium-r-*-*-14-*-*-*-*-*-iso10646-*"
#define NORMBORDERCOLOR "#333" #define NORMBORDERCOLOR "#333"
#define NORMBGCOLOR "#222" #define NORMBGCOLOR "#222"
#define NORMFGCOLOR "#ccc" #define NORMFGCOLOR "#ccc"

View File

@ -1,5 +1,5 @@
# dwm version # dwm version
VERSION = 4.2 VERSION = 4.3
# Customize below to fit your system # Customize below to fit your system

32
dwm.h
View File

@ -79,23 +79,24 @@ typedef struct {
} Layout; } Layout;
extern const char *tags[]; /* all tags */ extern const char *tags[]; /* all tags */
char stext[256]; /* status text */ extern char stext[256]; /* status text */
int screen, sx, sy, sw, sh; /* screen geometry */ extern int screen, sx, sy, sw, sh; /* screen geometry */
int wax, way, wah, waw; /* windowarea geometry */ extern int wax, way, wah, waw; /* windowarea geometry */
unsigned int bh, blw, bpos; /* bar height, bar layout label width, bar position */ extern unsigned int bh, blw, bpos; /* bar height, bar layout label width, bar position */
unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */ extern unsigned int ntags, numlockmask; /* number of tags, numlock mask */
void (*handler[LASTEvent])(XEvent *); /* event handler */ extern void (*handler[LASTEvent])(XEvent *); /* event handler */
Atom wmatom[WMLast], netatom[NetLast]; extern Atom wmatom[WMLast], netatom[NetLast];
Bool selscreen, *seltag; /* seltag is array of Bool */ extern Bool selscreen, *seltag; /* seltag is array of Bool */
Client *clients, *sel, *stack; /* global client list and stack */ extern Client *clients, *sel, *stack; /* global client list and stack */
Cursor cursor[CurLast]; extern Cursor cursor[CurLast];
DC dc; /* global draw context */ extern DC dc; /* global draw context */
Display *dpy; extern Display *dpy;
Layout *lt; extern Layout *lt;
Window root, barwin; extern Window root, barwin;
/* client.c */ /* client.c */
void attach(Client *c); /* attaches c to global client list */ void attach(Client *c); /* attaches c to global client list */
void ban(Client *c); /* bans c */
void configure(Client *c); /* send synthetic configure event */ void configure(Client *c); /* send synthetic configure event */
void detach(Client *c); /* detaches c from global client list */ void detach(Client *c); /* detaches c from global client list */
void focus(Client *c); /* focus c if visible && !NULL, or focus top visible */ void focus(Client *c); /* focus c if visible && !NULL, or focus top visible */
@ -104,9 +105,10 @@ void manage(Window w, XWindowAttributes *wa); /* manage new client */
void resize(Client *c, int x, int y, void resize(Client *c, int x, int y,
int w, int h, Bool sizehints); /* resize with given coordinates c*/ int w, int h, Bool sizehints); /* resize with given coordinates c*/
void togglefloating(const char *arg); /* toggles sel between floating/tiled state */ void togglefloating(const char *arg); /* toggles sel between floating/tiled state */
void unban(Client *c); /* unbans c */
void unmanage(Client *c); /* destroy c */
void updatesizehints(Client *c); /* update the size hint variables of c */ void updatesizehints(Client *c); /* update the size hint variables of c */
void updatetitle(Client *c); /* update the name of c */ void updatetitle(Client *c); /* update the name of c */
void unmanage(Client *c); /* destroy c */
/* draw.c */ /* draw.c */
void drawstatus(void); /* draw the bar */ void drawstatus(void); /* draw the bar */

View File

@ -11,22 +11,6 @@ static unsigned int nlayouts = 0;
static unsigned int masterw = MASTERWIDTH; static unsigned int masterw = MASTERWIDTH;
static unsigned int nmaster = NMASTER; static unsigned int nmaster = NMASTER;
static void
ban(Client *c) {
if (c->isbanned)
return;
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
c->isbanned = True;
}
static void
unban(Client *c) {
if (!c->isbanned)
return;
XMoveWindow(dpy, c->win, c->x, c->y);
c->isbanned = False;
}
static void static void
tile(void) { tile(void) {
unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th; unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
@ -88,9 +72,7 @@ floating(void) {
for(c = clients; c; c = c->next) for(c = clients; c; c = c->next)
if(isvisible(c)) { if(isvisible(c)) {
if(c->isbanned) unban(c);
XMoveWindow(dpy, c->win, c->x, c->y);
c->isbanned = False;
resize(c, c->x, c->y, c->w, c->h, True); resize(c, c->x, c->y, c->w, c->h, True);
} }
else else
@ -182,6 +164,7 @@ void
restack(void) { restack(void) {
Client *c; Client *c;
XEvent ev; XEvent ev;
XWindowChanges wc;
drawstatus(); drawstatus();
if(!sel) if(!sel)
@ -189,12 +172,17 @@ restack(void) {
if(sel->isfloating || lt->arrange == floating) if(sel->isfloating || lt->arrange == floating)
XRaiseWindow(dpy, sel->win); XRaiseWindow(dpy, sel->win);
if(lt->arrange != floating) { if(lt->arrange != floating) {
if(!sel->isfloating) wc.stack_mode = Below;
XLowerWindow(dpy, sel->win); wc.sibling = barwin;
if(!sel->isfloating) {
XConfigureWindow(dpy, sel->win, CWSibling | CWStackMode, &wc);
wc.sibling = sel->win;
}
for(c = nexttiled(clients); c; c = nexttiled(c->next)) { for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
if(c == sel) if(c == sel)
continue; continue;
XLowerWindow(dpy, c->win); XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
wc.sibling = c->win;
} }
} }
XSync(dpy, False); XSync(dpy, False);
@ -243,7 +231,7 @@ togglemax(const char *arg) {
sel->ry = sel->y; sel->ry = sel->y;
sel->rw = sel->w; sel->rw = sel->w;
sel->rh = sel->h; sel->rh = sel->h;
resize(sel, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True); resize(sel, wax, way, waw - 2 * sel->border, wah - 2 * sel->border, True);
} }
else else
resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True); resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);

9
main.c
View File

@ -16,7 +16,9 @@
char stext[256]; char stext[256];
int screen, sx, sy, sw, sh, wax, way, waw, wah; int screen, sx, sy, sw, sh, wax, way, waw, wah;
unsigned int bh, bpos, ntags, numlockmask; unsigned int bh, ntags;
unsigned int bpos = BARPOS;
unsigned int numlockmask = 0;
Atom wmatom[WMLast], netatom[NetLast]; Atom wmatom[WMLast], netatom[NetLast];
Bool *seltag; Bool *seltag;
Bool selscreen = True; Bool selscreen = True;
@ -38,8 +40,7 @@ static void
cleanup(void) { cleanup(void) {
close(STDIN_FILENO); close(STDIN_FILENO);
while(stack) { while(stack) {
if(stack->isbanned) unban(stack);
XMoveWindow(dpy, stack->win, stack->x, stack->y);
unmanage(stack); unmanage(stack);
} }
if(dc.font.set) if(dc.font.set)
@ -150,7 +151,6 @@ setup(void) {
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
/* init modifier map */ /* init modifier map */
numlockmask = 0;
modmap = XGetModifierMapping(dpy); modmap = XGetModifierMapping(dpy);
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
for (j = 0; j < modmap->max_keypermod; j++) { for (j = 0; j < modmap->max_keypermod; j++) {
@ -192,7 +192,6 @@ setup(void) {
DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
XDefineCursor(dpy, barwin, cursor[CurNormal]); XDefineCursor(dpy, barwin, cursor[CurNormal]);
bpos = BARPOS;
updatebarpos(); updatebarpos();
XMapRaised(dpy, barwin); XMapRaised(dpy, barwin);
strcpy(stext, "dwm-"VERSION); strcpy(stext, "dwm-"VERSION);