Compare commits

...

42 Commits
1.0 ... 1.2

Author SHA1 Message Date
140be1b4b3 prepared 1.2 2006-08-30 12:39:27 +02:00
79259acc12 now using Salmi's menu command 2006-08-30 11:21:56 +02:00
5a3bea2d69 removed a warning reported by Jukka 2006-08-30 11:15:58 +02:00
30d928591d simplified configurerequest 2006-08-29 19:24:28 +02:00
70a3e62257 now dwm enforces max screen size also in tiled mode on non-floating clients which are maximized 2006-08-29 18:05:02 +02:00
6828fba7a0 fixed 2006-08-29 17:33:27 +02:00
aa1bda8164 configurenotify remembers max geom now, and restores this if necessary, however it accepts to touch the max size on configurerequest, this shouldn't break fillscreen apps (tested with mplayer) 2006-08-29 17:31:55 +02:00
157ea539a2 applied patch similiar proposed by dave tweed 2006-08-29 17:11:37 +02:00
c3c94c0e0a improved selection policy 2006-08-29 15:28:29 +02:00
9d73909075 still something wrong with reorder() 2006-08-29 13:40:09 +02:00
016c54196e this algorithm seems to keep order for any scenario 2006-08-29 09:57:57 +02:00
5056bb952d fix client position in list also on tag and toggletag 2006-08-29 09:25:14 +02:00
8a6679b3b4 added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client 2006-08-29 09:23:44 +02:00
7b6d5ff298 removed crappy variables 2006-08-28 14:32:51 +02:00
846850914d changed config.arg.h - I really need the 4th tag 2006-08-28 12:27:00 +02:00
4e6c513ac2 updated html page 2006-08-28 10:21:40 +02:00
db9cda6a7d Added tag 1.1 for changeset 44a55e6e46bf6c231780b09d919977d6f01083de 2006-08-28 10:19:55 +02:00
a50b15a9e9 added a comment to spawn 2006-08-28 08:17:27 +02:00
0a25fe9188 applied sanders focus_ patches 2006-08-28 08:06:50 +02:00
2dd5212a79 applied sanders somepatches.patch 2006-08-28 08:02:29 +02:00
00e95e1f38 oh frking dear big font... 2006-08-25 18:14:55 +02:00
0a0759132c term enlightened 2006-08-25 18:05:18 +02:00
5cf362c7d0 switching to darker colorscheme with larger font 2006-08-25 18:03:56 +02:00
413be1112a patched arg.h 2006-08-25 17:42:58 +02:00
8233dc8568 new stuff 2006-08-25 17:34:03 +02:00
afa8b3bcd9 switching to dark colors again 2006-08-25 17:31:57 +02:00
c518345f40 updated man page of dwm 2006-08-25 16:21:45 +02:00
afe6ac9923 changed order of options 2006-08-25 16:15:13 +02:00
e995c1b532 trying a different configuration 2006-08-25 15:48:44 +02:00
e36929292e removed small 1px gap, somehow without it things feel better 2006-08-25 15:37:00 +02:00
03128f78df oops 2006-08-25 15:24:18 +02:00
7d4a5e654c fixed typo 2006-08-25 15:21:49 +02:00
41ba7a7984 s/TILED/TILE/g 2006-08-25 15:16:20 +02:00
aa471f2d65 removed a bunch of lines, made mode symbols configurable 2006-08-25 15:12:32 +02:00
d37dfa1bed changed symbols for float/tiled mode, added mouse-driven mode toggle to buttonpress() 2006-08-25 15:06:38 +02:00
9f35cc52fe small fix to separate client title from right-most tag 2006-08-25 14:46:01 +02:00
f1fe19bc2b restored config.arg.h 2006-08-25 13:02:07 +02:00
b55bd709ee new color stuff/new rendering stuff 2006-08-25 12:59:45 +02:00
9833610356 back to 3 colors 2006-08-25 07:54:49 +02:00
de7fc0011e fixed 2006-08-24 12:07:10 +02:00
2e0c767d74 3->4 colors 2006-08-24 12:04:56 +02:00
a5379e901c Added tag 1.0 for changeset bbc98e77ae89a7c9232a5be0835f60ea00d8036e 2006-08-24 10:28:50 +02:00
14 changed files with 249 additions and 164 deletions

View File

@ -7,3 +7,5 @@ c11f86db4550cac5d0a648a3fe4d6d3b9a4fcf7e 0.6
3fb41412e2492f66476d92ce8f007a8b48fb1d2a 0.7
cd15de32e173f8ce97bfe1c9b6607937b59056b4 0.8
fae61afa861755636c4a1070694209ace8efbb6c 0.9
bbc98e77ae89a7c9232a5be0835f60ea00d8036e 1.0
44a55e6e46bf6c231780b09d919977d6f01083de 1.1

View File

@ -11,23 +11,47 @@
/* static functions */
static void
grabbutton(Client *c, unsigned int button, unsigned int modifier)
grabbuttons(Client *c, Bool focus)
{
XGrabButton(dpy, button, modifier, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, button, modifier | LockMask, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, button, modifier | numlockmask, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, button, modifier | numlockmask | LockMask, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
if(focus) {
XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button1, MODKEY | numlockmask, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button1, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button2, MODKEY, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button2, MODKEY | LockMask, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button2, MODKEY | numlockmask, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button2, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button3, MODKEY | LockMask, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button3, MODKEY | numlockmask, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button3, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
}
else
XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
}
static void
resizetitle(Client *c)
{
int i;
c->tw = textw(c->name);
if(c->tw > c->w)
c->tw = c->w + 2;
@ -40,15 +64,6 @@ resizetitle(Client *c)
}
static void
ungrabbutton(Client *c, unsigned int button, unsigned int modifier)
{
XUngrabButton(dpy, button, modifier, c->win);
XUngrabButton(dpy, button, modifier | LockMask, c->win);
XUngrabButton(dpy, button, modifier | numlockmask, c->win);
XUngrabButton(dpy, button, modifier | numlockmask | LockMask, c->win);
}
static int
xerrordummy(Display *dsply, XErrorEvent *ee)
{
@ -77,10 +92,10 @@ focus(Client *c)
if(sel->ismax)
togglemax(NULL);
sel = c;
grabbutton(old, AnyButton, 0);
grabbuttons(old, False);
drawtitle(old);
}
ungrabbutton(c, AnyButton, 0);
grabbuttons(c, True);
drawtitle(c);
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
}
@ -215,15 +230,7 @@ manage(Window w, XWindowAttributes *wa)
DefaultVisual(dpy, screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
if(clients)
clients->prev = c;
c->next = clients;
clients = c;
grabbutton(c, Button1, MODKEY);
grabbutton(c, Button2, MODKEY);
grabbutton(c, Button3, MODKEY);
grabbuttons(c, False);
if((tc = getclient(trans))) /* inherit tags */
for(i = 0; i < ntags; i++)
c->tags[i] = tc->tags[i];
@ -233,6 +240,12 @@ manage(Window w, XWindowAttributes *wa)
c->isfloat = trans
|| (c->maxw && c->minw &&
c->maxw == c->minw && c->maxh == c->minh);
if(clients)
clients->prev = c;
c->next = clients;
clients = c;
settitle(c);
if(isvisible(c))
sel = c;
@ -325,7 +338,7 @@ void
settitle(Client *c)
{
char **list = NULL;
int i, n;
int n;
XTextProperty name;
name.nitems = 0;
@ -384,20 +397,23 @@ togglemax(Arg *arg)
void
unmanage(Client *c)
{
Client *tc;
Window trans;
XGrabServer(dpy);
XSetErrorHandler(xerrordummy);
XGetTransientForHint(dpy, c->win, &trans);
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
XDestroyWindow(dpy, c->twin);
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(clients);
detach(c);
if(sel == c) {
if(trans && (tc = getclient(trans)) && isvisible(tc))
sel = tc;
else
sel = getnext(clients);
}
free(c->tags);
free(c);

View File

@ -4,13 +4,20 @@
*/
#define TAGS \
const char *tags[] = { "work", "net", "fnord", NULL };
const char *tags[] = { "dev", "work", "net", "fnord", NULL };
#define DEFMODE dotile /* dofloat */
#define FLOATSYMBOL "><>"
#define TILESYMBOL "[]="
#define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
#define BGCOLOR "#666699"
#define FGCOLOR "#eeeeee"
#define BORDERCOLOR "#9999CC"
#define SELBGCOLOR "#333366"
#define SELFGCOLOR "#eeeeee"
#define NORMBGCOLOR "#333333"
#define NORMFGCOLOR "#dddddd"
#define STATUSBGCOLOR "#222222"
#define STATUSFGCOLOR "#9999cc"
#define MODKEY Mod1Mask
#define MASTERW 60 /* percent */
@ -18,10 +25,11 @@ const char *tags[] = { "work", "net", "fnord", NULL };
static Key key[] = { \
/* modifier key function arguments */ \
{ MODKEY|ShiftMask, XK_Return, spawn, \
{ .cmd = "exec uxterm -bg '#e0e0e0' -fg '#000000' -cr '#000000' +sb -fn '"FONT"'" } }, \
{ .cmd = "exec uxterm -bg '#111111' -fg '#eeeeee' -cr '#eeeeee' +sb -fn '"FONT"'" } }, \
{ MODKEY, XK_p, spawn, \
{ .cmd = "exec `ls -lL /usr/bin /usr/X11R6/bin /usr/local/bin 2>/dev/null | " \
"awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort -u | dmenu`" } }, \
{ .cmd = "exec \"$(IFS=:; for dir in $PATH; do " \
"for file in \"$dir\"/*; do [ -x \"$file\" ] && echo \"${file##*/}\"; done; " \
"done | sort -u | dmenu)\"" } }, \
{ MODKEY, XK_j, focusnext, { 0 } }, \
{ MODKEY, XK_k, focusprev, { 0 } }, \
{ MODKEY, XK_Return, zoom, { 0 } }, \
@ -29,17 +37,21 @@ static Key key[] = { \
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
{ MODKEY|ShiftMask, XK_4, tag, { .i = 3 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
{ MODKEY, XK_space, togglemode, { 0 } }, \
{ MODKEY, XK_1, view, { .i = 0 } }, \
{ MODKEY, XK_2, view, { .i = 1 } }, \
{ MODKEY, XK_3, view, { .i = 2 } }, \
{ MODKEY, XK_4, view, { .i = 3 } }, \
{ MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \
{ MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \
{ MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \
{ MODKEY|ControlMask, XK_4, toggleview, { .i = 3 } }, \
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
};

View File

@ -7,10 +7,17 @@
const char *tags[] = { "1", "2", "3", "4", "5", NULL };
#define DEFMODE dotile /* dofloat */
#define FLOATSYMBOL "~"
#define TILESYMBOL "#"
#define FONT "fixed"
#define BGCOLOR "#666699"
#define FGCOLOR "#eeeeee"
#define BORDERCOLOR "#9999CC"
#define SELBGCOLOR "#666699"
#define SELFGCOLOR "#eeeeee"
#define NORMBGCOLOR "#333366"
#define NORMFGCOLOR "#cccccc"
#define STATUSBGCOLOR "#dddddd"
#define STATUSFGCOLOR "#222222"
#define MODKEY Mod1Mask
#define MASTERW 60 /* percent */
@ -48,7 +55,7 @@ static Key key[] = { \
};
/* Query class:instance:title for regex matching info with following command:
* xprop | awk -F '"' '/^WM_CLASS/ { printf("%s:%s:",$4,$2) }; /^WM_NAME/{ printf("%s\n",$2) }' */
* xprop | awk -F '"' '/^WM_CLASS/ { printf("%s:%s:",$4,$2) }; /^WM_NAME/ { printf("%s\n",$2) }' */
#define RULES \
static Rule rule[] = { \
/* class:instance:title regex tags regex isfloat */ \

View File

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

73
draw.c
View File

@ -22,29 +22,16 @@ textnw(const char *text, unsigned int len)
}
static void
drawtext(const char *text, Bool invert, Bool highlight)
drawtext(const char *text, unsigned long col[ColLast], Bool highlight)
{
int x, y, w, h;
static char buf[256];
unsigned int len, olen;
XGCValues gcv;
XPoint points[5];
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg);
XSetForeground(dpy, dc.gc, col[ColBG]);
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
points[0].x = dc.x;
points[0].y = dc.y;
points[1].x = dc.w - 1;
points[1].y = 0;
points[2].x = 0;
points[2].y = dc.h - 1;
points[3].x = -(dc.w - 1);
points[3].y = 0;
points[4].x = 0;
points[4].y = -(dc.h - 1);
XSetForeground(dpy, dc.gc, dc.border);
XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
if(!text)
return;
@ -74,29 +61,21 @@ drawtext(const char *text, Bool invert, Bool highlight)
if(w > dc.w)
return; /* too long */
gcv.foreground = invert ? dc.bg : dc.fg;
gcv.background = invert ? dc.fg : dc.bg;
gcv.foreground = col[ColFG];
if(dc.font.set) {
XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv);
XChangeGC(dpy, dc.gc, GCForeground, &gcv);
XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
}
else {
gcv.font = dc.font.xfont->fid;
XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv);
XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv);
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
}
if(highlight) {
points[0].x = dc.x + 1;
points[0].y = dc.y + 1;
points[1].x = dc.w - 3;
points[1].y = 0;
points[2].x = 0;
points[2].y = dc.h - 3;
points[3].x = -(dc.w - 3);
points[3].y = 0;
points[4].x = 0;
points[4].y = -(dc.h - 3);
XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
r.x = dc.x + 2;
r.y = dc.y + 2;
r.width = r.height = 3;
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
}
}
@ -116,21 +95,21 @@ void
drawstatus()
{
int i, x;
Bool istile = arrange == dotile;
dc.x = dc.y = 0;
dc.w = bw;
drawtext(NULL, !istile, False);
dc.w = 0;
for(i = 0; i < ntags; i++) {
dc.x += dc.w;
dc.w = textw(tags[i]);
if(istile)
drawtext(tags[i], seltag[i], sel && sel->tags[i]);
if(seltag[i])
drawtext(tags[i], dc.sel, sel && sel->tags[i]);
else
drawtext(tags[i], !seltag[i], sel && sel->tags[i]);
drawtext(tags[i], dc.norm, sel && sel->tags[i]);
dc.x += dc.w;
}
dc.w = bmw;
drawtext(arrange == dotile ? TILESYMBOL : FLOATSYMBOL, dc.status, False);
x = dc.x + dc.w;
dc.w = textw(stext);
dc.x = bx + bw - dc.w;
@ -138,11 +117,14 @@ drawstatus()
dc.x = x;
dc.w = bw - x;
}
drawtext(stext, !istile, False);
drawtext(stext, dc.status, False);
if(sel && ((dc.w = dc.x - x) > bh)) {
if((dc.w = dc.x - x) > bh) {
dc.x = x;
drawtext(sel->name, istile, False);
if(sel)
drawtext(sel->name, dc.sel, False);
else
drawtext(NULL, dc.norm, False);
}
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
XSync(dpy, False);
@ -151,21 +133,18 @@ drawstatus()
void
drawtitle(Client *c)
{
int i;
Bool istile = arrange == dotile;
if(c == sel && issel) {
drawstatus();
XUnmapWindow(dpy, c->twin);
XSetWindowBorder(dpy, c->win, dc.fg);
XSetWindowBorder(dpy, c->win, dc.sel[ColBG]);
return;
}
XSetWindowBorder(dpy, c->win, dc.bg);
XSetWindowBorder(dpy, c->win, dc.norm[ColBG]);
XMapWindow(dpy, c->twin);
dc.x = dc.y = 0;
dc.w = c->tw;
drawtext(c->name, !istile, False);
drawtext(c->name, dc.norm, False);
XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);
XSync(dpy, False);
}

13
dwm.1
View File

@ -21,9 +21,9 @@ tags. Selecting a certain tag for viewing will display all windows with that
tag.
.P
.B dwm
contains a small status bar which displays all available tags, the title
of the focused window, and the text read from standard input. The tags of the
focused window are highlighted.
contains a small status bar which displays all available tags, the mode, the
title of the focused window, and the text read from standard input. The tags of
the focused window are highlighted with a small point.
.P
.B dwm
draws a 1-pixel border around windows to indicate the focus state.
@ -40,7 +40,12 @@ is read and displayed in the status text area.
.TP
.B Button1
click on a tag label views all windows with that
.BR tag .
.BR tag ,
click on the mode label toggles between
.B tiled
and
.B floating
mode.
.TP
.B Button3
click on a tag label adds/removes all windows with that

14
dwm.h
View File

@ -23,6 +23,9 @@ enum { WMProtocols, WMDelete, WMLast };
/* cursor */
enum { CurNormal, CurResize, CurMove, CurLast };
/* color */
enum { ColFG, ColBG, ColLast };
/* window corners */
typedef enum { TopLeft, TopRight, BotLeft, BotRight } Corner;
@ -36,9 +39,9 @@ typedef struct {
typedef struct { /* draw context */
int x, y, w, h;
unsigned long bg;
unsigned long fg;
unsigned long border;
unsigned long norm[ColLast];
unsigned long sel[ColLast];
unsigned long status[ColLast];
Drawable drawable;
Fnt font;
GC gc;
@ -53,7 +56,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int grav;
long flags;
unsigned int border;
unsigned int border, weight;
Bool isfloat;
Bool ismax;
Bool *tags;
@ -65,7 +68,7 @@ struct Client {
extern const char *tags[];
extern char stext[1024];
extern int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
extern int bx, by, bw, bh, bmw, mw, screen, sx, sy, sw, sh;
extern unsigned int ntags, numlockmask;
extern void (*handler[LASTEvent])(XEvent *);
extern void (*arrange)(Arg *);
@ -124,6 +127,7 @@ extern void *erealloc(void *ptr, unsigned int size);
extern void spawn(Arg *arg);
/* view.c */
extern void detach(Client *c);
extern void dofloat(Arg *arg);
extern void dotile(Arg *arg);
extern void focusnext(Arg *arg);

View File

@ -104,8 +104,8 @@
</ul>
<h3>Download</h3>
<ul>
<li><a href="http://10kloc.org/download/dwm-1.0.tar.gz">dwm 1.0</a> (15kb) (20060824)</li>
<li><a href="http://10kloc.org/download/dmenu-0.5.tar.gz">dmenu 0.5</a> (7kb) (20060824)</li>
<li><a href="http://10kloc.org/download/dwm-1.2.tar.gz">dwm 1.2</a> (15kb) (20060830)</li>
<li><a href="http://10kloc.org/download/dmenu-0.6.tar.gz">dmenu 0.6</a> (7kb) (20060828)</li>
</ul>
<h3>Development</h3>
<p>

46
event.c
View File

@ -116,10 +116,14 @@ buttonpress(XEvent *e)
return;
}
}
if(ev->x < x + bmw) {
if(ev->button == Button1)
togglemode(NULL);
}
}
else if((c = getclient(ev->window))) {
focus(c);
if(CLEANMASK(ev->state) == 0)
if(CLEANMASK(ev->state) != MODKEY)
return;
switch(ev->button) {
default:
@ -143,16 +147,38 @@ buttonpress(XEvent *e)
}
}
static void
synconfig(Client *c, int x, int y, int w, int h, unsigned int border)
{
XEvent synev;
synev.type = ConfigureNotify;
synev.xconfigure.display = dpy;
synev.xconfigure.event = c->win;
synev.xconfigure.window = c->win;
synev.xconfigure.x = x;
synev.xconfigure.y = y;
synev.xconfigure.width = w;
synev.xconfigure.height = h;
synev.xconfigure.border_width = border;
synev.xconfigure.above = None;
XSendEvent(dpy, c->win, True, NoEventMask, &synev);
}
static void
configurerequest(XEvent *e)
{
unsigned long newmask;
Client *c;
XConfigureRequestEvent *ev = &e->xconfigurerequest;
XEvent synev;
XWindowChanges wc;
if((c = getclient(ev->window))) {
if(!c->isfloat && (arrange != dofloat) && c->ismax) {
synconfig(c, sx, sy + bh, sw - 2, sh - 2 - bh, ev->border_width);
XSync(dpy, False);
return;
}
gravitate(c, True);
if(ev->value_mask & CWX)
c->x = ev->x;
@ -172,20 +198,8 @@ configurerequest(XEvent *e)
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
synconfig(c, c->x, c->y, c->w, c->h, c->border);
XSync(dpy, False);
if(c->isfloat)
resize(c, False, TopLeft);

14
main.c
View File

@ -19,7 +19,7 @@
char stext[1024];
Bool *seltag;
int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
int bx, by, bw, bh, bmw, mw, screen, sx, sy, sw, sh;
unsigned int ntags, numlockmask;
Atom wmatom[WMLast], netatom[NetLast];
Bool running = True;
@ -121,11 +121,15 @@ setup()
seltag[0] = True;
/* style */
dc.bg = getcolor(BGCOLOR);
dc.fg = getcolor(FGCOLOR);
dc.border = getcolor(BORDERCOLOR);
dc.norm[ColBG] = getcolor(NORMBGCOLOR);
dc.norm[ColFG] = getcolor(NORMFGCOLOR);
dc.sel[ColBG] = getcolor(SELBGCOLOR);
dc.sel[ColFG] = getcolor(SELFGCOLOR);
dc.status[ColBG] = getcolor(STATUSBGCOLOR);
dc.status[ColFG] = getcolor(STATUSFGCOLOR);
setfont(FONT);
bmw = textw(FLOATSYMBOL) > textw(TILESYMBOL) ? textw(FLOATSYMBOL) : textw(TILESYMBOL);
sx = sy = 0;
sw = DisplayWidth(dpy, screen);
sh = DisplayHeight(dpy, screen);
@ -133,7 +137,7 @@ setup()
bx = by = 0;
bw = sw;
dc.h = bh = dc.font.height + 4;
dc.h = bh = dc.font.height + 2;
wa.override_redirect = 1;
wa.background_pixmap = ParentRelative;
wa.event_mask = ButtonPressMask | ExposureMask;

25
tag.c
View File

@ -30,6 +30,17 @@ RULES
static RReg *rreg = NULL;
static unsigned int len = 0;
static void
commit()
{
/* asserts sel != NULL */
settitle(sel);
if(!isvisible(sel))
arrange(NULL);
else
drawstatus();
}
/* extern */
Client *
@ -106,6 +117,8 @@ settags(Client *c)
if(!matched)
for(i = 0; i < ntags; i++)
c->tags[i] = seltag[i];
for(i = 0; i < ntags && !c->tags[i]; i++);
c->weight = i;
}
void
@ -119,11 +132,7 @@ tag(Arg *arg)
for(i = 0; i < ntags; i++)
sel->tags[i] = False;
sel->tags[arg->i] = True;
settitle(sel);
if(!isvisible(sel))
arrange(NULL);
else
drawstatus();
commit();
}
void
@ -138,9 +147,5 @@ toggletag(Arg *arg)
for(i = 0; i < ntags && !sel->tags[i]; i++);
if(i == ntags)
sel->tags[arg->i] = True;
settitle(sel);
if(!isvisible(sel))
arrange(NULL);
else
drawstatus();
commit();
}

1
util.c
View File

@ -51,6 +51,7 @@ spawn(Arg *arg)
if(!arg->cmd)
return;
/* the double-fork construct avoids zombie processes */
if(fork() == 0) {
if(fork() == 0) {
if(dpy)

82
view.c
View File

@ -3,11 +3,57 @@
* See LICENSE file for license details.
*/
#include "dwm.h"
#include <stdio.h>
/* static */
static Client *
minclient()
{
Client *c, *min;
for(min = c = clients; c; c = c->next)
if(c->weight < min->weight)
min = c;
return min;
}
static void
reorder()
{
Client *c, *newclients, *tail;
newclients = tail = NULL;
while((c = minclient())) {
detach(c);
if(tail) {
c->prev = tail;
tail->next = c;
tail = c;
}
else
tail = newclients = c;
}
clients = newclients;
}
/* extern */
void (*arrange)(Arg *) = DEFMODE;
void
detach(Client *c)
{
if(c->prev)
c->prev->next = c->next;
if(c->next)
c->next->prev = c->prev;
if(c == clients)
clients = c->next;
c->next = c->prev = NULL;
}
void
dofloat(Arg *arg)
{
@ -21,9 +67,7 @@ dofloat(Arg *arg)
else
ban(c);
}
if(!sel || !isvisible(sel))
sel = getnext(clients);
if(sel)
if((sel = getnext(clients)))
focus(sel);
else
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
@ -86,9 +130,7 @@ dotile(Arg *arg)
else
ban(c);
}
if(!sel || !isvisible(sel))
sel = getnext(clients);
if(sel)
if((sel = getnext(clients)))
focus(sel);
else
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
@ -211,6 +253,7 @@ toggleview(Arg *arg)
for(i = 0; i < ntags && !seltag[i]; i++);
if(i == ntags)
seltag[arg->i] = True; /* cannot toggle last view */
reorder();
arrange(NULL);
}
@ -222,32 +265,25 @@ view(Arg *arg)
for(i = 0; i < ntags; i++)
seltag[i] = False;
seltag[arg->i] = True;
reorder();
arrange(NULL);
}
void
zoom(Arg *arg)
{
Client *c;
Client *c = sel;
if(!sel || (arrange != dotile) || sel->isfloat || sel->ismax)
if(!c || (arrange != dotile) || c->isfloat || c->ismax)
return;
if(sel == getnext(clients)) {
if((c = getnext(sel->next)))
sel = c;
else
if(c == getnext(clients))
if(!(c = getnext(c->next)))
return;
}
/* pop */
sel->prev->next = sel->next;
if(sel->next)
sel->next->prev = sel->prev;
sel->prev = NULL;
clients->prev = sel;
sel->next = clients;
clients = sel;
focus(sel);
detach(c);
c->next = clients;
clients->prev = c;
clients = c;
focus(c);
arrange(NULL);
}