Compare commits
32 Commits
Author | SHA1 | Date | |
---|---|---|---|
2d7f59424c | |||
e256afe31e | |||
64cfebc5e7 | |||
7a095d0ce2 | |||
5052c538d9 | |||
22d8c6fd18 | |||
71857b87ee | |||
6ba400ee0f | |||
35e65ea640 | |||
d0d986dd0e | |||
9685e7dbc2 | |||
37f39afb8e | |||
dc9f62f393 | |||
7055315725 | |||
fd995dac78 | |||
e5765cdd84 | |||
8d0e58f80b | |||
8fcd1bfda8 | |||
e39e697998 | |||
d2dd58eabd | |||
c6fc6b173d | |||
4590d7877c | |||
f577fe4e27 | |||
9ed5de00b6 | |||
28ffff801b | |||
44ef3f5a07 | |||
dafbd0dcb0 | |||
2ddc78720a | |||
7ece30ebc0 | |||
3d48f33025 | |||
19fd903d40 | |||
5732e471ae |
2
.hgtags
2
.hgtags
@ -34,3 +34,5 @@ e1c8bef05e6e48df4f26471ea0712aa43ab9d949 3.1
|
||||
4ce65f61f01b055fa6c2901c6d2527ef741aa4bf 3.2
|
||||
f2cabc83a18f9b5b548159329ddd4dee904fa31f 3.2.1
|
||||
d3876aa792923f9a95f7ad0c7f0134533404df35 3.2.2
|
||||
0f91934037b04221ff5d1ba3a6c39c1ff26e3661 3.3
|
||||
9ede7b2d2450537e750d5505789fbe63960e97e6 3.4
|
||||
|
7
Makefile
7
Makefile
@ -1,5 +1,5 @@
|
||||
# dwm - dynamic window manager
|
||||
# (C)opyright MMVII Anselm R. Garbe
|
||||
# (C)opyright MMVI-MMVII Anselm R. Garbe
|
||||
|
||||
include config.mk
|
||||
|
||||
@ -13,7 +13,6 @@ options:
|
||||
@echo "CFLAGS = ${CFLAGS}"
|
||||
@echo "LDFLAGS = ${LDFLAGS}"
|
||||
@echo "CC = ${CC}"
|
||||
@echo "LD = ${LD}"
|
||||
|
||||
.c.o:
|
||||
@echo CC $<
|
||||
@ -26,8 +25,8 @@ config.h:
|
||||
@cp config.default.h $@
|
||||
|
||||
dwm: ${OBJ}
|
||||
@echo LD $@
|
||||
@${LD} -o $@ ${OBJ} ${LDFLAGS}
|
||||
@echo CC -o $@
|
||||
@${CC} -o $@ ${OBJ} ${LDFLAGS}
|
||||
@strip $@
|
||||
|
||||
clean:
|
||||
|
99
client.c
99
client.c
@ -7,7 +7,7 @@
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
/* static functions */
|
||||
/* static */
|
||||
|
||||
static void
|
||||
detachstack(Client *c) {
|
||||
@ -65,23 +65,24 @@ xerrordummy(Display *dsply, XErrorEvent *ee) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* extern functions */
|
||||
/* extern */
|
||||
|
||||
void
|
||||
configure(Client *c) {
|
||||
XEvent synev;
|
||||
XConfigureEvent ce;
|
||||
|
||||
synev.type = ConfigureNotify;
|
||||
synev.xconfigure.display = dpy;
|
||||
synev.xconfigure.event = c->win;
|
||||
synev.xconfigure.window = c->win;
|
||||
synev.xconfigure.x = c->x;
|
||||
synev.xconfigure.y = c->y;
|
||||
synev.xconfigure.width = c->w;
|
||||
synev.xconfigure.height = c->h;
|
||||
synev.xconfigure.border_width = c->border;
|
||||
synev.xconfigure.above = None;
|
||||
XSendEvent(dpy, c->win, True, NoEventMask, &synev);
|
||||
ce.type = ConfigureNotify;
|
||||
ce.display = dpy;
|
||||
ce.event = c->win;
|
||||
ce.window = c->win;
|
||||
ce.x = c->x;
|
||||
ce.y = c->y;
|
||||
ce.width = c->w;
|
||||
ce.height = c->h;
|
||||
ce.border_width = c->border;
|
||||
ce.above = None;
|
||||
ce.override_redirect = False;
|
||||
XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce);
|
||||
}
|
||||
|
||||
void
|
||||
@ -120,11 +121,26 @@ getclient(Window w) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Bool
|
||||
isprotodel(Client *c) {
|
||||
int i, n;
|
||||
Atom *protocols;
|
||||
Bool ret = False;
|
||||
|
||||
if(XGetWMProtocols(dpy, c->win, &protocols, &n)) {
|
||||
for(i = 0; !ret && i < n; i++)
|
||||
if(protocols[i] == wmatom[WMDelete])
|
||||
ret = True;
|
||||
XFree(protocols);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
killclient(Arg *arg) {
|
||||
if(!sel)
|
||||
return;
|
||||
if(sel->proto & PROTODELWIN)
|
||||
if(isprotodel(sel))
|
||||
sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]);
|
||||
else
|
||||
XKillClient(dpy, sel->win);
|
||||
@ -132,7 +148,7 @@ killclient(Arg *arg) {
|
||||
|
||||
void
|
||||
manage(Window w, XWindowAttributes *wa) {
|
||||
Client *c;
|
||||
Client *c, *t;
|
||||
Window trans;
|
||||
|
||||
c = emallocz(sizeof(Client));
|
||||
@ -159,16 +175,16 @@ manage(Window w, XWindowAttributes *wa) {
|
||||
c->y = way;
|
||||
}
|
||||
updatesizehints(c);
|
||||
c->proto = getproto(c->win);
|
||||
XSelectInput(dpy, c->win,
|
||||
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
||||
XGetTransientForHint(dpy, c->win, &trans);
|
||||
grabbuttons(c, False);
|
||||
XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
|
||||
updatetitle(c);
|
||||
settags(c, getclient(trans));
|
||||
t = getclient(trans);
|
||||
settags(c, t);
|
||||
if(!c->isfloat)
|
||||
c->isfloat = trans || c->isfixed;
|
||||
c->isfloat = (t != 0) || c->isfixed;
|
||||
if(clients)
|
||||
clients->prev = c;
|
||||
c->next = clients;
|
||||
@ -184,15 +200,12 @@ manage(Window w, XWindowAttributes *wa) {
|
||||
|
||||
void
|
||||
resize(Client *c, Bool sizehints) {
|
||||
float actual, dx, dy, max, min;
|
||||
XWindowChanges wc;
|
||||
|
||||
if(c->w <= 0 || c->h <= 0)
|
||||
return;
|
||||
if(sizehints) {
|
||||
if(c->incw)
|
||||
c->w -= (c->w - c->basew) % c->incw;
|
||||
if(c->inch)
|
||||
c->h -= (c->h - c->baseh) % c->inch;
|
||||
if(c->minw && c->w < c->minw)
|
||||
c->w = c->minw;
|
||||
if(c->minh && c->h < c->minh)
|
||||
@ -201,6 +214,32 @@ resize(Client *c, Bool sizehints) {
|
||||
c->w = c->maxw;
|
||||
if(c->maxh && c->h > c->maxh)
|
||||
c->h = c->maxh;
|
||||
/* inspired by algorithm from fluxbox */
|
||||
if(c->minay > 0 && c->maxay && (c->h - c->baseh) > 0) {
|
||||
dx = (float)(c->w - c->basew);
|
||||
dy = (float)(c->h - c->baseh);
|
||||
min = (float)(c->minax) / (float)(c->minay);
|
||||
max = (float)(c->maxax) / (float)(c->maxay);
|
||||
actual = dx / dy;
|
||||
if(max > 0 && min > 0 && actual > 0) {
|
||||
if(actual < min) {
|
||||
dy = (dx * min + dy) / (min * min + 1);
|
||||
dx = dy * min;
|
||||
c->w = (int)dx + c->basew;
|
||||
c->h = (int)dy + c->baseh;
|
||||
}
|
||||
else if(actual > max) {
|
||||
dy = (dx * min + dy) / (max * max + 1);
|
||||
dx = dy * min;
|
||||
c->w = (int)dx + c->basew;
|
||||
c->h = (int)dy + c->baseh;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(c->incw)
|
||||
c->w -= (c->w - c->basew) % c->incw;
|
||||
if(c->inch)
|
||||
c->h -= (c->h - c->baseh) % c->inch;
|
||||
}
|
||||
if(c->w == sw && c->h == sh)
|
||||
c->border = 0;
|
||||
@ -257,8 +296,16 @@ updatesizehints(Client *c) {
|
||||
}
|
||||
else
|
||||
c->minw = c->minh = 0;
|
||||
c->isfixed = (c->maxw && c->minw && c->maxh && c->minh &&
|
||||
c->maxw == c->minw && c->maxh == c->minh);
|
||||
if(c->flags & PAspect) {
|
||||
c->minax = size.min_aspect.x;
|
||||
c->minay = size.min_aspect.y;
|
||||
c->maxax = size.max_aspect.x;
|
||||
c->maxay = size.max_aspect.y;
|
||||
}
|
||||
else
|
||||
c->minax = c->minay = c->maxax = c->maxay = 0;
|
||||
c->isfixed = (c->maxw && c->minw && c->maxh && c->minh
|
||||
&& c->maxw == c->minw && c->maxh == c->minh);
|
||||
}
|
||||
|
||||
void
|
||||
@ -278,7 +325,7 @@ updatetitle(Client *c) {
|
||||
strncpy(c->name, (char *)name.value, sizeof c->name);
|
||||
else {
|
||||
if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
|
||||
&& n > 0 && *list)
|
||||
&& n > 0 && *list)
|
||||
{
|
||||
strncpy(c->name, *list, sizeof c->name);
|
||||
XFreeStringList(list);
|
||||
|
@ -22,6 +22,7 @@ const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
|
||||
#define MODKEY Mod1Mask
|
||||
#define NMASTER 1 /* clients in master area */
|
||||
#define SNAP 40 /* pixel */
|
||||
#define TOPBAR True /* False */
|
||||
|
||||
#define KEYS \
|
||||
static Key key[] = { \
|
||||
@ -86,8 +87,8 @@ static Key key[] = { \
|
||||
#define RULES \
|
||||
static Rule rule[] = { \
|
||||
/* class:instance:title regex tags regex isfloat */ \
|
||||
{ "Firefox.*", "3", False }, \
|
||||
{ "Gimp.*", NULL, True }, \
|
||||
{ "MPlayer.*", NULL, True }, \
|
||||
{ "Acroread.*", NULL, True }, \
|
||||
{ "Firefox", "3", False }, \
|
||||
{ "Gimp", NULL, True }, \
|
||||
{ "MPlayer", NULL, True }, \
|
||||
{ "Acroread", NULL, True }, \
|
||||
};
|
||||
|
@ -22,6 +22,7 @@ const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
|
||||
#define MODKEY Mod1Mask
|
||||
#define NMASTER 1 /* clients in master area */
|
||||
#define SNAP 20 /* pixel */
|
||||
#define TOPBAR True /* False */
|
||||
|
||||
#define KEYS \
|
||||
static Key key[] = { \
|
||||
@ -83,5 +84,7 @@ static Key key[] = { \
|
||||
#define RULES \
|
||||
static Rule rule[] = { \
|
||||
/* class:instance:title regex tags regex isfloat */ \
|
||||
{ "Gimp.*", NULL, True }, \
|
||||
{ "Gimp", NULL, True }, \
|
||||
{ "MPlayer", NULL, True }, \
|
||||
{ "Acroread", NULL, True }, \
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
# dwm version
|
||||
VERSION = 3.3
|
||||
VERSION = 3.5
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
@ -27,4 +27,3 @@ LDFLAGS = ${LIBS}
|
||||
|
||||
# compiler and linker
|
||||
CC = cc
|
||||
LD = ${CC}
|
||||
|
18
draw.c
18
draw.c
@ -35,7 +35,6 @@ drawtext(const char *text, unsigned long col[ColLast], Bool filledsquare, Bool e
|
||||
unsigned int len, olen;
|
||||
XGCValues gcv;
|
||||
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
|
||||
XPoint pt[5];
|
||||
|
||||
XSetForeground(dpy, dc.gc, col[ColBG]);
|
||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||
@ -74,24 +73,15 @@ drawtext(const char *text, unsigned long col[ColLast], Bool filledsquare, Bool e
|
||||
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
|
||||
}
|
||||
x = (h + 2) / 4;
|
||||
r.x = dc.x + 1;
|
||||
r.y = dc.y + 1;
|
||||
if(filledsquare) {
|
||||
r.x = dc.x + 1;
|
||||
r.y = dc.y + 1;
|
||||
r.width = r.height = x + 1;
|
||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||
}
|
||||
else if(emptysquare) {
|
||||
pt[0].x = dc.x + 1;
|
||||
pt[0].y = dc.y + 1;
|
||||
pt[1].x = x;
|
||||
pt[1].y = 0;
|
||||
pt[2].x = 0;
|
||||
pt[2].y = x;
|
||||
pt[3].x = -x;
|
||||
pt[3].y = 0;
|
||||
pt[4].x = 0;
|
||||
pt[4].y = -x;
|
||||
XDrawLines(dpy, dc.drawable, dc.gc, pt, 5, CoordModePrevious);
|
||||
r.width = r.height = x;
|
||||
XDrawRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
4
dwm.1
4
dwm.1
@ -67,7 +67,7 @@ Focus next window.
|
||||
Focus previous window.
|
||||
.TP
|
||||
.B Mod1-Return
|
||||
Zooms/cycles current window to/from master area (tiling mode), toggles maximization current window (floating mode).
|
||||
Zooms/cycles current window to/from master area (tiling mode), toggles maximization of current window (floating mode).
|
||||
.TP
|
||||
.B Mod1-g
|
||||
Grow master area (tiling mode only).
|
||||
@ -124,7 +124,7 @@ Quit dwm.
|
||||
Move current window while dragging (floating mode only).
|
||||
.TP
|
||||
.B Mod1-Button2
|
||||
Zoom current window to the master area (tiling mode only).
|
||||
Zooms/cycles current window to/from master area (tiling mode), toggles maximization of current window (floating mode).
|
||||
.TP
|
||||
.B Mod1-Button3
|
||||
Resize current window while dragging (floating mode only).
|
||||
|
8
dwm.h
8
dwm.h
@ -36,8 +36,6 @@
|
||||
|
||||
/* mask shorthands, used in event.c and client.c */
|
||||
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
|
||||
/* other stuff used in different places */
|
||||
#define PROTODELWIN 1
|
||||
|
||||
enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
|
||||
enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */
|
||||
@ -69,13 +67,13 @@ typedef struct {
|
||||
typedef struct Client Client;
|
||||
struct Client {
|
||||
char name[256];
|
||||
int proto;
|
||||
int x, y, w, h;
|
||||
int rx, ry, rw, rh; /* revert geometry */
|
||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||
int minax, minay, maxax, maxay;
|
||||
long flags;
|
||||
unsigned int border;
|
||||
Bool isfloat, isfixed, ismax;
|
||||
Bool isfixed, isfloat, ismax;
|
||||
Bool *tags;
|
||||
Client *next;
|
||||
Client *prev;
|
||||
@ -104,6 +102,7 @@ extern Window root, barwin;
|
||||
extern void configure(Client *c); /* send synthetic configure event */
|
||||
extern void focus(Client *c); /* focus c, c may be NULL */
|
||||
extern Client *getclient(Window w); /* return client of w */
|
||||
extern Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */
|
||||
extern void killclient(Arg *arg); /* kill c nicely */
|
||||
extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
|
||||
extern void resize(Client *c, Bool sizehints); /* resize c*/
|
||||
@ -122,7 +121,6 @@ extern void grabkeys(void); /* grab all keys defined in config.h */
|
||||
extern void procevent(void); /* process pending X events */
|
||||
|
||||
/* main.c */
|
||||
extern int getproto(Window w); /* return protocol mask of WMProtocols property of w */
|
||||
extern void quit(Arg *arg); /* quit dwm nicely */
|
||||
extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
|
||||
extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
|
||||
|
58
event.c
58
event.c
@ -82,7 +82,10 @@ resizemouse(Client *c) {
|
||||
switch(ev.type) {
|
||||
case ButtonRelease:
|
||||
resize(c, True);
|
||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
|
||||
c->w + c->border - 1, c->h + c->border - 1);
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
return;
|
||||
case ConfigureRequest:
|
||||
case Expose:
|
||||
@ -153,8 +156,9 @@ buttonpress(XEvent *e) {
|
||||
}
|
||||
else if(ev->button == Button2)
|
||||
zoom(NULL);
|
||||
else if(ev->button == Button3 && (arrange == dofloat || c->isfloat) &&
|
||||
!c->isfixed) {
|
||||
else if(ev->button == Button3
|
||||
&& (arrange == dofloat || c->isfloat) && !c->isfixed)
|
||||
{
|
||||
restack();
|
||||
resizemouse(c);
|
||||
}
|
||||
@ -163,40 +167,32 @@ buttonpress(XEvent *e) {
|
||||
|
||||
static void
|
||||
configurerequest(XEvent *e) {
|
||||
unsigned long newmask;
|
||||
Client *c;
|
||||
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
||||
XWindowChanges wc;
|
||||
|
||||
if((c = getclient(ev->window))) {
|
||||
c->ismax = False;
|
||||
if(ev->value_mask & CWX)
|
||||
c->x = ev->x;
|
||||
if(ev->value_mask & CWY)
|
||||
c->y = ev->y;
|
||||
if(ev->value_mask & CWWidth)
|
||||
c->w = ev->width;
|
||||
if(ev->value_mask & CWHeight)
|
||||
c->h = ev->height;
|
||||
if(ev->value_mask & CWBorderWidth)
|
||||
c->border = ev->border_width;
|
||||
wc.x = c->x;
|
||||
wc.y = c->y;
|
||||
wc.width = c->w;
|
||||
wc.height = c->h;
|
||||
newmask = ev->value_mask & (~(CWSibling | CWStackMode | CWBorderWidth));
|
||||
if(newmask)
|
||||
XConfigureWindow(dpy, c->win, newmask, &wc);
|
||||
else
|
||||
configure(c);
|
||||
XSync(dpy, False);
|
||||
if(c->isfloat) {
|
||||
if(c->isfixed || c->isfloat || (arrange == dofloat)) {
|
||||
if(ev->value_mask & CWX)
|
||||
c->x = ev->x;
|
||||
if(ev->value_mask & CWY)
|
||||
c->y = ev->y;
|
||||
if(ev->value_mask & CWWidth)
|
||||
c->w = ev->width;
|
||||
if(ev->value_mask & CWHeight)
|
||||
c->h = ev->height;
|
||||
if((ev->value_mask & (CWX | CWY))
|
||||
&& !(ev->value_mask & (CWWidth | CWHeight)))
|
||||
configure(c);
|
||||
resize(c, False);
|
||||
if(!isvisible(c))
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
}
|
||||
else
|
||||
arrange();
|
||||
configure(c);
|
||||
}
|
||||
else {
|
||||
wc.x = ev->x;
|
||||
@ -207,8 +203,8 @@ configurerequest(XEvent *e) {
|
||||
wc.sibling = ev->above;
|
||||
wc.stack_mode = ev->detail;
|
||||
XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -254,14 +250,13 @@ keypress(XEvent *e) {
|
||||
XKeyEvent *ev = &e->xkey;
|
||||
|
||||
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
||||
for(i = 0; i < len; i++) {
|
||||
for(i = 0; i < len; i++)
|
||||
if(keysym == key[i].keysym
|
||||
&& CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
|
||||
&& CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
|
||||
{
|
||||
if(key[i].func)
|
||||
key[i].func(&key[i].arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -290,11 +285,8 @@ maprequest(XEvent *e) {
|
||||
|
||||
if(!XGetWindowAttributes(dpy, ev->window, &wa))
|
||||
return;
|
||||
if(wa.override_redirect) {
|
||||
XSelectInput(dpy, ev->window,
|
||||
(StructureNotifyMask | PropertyChangeMask));
|
||||
if(wa.override_redirect)
|
||||
return;
|
||||
}
|
||||
if(!getclient(ev->window))
|
||||
manage(ev->window, &wa);
|
||||
}
|
||||
@ -308,10 +300,6 @@ propertynotify(XEvent *e) {
|
||||
if(ev->state == PropertyDelete)
|
||||
return; /* ignore */
|
||||
if((c = getclient(ev->window))) {
|
||||
if(ev->atom == wmatom[WMProtocols]) {
|
||||
c->proto = getproto(c->win);
|
||||
return;
|
||||
}
|
||||
switch (ev->atom) {
|
||||
default: break;
|
||||
case XA_WM_TRANSIENT_FOR:
|
||||
|
39
main.c
39
main.c
@ -18,11 +18,11 @@
|
||||
/* extern */
|
||||
|
||||
char stext[256];
|
||||
Bool *seltag;
|
||||
int bh, bmw, screen, sx, sy, sw, sh, wax, way, waw, wah;
|
||||
unsigned int master, nmaster, ntags, numlockmask;
|
||||
Atom wmatom[WMLast], netatom[NetLast];
|
||||
Bool running = True;
|
||||
Bool *seltag;
|
||||
Bool selscreen = True;
|
||||
Client *clients = NULL;
|
||||
Client *sel = NULL;
|
||||
@ -69,9 +69,8 @@ scan(void) {
|
||||
wins = NULL;
|
||||
if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
|
||||
for(i = 0; i < num; i++) {
|
||||
if(!XGetWindowAttributes(dpy, wins[i], &wa))
|
||||
continue;
|
||||
if(wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
|
||||
if(!XGetWindowAttributes(dpy, wins[i], &wa)
|
||||
|| wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
|
||||
continue;
|
||||
if(wa.map_state == IsViewable)
|
||||
manage(wins[i], &wa);
|
||||
@ -104,12 +103,12 @@ setup(void) {
|
||||
/* init modifier map */
|
||||
numlockmask = 0;
|
||||
modmap = XGetModifierMapping(dpy);
|
||||
for (i = 0; i < 8; i++) {
|
||||
for (i = 0; i < 8; i++)
|
||||
for (j = 0; j < modmap->max_keypermod; j++) {
|
||||
if(modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(dpy, XK_Num_Lock))
|
||||
if(modmap->modifiermap[i * modmap->max_keypermod + j]
|
||||
== XKeysymToKeycode(dpy, XK_Num_Lock))
|
||||
numlockmask = (1 << i);
|
||||
}
|
||||
}
|
||||
XFreeModifiermap(modmap);
|
||||
/* select for events */
|
||||
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
||||
@ -141,15 +140,15 @@ setup(void) {
|
||||
wa.override_redirect = 1;
|
||||
wa.background_pixmap = ParentRelative;
|
||||
wa.event_mask = ButtonPressMask | ExposureMask;
|
||||
barwin = XCreateWindow(dpy, root, sx, sy, sw, bh, 0, DefaultDepth(dpy, screen),
|
||||
CopyFromParent, DefaultVisual(dpy, screen),
|
||||
barwin = XCreateWindow(dpy, root, sx, sy + (TOPBAR ? 0 : sh - bh), sw, bh, 0,
|
||||
DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||
XDefineCursor(dpy, barwin, cursor[CurNormal]);
|
||||
XMapRaised(dpy, barwin);
|
||||
strcpy(stext, "dwm-"VERSION);
|
||||
/* windowarea */
|
||||
wax = sx;
|
||||
way = sy + bh;
|
||||
way = sy + (TOPBAR ? bh : 0);
|
||||
wah = sh - bh;
|
||||
waw = sw;
|
||||
/* pixmap for everything */
|
||||
@ -172,24 +171,6 @@ xerrorstart(Display *dsply, XErrorEvent *ee) {
|
||||
|
||||
/* extern */
|
||||
|
||||
int
|
||||
getproto(Window w) {
|
||||
int i, format, protos, status;
|
||||
unsigned long extra, res;
|
||||
Atom *protocols, real;
|
||||
|
||||
protos = 0;
|
||||
status = XGetWindowProperty(dpy, w, wmatom[WMProtocols], 0L, 20L, False,
|
||||
XA_ATOM, &real, &format, &res, &extra, (unsigned char **)&protocols);
|
||||
if(status != Success || protocols == 0)
|
||||
return protos;
|
||||
for(i = 0; i < res; i++)
|
||||
if(protocols[i] == wmatom[WMDelete])
|
||||
protos |= PROTODELWIN;
|
||||
free(protocols);
|
||||
return protos;
|
||||
}
|
||||
|
||||
void
|
||||
sendevent(Window w, Atom a, long value) {
|
||||
XEvent e;
|
||||
@ -291,7 +272,7 @@ main(int argc, char *argv[]) {
|
||||
break;
|
||||
default:
|
||||
for(stext[r] = '\0', p = stext + strlen(stext) - 1; p >= stext && *p == '\n'; *p-- = '\0');
|
||||
for(p = stext + strlen(stext) - 1; p >= stext && *p != '\n'; --p);
|
||||
for(; p >= stext && *p != '\n'; --p);
|
||||
if(p > stext)
|
||||
strncpy(stext, p + 1, sizeof stext);
|
||||
}
|
||||
|
8
tag.c
8
tag.c
@ -76,13 +76,13 @@ settags(Client *c, Client *trans) {
|
||||
unsigned int i, j;
|
||||
regmatch_t tmp;
|
||||
Bool matched = trans != NULL;
|
||||
XClassHint ch;
|
||||
XClassHint ch = { 0 };
|
||||
|
||||
if(matched) {
|
||||
if(matched)
|
||||
for(i = 0; i < ntags; i++)
|
||||
c->tags[i] = trans->tags[i];
|
||||
}
|
||||
else if(XGetClassHint(dpy, c->win, &ch)) {
|
||||
else {
|
||||
XGetClassHint(dpy, c->win, &ch);
|
||||
snprintf(prop, sizeof prop, "%s:%s:%s",
|
||||
ch.res_class ? ch.res_class : "",
|
||||
ch.res_name ? ch.res_name : "", c->name);
|
||||
|
9
view.c
9
view.c
@ -55,9 +55,8 @@ dofloat(void) {
|
||||
Client *c;
|
||||
|
||||
for(c = clients; c; c = c->next) {
|
||||
if(isvisible(c)) {
|
||||
if(isvisible(c))
|
||||
resize(c, True);
|
||||
}
|
||||
else
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
}
|
||||
@ -150,7 +149,7 @@ focusprev(Arg *arg) {
|
||||
void
|
||||
incnmaster(Arg *arg) {
|
||||
if((arrange == dofloat) || (nmaster + arg->i < 1)
|
||||
|| (wah / (nmaster + arg->i) <= 2 * BORDERPX))
|
||||
|| (wah / (nmaster + arg->i) <= 2 * BORDERPX))
|
||||
return;
|
||||
nmaster += arg->i;
|
||||
if(sel)
|
||||
@ -175,7 +174,7 @@ resizemaster(Arg *arg) {
|
||||
master = MASTER;
|
||||
else {
|
||||
if(waw * (master + arg->i) / 1000 >= waw - 2 * BORDERPX
|
||||
|| waw * (master + arg->i) / 1000 <= 2 * BORDERPX)
|
||||
|| waw * (master + arg->i) / 1000 <= 2 * BORDERPX)
|
||||
return;
|
||||
master += arg->i;
|
||||
}
|
||||
@ -207,7 +206,7 @@ restack(void) {
|
||||
|
||||
void
|
||||
togglefloat(Arg *arg) {
|
||||
if (!sel || arrange == dofloat)
|
||||
if(!sel || arrange == dofloat)
|
||||
return;
|
||||
sel->isfloat = !sel->isfloat;
|
||||
arrange();
|
||||
|
Reference in New Issue
Block a user