Compare commits
46 Commits
Author | SHA1 | Date | |
---|---|---|---|
0f8249f262 | |||
b515765216 | |||
85e6d59956 | |||
95e8d12b71 | |||
a55f0e12fe | |||
0cf3ba0eab | |||
1d85225952 | |||
3af6434085 | |||
57871415c1 | |||
52021851d1 | |||
080a38d62d | |||
ab7a11c0c7 | |||
d8675f6f30 | |||
eff4478c2d | |||
81683351f0 | |||
b38905b004 | |||
d9a6a3b5d2 | |||
7c2e3bb67d | |||
b01a51a844 | |||
77f8c075c4 | |||
33b4821cd6 | |||
a73a882806 | |||
57416beefe | |||
1b63f832c5 | |||
7b5638f61d | |||
937cabfa0a | |||
deba5069e5 | |||
956113b295 | |||
db98a7d60f | |||
0464e42231 | |||
4970ef938e | |||
f85b163899 | |||
2b66f7afb1 | |||
67b3083dfd | |||
0c7bcc24cb | |||
98c6a92eb5 | |||
ba59bc8b9f | |||
cd8d8e1208 | |||
04eb016e78 | |||
0a4342098b | |||
72707c2fae | |||
06dc514bc7 | |||
2b5553b1eb | |||
4688ad181d | |||
dc5d967ee6 | |||
fe3756c8e1 |
2
.hgtags
2
.hgtags
@ -1,3 +1,5 @@
|
||||
d31b5ad96b0ba7b5b0a30928fcf000428339a577 0.1
|
||||
0a6472e2203994bc5738d40a340d26f7ec9d6062 0.2
|
||||
7e66082e5092fb0bccd18a3695a0bec52c80fdb2 0.3
|
||||
eb3165734f00fe7f7da8aeebaed00e60a57caac9 0.4
|
||||
22213b9a2114167ee8ba019a012e27da0422a61a 0.5
|
||||
|
3
Makefile
3
Makefile
@ -13,7 +13,6 @@ all: options dwm
|
||||
|
||||
options:
|
||||
@echo dwm build options:
|
||||
@echo "LIBS = ${LIBS}"
|
||||
@echo "CFLAGS = ${CFLAGS}"
|
||||
@echo "LDFLAGS = ${LDFLAGS}"
|
||||
@echo "CC = ${CC}"
|
||||
@ -29,7 +28,7 @@ dwm: ${OBJ}
|
||||
@${CC} -o $@ ${OBJ} ${LDFLAGS}
|
||||
|
||||
clean:
|
||||
rm -f dwm *.o core dwm-${VERSION}.tar.gz
|
||||
rm -f dwm *.o dwm-${VERSION}.tar.gz
|
||||
|
||||
dist: clean
|
||||
mkdir -p dwm-${VERSION}
|
||||
|
22
README
22
README
@ -1,7 +1,6 @@
|
||||
dwm - dynamic window manager
|
||||
----------------------------
|
||||
|
||||
dwm is an extremly fast, small, and dynamic X11 window manager.
|
||||
dwm is an extremely fast, small, and dynamic X11 window manager.
|
||||
|
||||
|
||||
Requirements
|
||||
@ -11,12 +10,13 @@ In order to build dwm you need the Xlib header files.
|
||||
|
||||
Installation
|
||||
------------
|
||||
Edit config.mk to match your local setup. dwm is installed into
|
||||
the /usr/local namespace by default.
|
||||
Edit config.mk to match your local setup (dwm is installed into
|
||||
the /usr/local namespace by default).
|
||||
|
||||
Afterwards enter the following command to build and install dwm (if
|
||||
necessary as root):
|
||||
|
||||
cp config.default.h config.h
|
||||
make clean install
|
||||
|
||||
|
||||
@ -31,10 +31,18 @@ the DISPLAY environment variable is set correctly, e.g.:
|
||||
|
||||
DISPLAY=foo.bar:1 exec dwm
|
||||
|
||||
This will start dwm on display :1 of the host foo.bar.
|
||||
(This will start dwm on display :1 of the host foo.bar.)
|
||||
|
||||
In order to display status info in the bar, you can do something
|
||||
like this in your .xinitrc:
|
||||
|
||||
while true
|
||||
do
|
||||
echo `date` `uptime | sed 's/.*://; s/,//g'`
|
||||
sleep 1
|
||||
done | dwm
|
||||
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
The configuration of dwm is done by customizing source code,
|
||||
grep for CUSTOMIZE keyword.
|
||||
The configuration of dwm is done by editing config.h.
|
||||
|
234
client.c
234
client.c
@ -3,7 +3,6 @@
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xatom.h>
|
||||
@ -70,11 +69,13 @@ focusnext(Arg *arg)
|
||||
if(!sel)
|
||||
return;
|
||||
|
||||
if(!(c = getnext(sel->next, tsel)))
|
||||
c = getnext(clients, tsel);
|
||||
if(sel->ismax)
|
||||
togglemax(NULL);
|
||||
|
||||
if(!(c = getnext(sel->next)))
|
||||
c = getnext(clients);
|
||||
if(c) {
|
||||
higher(c);
|
||||
c->revert = sel;
|
||||
focus(c);
|
||||
}
|
||||
}
|
||||
@ -87,7 +88,14 @@ focusprev(Arg *arg)
|
||||
if(!sel)
|
||||
return;
|
||||
|
||||
if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) {
|
||||
if(sel->ismax)
|
||||
togglemax(NULL);
|
||||
|
||||
if(!(c = getprev(sel->prev))) {
|
||||
for(c = clients; c && c->next; c = c->next);
|
||||
c = getprev(c);
|
||||
}
|
||||
if(c) {
|
||||
higher(c);
|
||||
focus(c);
|
||||
}
|
||||
@ -97,6 +105,7 @@ Client *
|
||||
getclient(Window w)
|
||||
{
|
||||
Client *c;
|
||||
|
||||
for(c = clients; c; c = c->next)
|
||||
if(c->win == w)
|
||||
return c;
|
||||
@ -107,6 +116,7 @@ Client *
|
||||
getctitle(Window w)
|
||||
{
|
||||
Client *c;
|
||||
|
||||
for(c = clients; c; c = c->next)
|
||||
if(c->title == w)
|
||||
return c;
|
||||
@ -119,6 +129,8 @@ gravitate(Client *c, Bool invert)
|
||||
int dx = 0, dy = 0;
|
||||
|
||||
switch(c->grav) {
|
||||
default:
|
||||
break;
|
||||
case StaticGravity:
|
||||
case NorthWestGravity:
|
||||
case NorthGravity:
|
||||
@ -135,11 +147,11 @@ gravitate(Client *c, Bool invert)
|
||||
case SouthWestGravity:
|
||||
dy = -(c->h);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (c->grav) {
|
||||
default:
|
||||
break;
|
||||
case StaticGravity:
|
||||
case NorthWestGravity:
|
||||
case WestGravity:
|
||||
@ -156,8 +168,6 @@ gravitate(Client *c, Bool invert)
|
||||
case SouthEastGravity:
|
||||
dx = -(c->w + c->border);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(invert) {
|
||||
@ -180,7 +190,7 @@ killclient(Arg *arg)
|
||||
{
|
||||
if(!sel)
|
||||
return;
|
||||
if(sel->proto & WM_PROTOCOL_DELWIN)
|
||||
if(sel->proto & PROTODELWIN)
|
||||
sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]);
|
||||
else
|
||||
XKillClient(dpy, sel->win);
|
||||
@ -196,10 +206,9 @@ lower(Client *c)
|
||||
void
|
||||
manage(Window w, XWindowAttributes *wa)
|
||||
{
|
||||
int diff;
|
||||
Client *c;
|
||||
XSetWindowAttributes twa;
|
||||
Window trans;
|
||||
XSetWindowAttributes twa;
|
||||
|
||||
c = emallocz(sizeof(Client));
|
||||
c->win = w;
|
||||
@ -209,136 +218,102 @@ manage(Window w, XWindowAttributes *wa)
|
||||
c->h = wa->height;
|
||||
c->th = bh;
|
||||
|
||||
if(c->y < bh)
|
||||
c->border = 0;
|
||||
setsize(c);
|
||||
|
||||
if(c->h != sh && c->y < bh)
|
||||
c->y = c->ty = bh;
|
||||
|
||||
c->border = 1;
|
||||
c->proto = getproto(c->win);
|
||||
setsize(c);
|
||||
XSelectInput(dpy, c->win,
|
||||
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
||||
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
||||
XGetTransientForHint(dpy, c->win, &trans);
|
||||
twa.override_redirect = 1;
|
||||
twa.background_pixmap = ParentRelative;
|
||||
twa.event_mask = ExposureMask;
|
||||
twa.event_mask = ExposureMask | EnterWindowMask;
|
||||
|
||||
c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
|
||||
0, DefaultDepth(dpy, screen), CopyFromParent,
|
||||
DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
||||
|
||||
settags(c);
|
||||
|
||||
if(clients)
|
||||
clients->prev = c;
|
||||
c->next = clients;
|
||||
clients = c;
|
||||
|
||||
XGrabButton(dpy, Button1, ControlMask, c->win, False, ButtonPressMask,
|
||||
XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
|
||||
GrabModeAsync, GrabModeSync, None, None);
|
||||
XGrabButton(dpy, Button1, MODKEY, c->win, False, ButtonPressMask,
|
||||
XGrabButton(dpy, Button2, MODKEY, c->win, False, BUTTONMASK,
|
||||
GrabModeAsync, GrabModeSync, None, None);
|
||||
XGrabButton(dpy, Button2, MODKEY, c->win, False, ButtonPressMask,
|
||||
GrabModeAsync, GrabModeSync, None, None);
|
||||
XGrabButton(dpy, Button3, MODKEY, c->win, False, ButtonPressMask,
|
||||
XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK,
|
||||
GrabModeAsync, GrabModeSync, None, None);
|
||||
|
||||
settags(c);
|
||||
if(!c->isfloat)
|
||||
c->isfloat = trans || (c->maxw && c->minw &&
|
||||
(c->maxw == c->minw) && (c->maxh == c->minh));
|
||||
|
||||
|
||||
c->isfloat = trans
|
||||
|| (c->maxw && c->minw &&
|
||||
c->maxw == c->minw && c->maxh == c->minh);
|
||||
settitle(c);
|
||||
arrange(NULL);
|
||||
|
||||
/* mapping the window now prevents flicker */
|
||||
if(c->tags[tsel]) {
|
||||
XMapRaised(dpy, c->win);
|
||||
XMapRaised(dpy, c->title);
|
||||
XMapRaised(dpy, c->win);
|
||||
XMapRaised(dpy, c->title);
|
||||
if(c->tags[tsel])
|
||||
focus(c);
|
||||
}
|
||||
else {
|
||||
XMapRaised(dpy, c->win);
|
||||
XMapRaised(dpy, c->title);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
maximize(Arg *arg)
|
||||
resize(Client *c, Bool sizehints, Corner sticky)
|
||||
{
|
||||
if(!sel)
|
||||
return;
|
||||
sel->x = sx;
|
||||
sel->y = sy + bh;
|
||||
sel->w = sw - 2 * sel->border;
|
||||
sel->h = sh - 2 * sel->border - bh;
|
||||
higher(sel);
|
||||
resize(sel, False, TopLeft);
|
||||
}
|
||||
|
||||
void
|
||||
pop(Client *c)
|
||||
{
|
||||
Client **l;
|
||||
for(l = &clients; *l && *l != c; l = &(*l)->next);
|
||||
*l = c->next;
|
||||
|
||||
c->next = clients; /* pop */
|
||||
clients = c;
|
||||
arrange(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
resize(Client *c, Bool inc, Corner sticky)
|
||||
{
|
||||
XConfigureEvent e;
|
||||
int right = c->x + c->w;
|
||||
int bottom = c->y + c->h;
|
||||
int right = c->x + c->w;
|
||||
/*XConfigureEvent e;*/
|
||||
XWindowChanges wc;
|
||||
|
||||
if(inc) {
|
||||
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)
|
||||
c->h = c->minh;
|
||||
if(c->maxw && c->w > c->maxw)
|
||||
c->w = c->maxw;
|
||||
if(c->maxh && c->h > c->maxh)
|
||||
c->h = c->maxh;
|
||||
}
|
||||
if(c->x > sw) /* might happen on restart */
|
||||
c->x = sw - c->w;
|
||||
if(c->y > sh)
|
||||
c->y = sh - c->h;
|
||||
if(c->minw && c->w < c->minw)
|
||||
c->w = c->minw;
|
||||
if(c->minh && c->h < c->minh)
|
||||
c->h = c->minh;
|
||||
if(c->maxw && c->w > c->maxw)
|
||||
c->w = c->maxw;
|
||||
if(c->maxh && c->h > c->maxh)
|
||||
c->h = c->maxh;
|
||||
if(c->x > right) /* might happen on restart */
|
||||
c->x = right - c->w;
|
||||
if(c->y > bottom)
|
||||
c->y = bottom - c->h;
|
||||
if(sticky == TopRight || sticky == BotRight)
|
||||
c->x = right - c->w;
|
||||
if(sticky == BotLeft || sticky == BotRight)
|
||||
c->y = bottom - c->h;
|
||||
|
||||
resizetitle(c);
|
||||
XSetWindowBorderWidth(dpy, c->win, 1);
|
||||
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
||||
|
||||
e.type = ConfigureNotify;
|
||||
e.event = c->win;
|
||||
e.window = c->win;
|
||||
e.x = c->x;
|
||||
e.y = c->y;
|
||||
e.width = c->w;
|
||||
e.height = c->h;
|
||||
e.border_width = c->border;
|
||||
e.above = None;
|
||||
e.override_redirect = False;
|
||||
XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&e);
|
||||
wc.x = c->x;
|
||||
wc.y = c->y;
|
||||
wc.width = c->w;
|
||||
wc.height = c->h;
|
||||
if(c->w == sw && c->h == sh)
|
||||
wc.border_width = 0;
|
||||
else
|
||||
wc.border_width = 1;
|
||||
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
void
|
||||
setsize(Client *c)
|
||||
{
|
||||
XSizeHints size;
|
||||
long msize;
|
||||
XSizeHints size;
|
||||
|
||||
if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags)
|
||||
size.flags = PSize;
|
||||
c->flags = size.flags;
|
||||
@ -375,9 +350,9 @@ setsize(Client *c)
|
||||
void
|
||||
settitle(Client *c)
|
||||
{
|
||||
XTextProperty name;
|
||||
int n;
|
||||
char **list = NULL;
|
||||
int n;
|
||||
XTextProperty name;
|
||||
|
||||
name.nitems = 0;
|
||||
c->name[0] = 0;
|
||||
@ -400,25 +375,60 @@ settitle(Client *c)
|
||||
resizetitle(c);
|
||||
}
|
||||
|
||||
void
|
||||
togglemax(Arg *arg)
|
||||
{
|
||||
int ox, oy, ow, oh;
|
||||
XEvent ev;
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
|
||||
if((sel->ismax = !sel->ismax)) {
|
||||
ox = sel->x;
|
||||
oy = sel->y;
|
||||
ow = sel->w;
|
||||
oh = sel->h;
|
||||
sel->x = sx;
|
||||
sel->y = sy + bh;
|
||||
sel->w = sw - 2;
|
||||
sel->h = sh - 2 - bh;
|
||||
|
||||
higher(sel);
|
||||
resize(sel, False, TopLeft);
|
||||
|
||||
sel->x = ox;
|
||||
sel->y = oy;
|
||||
sel->w = ow;
|
||||
sel->h = oh;
|
||||
}
|
||||
else
|
||||
resize(sel, False, TopLeft);
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
}
|
||||
|
||||
void
|
||||
unmanage(Client *c)
|
||||
{
|
||||
Client **l;
|
||||
|
||||
XGrabServer(dpy);
|
||||
XSetErrorHandler(xerrordummy);
|
||||
|
||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||
XDestroyWindow(dpy, c->title);
|
||||
|
||||
for(l = &clients; *l && *l != c; l = &(*l)->next);
|
||||
*l = c->next;
|
||||
for(l = &clients; *l; l = &(*l)->next)
|
||||
if((*l)->revert == c)
|
||||
(*l)->revert = NULL;
|
||||
if(sel == c)
|
||||
sel = sel->revert ? sel->revert : clients;
|
||||
|
||||
if(c->prev)
|
||||
c->prev->next = c->next;
|
||||
if(c->next)
|
||||
c->next->prev = c->prev;
|
||||
if(c == clients)
|
||||
clients = c->next;
|
||||
if(sel == c) {
|
||||
sel = getnext(c->next);
|
||||
if(!sel)
|
||||
sel = getprev(c->prev);
|
||||
if(!sel)
|
||||
sel = clients;
|
||||
}
|
||||
free(c);
|
||||
|
||||
XSync(dpy, False);
|
||||
@ -437,11 +447,21 @@ zoom(Arg *arg)
|
||||
if(!sel)
|
||||
return;
|
||||
|
||||
if(sel == getnext(clients, tsel) && sel->next) {
|
||||
if((c = getnext(sel->next, tsel)))
|
||||
if(sel == getnext(clients) && sel->next) {
|
||||
if((c = getnext(sel->next)))
|
||||
sel = c;
|
||||
}
|
||||
|
||||
pop(sel);
|
||||
/* pop */
|
||||
if(sel->prev)
|
||||
sel->prev->next = sel->next;
|
||||
if(sel->next)
|
||||
sel->next->prev = sel->prev;
|
||||
sel->prev = NULL;
|
||||
if(clients)
|
||||
clients->prev = sel;
|
||||
sel->next = clients;
|
||||
clients = sel;
|
||||
arrange(NULL);
|
||||
focus(sel);
|
||||
}
|
||||
|
73
config.arg.h
Normal file
73
config.arg.h
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
|
||||
enum { Tfnord, Tdev, Tnet, Twork, Tmisc, TLast };
|
||||
#define TAGS \
|
||||
char *tags[TLast] = { \
|
||||
[Tfnord] = "fnord", \
|
||||
[Tdev] = "dev", \
|
||||
[Tnet] = "net", \
|
||||
[Twork] = "work", \
|
||||
[Tmisc] = "misc", \
|
||||
};
|
||||
|
||||
#define DEFMODE dotile /* dofloat */
|
||||
#define DEFTAG Tdev
|
||||
#define FONT "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*"
|
||||
#define BGCOLOR "#0a2c2d"
|
||||
#define FGCOLOR "#ddeeee"
|
||||
#define BORDERCOLOR "#176164"
|
||||
#define MODKEY Mod1Mask
|
||||
#define NUMLOCKMASK Mod2Mask
|
||||
#define MASTERW 52 /* percent */
|
||||
|
||||
#define KEYS \
|
||||
const char *browse[] = { "firefox", NULL }; \
|
||||
const char *gimp[] = { "gimp", NULL }; \
|
||||
const char *term[] = { \
|
||||
"urxvt", "-tr", "+sb", "-bg", "black", "-fg", "white", "-cr", "white", \
|
||||
"-fn", "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", NULL \
|
||||
}; \
|
||||
const char *xlock[] = { "xlock", NULL }; \
|
||||
static Key key[] = { \
|
||||
/* modifier key function arguments */ \
|
||||
{ MODKEY, XK_0, view, { .i = Tfnord } }, \
|
||||
{ MODKEY, XK_1, view, { .i = Tdev } }, \
|
||||
{ MODKEY, XK_2, view, { .i = Tnet } }, \
|
||||
{ MODKEY, XK_3, view, { .i = Twork } }, \
|
||||
{ MODKEY, XK_4, view, { .i = Tmisc} }, \
|
||||
{ MODKEY, XK_h, viewprev, { 0 } }, \
|
||||
{ MODKEY, XK_j, focusnext, { 0 } }, \
|
||||
{ MODKEY, XK_k, focusprev, { 0 } }, \
|
||||
{ MODKEY, XK_l, viewnext, { 0 } }, \
|
||||
{ MODKEY, XK_m, togglemax, { 0 } }, \
|
||||
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
||||
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
||||
{ MODKEY|ControlMask, XK_0, appendtag, { .i = Tfnord } }, \
|
||||
{ MODKEY|ControlMask, XK_1, appendtag, { .i = Tdev } }, \
|
||||
{ MODKEY|ControlMask, XK_2, appendtag, { .i = Tnet } }, \
|
||||
{ MODKEY|ControlMask, XK_3, appendtag, { .i = Twork } }, \
|
||||
{ MODKEY|ControlMask, XK_4, appendtag, { .i = Tmisc } }, \
|
||||
{ MODKEY|ShiftMask, XK_0, replacetag, { .i = Tfnord } }, \
|
||||
{ MODKEY|ShiftMask, XK_1, replacetag, { .i = Tdev } }, \
|
||||
{ MODKEY|ShiftMask, XK_2, replacetag, { .i = Tnet } }, \
|
||||
{ MODKEY|ShiftMask, XK_3, replacetag, { .i = Twork } }, \
|
||||
{ MODKEY|ShiftMask, XK_4, replacetag, { .i = Tmisc } }, \
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
|
||||
{ MODKEY|ShiftMask, XK_Return, spawn, { .argv = term } }, \
|
||||
{ MODKEY|ShiftMask, XK_g, spawn, { .argv = gimp } }, \
|
||||
{ MODKEY|ShiftMask, XK_l, spawn, { .argv = xlock } }, \
|
||||
{ MODKEY|ShiftMask, XK_w, spawn, { .argv = browse } }, \
|
||||
};
|
||||
|
||||
#define RULES \
|
||||
static Rule rule[] = { \
|
||||
/* class:instance tags isfloat */ \
|
||||
{ "Firefox.*", { [Tnet] = "net" }, False }, \
|
||||
{ "Gimp.*", { 0 }, True}, \
|
||||
{ "MPlayer.*", { 0 }, True}, \
|
||||
{ "Acroread.*", { 0 }, True}, \
|
||||
};
|
62
config.default.h
Normal file
62
config.default.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
|
||||
enum { Tfnord, Tdev, Tnet, Twork, Tmisc, TLast };
|
||||
#define TAGS \
|
||||
char *tags[TLast] = { \
|
||||
[Tfnord] = "fnord", \
|
||||
[Tdev] = "dev", \
|
||||
[Tnet] = "net", \
|
||||
[Twork] = "work", \
|
||||
[Tmisc] = "misc", \
|
||||
};
|
||||
|
||||
#define DEFMODE dotile /* dofloat */
|
||||
#define DEFTAG Tdev
|
||||
#define FONT "fixed"
|
||||
#define BGCOLOR "#666699"
|
||||
#define FGCOLOR "#eeeeee"
|
||||
#define BORDERCOLOR "#9999CC"
|
||||
#define MODKEY Mod1Mask
|
||||
#define NUMLOCKMASK Mod2Mask
|
||||
#define MASTERW 52 /* percent */
|
||||
|
||||
#define KEYS \
|
||||
const char *term[] = { "xterm", NULL }; \
|
||||
static Key key[] = { \
|
||||
/* modifier key function arguments */ \
|
||||
{ MODKEY, XK_0, view, { .i = Tfnord } }, \
|
||||
{ MODKEY, XK_1, view, { .i = Tdev } }, \
|
||||
{ MODKEY, XK_2, view, { .i = Tnet } }, \
|
||||
{ MODKEY, XK_3, view, { .i = Twork } }, \
|
||||
{ MODKEY, XK_4, view, { .i = Tmisc} }, \
|
||||
{ MODKEY, XK_h, viewprev, { 0 } }, \
|
||||
{ MODKEY, XK_j, focusnext, { 0 } }, \
|
||||
{ MODKEY, XK_k, focusprev, { 0 } }, \
|
||||
{ MODKEY, XK_l, viewnext, { 0 } }, \
|
||||
{ MODKEY, XK_m, togglemax, { 0 } }, \
|
||||
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
||||
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
||||
{ MODKEY|ControlMask, XK_0, appendtag, { .i = Tfnord } }, \
|
||||
{ MODKEY|ControlMask, XK_1, appendtag, { .i = Tdev } }, \
|
||||
{ MODKEY|ControlMask, XK_2, appendtag, { .i = Tnet } }, \
|
||||
{ MODKEY|ControlMask, XK_3, appendtag, { .i = Twork } }, \
|
||||
{ MODKEY|ControlMask, XK_4, appendtag, { .i = Tmisc } }, \
|
||||
{ MODKEY|ShiftMask, XK_0, replacetag, { .i = Tfnord } }, \
|
||||
{ MODKEY|ShiftMask, XK_1, replacetag, { .i = Tdev } }, \
|
||||
{ MODKEY|ShiftMask, XK_2, replacetag, { .i = Tnet } }, \
|
||||
{ MODKEY|ShiftMask, XK_3, replacetag, { .i = Twork } }, \
|
||||
{ MODKEY|ShiftMask, XK_4, replacetag, { .i = Tmisc } }, \
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
|
||||
{ MODKEY|ShiftMask, XK_Return, spawn, { .argv = term } }, \
|
||||
};
|
||||
|
||||
#define RULES \
|
||||
static Rule rule[] = { \
|
||||
/* class:instance tags isfloat */ \
|
||||
{ "Firefox.*", { [Tnet] = "net" }, False }, \
|
||||
{ "Gimp.*", { 0 }, True}, \
|
||||
};
|
26
config.mk
26
config.mk
@ -1,4 +1,7 @@
|
||||
# Customize to fit your system
|
||||
# dwm version
|
||||
VERSION = 0.6
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
# paths
|
||||
PREFIX = /usr/local
|
||||
@ -7,24 +10,15 @@ MANPREFIX = ${PREFIX}/share/man
|
||||
X11INC = /usr/X11R6/include
|
||||
X11LIB = /usr/X11R6/lib
|
||||
|
||||
VERSION = 0.4
|
||||
|
||||
# includes and libs
|
||||
LIBS = -L${PREFIX}/lib -L/usr/lib -lc -L${X11LIB} -lX11
|
||||
INCS = -I/usr/lib -I${X11INC}
|
||||
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
|
||||
|
||||
# Linux/BSD
|
||||
CFLAGS = -O3 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
|
||||
-DVERSION=\"${VERSION}\"
|
||||
# flags
|
||||
CFLAGS = -O3 ${INCS} -DVERSION=\"${VERSION}\"
|
||||
LDFLAGS = ${LIBS}
|
||||
#CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
|
||||
# -DVERSION=\"${VERSION}\"
|
||||
#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
|
||||
#LDFLAGS = -g ${LIBS}
|
||||
|
||||
|
||||
# Solaris
|
||||
#CFLAGS = -fast -xtarget=ultra ${INCLUDES} -DVERSION=\"${VERSION}\"
|
||||
#LIBS += -lnsl -lsocket
|
||||
|
||||
AR = ar cr
|
||||
# compiler
|
||||
CC = cc
|
||||
RANLIB = ranlib
|
||||
|
22
draw.c
22
draw.c
@ -3,7 +3,6 @@
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlocale.h>
|
||||
@ -14,6 +13,7 @@ static void
|
||||
drawborder(void)
|
||||
{
|
||||
XPoint points[5];
|
||||
|
||||
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
||||
XSetForeground(dpy, dc.gc, dc.border);
|
||||
points[0].x = dc.x;
|
||||
@ -33,6 +33,7 @@ static unsigned int
|
||||
textnw(char *text, unsigned int len)
|
||||
{
|
||||
XRectangle r;
|
||||
|
||||
if(dc.font.set) {
|
||||
XmbTextExtents(dc.font.set, text, len, NULL, &r);
|
||||
return r.width;
|
||||
@ -44,8 +45,8 @@ static void
|
||||
drawtext(const char *text, Bool invert, Bool border)
|
||||
{
|
||||
int x, y, w, h;
|
||||
unsigned int len;
|
||||
static char buf[256];
|
||||
unsigned int len;
|
||||
XGCValues gcv;
|
||||
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
|
||||
|
||||
@ -97,7 +98,7 @@ drawall()
|
||||
{
|
||||
Client *c;
|
||||
|
||||
for(c = clients; c; c = getnext(c->next, tsel))
|
||||
for(c = clients; c; c = getnext(c->next))
|
||||
drawtitle(c);
|
||||
drawstatus();
|
||||
}
|
||||
@ -105,7 +106,7 @@ drawall()
|
||||
void
|
||||
drawstatus()
|
||||
{
|
||||
int i;
|
||||
int i, x;
|
||||
Bool istile = arrange == dotile;
|
||||
|
||||
dc.x = dc.y = 0;
|
||||
@ -121,15 +122,14 @@ drawstatus()
|
||||
else
|
||||
drawtext(tags[i], (i != tsel), True);
|
||||
}
|
||||
if(sel) {
|
||||
dc.x += dc.w;
|
||||
dc.w = textw(sel->name);
|
||||
drawtext(sel->name, istile, True);
|
||||
}
|
||||
x = dc.x + dc.w;
|
||||
dc.w = textw(stext);
|
||||
dc.x = bx + bw - dc.w;
|
||||
drawtext(stext, !istile, False);
|
||||
|
||||
if(sel && ((dc.w = dc.x - x) >= bh)) {
|
||||
dc.x = x;
|
||||
drawtext(sel->name, istile, True);
|
||||
}
|
||||
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
@ -170,8 +170,8 @@ drawtitle(Client *c)
|
||||
unsigned long
|
||||
getcolor(const char *colstr)
|
||||
{
|
||||
XColor color;
|
||||
Colormap cmap = DefaultColormap(dpy, screen);
|
||||
XColor color;
|
||||
|
||||
XAllocNamedColor(dpy, cmap, colstr, &color, &color);
|
||||
return color.pixel;
|
||||
|
70
dwm.1
70
dwm.1
@ -1,4 +1,4 @@
|
||||
.TH DWM 1 dwm-0.4
|
||||
.TH DWM 1 dwm-0.6
|
||||
.SH NAME
|
||||
dwm \- dynamic window manager
|
||||
.SH SYNOPSIS
|
||||
@ -21,7 +21,7 @@ time. But each window may contain more than one tag, which makes it visible in
|
||||
several views.
|
||||
.P
|
||||
.B dwm
|
||||
consists of a small status bar which reads the text displayed from standard
|
||||
has a small status bar which reads the text displayed from standard
|
||||
input, if written. It draws 1-pixel borders around windows to indicate the
|
||||
focus state. Unfocused windows contain a small bar in front of the window
|
||||
displaying the tags and the window title.
|
||||
@ -38,37 +38,42 @@ to the
|
||||
.B master
|
||||
column
|
||||
.TP
|
||||
.B Mod1-k
|
||||
.B Mod1-h
|
||||
Focus previous
|
||||
.B window
|
||||
.B tag
|
||||
.TP
|
||||
.B Mod1-j
|
||||
Focus next
|
||||
.B window
|
||||
.TP
|
||||
.B Mod1-k
|
||||
Focus previous
|
||||
.B window
|
||||
.TP
|
||||
.B Mod1-l
|
||||
Focus next
|
||||
.B tag
|
||||
.TP
|
||||
.B Mod1-m
|
||||
Maximize current
|
||||
.B window
|
||||
.TP
|
||||
.B Mod1-[0..n]
|
||||
Focus
|
||||
.B nth
|
||||
tag
|
||||
.B nth tag
|
||||
.TP
|
||||
.B Mod1-space
|
||||
(Re-)arrange
|
||||
.B all
|
||||
windows tiled
|
||||
.TP
|
||||
.B Mod1-Shift-space
|
||||
(Re-)arrange
|
||||
.B all
|
||||
windows floating
|
||||
Toggle between
|
||||
.B tiled
|
||||
and
|
||||
.B floating
|
||||
mode (affects
|
||||
.BR "all windows" )
|
||||
.TP
|
||||
.B Mod1-Shift-[0..n]
|
||||
Apply
|
||||
.B nth
|
||||
tag to current
|
||||
.B nth tag
|
||||
to current
|
||||
.B window
|
||||
.TP
|
||||
.B Mod1-Shift-q
|
||||
@ -79,33 +84,12 @@ Quit
|
||||
Start
|
||||
.B terminal
|
||||
.TP
|
||||
.B Mod1-Shift-w
|
||||
Start
|
||||
.B web browser
|
||||
.TP
|
||||
.B Mod1-Shift-l
|
||||
Lock
|
||||
.B screen
|
||||
.TP
|
||||
.B Control-[0..n]
|
||||
.B Mod1-Control-[0..n]
|
||||
Append
|
||||
.B nth
|
||||
tag to current
|
||||
.B nth tag
|
||||
to current
|
||||
.B window
|
||||
.TP
|
||||
.B Control-Shift-[0..n]
|
||||
Replace current
|
||||
.B window
|
||||
of
|
||||
.B nth
|
||||
tag with current tag.
|
||||
.B window
|
||||
.TP
|
||||
.B Control-Button1
|
||||
Zooms the clicked
|
||||
.B window
|
||||
to master column
|
||||
.TP
|
||||
.B Mod1-Button1
|
||||
Moves current
|
||||
.B window
|
||||
@ -121,7 +105,5 @@ Resizes current
|
||||
while dragging
|
||||
.SH CUSTOMIZATION
|
||||
.B dwm
|
||||
is customized through editing its source code. This keeps it fast, secure and
|
||||
simple. The source code contains the
|
||||
.I CUSTOMIZE
|
||||
keyword to highlight relevant portions for customization.
|
||||
is customized by editing the file config.h of the source code.
|
||||
This keeps it fast, secure and simple.
|
||||
|
45
dwm.h
45
dwm.h
@ -3,31 +3,16 @@
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
/********** CUSTOMIZE **********/
|
||||
|
||||
#define FONT "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*"
|
||||
#define BGCOLOR "#0a2c2d"
|
||||
#define FGCOLOR "#ddeeee"
|
||||
#define BORDERCOLOR "#176164"
|
||||
#define MODKEY Mod1Mask /* Mod4Mask */
|
||||
/*
|
||||
#define BGCOLOR "#666699"
|
||||
#define FGCOLOR "#eeeeee"
|
||||
#define BORDERCOLOR "#9999CC"
|
||||
*/
|
||||
#define MASTERW 52 /* percent */
|
||||
#define WM_PROTOCOL_DELWIN 1
|
||||
|
||||
/* tags */
|
||||
enum { Tscratch, Tdev, Twww, Twork, TLast };
|
||||
|
||||
/********** CUSTOMIZE **********/
|
||||
/* mask shorthands, used in event.c and client.c */
|
||||
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
|
||||
#define MOUSEMASK (BUTTONMASK | PointerMotionMask)
|
||||
#define PROTODELWIN 1
|
||||
|
||||
typedef union Arg Arg;
|
||||
typedef struct Client Client;
|
||||
typedef enum Corner Corner;
|
||||
typedef struct DC DC;
|
||||
typedef struct Fnt Fnt;
|
||||
|
||||
@ -43,7 +28,8 @@ enum { WMProtocols, WMDelete, WMLast };
|
||||
/* cursor */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast };
|
||||
|
||||
enum Corner { TopLeft, TopRight, BotLeft, BotRight };
|
||||
/* windowcorners */
|
||||
typedef enum { TopLeft, TopRight, BotLeft, BotRight } Corner;
|
||||
|
||||
struct Fnt {
|
||||
int ascent;
|
||||
@ -71,11 +57,12 @@ struct Client {
|
||||
int tx, ty, tw, th; /* title */
|
||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||
int grav;
|
||||
unsigned int border;
|
||||
long flags;
|
||||
unsigned int border;
|
||||
Bool isfloat;
|
||||
Bool ismax;
|
||||
Client *next;
|
||||
Client *revert;
|
||||
Client *prev;
|
||||
Window win;
|
||||
Window title;
|
||||
};
|
||||
@ -104,11 +91,10 @@ extern void higher(Client *c);
|
||||
extern void killclient(Arg *arg);
|
||||
extern void lower(Client *c);
|
||||
extern void manage(Window w, XWindowAttributes *wa);
|
||||
extern void maximize(Arg *arg);
|
||||
extern void pop(Client *c);
|
||||
extern void resize(Client *c, Bool inc, Corner sticky);
|
||||
extern void resize(Client *c, Bool sizehints, Corner sticky);
|
||||
extern void setsize(Client *c);
|
||||
extern void settitle(Client *c);
|
||||
extern void togglemax(Arg *arg);
|
||||
extern void unmanage(Client *c);
|
||||
extern void zoom(Arg *arg);
|
||||
|
||||
@ -133,11 +119,14 @@ extern int xerror(Display *dsply, XErrorEvent *ee);
|
||||
extern void appendtag(Arg *arg);
|
||||
extern void dofloat(Arg *arg);
|
||||
extern void dotile(Arg *arg);
|
||||
extern Client *getnext(Client *c, unsigned int t);
|
||||
extern void heretag(Arg *arg);
|
||||
extern Client *getnext(Client *c);
|
||||
extern Client *getprev(Client *c);
|
||||
extern void replacetag(Arg *arg);
|
||||
extern void settags(Client *c);
|
||||
extern void togglemode(Arg *arg);
|
||||
extern void view(Arg *arg);
|
||||
extern void viewnext(Arg *arg);
|
||||
extern void viewprev(Arg *arg);
|
||||
|
||||
/* util.c */
|
||||
extern void *emallocz(unsigned int size);
|
||||
|
12
dwm.html
12
dwm.html
@ -67,7 +67,7 @@
|
||||
and status text read from standard input. You don't have to learn
|
||||
Lua/sh/ruby or some weird configuration file format (like X
|
||||
resource files), beside C to customize it for your needs,
|
||||
you <b>only</b> have to learn C.
|
||||
you <b>only</b> have to learn C (at least editing header files).
|
||||
</li>
|
||||
<li>
|
||||
Because dwm is customized through editing its source code, it's
|
||||
@ -97,6 +97,10 @@
|
||||
<li>Mailing List: <a href="http://10kloc.org/cgi-bin/mailman/listinfo/dwm">dwm at wmii dot de</a> <a href="http://10kloc.org/pipermail/dwm/">(Archives)</a></li>
|
||||
<li>IRC channel: <code>#dwm</code> at <code>irc.oftc.net</code></li>
|
||||
</ul>
|
||||
<h3>Download</h3>
|
||||
<ul>
|
||||
<li><a href="http://10kloc.org/download/dwm-0.5.tar.gz">dwm 0.5</a> (13kb) (20060721)</li>
|
||||
</ul>
|
||||
<h3>Development</h3>
|
||||
<p>
|
||||
dwm is actively developed in parallel to wmii. You can <a href="http://10kloc.org/cgi-bin/hgwebdir.cgi/dwm">browse</a> its source code repository or get a copy using <a href="http://www.selenic.com/mercurial/">Mercurial</a> with following command:
|
||||
@ -104,15 +108,11 @@
|
||||
<p>
|
||||
<code>hg clone http://10kloc.org/cgi-bin/hgwebdir.cgi/dwm</code>
|
||||
</p>
|
||||
<h3>Download</h3>
|
||||
<ul>
|
||||
<li><a href="http://10kloc.org/download/dwm-0.4.tar.gz">dwm 0.4</a> (13kb) (20060720)</li>
|
||||
</ul>
|
||||
<h3>Miscellaneous</h3>
|
||||
<p>
|
||||
You can purchase this <a href="https://www.spreadshirt.net/shop.php?op=article&article_id=3298632&view=403">tricot</a>
|
||||
if you like dwm and the dwm logo, which has been designed by Anselm.
|
||||
</p>
|
||||
<p><small>--Anselm (20060719)</small></p>
|
||||
<p><small>--Anselm (20060801)</small></p>
|
||||
</body>
|
||||
</html>
|
||||
|
194
event.c
194
event.c
@ -3,15 +3,11 @@
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#define ButtonMask (ButtonPressMask | ButtonReleaseMask)
|
||||
#define MouseMask (ButtonMask | PointerMotionMask)
|
||||
|
||||
/* CUSTOMIZE */
|
||||
/* static */
|
||||
|
||||
typedef struct {
|
||||
unsigned long mod;
|
||||
@ -20,70 +16,26 @@ typedef struct {
|
||||
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 };
|
||||
*/
|
||||
KEYS
|
||||
|
||||
static Key key[] = {
|
||||
/* modifier key function arguments */
|
||||
{ ControlMask, XK_0, appendtag, { .i = Tscratch } },
|
||||
{ ControlMask, XK_1, appendtag, { .i = Tdev } },
|
||||
{ ControlMask, XK_2, appendtag, { .i = Twww } },
|
||||
{ ControlMask, XK_3, appendtag, { .i = Twork } },
|
||||
{ MODKEY, XK_0, view, { .i = Tscratch } },
|
||||
{ MODKEY, XK_1, view, { .i = Tdev } },
|
||||
{ MODKEY, XK_2, view, { .i = Twww } },
|
||||
{ MODKEY, XK_3, view, { .i = Twork } },
|
||||
{ MODKEY, XK_j, focusnext, { 0 } },
|
||||
{ MODKEY, XK_k, focusprev, { 0 } },
|
||||
{ MODKEY, XK_m, maximize, { 0 } },
|
||||
{ MODKEY, XK_space, dotile, { 0 } },
|
||||
{ MODKEY, XK_Return, zoom, { 0 } },
|
||||
{ ControlMask|ShiftMask,XK_0, heretag, { .i = Tscratch } },
|
||||
{ ControlMask|ShiftMask,XK_1, heretag, { .i = Tdev } },
|
||||
{ ControlMask|ShiftMask,XK_2, heretag, { .i = Twww } },
|
||||
{ ControlMask|ShiftMask,XK_3, heretag, { .i = Twork } },
|
||||
{ MODKEY|ShiftMask, XK_0, replacetag, { .i = Tscratch } },
|
||||
{ MODKEY|ShiftMask, XK_1, replacetag, { .i = Tdev } },
|
||||
{ MODKEY|ShiftMask, XK_2, replacetag, { .i = Twww } },
|
||||
{ MODKEY|ShiftMask, XK_3, replacetag, { .i = Twork } },
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } },
|
||||
/*
|
||||
{ MODKEY|ShiftMask, XK_g, spawn, { .argv = gimp } },
|
||||
{ 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 */
|
||||
#define CLEANMASK(mask) (mask & ~(NUMLOCKMASK | LockMask))
|
||||
|
||||
static void
|
||||
movemouse(Client *c)
|
||||
{
|
||||
XEvent ev;
|
||||
int x1, y1, ocx, ocy, di;
|
||||
unsigned int dui;
|
||||
Window dummy;
|
||||
XEvent ev;
|
||||
|
||||
ocx = c->x;
|
||||
ocy = c->y;
|
||||
if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
|
||||
None, cursor[CurMove], CurrentTime) != GrabSuccess)
|
||||
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
||||
None, cursor[CurMove], CurrentTime) != GrabSuccess)
|
||||
return;
|
||||
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
|
||||
for(;;) {
|
||||
XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
|
||||
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
|
||||
switch (ev.type) {
|
||||
default: break;
|
||||
case Expose:
|
||||
@ -105,18 +57,18 @@ movemouse(Client *c)
|
||||
static void
|
||||
resizemouse(Client *c)
|
||||
{
|
||||
XEvent ev;
|
||||
int ocx, ocy;
|
||||
Corner sticky;
|
||||
XEvent ev;
|
||||
|
||||
ocx = c->x;
|
||||
ocy = c->y;
|
||||
if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
|
||||
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
||||
None, cursor[CurResize], CurrentTime) != GrabSuccess)
|
||||
return;
|
||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
|
||||
for(;;) {
|
||||
XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
|
||||
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
|
||||
switch(ev.type) {
|
||||
default: break;
|
||||
case Expose:
|
||||
@ -146,8 +98,8 @@ buttonpress(XEvent *e)
|
||||
{
|
||||
int x;
|
||||
Arg a;
|
||||
XButtonPressedEvent *ev = &e->xbutton;
|
||||
Client *c;
|
||||
XButtonPressedEvent *ev = &e->xbutton;
|
||||
|
||||
if(barwin == ev->window) {
|
||||
switch(ev->button) {
|
||||
@ -162,25 +114,20 @@ buttonpress(XEvent *e)
|
||||
}
|
||||
break;
|
||||
case Button4:
|
||||
a.i = (tsel + 1 < TLast) ? tsel + 1 : 0;
|
||||
view(&a);
|
||||
viewnext(&a);
|
||||
break;
|
||||
case Button5:
|
||||
a.i = (tsel - 1 >= 0) ? tsel - 1 : TLast - 1;
|
||||
view(&a);
|
||||
viewprev(&a);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if((c = getclient(ev->window))) {
|
||||
focus(c);
|
||||
switch(ev->button) {
|
||||
default:
|
||||
break;
|
||||
case Button1:
|
||||
if(arrange == dotile && !c->isfloat) {
|
||||
if((ev->state & ControlMask) && (ev->button == Button1))
|
||||
zoom(NULL);
|
||||
}
|
||||
else {
|
||||
if(!c->ismax && (arrange == dofloat || c->isfloat)) {
|
||||
higher(c);
|
||||
movemouse(c);
|
||||
}
|
||||
@ -189,7 +136,7 @@ buttonpress(XEvent *e)
|
||||
lower(c);
|
||||
break;
|
||||
case Button3:
|
||||
if(arrange == dofloat || c->isfloat) {
|
||||
if(!c->ismax && (arrange == dofloat || c->isfloat)) {
|
||||
higher(c);
|
||||
resizemouse(c);
|
||||
}
|
||||
@ -201,37 +148,62 @@ buttonpress(XEvent *e)
|
||||
static void
|
||||
configurerequest(XEvent *e)
|
||||
{
|
||||
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
||||
XWindowChanges wc;
|
||||
Client *c;
|
||||
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
||||
XEvent synev;
|
||||
XWindowChanges wc;
|
||||
unsigned long newmask;
|
||||
|
||||
ev->value_mask &= ~CWSibling;
|
||||
if((c = getclient(ev->window))) {
|
||||
gravitate(c, True);
|
||||
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(c->isfloat) {
|
||||
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 = 1;
|
||||
c->border = ev->border_width;
|
||||
gravitate(c, False);
|
||||
resize(c, True, TopLeft);
|
||||
}
|
||||
|
||||
wc.x = ev->x;
|
||||
wc.y = ev->y;
|
||||
wc.width = ev->width;
|
||||
wc.height = ev->height;
|
||||
wc.border_width = 1;
|
||||
wc.sibling = None;
|
||||
wc.stack_mode = Above;
|
||||
ev->value_mask &= ~CWStackMode;
|
||||
ev->value_mask |= CWBorderWidth;
|
||||
XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
|
||||
resize(c, True, TopLeft);
|
||||
|
||||
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 {
|
||||
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;
|
||||
/* Send synthetic ConfigureNotify */
|
||||
XSendEvent(dpy, c->win, True, NoEventMask, &synev);
|
||||
}
|
||||
}
|
||||
else {
|
||||
wc.x = ev->x;
|
||||
wc.y = ev->y;
|
||||
wc.width = ev->width;
|
||||
wc.height = ev->height;
|
||||
wc.border_width = ev->border_width;
|
||||
wc.sibling = ev->above;
|
||||
wc.stack_mode = ev->detail;
|
||||
XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
|
||||
}
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
@ -248,13 +220,13 @@ destroynotify(XEvent *e)
|
||||
static void
|
||||
enternotify(XEvent *e)
|
||||
{
|
||||
XCrossingEvent *ev = &e->xcrossing;
|
||||
Client *c;
|
||||
XCrossingEvent *ev = &e->xcrossing;
|
||||
|
||||
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
|
||||
if(ev->detail == NotifyInferior)
|
||||
return;
|
||||
|
||||
if((c = getclient(ev->window)))
|
||||
if((c = getclient(ev->window)) || (c = getctitle(ev->window)))
|
||||
focus(c);
|
||||
else if(ev->window == root)
|
||||
issel = True;
|
||||
@ -263,8 +235,8 @@ enternotify(XEvent *e)
|
||||
static void
|
||||
expose(XEvent *e)
|
||||
{
|
||||
XExposeEvent *ev = &e->xexpose;
|
||||
Client *c;
|
||||
XExposeEvent *ev = &e->xexpose;
|
||||
|
||||
if(ev->count == 0) {
|
||||
if(barwin == ev->window)
|
||||
@ -277,14 +249,15 @@ expose(XEvent *e)
|
||||
static void
|
||||
keypress(XEvent *e)
|
||||
{
|
||||
XKeyEvent *ev = &e->xkey;
|
||||
static unsigned int len = key ? sizeof(key) / sizeof(key[0]) : 0;
|
||||
static unsigned int len = sizeof(key) / sizeof(key[0]);
|
||||
unsigned int i;
|
||||
KeySym keysym;
|
||||
XKeyEvent *ev = &e->xkey;
|
||||
|
||||
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
||||
for(i = 0; i < len; i++)
|
||||
if((keysym == key[i].keysym) && (key[i].mod == ev->state)) {
|
||||
if(keysym == key[i].keysym &&
|
||||
CLEANMASK(key[i].mod) == CLEANMASK(ev->state)) {
|
||||
if(key[i].func)
|
||||
key[i].func(&key[i].arg);
|
||||
return;
|
||||
@ -303,8 +276,8 @@ leavenotify(XEvent *e)
|
||||
static void
|
||||
maprequest(XEvent *e)
|
||||
{
|
||||
XMapRequestEvent *ev = &e->xmaprequest;
|
||||
static XWindowAttributes wa;
|
||||
XMapRequestEvent *ev = &e->xmaprequest;
|
||||
|
||||
if(!XGetWindowAttributes(dpy, ev->window, &wa))
|
||||
return;
|
||||
@ -322,9 +295,9 @@ maprequest(XEvent *e)
|
||||
static void
|
||||
propertynotify(XEvent *e)
|
||||
{
|
||||
XPropertyEvent *ev = &e->xproperty;
|
||||
Window trans;
|
||||
Client *c;
|
||||
Window trans;
|
||||
XPropertyEvent *ev = &e->xproperty;
|
||||
|
||||
if(ev->state == PropertyDelete)
|
||||
return; /* ignore */
|
||||
@ -380,14 +353,27 @@ void (*handler[LASTEvent]) (XEvent *) = {
|
||||
void
|
||||
grabkeys()
|
||||
{
|
||||
static unsigned int len = key ? sizeof(key) / sizeof(key[0]) : 0;
|
||||
static unsigned int len = sizeof(key) / sizeof(key[0]);
|
||||
unsigned int i;
|
||||
KeyCode code;
|
||||
|
||||
for(i = 0; i < len; i++) {
|
||||
code = XKeysymToKeycode(dpy, key[i].keysym);
|
||||
/* normal */
|
||||
XUngrabKey(dpy, code, key[i].mod, root);
|
||||
XGrabKey(dpy, code, key[i].mod, root, True,
|
||||
GrabModeAsync, GrabModeAsync);
|
||||
/* capslock */
|
||||
XUngrabKey(dpy, code, key[i].mod | LockMask, root);
|
||||
XGrabKey(dpy, code, key[i].mod | LockMask, root, True,
|
||||
GrabModeAsync, GrabModeAsync);
|
||||
/* numlock */
|
||||
XUngrabKey(dpy, code, key[i].mod | NUMLOCKMASK, root);
|
||||
XGrabKey(dpy, code, key[i].mod | NUMLOCKMASK, root, True,
|
||||
GrabModeAsync, GrabModeAsync);
|
||||
/* capslock & numlock */
|
||||
XUngrabKey(dpy, code, key[i].mod | NUMLOCKMASK | LockMask, root);
|
||||
XGrabKey(dpy, code, key[i].mod | NUMLOCKMASK | LockMask, root, True,
|
||||
GrabModeAsync, GrabModeAsync);
|
||||
}
|
||||
}
|
||||
|
92
main.c
92
main.c
@ -4,21 +4,20 @@
|
||||
*/
|
||||
|
||||
#include "dwm.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/select.h>
|
||||
#include <X11/cursorfont.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xproto.h>
|
||||
|
||||
|
||||
/* static */
|
||||
|
||||
static Bool otherwm;
|
||||
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
||||
static Bool otherwm;
|
||||
|
||||
static void
|
||||
cleanup()
|
||||
@ -34,9 +33,8 @@ static void
|
||||
scan()
|
||||
{
|
||||
unsigned int i, num;
|
||||
Window *wins;
|
||||
Window *wins, d1, d2;
|
||||
XWindowAttributes wa;
|
||||
Window d1, d2;
|
||||
|
||||
if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
|
||||
for(i = 0; i < num; i++) {
|
||||
@ -55,10 +53,9 @@ scan()
|
||||
static int
|
||||
win_property(Window w, Atom a, Atom t, long l, unsigned char **prop)
|
||||
{
|
||||
Atom real;
|
||||
int format;
|
||||
int status, format;
|
||||
unsigned long res, extra;
|
||||
int status;
|
||||
Atom real;
|
||||
|
||||
status = XGetWindowProperty(dpy, w, a, 0L, l, False, t, &real, &format,
|
||||
&res, &extra, prop);
|
||||
@ -86,7 +83,7 @@ xerrorstart(Display *dsply, XErrorEvent *ee)
|
||||
/* extern */
|
||||
|
||||
char stext[1024];
|
||||
int tsel = Tdev; /* default tag */
|
||||
int tsel = DEFTAG;
|
||||
int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
|
||||
Atom wmatom[WMLast], netatom[NetLast];
|
||||
Bool running = True;
|
||||
@ -101,10 +98,10 @@ Window root, barwin;
|
||||
int
|
||||
getproto(Window w)
|
||||
{
|
||||
unsigned char *protocols;
|
||||
long res;
|
||||
int protos = 0;
|
||||
int i;
|
||||
long res;
|
||||
unsigned char *protocols;
|
||||
|
||||
res = win_property(w, wmatom[WMProtocols], XA_ATOM, 20L, &protocols);
|
||||
if(res <= 0) {
|
||||
@ -112,7 +109,7 @@ getproto(Window w)
|
||||
}
|
||||
for(i = 0; i < res; i++) {
|
||||
if(protocols[i] == wmatom[WMDelete])
|
||||
protos |= WM_PROTOCOL_DELWIN;
|
||||
protos |= PROTODELWIN;
|
||||
}
|
||||
free((char *) protocols);
|
||||
return protos;
|
||||
@ -148,46 +145,35 @@ int
|
||||
xerror(Display *dpy, XErrorEvent *ee)
|
||||
{
|
||||
if(ee->error_code == BadWindow
|
||||
|| (ee->request_code == X_SetInputFocus
|
||||
&& ee->error_code == BadMatch)
|
||||
|| (ee->request_code == X_PolyText8
|
||||
&& ee->error_code == BadDrawable)
|
||||
|| (ee->request_code == X_PolyFillRectangle
|
||||
&& ee->error_code == BadDrawable)
|
||||
|| (ee->request_code == X_PolySegment
|
||||
&& ee->error_code == BadDrawable)
|
||||
|| (ee->request_code == X_ConfigureWindow
|
||||
&& ee->error_code == BadMatch)
|
||||
|| (ee->request_code == X_GrabKey
|
||||
&& ee->error_code == BadAccess))
|
||||
|| (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
|
||||
|| (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
|
||||
|| (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable)
|
||||
|| (ee->request_code == X_PolySegment && ee->error_code == BadDrawable)
|
||||
|| (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch)
|
||||
|| (ee->request_code == X_GrabKey && ee->error_code == BadAccess))
|
||||
return 0;
|
||||
fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
|
||||
ee->request_code, ee->error_code);
|
||||
ee->request_code, ee->error_code);
|
||||
return xerrorxlib(dpy, ee); /* may call exit() */
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int i, n;
|
||||
fd_set rd;
|
||||
XSetWindowAttributes wa;
|
||||
int i;
|
||||
unsigned int mask;
|
||||
Bool readstdin = True;
|
||||
fd_set rd;
|
||||
Bool readin = True;
|
||||
Window w;
|
||||
XEvent ev;
|
||||
XSetWindowAttributes wa;
|
||||
|
||||
for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
|
||||
switch (argv[i][1]) {
|
||||
default:
|
||||
eprint("usage: dwm [-v]\n");
|
||||
break;
|
||||
case 'v':
|
||||
fputs("dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
if(argc == 2 && !strncmp("-v", argv[1], 3)) {
|
||||
fputs("dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
else if(argc != 1)
|
||||
eprint("usage: dwm [-v]\n");
|
||||
|
||||
dpy = XOpenDisplay(0);
|
||||
if(!dpy)
|
||||
@ -254,21 +240,17 @@ main(int argc, char *argv[])
|
||||
|
||||
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
||||
|
||||
wa.event_mask = SubstructureRedirectMask | EnterWindowMask \
|
||||
| LeaveWindowMask;
|
||||
wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask;
|
||||
wa.cursor = cursor[CurNormal];
|
||||
|
||||
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
|
||||
|
||||
strcpy(stext, "dwm-"VERSION);
|
||||
|
||||
scan();
|
||||
|
||||
/* main event loop, reads status text from stdin as well */
|
||||
Mainloop:
|
||||
while(running) {
|
||||
FD_ZERO(&rd);
|
||||
if(readstdin)
|
||||
if(readin)
|
||||
FD_SET(STDIN_FILENO, &rd);
|
||||
FD_SET(ConnectionNumber(dpy), &rd);
|
||||
|
||||
@ -285,20 +267,12 @@ Mainloop:
|
||||
(handler[ev.type])(&ev); /* call handler */
|
||||
}
|
||||
}
|
||||
if(readstdin && FD_ISSET(STDIN_FILENO, &rd)) {
|
||||
i = n = 0;
|
||||
for(;;) {
|
||||
if((i = getchar()) == EOF) {
|
||||
/* broken pipe/end of producer */
|
||||
readstdin = False;
|
||||
strcpy(stext, "broken pipe");
|
||||
goto Mainloop;
|
||||
}
|
||||
if(i == '\n' || n >= sizeof(stext) - 1)
|
||||
break;
|
||||
stext[n++] = i;
|
||||
}
|
||||
stext[n] = 0;
|
||||
if(readin && FD_ISSET(STDIN_FILENO, &rd)) {
|
||||
readin = NULL != fgets(stext, sizeof(stext), stdin);
|
||||
if(readin)
|
||||
stext[strlen(stext) - 1] = 0;
|
||||
else
|
||||
strcpy(stext, "broken pipe");
|
||||
drawstatus();
|
||||
}
|
||||
}
|
||||
|
103
tag.c
103
tag.c
@ -3,7 +3,6 @@
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
|
||||
#include <regex.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -18,24 +17,13 @@ typedef struct {
|
||||
Bool isfloat;
|
||||
} Rule;
|
||||
|
||||
/* CUSTOMIZE */
|
||||
static Rule rule[] = {
|
||||
/* class instance tags isfloat */
|
||||
{ "Firefox.*", { [Twww] = "www" }, False },
|
||||
{ "Gimp.*", { 0 }, True},
|
||||
};
|
||||
TAGS
|
||||
RULES
|
||||
|
||||
void (*arrange)(Arg *) = DEFMODE;
|
||||
|
||||
/* extern */
|
||||
|
||||
/* CUSTOMIZE */
|
||||
char *tags[TLast] = {
|
||||
[Tscratch] = "scratch",
|
||||
[Tdev] = "dev",
|
||||
[Twww] = "www",
|
||||
[Twork] = "work",
|
||||
};
|
||||
void (*arrange)(Arg *) = dotile;
|
||||
|
||||
void
|
||||
appendtag(Arg *arg)
|
||||
{
|
||||
@ -51,8 +39,8 @@ dofloat(Arg *arg)
|
||||
{
|
||||
Client *c;
|
||||
|
||||
arrange = dofloat;
|
||||
for(c = clients; c; c = c->next) {
|
||||
c->ismax = False;
|
||||
if(c->tags[tsel]) {
|
||||
resize(c, True, TopLeft);
|
||||
}
|
||||
@ -60,10 +48,12 @@ dofloat(Arg *arg)
|
||||
ban(c);
|
||||
}
|
||||
if(sel && !sel->tags[tsel]) {
|
||||
if((sel = getnext(clients, tsel))) {
|
||||
if((sel = getnext(clients))) {
|
||||
higher(sel);
|
||||
focus(sel);
|
||||
}
|
||||
else
|
||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||
}
|
||||
drawall();
|
||||
}
|
||||
@ -71,11 +61,10 @@ dofloat(Arg *arg)
|
||||
void
|
||||
dotile(Arg *arg)
|
||||
{
|
||||
Client *c;
|
||||
int n, i, w, h;
|
||||
Client *c;
|
||||
|
||||
w = sw - mw;
|
||||
arrange = dotile;
|
||||
for(n = 0, c = clients; c; c = c->next)
|
||||
if(c->tags[tsel] && !c->isfloat)
|
||||
n++;
|
||||
@ -86,6 +75,7 @@ dotile(Arg *arg)
|
||||
h = sh - bh;
|
||||
|
||||
for(i = 0, c = clients; c; c = c->next) {
|
||||
c->ismax = False;
|
||||
if(c->tags[tsel]) {
|
||||
if(c->isfloat) {
|
||||
higher(c);
|
||||
@ -95,26 +85,26 @@ dotile(Arg *arg)
|
||||
if(n == 1) {
|
||||
c->x = sx;
|
||||
c->y = sy + bh;
|
||||
c->w = sw - 2 * c->border;
|
||||
c->h = sh - 2 * c->border - bh;
|
||||
c->w = sw - 2;
|
||||
c->h = sh - 2 - bh;
|
||||
}
|
||||
else if(i == 0) {
|
||||
c->x = sx;
|
||||
c->y = sy + bh;
|
||||
c->w = mw - 2 * c->border;
|
||||
c->h = sh - 2 * c->border - bh;
|
||||
c->w = mw - 2;
|
||||
c->h = sh - 2 - bh;
|
||||
}
|
||||
else if(h > bh) {
|
||||
c->x = sx + mw;
|
||||
c->y = sy + (i - 1) * h + bh;
|
||||
c->w = w - 2 * c->border;
|
||||
c->h = h - 2 * c->border;
|
||||
c->w = w - 2;
|
||||
c->h = h - 2;
|
||||
}
|
||||
else { /* fallback if h < bh */
|
||||
c->x = sx + mw;
|
||||
c->y = sy + bh;
|
||||
c->w = w - 2 * c->border;
|
||||
c->h = sh - 2 * c->border - bh;
|
||||
c->w = w - 2;
|
||||
c->h = sh - 2 - bh;
|
||||
}
|
||||
resize(c, False, TopLeft);
|
||||
i++;
|
||||
@ -123,44 +113,35 @@ dotile(Arg *arg)
|
||||
ban(c);
|
||||
}
|
||||
if(!sel || (sel && !sel->tags[tsel])) {
|
||||
if((sel = getnext(clients, tsel))) {
|
||||
if((sel = getnext(clients))) {
|
||||
higher(sel);
|
||||
focus(sel);
|
||||
}
|
||||
else
|
||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||
}
|
||||
drawall();
|
||||
}
|
||||
|
||||
Client *
|
||||
getnext(Client *c, unsigned int t)
|
||||
getnext(Client *c)
|
||||
{
|
||||
for(; c && !c->tags[t]; c = c->next);
|
||||
for(; c && !c->tags[tsel]; c = c->next);
|
||||
return c;
|
||||
}
|
||||
|
||||
void
|
||||
heretag(Arg *arg)
|
||||
Client *
|
||||
getprev(Client *c)
|
||||
{
|
||||
int i;
|
||||
Client *c;
|
||||
|
||||
if(arg->i == tsel)
|
||||
return;
|
||||
|
||||
if(!(c = getnext(clients, arg->i)))
|
||||
return;
|
||||
|
||||
for(i = 0; i < TLast; i++)
|
||||
c->tags[i] = NULL;
|
||||
c->tags[tsel] = tags[tsel];
|
||||
pop(c);
|
||||
focus(c);
|
||||
for(; c && !c->tags[tsel]; c = c->prev);
|
||||
return c;
|
||||
}
|
||||
|
||||
void
|
||||
replacetag(Arg *arg)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
|
||||
@ -173,18 +154,13 @@ void
|
||||
settags(Client *c)
|
||||
{
|
||||
char classinst[256];
|
||||
static unsigned int len = rule ? sizeof(rule) / sizeof(rule[0]) : 0;
|
||||
static unsigned int len = sizeof(rule) / sizeof(rule[0]);
|
||||
unsigned int i, j;
|
||||
regex_t regex;
|
||||
regmatch_t tmp;
|
||||
Bool matched = False;
|
||||
XClassHint ch;
|
||||
|
||||
if(!len) {
|
||||
c->tags[tsel] = tags[tsel];
|
||||
return;
|
||||
}
|
||||
|
||||
if(XGetClassHint(dpy, c->win, &ch)) {
|
||||
snprintf(classinst, sizeof(classinst), "%s:%s",
|
||||
ch.res_class ? ch.res_class : "",
|
||||
@ -211,6 +187,13 @@ settags(Client *c)
|
||||
c->tags[tsel] = tags[tsel];
|
||||
}
|
||||
|
||||
void
|
||||
togglemode(Arg *arg)
|
||||
{
|
||||
arrange = arrange == dofloat ? dotile : dofloat;
|
||||
arrange(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
view(Arg *arg)
|
||||
{
|
||||
@ -218,3 +201,17 @@ view(Arg *arg)
|
||||
arrange(NULL);
|
||||
drawall();
|
||||
}
|
||||
|
||||
void
|
||||
viewnext(Arg *arg)
|
||||
{
|
||||
arg->i = (tsel < TLast-1) ? tsel+1 : 0;
|
||||
view(arg);
|
||||
}
|
||||
|
||||
void
|
||||
viewprev(Arg *arg)
|
||||
{
|
||||
arg->i = (tsel > 0) ? tsel-1 : TLast-1;
|
||||
view(arg);
|
||||
}
|
||||
|
10
util.c
10
util.c
@ -3,7 +3,6 @@
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -15,9 +14,7 @@
|
||||
static void
|
||||
bad_malloc(unsigned int size)
|
||||
{
|
||||
fprintf(stderr, "fatal: could not malloc() %d bytes\n",
|
||||
(int) size);
|
||||
exit(EXIT_FAILURE);
|
||||
eprint("fatal: could not malloc() %u bytes\n", size);
|
||||
}
|
||||
|
||||
/* extern */
|
||||
@ -26,6 +23,7 @@ void *
|
||||
emallocz(unsigned int size)
|
||||
{
|
||||
void *res = calloc(1, size);
|
||||
|
||||
if(!res)
|
||||
bad_malloc(size);
|
||||
return res;
|
||||
@ -34,6 +32,7 @@ emallocz(unsigned int size)
|
||||
void
|
||||
eprint(const char *errstr, ...) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, errstr);
|
||||
vfprintf(stderr, errstr, ap);
|
||||
va_end(ap);
|
||||
@ -44,6 +43,7 @@ void
|
||||
spawn(Arg *arg)
|
||||
{
|
||||
char **argv = (char **)arg->argv;
|
||||
|
||||
if(!argv || !argv[0])
|
||||
return;
|
||||
if(fork() == 0) {
|
||||
@ -55,7 +55,7 @@ spawn(Arg *arg)
|
||||
fprintf(stderr, "dwm: execvp %s", argv[0]);
|
||||
perror(" failed");
|
||||
}
|
||||
exit(EXIT_FAILURE);
|
||||
exit(0);
|
||||
}
|
||||
wait(0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user