Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
01b151f5f8 | |||
8bb4a93f2b | |||
5ec04b7726 | |||
3657eaedf3 | |||
9291283a18 | |||
eccd02def2 | |||
11737233a7 | |||
bcaf6a7a0f | |||
f95eed34b4 | |||
1eaffa372f | |||
b1697e8d5f | |||
801d11c7e7 | |||
1b855fccd7 |
1
.hgtags
1
.hgtags
@ -1,2 +1,3 @@
|
|||||||
d31b5ad96b0ba7b5b0a30928fcf000428339a577 0.1
|
d31b5ad96b0ba7b5b0a30928fcf000428339a577 0.1
|
||||||
0a6472e2203994bc5738d40a340d26f7ec9d6062 0.2
|
0a6472e2203994bc5738d40a340d26f7ec9d6062 0.2
|
||||||
|
7e66082e5092fb0bccd18a3695a0bec52c80fdb2 0.3
|
||||||
|
6
Makefile
6
Makefile
@ -41,9 +41,15 @@ dist: clean
|
|||||||
install: all
|
install: all
|
||||||
@mkdir -p ${DESTDIR}${PREFIX}/bin
|
@mkdir -p ${DESTDIR}${PREFIX}/bin
|
||||||
@cp -f ${BIN} ${DESTDIR}${PREFIX}/bin
|
@cp -f ${BIN} ${DESTDIR}${PREFIX}/bin
|
||||||
|
@for i in ${BIN}; do \
|
||||||
|
chmod 755 ${DESTDIR}${PREFIX}/bin/`basename $$i`; \
|
||||||
|
done
|
||||||
@echo installed executable files to ${DESTDIR}${PREFIX}/bin
|
@echo installed executable files to ${DESTDIR}${PREFIX}/bin
|
||||||
@mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
@mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
||||||
@cp -f ${MAN1} ${DESTDIR}${MANPREFIX}/man1
|
@cp -f ${MAN1} ${DESTDIR}${MANPREFIX}/man1
|
||||||
|
@for i in ${MAN1}; do \
|
||||||
|
chmod 444 ${DESTDIR}${MANPREFIX}/man1/`basename $$i`; \
|
||||||
|
done
|
||||||
@echo installed manual pages to ${DESTDIR}${MANPREFIX}/man1
|
@echo installed manual pages to ${DESTDIR}${MANPREFIX}/man1
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
|
1
TODO
1
TODO
@ -1 +0,0 @@
|
|||||||
- improve mouse based resizals with quadrant approach (then I think we have feature completeness already)
|
|
139
client.c
139
client.c
@ -16,19 +16,19 @@ resizetitle(Client *c)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
c->bw = 0;
|
c->tw = 0;
|
||||||
for(i = 0; i < TLast; i++)
|
for(i = 0; i < TLast; i++)
|
||||||
if(c->tags[i])
|
if(c->tags[i])
|
||||||
c->bw += textw(c->tags[i]);
|
c->tw += textw(c->tags[i]);
|
||||||
c->bw += textw(c->name);
|
c->tw += textw(c->name);
|
||||||
if(c->bw > *c->w)
|
if(c->tw > c->w)
|
||||||
c->bw = *c->w + 2;
|
c->tw = c->w + 2;
|
||||||
c->bx = *c->x + *c->w - c->bw + 2;
|
c->tx = c->x + c->w - c->tw + 2;
|
||||||
c->by = *c->y;
|
c->ty = c->y;
|
||||||
if(c->tags[tsel])
|
if(c->tags[tsel])
|
||||||
XMoveResizeWindow(dpy, c->title, c->bx, c->by, c->bw, c->bh);
|
XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th);
|
||||||
else
|
else
|
||||||
XMoveResizeWindow(dpy, c->title, c->bx + 2 * sw, c->by, c->bw, c->bh);
|
XMoveResizeWindow(dpy, c->title, c->tx + 2 * sw, c->ty, c->tw, c->th);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,8 +43,8 @@ xerrordummy(Display *dsply, XErrorEvent *ee)
|
|||||||
void
|
void
|
||||||
ban(Client *c)
|
ban(Client *c)
|
||||||
{
|
{
|
||||||
XMoveWindow(dpy, c->win, *c->x + 2 * sw, *c->y);
|
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||||
XMoveWindow(dpy, c->title, c->bx + 2 * sw, c->by);
|
XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -128,12 +128,12 @@ gravitate(Client *c, Bool invert)
|
|||||||
case EastGravity:
|
case EastGravity:
|
||||||
case CenterGravity:
|
case CenterGravity:
|
||||||
case WestGravity:
|
case WestGravity:
|
||||||
dy = -(*c->h / 2) + c->border;
|
dy = -(c->h / 2) + c->border;
|
||||||
break;
|
break;
|
||||||
case SouthEastGravity:
|
case SouthEastGravity:
|
||||||
case SouthGravity:
|
case SouthGravity:
|
||||||
case SouthWestGravity:
|
case SouthWestGravity:
|
||||||
dy = -(*c->h);
|
dy = -(c->h);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -149,12 +149,12 @@ gravitate(Client *c, Bool invert)
|
|||||||
case NorthGravity:
|
case NorthGravity:
|
||||||
case CenterGravity:
|
case CenterGravity:
|
||||||
case SouthGravity:
|
case SouthGravity:
|
||||||
dx = -(*c->w / 2) + c->border;
|
dx = -(c->w / 2) + c->border;
|
||||||
break;
|
break;
|
||||||
case NorthEastGravity:
|
case NorthEastGravity:
|
||||||
case EastGravity:
|
case EastGravity:
|
||||||
case SouthEastGravity:
|
case SouthEastGravity:
|
||||||
dx = -(*c->w + c->border);
|
dx = -(c->w + c->border);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -164,8 +164,8 @@ gravitate(Client *c, Bool invert)
|
|||||||
dx = -dx;
|
dx = -dx;
|
||||||
dy = -dy;
|
dy = -dy;
|
||||||
}
|
}
|
||||||
*c->x += dx;
|
c->x += dx;
|
||||||
*c->y += dy;
|
c->y += dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -203,19 +203,14 @@ manage(Window w, XWindowAttributes *wa)
|
|||||||
|
|
||||||
c = emallocz(sizeof(Client));
|
c = emallocz(sizeof(Client));
|
||||||
c->win = w;
|
c->win = w;
|
||||||
c->bx = c->fx = c->tx = wa->x;
|
c->x = c->tx = wa->x;
|
||||||
c->by = c->fy = c->ty = wa->y;
|
c->y = c->ty = wa->y;
|
||||||
c->bw = c->fw = c->tw = wa->width;
|
c->w = c->tw = wa->width;
|
||||||
c->fh = c->th = wa->height;
|
c->h = wa->height;
|
||||||
c->bh = bh;
|
c->th = bh;
|
||||||
|
|
||||||
diff = sw - c->fw;
|
if(c->y < bh)
|
||||||
c->fx = random() % (diff ? diff : 1);
|
c->y = c->ty = bh;
|
||||||
diff = sh - c->fh - bh;
|
|
||||||
c->fy = random() % (diff ? diff : 1);
|
|
||||||
|
|
||||||
if(c->fy < bh)
|
|
||||||
c->by = c->fy = c->ty = bh;
|
|
||||||
|
|
||||||
c->border = 1;
|
c->border = 1;
|
||||||
c->proto = getproto(c->win);
|
c->proto = getproto(c->win);
|
||||||
@ -227,7 +222,7 @@ manage(Window w, XWindowAttributes *wa)
|
|||||||
twa.background_pixmap = ParentRelative;
|
twa.background_pixmap = ParentRelative;
|
||||||
twa.event_mask = ExposureMask;
|
twa.event_mask = ExposureMask;
|
||||||
|
|
||||||
c->title = XCreateWindow(dpy, root, c->bx, c->by, c->bw, c->bh,
|
c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
|
||||||
0, DefaultDepth(dpy, screen), CopyFromParent,
|
0, DefaultDepth(dpy, screen), CopyFromParent,
|
||||||
DefaultVisual(dpy, screen),
|
DefaultVisual(dpy, screen),
|
||||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
||||||
@ -239,20 +234,19 @@ manage(Window w, XWindowAttributes *wa)
|
|||||||
|
|
||||||
XGrabButton(dpy, Button1, ControlMask, c->win, False, ButtonPressMask,
|
XGrabButton(dpy, Button1, ControlMask, c->win, False, ButtonPressMask,
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask,
|
XGrabButton(dpy, Button1, MODKEY, c->win, False, ButtonPressMask,
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask,
|
XGrabButton(dpy, Button2, MODKEY, c->win, False, ButtonPressMask,
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask,
|
XGrabButton(dpy, Button3, MODKEY, c->win, False, ButtonPressMask,
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
|
|
||||||
if(!c->isfloat)
|
if(!c->isfloat)
|
||||||
c->isfloat = trans
|
c->isfloat = trans || (c->maxw && c->minw &&
|
||||||
|| ((c->maxw == c->minw) && (c->maxh == c->minh));
|
(c->maxw == c->minw) && (c->maxh == c->minh));
|
||||||
|
|
||||||
|
|
||||||
setgeom(c);
|
|
||||||
settitle(c);
|
settitle(c);
|
||||||
|
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
|
|
||||||
/* mapping the window now prevents flicker */
|
/* mapping the window now prevents flicker */
|
||||||
@ -272,10 +266,10 @@ maximize(Arg *arg)
|
|||||||
{
|
{
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
*sel->x = sx;
|
sel->x = sx;
|
||||||
*sel->y = sy + bh;
|
sel->y = sy + bh;
|
||||||
*sel->w = sw - 2 * sel->border;
|
sel->w = sw - 2 * sel->border;
|
||||||
*sel->h = sh - 2 * sel->border - bh;
|
sel->h = sh - 2 * sel->border - bh;
|
||||||
higher(sel);
|
higher(sel);
|
||||||
resize(sel, False, TopLeft);
|
resize(sel, False, TopLeft);
|
||||||
}
|
}
|
||||||
@ -296,43 +290,43 @@ void
|
|||||||
resize(Client *c, Bool inc, Corner sticky)
|
resize(Client *c, Bool inc, Corner sticky)
|
||||||
{
|
{
|
||||||
XConfigureEvent e;
|
XConfigureEvent e;
|
||||||
int right = *c->x + *c->w;
|
int right = c->x + c->w;
|
||||||
int bottom = *c->y + *c->h;
|
int bottom = c->y + c->h;
|
||||||
|
|
||||||
if(inc) {
|
if(inc) {
|
||||||
if(c->incw)
|
if(c->incw)
|
||||||
*c->w -= (*c->w - c->basew) % c->incw;
|
c->w -= (c->w - c->basew) % c->incw;
|
||||||
if(c->inch)
|
if(c->inch)
|
||||||
*c->h -= (*c->h - c->baseh) % c->inch;
|
c->h -= (c->h - c->baseh) % c->inch;
|
||||||
}
|
}
|
||||||
if(*c->x > sw) /* might happen on restart */
|
if(c->x > sw) /* might happen on restart */
|
||||||
*c->x = sw - *c->w;
|
c->x = sw - c->w;
|
||||||
if(*c->y > sh)
|
if(c->y > sh)
|
||||||
*c->y = sh - *c->h;
|
c->y = sh - c->h;
|
||||||
if(c->minw && *c->w < c->minw)
|
if(c->minw && c->w < c->minw)
|
||||||
*c->w = c->minw;
|
c->w = c->minw;
|
||||||
if(c->minh && *c->h < c->minh)
|
if(c->minh && c->h < c->minh)
|
||||||
*c->h = c->minh;
|
c->h = c->minh;
|
||||||
if(c->maxw && *c->w > c->maxw)
|
if(c->maxw && c->w > c->maxw)
|
||||||
*c->w = c->maxw;
|
c->w = c->maxw;
|
||||||
if(c->maxh && *c->h > c->maxh)
|
if(c->maxh && c->h > c->maxh)
|
||||||
*c->h = c->maxh;
|
c->h = c->maxh;
|
||||||
if(sticky == TopRight || sticky == BotRight)
|
if(sticky == TopRight || sticky == BotRight)
|
||||||
*c->x = right - *c->w;
|
c->x = right - c->w;
|
||||||
if(sticky == BotLeft || sticky == BotRight)
|
if(sticky == BotLeft || sticky == BotRight)
|
||||||
*c->y = bottom - *c->h;
|
c->y = bottom - c->h;
|
||||||
|
|
||||||
resizetitle(c);
|
resizetitle(c);
|
||||||
XSetWindowBorderWidth(dpy, c->win, 1);
|
XSetWindowBorderWidth(dpy, c->win, 1);
|
||||||
XMoveResizeWindow(dpy, c->win, *c->x, *c->y, *c->w, *c->h);
|
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
||||||
|
|
||||||
e.type = ConfigureNotify;
|
e.type = ConfigureNotify;
|
||||||
e.event = c->win;
|
e.event = c->win;
|
||||||
e.window = c->win;
|
e.window = c->win;
|
||||||
e.x = *c->x;
|
e.x = c->x;
|
||||||
e.y = *c->y;
|
e.y = c->y;
|
||||||
e.width = *c->w;
|
e.width = c->w;
|
||||||
e.height = *c->h;
|
e.height = c->h;
|
||||||
e.border_width = c->border;
|
e.border_width = c->border;
|
||||||
e.above = None;
|
e.above = None;
|
||||||
e.override_redirect = False;
|
e.override_redirect = False;
|
||||||
@ -340,23 +334,6 @@ resize(Client *c, Bool inc, Corner sticky)
|
|||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
setgeom(Client *c)
|
|
||||||
{
|
|
||||||
if((arrange == dotile) && !c->isfloat) {
|
|
||||||
c->x = &c->tx;
|
|
||||||
c->y = &c->ty;
|
|
||||||
c->w = &c->tw;
|
|
||||||
c->h = &c->th;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
c->x = &c->fx;
|
|
||||||
c->y = &c->fy;
|
|
||||||
c->w = &c->fw;
|
|
||||||
c->h = &c->fh;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
setsize(Client *c)
|
setsize(Client *c)
|
||||||
{
|
{
|
||||||
|
@ -7,13 +7,13 @@ MANPREFIX = ${PREFIX}/share/man
|
|||||||
X11INC = /usr/X11R6/include
|
X11INC = /usr/X11R6/include
|
||||||
X11LIB = /usr/X11R6/lib
|
X11LIB = /usr/X11R6/lib
|
||||||
|
|
||||||
VERSION = 0.3
|
VERSION = 0.4
|
||||||
|
|
||||||
# includes and libs
|
# includes and libs
|
||||||
LIBS = -L${PREFIX}/lib -L/usr/lib -lc -L${X11LIB} -lX11
|
LIBS = -L${PREFIX}/lib -L/usr/lib -lc -L${X11LIB} -lX11
|
||||||
|
|
||||||
# Linux/BSD
|
# Linux/BSD
|
||||||
CFLAGS = -Os -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
|
CFLAGS = -O3 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
|
||||||
-DVERSION=\"${VERSION}\"
|
-DVERSION=\"${VERSION}\"
|
||||||
LDFLAGS = ${LIBS}
|
LDFLAGS = ${LIBS}
|
||||||
#CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
|
#CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
|
||||||
|
2
dwm.1
2
dwm.1
@ -1,4 +1,4 @@
|
|||||||
.TH DWM 1 dwm-0.2
|
.TH DWM 1 dwm-0.4
|
||||||
.SH NAME
|
.SH NAME
|
||||||
dwm \- dynamic window manager
|
dwm \- dynamic window manager
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
25
dwm.h
25
dwm.h
@ -11,6 +11,7 @@
|
|||||||
#define BGCOLOR "#0a2c2d"
|
#define BGCOLOR "#0a2c2d"
|
||||||
#define FGCOLOR "#ddeeee"
|
#define FGCOLOR "#ddeeee"
|
||||||
#define BORDERCOLOR "#176164"
|
#define BORDERCOLOR "#176164"
|
||||||
|
#define MODKEY Mod1Mask /* Mod4Mask */
|
||||||
/*
|
/*
|
||||||
#define BGCOLOR "#666699"
|
#define BGCOLOR "#666699"
|
||||||
#define FGCOLOR "#eeeeee"
|
#define FGCOLOR "#eeeeee"
|
||||||
@ -29,8 +30,6 @@ typedef struct Client Client;
|
|||||||
typedef enum Corner Corner;
|
typedef enum Corner Corner;
|
||||||
typedef struct DC DC;
|
typedef struct DC DC;
|
||||||
typedef struct Fnt Fnt;
|
typedef struct Fnt Fnt;
|
||||||
typedef struct Key Key;
|
|
||||||
typedef struct Rule Rule;
|
|
||||||
|
|
||||||
union Arg {
|
union Arg {
|
||||||
const char **argv;
|
const char **argv;
|
||||||
@ -68,10 +67,8 @@ struct Client {
|
|||||||
char name[256];
|
char name[256];
|
||||||
char *tags[TLast];
|
char *tags[TLast];
|
||||||
int proto;
|
int proto;
|
||||||
int *x, *y, *w, *h; /* current geom */
|
int x, y, w, h;
|
||||||
int bx, by, bw, bh; /* title bar */
|
int tx, ty, tw, th; /* title */
|
||||||
int fx, fy, fw, fh; /* floating geom */
|
|
||||||
int tx, ty, tw, th; /* tiled geom */
|
|
||||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||||
int grav;
|
int grav;
|
||||||
unsigned int border;
|
unsigned int border;
|
||||||
@ -83,20 +80,6 @@ struct Client {
|
|||||||
Window title;
|
Window title;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Rule {
|
|
||||||
const char *class;
|
|
||||||
const char *instance;
|
|
||||||
char *tags[TLast];
|
|
||||||
Bool isfloat;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Key {
|
|
||||||
unsigned long mod;
|
|
||||||
KeySym keysym;
|
|
||||||
void (*func)(Arg *arg);
|
|
||||||
Arg arg;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern char *tags[TLast], stext[1024];
|
extern char *tags[TLast], stext[1024];
|
||||||
extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
|
extern int tsel, screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
|
||||||
extern void (*handler[LASTEvent])(XEvent *);
|
extern void (*handler[LASTEvent])(XEvent *);
|
||||||
@ -107,7 +90,6 @@ extern Client *clients, *sel;
|
|||||||
extern Cursor cursor[CurLast];
|
extern Cursor cursor[CurLast];
|
||||||
extern DC dc;
|
extern DC dc;
|
||||||
extern Display *dpy;
|
extern Display *dpy;
|
||||||
extern Key key[];
|
|
||||||
extern Window root, barwin;
|
extern Window root, barwin;
|
||||||
|
|
||||||
/* client.c */
|
/* client.c */
|
||||||
@ -125,7 +107,6 @@ extern void manage(Window w, XWindowAttributes *wa);
|
|||||||
extern void maximize(Arg *arg);
|
extern void maximize(Arg *arg);
|
||||||
extern void pop(Client *c);
|
extern void pop(Client *c);
|
||||||
extern void resize(Client *c, Bool inc, Corner sticky);
|
extern void resize(Client *c, Bool inc, Corner sticky);
|
||||||
extern void setgeom(Client *c);
|
|
||||||
extern void setsize(Client *c);
|
extern void setsize(Client *c);
|
||||||
extern void settitle(Client *c);
|
extern void settitle(Client *c);
|
||||||
extern void unmanage(Client *c);
|
extern void unmanage(Client *c);
|
||||||
|
2
dwm.html
2
dwm.html
@ -106,7 +106,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<h3>Download</h3>
|
<h3>Download</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="http://10kloc.org/download/dwm-0.3.tar.gz">dwm 0.3</a> (13kb) (20060719)</li>
|
<li><a href="http://10kloc.org/download/dwm-0.4.tar.gz">dwm 0.4</a> (13kb) (20060720)</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h3>Miscellaneous</h3>
|
<h3>Miscellaneous</h3>
|
||||||
<p>
|
<p>
|
||||||
|
BIN
dwm.png
BIN
dwm.png
Binary file not shown.
Before Width: | Height: | Size: 387 B After Width: | Height: | Size: 373 B |
91
event.c
91
event.c
@ -12,35 +12,58 @@
|
|||||||
#define MouseMask (ButtonMask | PointerMotionMask)
|
#define MouseMask (ButtonMask | PointerMotionMask)
|
||||||
|
|
||||||
/* CUSTOMIZE */
|
/* CUSTOMIZE */
|
||||||
const char *term[] = { "xterm", NULL };
|
|
||||||
|
|
||||||
Key key[] = {
|
typedef struct {
|
||||||
|
unsigned long mod;
|
||||||
|
KeySym keysym;
|
||||||
|
void (*func)(Arg *arg);
|
||||||
|
Arg arg;
|
||||||
|
} Key;
|
||||||
|
|
||||||
|
/*
|
||||||
|
const char *browse[] = { "firefox", NULL };
|
||||||
|
const char *gimp[] = { "gimp", NULL };
|
||||||
|
*/
|
||||||
|
const char *term[] = { "xterm", NULL };
|
||||||
|
/*
|
||||||
|
"urxvtc", "-tr", "+sb", "-bg", "black", "-fg", "white", "-cr", "white",
|
||||||
|
"-fn", "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", NULL
|
||||||
|
};
|
||||||
|
coonst char *xlock[] = { "xlock", NULL };
|
||||||
|
*/
|
||||||
|
|
||||||
|
static Key key[] = {
|
||||||
/* modifier key function arguments */
|
/* modifier key function arguments */
|
||||||
{ ControlMask, XK_0, appendtag, { .i = Tscratch } },
|
{ ControlMask, XK_0, appendtag, { .i = Tscratch } },
|
||||||
{ ControlMask, XK_1, appendtag, { .i = Tdev } },
|
{ ControlMask, XK_1, appendtag, { .i = Tdev } },
|
||||||
{ ControlMask, XK_2, appendtag, { .i = Twww } },
|
{ ControlMask, XK_2, appendtag, { .i = Twww } },
|
||||||
{ ControlMask, XK_3, appendtag, { .i = Twork } },
|
{ ControlMask, XK_3, appendtag, { .i = Twork } },
|
||||||
{ Mod1Mask, XK_0, view, { .i = Tscratch } },
|
{ MODKEY, XK_0, view, { .i = Tscratch } },
|
||||||
{ Mod1Mask, XK_1, view, { .i = Tdev } },
|
{ MODKEY, XK_1, view, { .i = Tdev } },
|
||||||
{ Mod1Mask, XK_2, view, { .i = Twww } },
|
{ MODKEY, XK_2, view, { .i = Twww } },
|
||||||
{ Mod1Mask, XK_3, view, { .i = Twork } },
|
{ MODKEY, XK_3, view, { .i = Twork } },
|
||||||
{ Mod1Mask, XK_j, focusnext, { 0 } },
|
{ MODKEY, XK_j, focusnext, { 0 } },
|
||||||
{ Mod1Mask, XK_k, focusprev, { 0 } },
|
{ MODKEY, XK_k, focusprev, { 0 } },
|
||||||
{ Mod1Mask, XK_m, maximize, { 0 } },
|
{ MODKEY, XK_m, maximize, { 0 } },
|
||||||
{ Mod1Mask, XK_space, dotile, { 0 } },
|
{ MODKEY, XK_space, dotile, { 0 } },
|
||||||
{ Mod1Mask, XK_Return, zoom, { 0 } },
|
{ MODKEY, XK_Return, zoom, { 0 } },
|
||||||
{ ControlMask|ShiftMask,XK_0, heretag, { .i = Tscratch } },
|
{ ControlMask|ShiftMask,XK_0, heretag, { .i = Tscratch } },
|
||||||
{ ControlMask|ShiftMask,XK_1, heretag, { .i = Tdev } },
|
{ ControlMask|ShiftMask,XK_1, heretag, { .i = Tdev } },
|
||||||
{ ControlMask|ShiftMask,XK_2, heretag, { .i = Twww } },
|
{ ControlMask|ShiftMask,XK_2, heretag, { .i = Twww } },
|
||||||
{ ControlMask|ShiftMask,XK_3, heretag, { .i = Twork } },
|
{ ControlMask|ShiftMask,XK_3, heretag, { .i = Twork } },
|
||||||
{ Mod1Mask|ShiftMask, XK_0, replacetag, { .i = Tscratch } },
|
{ MODKEY|ShiftMask, XK_0, replacetag, { .i = Tscratch } },
|
||||||
{ Mod1Mask|ShiftMask, XK_1, replacetag, { .i = Tdev } },
|
{ MODKEY|ShiftMask, XK_1, replacetag, { .i = Tdev } },
|
||||||
{ Mod1Mask|ShiftMask, XK_2, replacetag, { .i = Twww } },
|
{ MODKEY|ShiftMask, XK_2, replacetag, { .i = Twww } },
|
||||||
{ Mod1Mask|ShiftMask, XK_3, replacetag, { .i = Twork } },
|
{ MODKEY|ShiftMask, XK_3, replacetag, { .i = Twork } },
|
||||||
{ Mod1Mask|ShiftMask, XK_c, killclient, { 0 } },
|
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } },
|
||||||
{ Mod1Mask|ShiftMask, XK_q, quit, { 0 } },
|
/*
|
||||||
{ Mod1Mask|ShiftMask, XK_space, dofloat, { 0 } },
|
{ MODKEY|ShiftMask, XK_g, spawn, { .argv = gimp } },
|
||||||
{ Mod1Mask|ShiftMask, XK_Return, spawn, { .argv = term } },
|
{ MODKEY|ShiftMask, XK_l, spawn, { .argv = xlock } },
|
||||||
|
*/
|
||||||
|
{ MODKEY|ShiftMask, XK_q, quit, { 0 } },
|
||||||
|
{ MODKEY|ShiftMask, XK_space, dofloat, { 0 } },
|
||||||
|
/*{ MODKEY|ShiftMask, XK_w, spawn, { .argv = browse } },*/
|
||||||
|
{ MODKEY|ShiftMask, XK_Return, spawn, { .argv = term } },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
@ -53,8 +76,8 @@ movemouse(Client *c)
|
|||||||
unsigned int dui;
|
unsigned int dui;
|
||||||
Window dummy;
|
Window dummy;
|
||||||
|
|
||||||
ocx = *c->x;
|
ocx = c->x;
|
||||||
ocy = *c->y;
|
ocy = c->y;
|
||||||
if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
|
if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
|
||||||
None, cursor[CurMove], CurrentTime) != GrabSuccess)
|
None, cursor[CurMove], CurrentTime) != GrabSuccess)
|
||||||
return;
|
return;
|
||||||
@ -68,8 +91,8 @@ movemouse(Client *c)
|
|||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
*c->x = ocx + (ev.xmotion.x - x1);
|
c->x = ocx + (ev.xmotion.x - x1);
|
||||||
*c->y = ocy + (ev.xmotion.y - y1);
|
c->y = ocy + (ev.xmotion.y - y1);
|
||||||
resize(c, False, TopLeft);
|
resize(c, False, TopLeft);
|
||||||
break;
|
break;
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
@ -86,12 +109,12 @@ resizemouse(Client *c)
|
|||||||
int ocx, ocy;
|
int ocx, ocy;
|
||||||
Corner sticky;
|
Corner sticky;
|
||||||
|
|
||||||
ocx = *c->x;
|
ocx = c->x;
|
||||||
ocy = *c->y;
|
ocy = c->y;
|
||||||
if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
|
if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
|
||||||
None, cursor[CurResize], CurrentTime) != GrabSuccess)
|
None, cursor[CurResize], CurrentTime) != GrabSuccess)
|
||||||
return;
|
return;
|
||||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, *c->w, *c->h);
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
|
||||||
for(;;) {
|
for(;;) {
|
||||||
XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
|
XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
|
||||||
switch(ev.type) {
|
switch(ev.type) {
|
||||||
@ -101,10 +124,10 @@ resizemouse(Client *c)
|
|||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
*c->w = abs(ocx - ev.xmotion.x);
|
c->w = abs(ocx - ev.xmotion.x);
|
||||||
*c->h = abs(ocy - ev.xmotion.y);
|
c->h = abs(ocy - ev.xmotion.y);
|
||||||
*c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - *c->w;
|
c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
|
||||||
*c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - *c->h;
|
c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
|
||||||
if(ocx <= ev.xmotion.x)
|
if(ocx <= ev.xmotion.x)
|
||||||
sticky = (ocy <= ev.xmotion.y) ? TopLeft : BotLeft;
|
sticky = (ocy <= ev.xmotion.y) ? TopLeft : BotLeft;
|
||||||
else
|
else
|
||||||
@ -186,13 +209,13 @@ configurerequest(XEvent *e)
|
|||||||
if((c = getclient(ev->window))) {
|
if((c = getclient(ev->window))) {
|
||||||
gravitate(c, True);
|
gravitate(c, True);
|
||||||
if(ev->value_mask & CWX)
|
if(ev->value_mask & CWX)
|
||||||
*c->x = ev->x;
|
c->x = ev->x;
|
||||||
if(ev->value_mask & CWY)
|
if(ev->value_mask & CWY)
|
||||||
*c->y = ev->y;
|
c->y = ev->y;
|
||||||
if(ev->value_mask & CWWidth)
|
if(ev->value_mask & CWWidth)
|
||||||
*c->w = ev->width;
|
c->w = ev->width;
|
||||||
if(ev->value_mask & CWHeight)
|
if(ev->value_mask & CWHeight)
|
||||||
*c->h = ev->height;
|
c->h = ev->height;
|
||||||
if(ev->value_mask & CWBorderWidth)
|
if(ev->value_mask & CWBorderWidth)
|
||||||
c->border = 1;
|
c->border = 1;
|
||||||
gravitate(c, False);
|
gravitate(c, False);
|
||||||
|
74
tag.c
74
tag.c
@ -4,15 +4,25 @@
|
|||||||
*/
|
*/
|
||||||
#include "dwm.h"
|
#include "dwm.h"
|
||||||
|
|
||||||
|
#include <regex.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *pattern;
|
||||||
|
char *tags[TLast];
|
||||||
|
Bool isfloat;
|
||||||
|
} Rule;
|
||||||
|
|
||||||
/* CUSTOMIZE */
|
/* CUSTOMIZE */
|
||||||
static Rule rule[] = {
|
static Rule rule[] = {
|
||||||
/* class instance tags isfloat */
|
/* class instance tags isfloat */
|
||||||
{ "Firefox-bin", "firefox-bin", { [Twww] = "www" }, False },
|
{ "Firefox.*", { [Twww] = "www" }, False },
|
||||||
|
{ "Gimp.*", { 0 }, True},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* extern */
|
/* extern */
|
||||||
@ -43,7 +53,6 @@ dofloat(Arg *arg)
|
|||||||
|
|
||||||
arrange = dofloat;
|
arrange = dofloat;
|
||||||
for(c = clients; c; c = c->next) {
|
for(c = clients; c; c = c->next) {
|
||||||
setgeom(c);
|
|
||||||
if(c->tags[tsel]) {
|
if(c->tags[tsel]) {
|
||||||
resize(c, True, TopLeft);
|
resize(c, True, TopLeft);
|
||||||
}
|
}
|
||||||
@ -77,7 +86,6 @@ dotile(Arg *arg)
|
|||||||
h = sh - bh;
|
h = sh - bh;
|
||||||
|
|
||||||
for(i = 0, c = clients; c; c = c->next) {
|
for(i = 0, c = clients; c; c = c->next) {
|
||||||
setgeom(c);
|
|
||||||
if(c->tags[tsel]) {
|
if(c->tags[tsel]) {
|
||||||
if(c->isfloat) {
|
if(c->isfloat) {
|
||||||
higher(c);
|
higher(c);
|
||||||
@ -85,28 +93,28 @@ dotile(Arg *arg)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(n == 1) {
|
if(n == 1) {
|
||||||
*c->x = sx;
|
c->x = sx;
|
||||||
*c->y = sy + bh;
|
c->y = sy + bh;
|
||||||
*c->w = sw - 2 * c->border;
|
c->w = sw - 2 * c->border;
|
||||||
*c->h = sh - 2 * c->border - bh;
|
c->h = sh - 2 * c->border - bh;
|
||||||
}
|
}
|
||||||
else if(i == 0) {
|
else if(i == 0) {
|
||||||
*c->x = sx;
|
c->x = sx;
|
||||||
*c->y = sy + bh;
|
c->y = sy + bh;
|
||||||
*c->w = mw - 2 * c->border;
|
c->w = mw - 2 * c->border;
|
||||||
*c->h = sh - 2 * c->border - bh;
|
c->h = sh - 2 * c->border - bh;
|
||||||
}
|
}
|
||||||
else if(h > bh) {
|
else if(h > bh) {
|
||||||
*c->x = sx + mw;
|
c->x = sx + mw;
|
||||||
*c->y = sy + (i - 1) * h + bh;
|
c->y = sy + (i - 1) * h + bh;
|
||||||
*c->w = w - 2 * c->border;
|
c->w = w - 2 * c->border;
|
||||||
*c->h = h - 2 * c->border;
|
c->h = h - 2 * c->border;
|
||||||
}
|
}
|
||||||
else { /* fallback if h < bh */
|
else { /* fallback if h < bh */
|
||||||
*c->x = sx + mw;
|
c->x = sx + mw;
|
||||||
*c->y = sy + bh;
|
c->y = sy + bh;
|
||||||
*c->w = w - 2 * c->border;
|
c->w = w - 2 * c->border;
|
||||||
*c->h = sh - 2 * c->border - bh;
|
c->h = sh - 2 * c->border - bh;
|
||||||
}
|
}
|
||||||
resize(c, False, TopLeft);
|
resize(c, False, TopLeft);
|
||||||
i++;
|
i++;
|
||||||
@ -164,10 +172,13 @@ replacetag(Arg *arg)
|
|||||||
void
|
void
|
||||||
settags(Client *c)
|
settags(Client *c)
|
||||||
{
|
{
|
||||||
XClassHint ch;
|
char classinst[256];
|
||||||
static unsigned int len = rule ? sizeof(rule) / sizeof(rule[0]) : 0;
|
static unsigned int len = rule ? sizeof(rule) / sizeof(rule[0]) : 0;
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
regex_t regex;
|
||||||
|
regmatch_t tmp;
|
||||||
Bool matched = False;
|
Bool matched = False;
|
||||||
|
XClassHint ch;
|
||||||
|
|
||||||
if(!len) {
|
if(!len) {
|
||||||
c->tags[tsel] = tags[tsel];
|
c->tags[tsel] = tags[tsel];
|
||||||
@ -175,24 +186,27 @@ settags(Client *c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(XGetClassHint(dpy, c->win, &ch)) {
|
if(XGetClassHint(dpy, c->win, &ch)) {
|
||||||
if(ch.res_class && ch.res_name) {
|
snprintf(classinst, sizeof(classinst), "%s:%s",
|
||||||
for(i = 0; i < len; i++)
|
ch.res_class ? ch.res_class : "",
|
||||||
if(!strncmp(rule[i].class, ch.res_class, sizeof(rule[i].class))
|
ch.res_name ? ch.res_name : "");
|
||||||
&& !strncmp(rule[i].instance, ch.res_name, sizeof(rule[i].instance)))
|
for(i = 0; !matched && i < len; i++) {
|
||||||
{
|
if(!regcomp(®ex, rule[i].pattern, 0)) {
|
||||||
for(j = 0; j < TLast; j++)
|
if(!regexec(®ex, classinst, 1, &tmp, 0)) {
|
||||||
|
for(j = 0; j < TLast; j++) {
|
||||||
|
if(rule[i].tags[j])
|
||||||
|
matched = True;
|
||||||
c->tags[j] = rule[i].tags[j];
|
c->tags[j] = rule[i].tags[j];
|
||||||
|
}
|
||||||
c->isfloat = rule[i].isfloat;
|
c->isfloat = rule[i].isfloat;
|
||||||
matched = True;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
regfree(®ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(ch.res_class)
|
if(ch.res_class)
|
||||||
XFree(ch.res_class);
|
XFree(ch.res_class);
|
||||||
if(ch.res_name)
|
if(ch.res_name)
|
||||||
XFree(ch.res_name);
|
XFree(ch.res_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!matched)
|
if(!matched)
|
||||||
c->tags[tsel] = tags[tsel];
|
c->tags[tsel] = tags[tsel];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user