Compare commits
253 Commits
Author | SHA1 | Date | |
---|---|---|---|
55be4d6137 | |||
1f18466409 | |||
b65a1e3379 | |||
87836d79ef | |||
c8a12a0852 | |||
71b84c2114 | |||
edb2660a2e | |||
17ec726b49 | |||
373b11de11 | |||
04a2b74529 | |||
fcd98308ba | |||
b233089815 | |||
201c56f6d3 | |||
1e051d71f5 | |||
ddc79603f9 | |||
dee5ea2335 | |||
b1c9f5f144 | |||
a542bdf658 | |||
96e1b25c8c | |||
caf5a16271 | |||
936e11fd54 | |||
9715ba82aa | |||
3c35b90dd3 | |||
1d63030665 | |||
6a5b41203e | |||
fbd310972d | |||
3059c9c507 | |||
3b18f17d4d | |||
72faa1919e | |||
f8181f64e2 | |||
0045ad87df | |||
ceea528eff | |||
6c5dc7017c | |||
ae0b4fdd92 | |||
b3cea4d388 | |||
d296081321 | |||
177ed7e5de | |||
f679125206 | |||
58beead14d | |||
e1811c37ca | |||
a24a6701c8 | |||
d108cfa7fc | |||
92cb5ebb7c | |||
653826572d | |||
5a5851bac2 | |||
1d4a24dae0 | |||
a768ea93fd | |||
c95fe6e24b | |||
c75168186b | |||
3a96c9a8d5 | |||
1617b95598 | |||
726ae5bf6d | |||
3e11b38349 | |||
16ed879524 | |||
20d7b5d058 | |||
11a08b9cfc | |||
c2b753d917 | |||
6c767072a3 | |||
e9cfae7aba | |||
7ac0de8350 | |||
0b7c0f10ee | |||
51f6405b0d | |||
6096f8a113 | |||
d939f301fa | |||
8c4623da80 | |||
0faaba04a5 | |||
ec7a5ffff1 | |||
98afb7b9d0 | |||
06bae9dfb7 | |||
0b80d1842d | |||
d7ec23a5db | |||
2cf8ef9520 | |||
184471b4bb | |||
21898c6049 | |||
6a9300e815 | |||
ac24f132db | |||
cb4aa5bc35 | |||
beac539f31 | |||
b5d297f02f | |||
9056d7ea88 | |||
ebd17e4827 | |||
7e59c89250 | |||
9e4e4d9022 | |||
71fd06f843 | |||
58e6866d86 | |||
c7da124149 | |||
21bd90d7d3 | |||
c8f96b5b4c | |||
ded60365d4 | |||
629647dfee | |||
4ca3d861f0 | |||
069e7a6e24 | |||
ac6e34ea06 | |||
a308b7507a | |||
630e7ff26f | |||
3764ab471b | |||
a3319c6f8e | |||
66c699a701 | |||
aaf1e44da9 | |||
1ef2307ec4 | |||
d42c3ba2dc | |||
4b06155873 | |||
857d825eeb | |||
6b345353e3 | |||
ab3b3a8f61 | |||
71b82fb1f6 | |||
9bd9ea423e | |||
99964398e7 | |||
7009ebfa69 | |||
760e23dd3a | |||
c53d9d516a | |||
7739e6b466 | |||
4881857458 | |||
c73d5cb7b6 | |||
6458803d21 | |||
6e72d781f7 | |||
4e926a9ef2 | |||
4ba3cfaee9 | |||
e655e8a7d5 | |||
c34e4e4b39 | |||
a678ee6365 | |||
49f0ee329d | |||
0c9d9a3d94 | |||
89e1acb0bb | |||
c2ed26b711 | |||
42fd392e05 | |||
e06447ee88 | |||
683dabe5e6 | |||
3aff96177c | |||
0a915eba8f | |||
19dcbc5717 | |||
d2a4952956 | |||
0c97b21b61 | |||
19390b1a91 | |||
8dc86051df | |||
46d5f9d1bf | |||
35e96b8deb | |||
2210ea7e3b | |||
61a1910f91 | |||
27ef73507b | |||
2b35fb643e | |||
478f6f95f1 | |||
44411d2d48 | |||
a2175cf71a | |||
4606d218c3 | |||
d37d0f24e6 | |||
321e8d51ed | |||
78f4b51757 | |||
7d168a2621 | |||
931e712eac | |||
4ec04209e0 | |||
82ddba88a2 | |||
52a8cc8d46 | |||
d175df8aa3 | |||
b003a35fde | |||
df1a0f9445 | |||
5b07b85838 | |||
f320cd203b | |||
f78c16f8c6 | |||
0c5f47e720 | |||
4b5b3d90af | |||
2cce4b95cd | |||
8e6eb52196 | |||
04b633ddf3 | |||
b76561a212 | |||
51c7589c87 | |||
99785382ae | |||
dc1690ce0f | |||
b6614261ea | |||
91e569ca37 | |||
0f395c1b11 | |||
2b13e7466f | |||
0982e47408 | |||
b93ebcf42f | |||
a08d83ba62 | |||
2b7c275ce8 | |||
040d0f48a0 | |||
724f35a664 | |||
6f3872edbd | |||
87324e680c | |||
c2b908f603 | |||
d7734f996f | |||
8b68890650 | |||
b60406cb9b | |||
ce9a9934ec | |||
720b2abe17 | |||
5983c00b95 | |||
6651dd7fd9 | |||
acdea31916 | |||
10885d349a | |||
1c1d09f3e9 | |||
0384faeee5 | |||
6cca3999c8 | |||
69408d384d | |||
4aea423f06 | |||
6fc8a63041 | |||
2583a7c0d1 | |||
0ef6e3103c | |||
7c052b37c8 | |||
d9c475d7f4 | |||
c8e57332d1 | |||
c045459917 | |||
e0f64e63db | |||
dddd58a8cd | |||
010fd21b20 | |||
1802fad2f9 | |||
f833d109d1 | |||
7225c99903 | |||
36178933ed | |||
ad0da9a571 | |||
6646468125 | |||
fee8df6ccf | |||
8fa47ac679 | |||
b427a2c6cb | |||
14d05e7c72 | |||
a118a57fe3 | |||
02cea3b47e | |||
1c2d673ded | |||
c34df2c1b6 | |||
6092aa977e | |||
c9cc2b385a | |||
b39d0c521a | |||
e87bed6df2 | |||
4ee05b3294 | |||
e81eb46a78 | |||
f315832f75 | |||
97ced11e53 | |||
4d6c4d36ce | |||
b4d53bf194 | |||
67bc08d1b9 | |||
bcb07de750 | |||
7d7cde0fd6 | |||
6b25d06d7d | |||
cff951c650 | |||
114cc3ec02 | |||
3c4b7672a8 | |||
6de149eb22 | |||
da909dd1e8 | |||
67986e81ee | |||
346bdea946 | |||
05c10c5776 | |||
b2cb925d99 | |||
9fb6502b3b | |||
9eb226ff78 | |||
e34c4eaf61 | |||
9e75bcfc75 | |||
d800ec05ff | |||
bda53ac6ad | |||
4230932563 | |||
f17e898bd1 | |||
886b2088f1 | |||
551d6bb23d | |||
d504005e91 |
19
.hgtags
19
.hgtags
@ -13,3 +13,22 @@ e3179ce2b90451d2807cd53b589d768412b8666b 1.2
|
||||
f5f5cbf016a94b48a8fe9c47f0736e96d166d5d4 1.3
|
||||
3cff9403766bf83a9fc2a0aef230115d68de2a8e 1.4
|
||||
728c9089b079721b43c3347124639a29baa22a97 1.5
|
||||
ad3fa2d185426c51fd5deceae809770363f8d33c 1.6
|
||||
4dbdb61c8b8ce21dee5c7050a6b103855964ed20 1.7
|
||||
d5ad819f2a66a40fa75dd2e44429f3bfc884d07b 1.7.1
|
||||
c71952fa3c7ca848ec38a6923b5c6d0e18fff431 1.8
|
||||
a5567a0d30112822db2627a04a2e7aa3b6c38148 1.9
|
||||
12deea36603da407e3f32640048846a3bd74a9ec 2.0
|
||||
a2c465098a3b972bbed00feda9804b6aae1e9531 2.1
|
||||
7e92f58754ae6edb3225f26d754bd89c1ff458cf 2.2
|
||||
719b37b37b0df829d7cf017ac70e353088fe5849 2.3
|
||||
32b246925086910d63147483160281a91a47479f 2.4
|
||||
dcbbfabc8ecc5f33a6cc950584de87da1a368045 2.5
|
||||
c7f84f23ec5aef29988dcdc4ec22a7352ee8f58e 2.5.1
|
||||
5308dd22b6ee8e3218c81d9e7e4125f235bb5778 2.6
|
||||
21951c0dfbae5af68ed77821a4d87253ee91803f 2.7
|
||||
107719a9ce3bd0c79f9f1f626596eb338a276561 2.8
|
||||
3a5910fac3ccb522a98aeeba7af7008530b25092 2.9
|
||||
76b58d21ea98257c05565a3b9c850b9b26a32968 3.0
|
||||
e1c8bef05e6e48df4f26471ea0712aa43ab9d949 3.1
|
||||
4ce65f61f01b055fa6c2901c6d2527ef741aa4bf 3.2
|
||||
|
4
LICENSE
4
LICENSE
@ -1,7 +1,7 @@
|
||||
MIT/X Consortium License
|
||||
|
||||
(C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
(C)opyright MMVI Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
(C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
(C)opyright MMVI-MMVII Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
|
2
Makefile
2
Makefile
@ -1,5 +1,5 @@
|
||||
# dwm - dynamic window manager
|
||||
# (C)opyright MMVI Anselm R. Garbe
|
||||
# (C)opyright MMVII Anselm R. Garbe
|
||||
|
||||
include config.mk
|
||||
|
||||
|
4
README
4
README
@ -1,5 +1,5 @@
|
||||
dwm - dynamic window manager
|
||||
----------------------------
|
||||
============================
|
||||
dwm is an extremely fast, small, and dynamic window manager for X.
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ like this in your .xinitrc:
|
||||
|
||||
while true
|
||||
do
|
||||
echo `date` `uptime | sed 's/.*://; s/,//g'`
|
||||
echo `date` `uptime | sed 's/.*,//'`
|
||||
sleep 1
|
||||
done | dwm
|
||||
|
||||
|
271
client.c
271
client.c
@ -1,5 +1,4 @@
|
||||
/*
|
||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
@ -54,19 +53,6 @@ grabbuttons(Client *c, Bool focused) {
|
||||
GrabModeAsync, GrabModeSync, None, None);
|
||||
}
|
||||
|
||||
static void
|
||||
resizetitle(Client *c) {
|
||||
c->tw = textw(c->name);
|
||||
if(c->tw > c->w)
|
||||
c->tw = c->w + 2;
|
||||
c->tx = c->x + c->w - c->tw + 2;
|
||||
c->ty = c->y;
|
||||
if(isvisible(c))
|
||||
XMoveResizeWindow(dpy, c->twin, c->tx, c->ty, c->tw, c->th);
|
||||
else
|
||||
XMoveResizeWindow(dpy, c->twin, c->tx + 2 * sw, c->ty, c->tw, c->th);
|
||||
}
|
||||
|
||||
static int
|
||||
xerrordummy(Display *dsply, XErrorEvent *ee) {
|
||||
return 0;
|
||||
@ -75,35 +61,42 @@ xerrordummy(Display *dsply, XErrorEvent *ee) {
|
||||
/* extern functions */
|
||||
|
||||
void
|
||||
ban(Client *c) {
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
XMoveWindow(dpy, c->twin, c->tx + 2 * sw, c->ty);
|
||||
configure(Client *c) {
|
||||
XEvent synev;
|
||||
|
||||
synev.type = ConfigureNotify;
|
||||
synev.xconfigure.display = dpy;
|
||||
synev.xconfigure.event = c->win;
|
||||
synev.xconfigure.window = c->win;
|
||||
synev.xconfigure.x = c->x;
|
||||
synev.xconfigure.y = c->y;
|
||||
synev.xconfigure.width = c->w;
|
||||
synev.xconfigure.height = c->h;
|
||||
synev.xconfigure.border_width = c->border;
|
||||
synev.xconfigure.above = None;
|
||||
XSendEvent(dpy, c->win, True, NoEventMask, &synev);
|
||||
}
|
||||
|
||||
void
|
||||
focus(Client *c) {
|
||||
Client *old;
|
||||
|
||||
if(!issel || (c && !isvisible(c)))
|
||||
if(c && !isvisible(c))
|
||||
return;
|
||||
if(!sel)
|
||||
sel = c;
|
||||
else if(sel != c) {
|
||||
if(maximized)
|
||||
togglemax(NULL);
|
||||
old = sel;
|
||||
sel = c;
|
||||
if(old) {
|
||||
grabbuttons(old, False);
|
||||
drawtitle(old);
|
||||
}
|
||||
if(sel && sel != c) {
|
||||
grabbuttons(sel, False);
|
||||
XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
|
||||
}
|
||||
if(c) {
|
||||
detachstack(c);
|
||||
c->snext = stack;
|
||||
stack = c;
|
||||
grabbuttons(c, True);
|
||||
drawtitle(c);
|
||||
}
|
||||
sel = c;
|
||||
drawstatus();
|
||||
if(!selscreen)
|
||||
return;
|
||||
if(c) {
|
||||
XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
|
||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||
}
|
||||
else
|
||||
@ -120,70 +113,6 @@ getclient(Window w) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Client *
|
||||
getctitle(Window w) {
|
||||
Client *c;
|
||||
|
||||
for(c = clients; c; c = c->next)
|
||||
if(c->twin == w)
|
||||
return c;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gravitate(Client *c, Bool invert) {
|
||||
int dx = 0, dy = 0;
|
||||
|
||||
switch(c->grav) {
|
||||
default:
|
||||
break;
|
||||
case StaticGravity:
|
||||
case NorthWestGravity:
|
||||
case NorthGravity:
|
||||
case NorthEastGravity:
|
||||
dy = c->border;
|
||||
break;
|
||||
case EastGravity:
|
||||
case CenterGravity:
|
||||
case WestGravity:
|
||||
dy = -(c->h / 2) + c->border;
|
||||
break;
|
||||
case SouthEastGravity:
|
||||
case SouthGravity:
|
||||
case SouthWestGravity:
|
||||
dy = -(c->h);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (c->grav) {
|
||||
default:
|
||||
break;
|
||||
case StaticGravity:
|
||||
case NorthWestGravity:
|
||||
case WestGravity:
|
||||
case SouthWestGravity:
|
||||
dx = c->border;
|
||||
break;
|
||||
case NorthGravity:
|
||||
case CenterGravity:
|
||||
case SouthGravity:
|
||||
dx = -(c->w / 2) + c->border;
|
||||
break;
|
||||
case NorthEastGravity:
|
||||
case EastGravity:
|
||||
case SouthEastGravity:
|
||||
dx = -(c->w + c->border);
|
||||
break;
|
||||
}
|
||||
|
||||
if(invert) {
|
||||
dx = -dx;
|
||||
dy = -dy;
|
||||
}
|
||||
c->x += dx;
|
||||
c->y += dy;
|
||||
}
|
||||
|
||||
void
|
||||
killclient(Arg *arg) {
|
||||
if(!sel)
|
||||
@ -198,68 +127,55 @@ void
|
||||
manage(Window w, XWindowAttributes *wa) {
|
||||
Client *c;
|
||||
Window trans;
|
||||
XSetWindowAttributes twa;
|
||||
|
||||
c = emallocz(sizeof(Client));
|
||||
c->tags = emallocz(ntags * sizeof(Bool));
|
||||
c->win = w;
|
||||
c->x = c->tx = wa->x;
|
||||
c->y = c->ty = wa->y;
|
||||
c->w = c->tw = wa->width;
|
||||
c->x = wa->x;
|
||||
c->y = wa->y;
|
||||
c->w = wa->width;
|
||||
c->h = wa->height;
|
||||
c->th = bh;
|
||||
|
||||
if(c->w == sw && c->h == sh) {
|
||||
c->border = 0;
|
||||
updatesize(c);
|
||||
|
||||
if(c->x + c->w + 2 > sw)
|
||||
c->x = sw - c->w - 2;
|
||||
if(c->x < 0)
|
||||
c->x = 0;
|
||||
if(c->y + c->h + 2 > sh)
|
||||
c->y = sh - c->h - 2;
|
||||
if(c->h != sh && c->y < bh)
|
||||
c->y = bh;
|
||||
|
||||
c->x = sx;
|
||||
c->y = sy;
|
||||
}
|
||||
else {
|
||||
c->border = BORDERPX;
|
||||
if(c->x + c->w + 2 * c->border > wax + waw)
|
||||
c->x = wax + waw - c->w - 2 * c->border;
|
||||
if(c->y + c->h + 2 * c->border > way + wah)
|
||||
c->y = way + wah - c->h - 2 * c->border;
|
||||
if(c->x < wax)
|
||||
c->x = wax;
|
||||
if(c->y < way)
|
||||
c->y = way;
|
||||
}
|
||||
updatesizehints(c);
|
||||
c->proto = getproto(c->win);
|
||||
XSelectInput(dpy, c->win,
|
||||
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
||||
XGetTransientForHint(dpy, c->win, &trans);
|
||||
twa.override_redirect = 1;
|
||||
twa.background_pixmap = ParentRelative;
|
||||
twa.event_mask = ExposureMask | EnterWindowMask;
|
||||
|
||||
c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
|
||||
0, DefaultDepth(dpy, screen), CopyFromParent,
|
||||
DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
||||
|
||||
grabbuttons(c, False);
|
||||
XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
|
||||
updatetitle(c);
|
||||
settags(c, getclient(trans));
|
||||
if(!c->isfloat)
|
||||
c->isfloat = trans
|
||||
|| (c->maxw && c->minw &&
|
||||
c->maxw == c->minw && c->maxh == c->minh);
|
||||
|
||||
c->isfloat = trans || c->isfixed;
|
||||
if(clients)
|
||||
clients->prev = c;
|
||||
c->next = clients;
|
||||
c->snext = stack;
|
||||
stack = clients = c;
|
||||
|
||||
updatetitle(c);
|
||||
ban(c);
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
XMapWindow(dpy, c->win);
|
||||
XMapWindow(dpy, c->twin);
|
||||
if(isvisible(c))
|
||||
focus(c);
|
||||
arrange(NULL);
|
||||
arrange();
|
||||
}
|
||||
|
||||
void
|
||||
resize(Client *c, Bool sizehints, Corner sticky) {
|
||||
int bottom = c->y + c->h;
|
||||
int right = c->x + c->w;
|
||||
resize(Client *c, Bool sizehints) {
|
||||
XWindowChanges wc;
|
||||
|
||||
if(sizehints) {
|
||||
@ -276,36 +192,31 @@ resize(Client *c, Bool sizehints, Corner sticky) {
|
||||
if(c->maxh && c->h > c->maxh)
|
||||
c->h = c->maxh;
|
||||
}
|
||||
if(sticky == TopRight || sticky == BotRight)
|
||||
c->x = right - c->w;
|
||||
if(sticky == BotLeft || sticky == BotRight)
|
||||
c->y = bottom - c->h;
|
||||
|
||||
if(c->w == sw && c->h == sh)
|
||||
c->border = 0;
|
||||
else
|
||||
c->border = BORDERPX;
|
||||
/* offscreen appearance fixes */
|
||||
if(c->x + c->w < 0)
|
||||
c->x = 0;
|
||||
if(c->y + c->h < bh)
|
||||
c->y = bh;
|
||||
if(c->x > sw)
|
||||
c->x = sw - c->w;
|
||||
c->x = sw - c->w - 2 * c->border;
|
||||
if(c->y > sh)
|
||||
c->y = sh - c->h;
|
||||
|
||||
resizetitle(c);
|
||||
c->y = sh - c->h - 2 * c->border;
|
||||
if(c->x + c->w + 2 * c->border < sx)
|
||||
c->x = sx;
|
||||
if(c->y + c->h + 2 * c->border < sy)
|
||||
c->y = sy;
|
||||
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;
|
||||
wc.border_width = c->border;
|
||||
XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
|
||||
configure(c);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
void
|
||||
updatesize(Client *c) {
|
||||
updatesizehints(Client *c) {
|
||||
long msize;
|
||||
XSizeHints size;
|
||||
|
||||
@ -336,10 +247,8 @@ updatesize(Client *c) {
|
||||
}
|
||||
else
|
||||
c->minw = c->minh = 0;
|
||||
if(c->flags & PWinGravity)
|
||||
c->grav = size.win_gravity;
|
||||
else
|
||||
c->grav = NorthWestGravity;
|
||||
c->isfixed = (c->maxw && c->minw && c->maxh && c->minh &&
|
||||
c->maxw == c->minw && c->maxh == c->minh);
|
||||
}
|
||||
|
||||
void
|
||||
@ -356,76 +265,36 @@ updatetitle(Client *c) {
|
||||
if(!name.nitems)
|
||||
return;
|
||||
if(name.encoding == XA_STRING)
|
||||
strncpy(c->name, (char *)name.value, sizeof(c->name));
|
||||
strncpy(c->name, (char *)name.value, sizeof c->name);
|
||||
else {
|
||||
if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
|
||||
&& n > 0 && *list)
|
||||
{
|
||||
strncpy(c->name, *list, sizeof(c->name));
|
||||
strncpy(c->name, *list, sizeof c->name);
|
||||
XFreeStringList(list);
|
||||
}
|
||||
}
|
||||
XFree(name.value);
|
||||
resizetitle(c);
|
||||
}
|
||||
|
||||
void
|
||||
togglemax(Arg *arg) {
|
||||
int ox, oy, ow, oh;
|
||||
Client *c;
|
||||
XEvent ev;
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
|
||||
if((maximized = !maximized)) {
|
||||
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;
|
||||
|
||||
restack();
|
||||
for(c = getnext(clients); c; c = getnext(c->next))
|
||||
if(c != sel)
|
||||
ban(c);
|
||||
resize(sel, arrange == dofloat, TopLeft);
|
||||
|
||||
sel->x = ox;
|
||||
sel->y = oy;
|
||||
sel->w = ow;
|
||||
sel->h = oh;
|
||||
}
|
||||
else
|
||||
arrange(NULL);
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
}
|
||||
|
||||
void
|
||||
unmanage(Client *c) {
|
||||
Client *nc;
|
||||
|
||||
/* The server grab construct avoids race conditions. */
|
||||
XGrabServer(dpy);
|
||||
XSetErrorHandler(xerrordummy);
|
||||
|
||||
detach(c);
|
||||
detachstack(c);
|
||||
if(sel == c) {
|
||||
for(nc = stack; nc && !isvisible(nc); nc = nc->snext);
|
||||
focus(nc);
|
||||
}
|
||||
|
||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||
XDestroyWindow(dpy, c->twin);
|
||||
|
||||
free(c->tags);
|
||||
free(c);
|
||||
|
||||
XSync(dpy, False);
|
||||
XSetErrorHandler(xerror);
|
||||
XUngrabServer(dpy);
|
||||
arrange(NULL);
|
||||
arrange();
|
||||
}
|
||||
|
67
config.arg.h
67
config.arg.h
@ -1,67 +1,92 @@
|
||||
/*
|
||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
|
||||
#define TAGS \
|
||||
const char *tags[] = { "dev", "work", "net", "fnord", NULL };
|
||||
const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
|
||||
|
||||
#define BORDERPX 1
|
||||
#define DEFMODE dotile /* dofloat */
|
||||
#define FLOATSYMBOL "><>"
|
||||
#define TILESYMBOL "[]="
|
||||
|
||||
#define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
|
||||
#define SELBGCOLOR "#333366"
|
||||
#define SELFGCOLOR "#eeeeee"
|
||||
#define NORMBGCOLOR "#333333"
|
||||
#define NORMFGCOLOR "#dddddd"
|
||||
#define STATUSBGCOLOR "#222222"
|
||||
#define STATUSFGCOLOR "#9999cc"
|
||||
#define FONT "-*-terminus-medium-r-*-*-14-*-*-*-*-*-*-*"
|
||||
#define NORMBORDERCOLOR "#333"
|
||||
#define NORMBGCOLOR "#222"
|
||||
#define NORMFGCOLOR "#ccc"
|
||||
#define SELBORDERCOLOR "#69c"
|
||||
#define SELBGCOLOR "#555"
|
||||
#define SELFGCOLOR "#fff"
|
||||
|
||||
#define MASTER 600 /* per thousand */
|
||||
#define MODKEY Mod1Mask
|
||||
#define MASTERW 60 /* percent */
|
||||
#define NMASTER 1 /* clients in master area */
|
||||
#define SNAP 40 /* pixel */
|
||||
|
||||
#define KEYS \
|
||||
static Key key[] = { \
|
||||
/* modifier key function arguments */ \
|
||||
/* modifier key function argument */ \
|
||||
{ MODKEY|ShiftMask, XK_Return, spawn, \
|
||||
{ .cmd = "exec uxterm -bg '#111111' -fg '#eeeeee' -cr '#eeeeee' +sb -fn '"FONT"'" } }, \
|
||||
{ .cmd = "exec uxterm -bg '#222' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" } }, \
|
||||
{ MODKEY, XK_p, spawn, \
|
||||
{ .cmd = "exe=\"$(IFS=:; for dir in $PATH; do " \
|
||||
"for file in \"$dir\"/*; do [ -x \"$file\" ] && echo \"${file##*/}\"; done; " \
|
||||
"done | sort -u | dmenu)\" && exec $exe" } }, \
|
||||
{ .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \
|
||||
" | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \
|
||||
"-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \
|
||||
{ MODKEY, XK_j, focusnext, { 0 } }, \
|
||||
{ MODKEY, XK_k, focusprev, { 0 } }, \
|
||||
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
||||
{ MODKEY, XK_m, togglemax, { 0 } }, \
|
||||
{ MODKEY, XK_g, resizecol, { .i = 20 } }, \
|
||||
{ MODKEY, XK_s, resizecol, { .i = -20 } }, \
|
||||
{ MODKEY, XK_g, resizemaster, { .i = 15 } }, \
|
||||
{ MODKEY, XK_s, resizemaster, { .i = -15 } }, \
|
||||
{ MODKEY, XK_i, incnmaster, { .i = 1 } }, \
|
||||
{ MODKEY, XK_d, incnmaster, { .i = -1 } }, \
|
||||
{ MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
|
||||
{ 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|ShiftMask, XK_5, tag, { .i = 4 } }, \
|
||||
{ MODKEY|ShiftMask, XK_6, tag, { .i = 5 } }, \
|
||||
{ MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \
|
||||
{ MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \
|
||||
{ MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \
|
||||
{ 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|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_6, toggletag, { .i = 5 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_7, toggletag, { .i = 6 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
||||
{ MODKEY, XK_0, viewall, { 0 } }, \
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloat, { 0 } }, \
|
||||
{ MODKEY, XK_0, view, { .i = -1 } }, \
|
||||
{ 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, XK_5, view, { .i = 4 } }, \
|
||||
{ MODKEY, XK_6, view, { .i = 5 } }, \
|
||||
{ MODKEY, XK_7, view, { .i = 6 } }, \
|
||||
{ MODKEY, XK_8, view, { .i = 7 } }, \
|
||||
{ MODKEY, XK_9, view, { .i = 8 } }, \
|
||||
{ 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|ControlMask, XK_5, toggleview, { .i = 4 } }, \
|
||||
{ MODKEY|ControlMask, XK_6, toggleview, { .i = 5 } }, \
|
||||
{ MODKEY|ControlMask, XK_7, toggleview, { .i = 6 } }, \
|
||||
{ MODKEY|ControlMask, XK_8, toggleview, { .i = 7 } }, \
|
||||
{ MODKEY|ControlMask, XK_9, toggleview, { .i = 8 } }, \
|
||||
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
|
||||
};
|
||||
|
||||
#define RULES \
|
||||
static Rule rule[] = { \
|
||||
/* class:instance:title regex tags regex isfloat */ \
|
||||
{ "Firefox.*", "net", False }, \
|
||||
{ "Firefox.*", "3", False }, \
|
||||
{ "Gimp.*", NULL, True }, \
|
||||
{ "MPlayer.*", NULL, True }, \
|
||||
{ "Acroread.*", NULL, True }, \
|
||||
|
@ -1,59 +1,80 @@
|
||||
/*
|
||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
|
||||
#define TAGS \
|
||||
const char *tags[] = { "1", "2", "3", "4", "5", NULL };
|
||||
const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL };
|
||||
|
||||
#define BORDERPX 1
|
||||
#define DEFMODE dotile /* dofloat */
|
||||
#define FLOATSYMBOL "><>"
|
||||
#define TILESYMBOL "[]="
|
||||
|
||||
#define FONT "fixed"
|
||||
#define SELBGCOLOR "#666699"
|
||||
#define SELFGCOLOR "#eeeeee"
|
||||
#define NORMBGCOLOR "#333366"
|
||||
#define NORMFGCOLOR "#cccccc"
|
||||
#define STATUSBGCOLOR "#dddddd"
|
||||
#define STATUSFGCOLOR "#222222"
|
||||
#define FONT "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*"
|
||||
#define NORMBORDERCOLOR "#dddddd"
|
||||
#define NORMBGCOLOR "#eeeeee"
|
||||
#define NORMFGCOLOR "#222222"
|
||||
#define SELBORDERCOLOR "#ff0000"
|
||||
#define SELBGCOLOR "#006699"
|
||||
#define SELFGCOLOR "#ffffff"
|
||||
|
||||
#define MASTER 600 /* per thousand */
|
||||
#define MODKEY Mod1Mask
|
||||
#define MASTERW 60 /* percent */
|
||||
#define NMASTER 1 /* clients in master area */
|
||||
#define SNAP 20 /* pixel */
|
||||
|
||||
#define KEYS \
|
||||
static Key key[] = { \
|
||||
/* modifier key function arguments */ \
|
||||
/* modifier key function argument */ \
|
||||
{ MODKEY|ShiftMask, XK_Return, spawn, { .cmd = "exec xterm" } }, \
|
||||
{ MODKEY, XK_Tab, focusnext, { 0 } }, \
|
||||
{ MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \
|
||||
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
||||
{ MODKEY, XK_m, togglemax, { 0 } }, \
|
||||
{ MODKEY, XK_g, resizecol, { .i = 20 } }, \
|
||||
{ MODKEY, XK_s, resizecol, { .i = -20 } }, \
|
||||
{ MODKEY, XK_g, resizemaster, { .i = 15 } }, \
|
||||
{ MODKEY, XK_s, resizemaster, { .i = -15 } }, \
|
||||
{ MODKEY, XK_i, incnmaster, { .i = 1 } }, \
|
||||
{ MODKEY, XK_d, incnmaster, { .i = -1 } }, \
|
||||
{ MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
|
||||
{ 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|ShiftMask, XK_5, tag, { .i = 4 } }, \
|
||||
{ MODKEY|ShiftMask, XK_6, tag, { .i = 5 } }, \
|
||||
{ MODKEY|ShiftMask, XK_7, tag, { .i = 6 } }, \
|
||||
{ MODKEY|ShiftMask, XK_8, tag, { .i = 7 } }, \
|
||||
{ MODKEY|ShiftMask, XK_9, tag, { .i = 8 } }, \
|
||||
{ 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|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_6, toggletag, { .i = 5 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_7, toggletag, { .i = 6 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \
|
||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
||||
{ MODKEY, XK_0, viewall, { 0 } }, \
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloat, { 0 } }, \
|
||||
{ MODKEY, XK_0, view, { .i = -1 } }, \
|
||||
{ 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, XK_5, view, { .i = 4 } }, \
|
||||
{ MODKEY, XK_6, view, { .i = 5 } }, \
|
||||
{ MODKEY, XK_7, view, { .i = 6 } }, \
|
||||
{ MODKEY, XK_8, view, { .i = 7 } }, \
|
||||
{ MODKEY, XK_9, view, { .i = 8 } }, \
|
||||
{ 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|ControlMask, XK_5, toggleview, { .i = 4 } }, \
|
||||
{ MODKEY|ControlMask, XK_6, toggleview, { .i = 5 } }, \
|
||||
{ MODKEY|ControlMask, XK_7, toggleview, { .i = 6 } }, \
|
||||
{ MODKEY|ControlMask, XK_8, toggleview, { .i = 7 } }, \
|
||||
{ MODKEY|ControlMask, XK_9, toggleview, { .i = 8 } }, \
|
||||
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
|
||||
};
|
||||
|
||||
@ -62,6 +83,5 @@ static Key key[] = { \
|
||||
#define RULES \
|
||||
static Rule rule[] = { \
|
||||
/* class:instance:title regex tags regex isfloat */ \
|
||||
{ "Firefox.*", "2", False }, \
|
||||
{ "Gimp.*", NULL, True }, \
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
# dwm version
|
||||
VERSION = 1.6
|
||||
VERSION = 3.2.1
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
@ -20,6 +20,11 @@ LDFLAGS = ${LIBS}
|
||||
#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
|
||||
#LDFLAGS = -g ${LIBS}
|
||||
|
||||
# Solaris
|
||||
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
|
||||
#LDFLAGS = ${LIBS}
|
||||
#CFLAGS += -xtarget=ultra
|
||||
|
||||
# compiler and linker
|
||||
CC = cc
|
||||
LD = ${CC}
|
||||
|
118
draw.c
118
draw.c
@ -1,14 +1,22 @@
|
||||
/*
|
||||
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMIV-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlocale.h>
|
||||
|
||||
/* static */
|
||||
|
||||
static Bool
|
||||
isoccupied(unsigned int t)
|
||||
{
|
||||
Client *c;
|
||||
for(c = clients; c; c = c->next)
|
||||
if(c->tags[t])
|
||||
return True;
|
||||
return False;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
textnw(const char *text, unsigned int len) {
|
||||
XRectangle r;
|
||||
@ -21,30 +29,27 @@ textnw(const char *text, unsigned int len) {
|
||||
}
|
||||
|
||||
static void
|
||||
drawtext(const char *text, unsigned long col[ColLast], Bool highlight) {
|
||||
drawtext(const char *text, unsigned long col[ColLast], Bool filledsquare, Bool emptysquare) {
|
||||
int x, y, w, h;
|
||||
static char buf[256];
|
||||
unsigned int len, olen;
|
||||
XGCValues gcv;
|
||||
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
|
||||
XPoint pt[5];
|
||||
|
||||
XSetForeground(dpy, dc.gc, col[ColBG]);
|
||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||
|
||||
if(!text)
|
||||
return;
|
||||
|
||||
w = 0;
|
||||
olen = len = strlen(text);
|
||||
if(len >= sizeof(buf))
|
||||
len = sizeof(buf) - 1;
|
||||
if(len >= sizeof buf)
|
||||
len = sizeof buf - 1;
|
||||
memcpy(buf, text, len);
|
||||
buf[len] = 0;
|
||||
|
||||
h = dc.font.ascent + dc.font.descent;
|
||||
y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
|
||||
x = dc.x + (h / 2);
|
||||
|
||||
/* shorten text if necessary */
|
||||
while(len && (w = textnw(buf, len)) > dc.w - h)
|
||||
buf[--len] = 0;
|
||||
@ -56,7 +61,6 @@ drawtext(const char *text, unsigned long col[ColLast], Bool highlight) {
|
||||
if(len > 3)
|
||||
buf[len - 3] = '.';
|
||||
}
|
||||
|
||||
if(w > dc.w)
|
||||
return; /* too long */
|
||||
gcv.foreground = col[ColFG];
|
||||
@ -69,78 +73,58 @@ drawtext(const char *text, unsigned long col[ColLast], Bool highlight) {
|
||||
XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv);
|
||||
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
|
||||
}
|
||||
if(highlight) {
|
||||
r.x = dc.x + 2;
|
||||
r.y = dc.y + 2;
|
||||
r.width = r.height = 3;
|
||||
x = (h + 2) / 4;
|
||||
if(filledsquare) {
|
||||
r.x = dc.x + 1;
|
||||
r.y = dc.y + 1;
|
||||
r.width = r.height = x + 1;
|
||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||
}
|
||||
else if(emptysquare) {
|
||||
pt[0].x = dc.x + 1;
|
||||
pt[0].y = dc.y + 1;
|
||||
pt[1].x = x;
|
||||
pt[1].y = 0;
|
||||
pt[2].x = 0;
|
||||
pt[2].y = x;
|
||||
pt[3].x = -x;
|
||||
pt[3].y = 0;
|
||||
pt[4].x = 0;
|
||||
pt[4].y = -x;
|
||||
XDrawLines(dpy, dc.drawable, dc.gc, pt, 5, CoordModePrevious);
|
||||
}
|
||||
}
|
||||
|
||||
/* extern */
|
||||
|
||||
void
|
||||
drawall() {
|
||||
Client *c;
|
||||
|
||||
for(c = clients; c; c = getnext(c->next))
|
||||
drawtitle(c);
|
||||
drawstatus();
|
||||
}
|
||||
|
||||
void
|
||||
drawstatus() {
|
||||
drawstatus(void) {
|
||||
int i, x;
|
||||
|
||||
dc.x = dc.y = 0;
|
||||
|
||||
for(i = 0; i < ntags; i++) {
|
||||
dc.w = textw(tags[i]);
|
||||
if(seltag[i])
|
||||
drawtext(tags[i], dc.sel, sel && sel->tags[i]);
|
||||
drawtext(tags[i], dc.sel, sel && sel->tags[i], isoccupied(i));
|
||||
else
|
||||
drawtext(tags[i], dc.norm, sel && sel->tags[i]);
|
||||
drawtext(tags[i], dc.norm, sel && sel->tags[i], isoccupied(i));
|
||||
dc.x += dc.w;
|
||||
}
|
||||
|
||||
dc.w = bmw;
|
||||
drawtext(arrange == dotile ? TILESYMBOL : FLOATSYMBOL, dc.status, False);
|
||||
|
||||
drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.norm, False, False);
|
||||
x = dc.x + dc.w;
|
||||
dc.w = textw(stext);
|
||||
dc.x = bx + bw - dc.w;
|
||||
dc.x = sw - dc.w;
|
||||
if(dc.x < x) {
|
||||
dc.x = x;
|
||||
dc.w = bw - x;
|
||||
dc.w = sw - x;
|
||||
}
|
||||
drawtext(stext, dc.status, False);
|
||||
|
||||
drawtext(stext, dc.norm, False, False);
|
||||
if((dc.w = dc.x - x) > bh) {
|
||||
dc.x = x;
|
||||
if(sel)
|
||||
drawtext(sel->name, dc.sel, False);
|
||||
else
|
||||
drawtext(NULL, dc.norm, False);
|
||||
drawtext(sel ? sel->name : NULL, sel ? dc.sel : dc.norm, False, False);
|
||||
}
|
||||
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
void
|
||||
drawtitle(Client *c) {
|
||||
if(c == sel && issel) {
|
||||
drawstatus();
|
||||
XUnmapWindow(dpy, c->twin);
|
||||
XSetWindowBorder(dpy, c->win, dc.sel[ColBG]);
|
||||
return;
|
||||
}
|
||||
|
||||
XSetWindowBorder(dpy, c->win, dc.norm[ColBG]);
|
||||
XMapWindow(dpy, c->twin);
|
||||
dc.x = dc.y = 0;
|
||||
dc.w = c->tw;
|
||||
drawtext(c->name, dc.norm, False);
|
||||
XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);
|
||||
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
@ -149,17 +133,17 @@ getcolor(const char *colstr) {
|
||||
Colormap cmap = DefaultColormap(dpy, screen);
|
||||
XColor color;
|
||||
|
||||
XAllocNamedColor(dpy, cmap, colstr, &color, &color);
|
||||
if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
|
||||
eprint("error, cannot allocate color '%s'\n", colstr);
|
||||
return color.pixel;
|
||||
}
|
||||
|
||||
void
|
||||
setfont(const char *fontstr) {
|
||||
char **missing, *def;
|
||||
char *def, **missing;
|
||||
int i, n;
|
||||
|
||||
missing = NULL;
|
||||
setlocale(LC_ALL, "");
|
||||
if(dc.font.set)
|
||||
XFreeFontSet(dpy, dc.font.set);
|
||||
dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
|
||||
@ -167,16 +151,11 @@ setfont(const char *fontstr) {
|
||||
while(n--)
|
||||
fprintf(stderr, "missing fontset: %s\n", missing[n]);
|
||||
XFreeStringList(missing);
|
||||
if(dc.font.set) {
|
||||
XFreeFontSet(dpy, dc.font.set);
|
||||
dc.font.set = NULL;
|
||||
}
|
||||
}
|
||||
if(dc.font.set) {
|
||||
XFontSetExtents *font_extents;
|
||||
XFontStruct **xfonts;
|
||||
char **font_names;
|
||||
|
||||
dc.font.ascent = dc.font.descent = 0;
|
||||
font_extents = XExtentsOfFontSet(dc.font.set);
|
||||
n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
|
||||
@ -192,11 +171,8 @@ setfont(const char *fontstr) {
|
||||
if(dc.font.xfont)
|
||||
XFreeFont(dpy, dc.font.xfont);
|
||||
dc.font.xfont = NULL;
|
||||
dc.font.xfont = XLoadQueryFont(dpy, fontstr);
|
||||
if (!dc.font.xfont)
|
||||
dc.font.xfont = XLoadQueryFont(dpy, "fixed");
|
||||
if (!dc.font.xfont)
|
||||
eprint("error, cannot init 'fixed' font\n");
|
||||
if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr)))
|
||||
eprint("error, cannot load font: '%s'\n", fontstr);
|
||||
dc.font.ascent = dc.font.xfont->ascent;
|
||||
dc.font.descent = dc.font.xfont->descent;
|
||||
}
|
||||
|
66
dwm.1
66
dwm.1
@ -9,22 +9,23 @@ dwm is a dynamic window manager for X. It manages windows in tiling and
|
||||
floating modes. Either mode can be applied dynamically, optimizing the
|
||||
environment for the application in use and the task performed.
|
||||
.P
|
||||
In tiling mode windows are managed in a master and stacking column. The master
|
||||
column contains the window which currently needs most attention, whereas the
|
||||
stacking column contains all other windows. In floating mode windows can be
|
||||
In tiling mode windows are managed in a master and stacking area. The master
|
||||
area contains the windows which currently need most attention, whereas the
|
||||
stacking area contains all other windows. In floating mode windows can be
|
||||
resized and moved freely. Dialog windows are always managed floating,
|
||||
regardless of the mode selected.
|
||||
regardless of the mode applied.
|
||||
.P
|
||||
Windows are grouped by tags. Each window can be tagged with one or multiple
|
||||
tags. Selecting certain tags displays all windows with that tag.
|
||||
tags. Selecting certain tags displays all windows with these tags.
|
||||
.P
|
||||
dwm 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
|
||||
selected tags are highlighted with a different color, the tags of the focused
|
||||
window are highlighted with a small point.
|
||||
selected tags are indicated with a different color. The tags of the focused
|
||||
window are indicated with a filled square in the top left corner. The tags
|
||||
which are applied to one or more windows are indicated with an empty square in
|
||||
the top left corner.
|
||||
.P
|
||||
dwm draws a 1-pixel border around windows to indicate the focus state.
|
||||
Unfocused windows contain a small bar in front of them displaying their title.
|
||||
dwm draws a small border around windows to indicate the focus state.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-v
|
||||
@ -37,11 +38,17 @@ is read and displayed in the status text area.
|
||||
.TP
|
||||
.B Button1
|
||||
click on a tag label to display all windows with that tag, click on the mode
|
||||
label toggles between tiled and floating mode.
|
||||
label toggles between tiling and floating mode.
|
||||
.TP
|
||||
.B Button3
|
||||
click on a tag label adds/removes all windows with that tag to/from the view.
|
||||
.TP
|
||||
.B Button4
|
||||
click on the mode label increases the number of windows in the master area (tiling mode only).
|
||||
.TP
|
||||
.B Button5
|
||||
click on the mode label decreases the number of windows in the master area (tiling mode only).
|
||||
.TP
|
||||
.B Mod1-Button1
|
||||
click on a tag label applies that tag to the focused window.
|
||||
.TP
|
||||
@ -60,22 +67,28 @@ Focus next window.
|
||||
Focus previous window.
|
||||
.TP
|
||||
.B Mod1-Return
|
||||
Zoom current window to the master column (tiling mode only).
|
||||
.TP
|
||||
.B Mod1-m
|
||||
Maximize current window.
|
||||
Zooms/cycles current window to/from master area (tiling mode), toggles maximization current window (floating mode).
|
||||
.TP
|
||||
.B Mod1-g
|
||||
Grow current column (tiling mode only).
|
||||
Grow master area (tiling mode only).
|
||||
.TP
|
||||
.B Mod1-s
|
||||
Shrink current column (tiling mode only).
|
||||
Shrink master area (tiling mode only).
|
||||
.TP
|
||||
.B Mod1-i
|
||||
Increase the number of windows in the master area (tiling mode only).
|
||||
.TP
|
||||
.B Mod1-d
|
||||
Decrease the number of windows in the master area (tiling mode only).
|
||||
.TP
|
||||
.B Mod1-Shift-[1..n]
|
||||
Apply
|
||||
.RB nth
|
||||
tag to current window.
|
||||
.TP
|
||||
.B Mod1-Shift-0
|
||||
Apply all tags to current window.
|
||||
.TP
|
||||
.B Mod1-Control-Shift-[1..n]
|
||||
Add/remove
|
||||
.B nth
|
||||
@ -85,7 +98,10 @@ tag to/from current window.
|
||||
Close focused window.
|
||||
.TP
|
||||
.B Mod1-space
|
||||
Toggle between tiled and floating mode (affects all windows).
|
||||
Toggle between tiling and floating mode (affects all windows).
|
||||
.TP
|
||||
.B Mod1-Shift-space
|
||||
Toggle focused window between floating and non-floating state (tiling mode only).
|
||||
.TP
|
||||
.B Mod1-[1..n]
|
||||
View all windows with
|
||||
@ -108,7 +124,7 @@ Quit dwm.
|
||||
Move current window while dragging (floating mode only).
|
||||
.TP
|
||||
.B Mod1-Button2
|
||||
Zoom current window to the master column (tiling mode only).
|
||||
Zoom current window to the master area (tiling mode only).
|
||||
.TP
|
||||
.B Mod1-Button3
|
||||
Resize current window while dragging (floating mode only).
|
||||
@ -117,9 +133,17 @@ dwm is customized by creating a custom config.h and (re)compiling the source
|
||||
code. This keeps it fast, secure and simple.
|
||||
.SH CAVEATS
|
||||
The status bar may display
|
||||
.BR "broken pipe"
|
||||
when dwm has been started by
|
||||
.BR "EOF"
|
||||
when dwm has been started by an X session manager like
|
||||
.BR xdm (1),
|
||||
because it closes standard output before executing dwm.
|
||||
because those close standard output before executing dwm.
|
||||
.P
|
||||
Java applications which use the XToolkit/XAWT backend may draw grey windows
|
||||
only. The XToolkit/XAWT backend breaks ICCCM-compliance in recent JDK 1.5 and early
|
||||
JDK 1.6 versions, because it assumes a reparenting window manager. As a workaround
|
||||
you can use JDK 1.4 (which doesn't contain the XToolkit/XAWT backend) or you
|
||||
can set the following environment variable (to use the older Motif
|
||||
backend instead):
|
||||
.BR AWT_TOOLKIT=MToolkit .
|
||||
.SH SEE ALSO
|
||||
.BR dmenu (1)
|
||||
|
95
dwm.h
95
dwm.h
@ -1,35 +1,34 @@
|
||||
/*
|
||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*
|
||||
* dynamic window manager is designed like any other X client as well. It is
|
||||
* driven through handling X events. In contrast to other X clients, a window
|
||||
* manager like dwm selects for SubstructureRedirectMask on the root window, to
|
||||
* receive events about window appearance and disappearance. Only one X
|
||||
* connection at a time is allowed to select for this event mask.
|
||||
* manager selects for SubstructureRedirectMask on the root window, to receive
|
||||
* events about window (dis-)appearance. Only one X connection at a time is
|
||||
* allowed to select for this event mask.
|
||||
*
|
||||
* Calls to fetch an X event from the X event queue connection are blocking.
|
||||
* Due reading status text from standard input, a select-driven main loop has
|
||||
* been implemented which selects for reads on the X connection and
|
||||
* STDIN_FILENO to handle all data smoothly and without busy-loop quirks. The
|
||||
* event handlers of dwm are organized in an array which is accessed whenever a
|
||||
* new event has been fetched. This allows event dispatching in O(1) time.
|
||||
* Calls to fetch an X event from the event queue are blocking. Due reading
|
||||
* status text from standard input, a select()-driven main loop has been
|
||||
* implemented which selects for reads on the X connection and STDIN_FILENO to
|
||||
* handle all data smoothly. The event handlers of dwm are organized in an
|
||||
* array which is accessed whenever a new event has been fetched. This allows
|
||||
* event dispatching in O(1) time.
|
||||
*
|
||||
* Each child of the root window is called a client, except windows which have
|
||||
* set the override_redirect flag. Clients are organized in a global
|
||||
* doubly-linked client list, the focus history is remembered through a global
|
||||
* stack list. Each client contains an array of Bools of the same size as the
|
||||
* global tags array to indicate the tags of a client. For each client dwm
|
||||
* creates a small title window which is resized whenever the WM_NAME or
|
||||
* _NET_WM_NAME properties are updated or the client is resized.
|
||||
* creates a small title window, which is resized whenever the (_NET_)WM_NAME
|
||||
* properties are updated or the client is moved/resized.
|
||||
*
|
||||
* Keys and tagging rules are organized as arrays and defined in the config.h
|
||||
* file. These arrays are kept static in event.o and tag.o respectively,
|
||||
* because no other part of dwm needs access to them. The current mode is
|
||||
* represented by the arrange function pointer which wether points to dofloat
|
||||
* or dotile.
|
||||
* represented by the arrange() function pointer, which wether points to
|
||||
* dofloat() or dotile().
|
||||
*
|
||||
* To understand everything else, start with reading main.c:main().
|
||||
* To understand everything else, start reading main.c:main().
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@ -37,17 +36,13 @@
|
||||
|
||||
/* mask shorthands, used in event.c and client.c */
|
||||
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
|
||||
#define MOUSEMASK (BUTTONMASK | PointerMotionMask)
|
||||
/* other stuff used in different places */
|
||||
#define PROTODELWIN 1
|
||||
|
||||
enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
|
||||
enum { WMProtocols, WMDelete, WMLast }; /* default atoms */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
|
||||
enum { ColFG, ColBG, ColLast }; /* color */
|
||||
|
||||
typedef enum {
|
||||
TopLeft, TopRight, BotLeft, BotRight
|
||||
} Corner; /* window corners */
|
||||
enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
|
||||
|
||||
typedef union {
|
||||
const char *cmd;
|
||||
@ -66,7 +61,6 @@ typedef struct {
|
||||
int x, y, w, h;
|
||||
unsigned long norm[ColLast];
|
||||
unsigned long sel[ColLast];
|
||||
unsigned long status[ColLast];
|
||||
Drawable drawable;
|
||||
Fnt font;
|
||||
GC gc;
|
||||
@ -77,60 +71,55 @@ struct Client {
|
||||
char name[256];
|
||||
int proto;
|
||||
int x, y, w, h;
|
||||
int tx, ty, tw, th; /* title window geometry */
|
||||
int rx, ry, rw, rh; /* revert geometry */
|
||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||
int grav;
|
||||
long flags;
|
||||
unsigned int border, weight;
|
||||
Bool isfloat;
|
||||
unsigned int border;
|
||||
Bool isfloat, isfixed, ismax;
|
||||
Bool *tags;
|
||||
Client *next;
|
||||
Client *prev;
|
||||
Client *snext;
|
||||
Window win;
|
||||
Window twin;
|
||||
};
|
||||
|
||||
extern const char *tags[]; /* all tags */
|
||||
extern char stext[1024]; /* status text */
|
||||
extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */
|
||||
extern int mw, screen, sx, sy, sw, sh; /* screen geometry, master width */
|
||||
extern char stext[256]; /* status text */
|
||||
extern int bh, bmw; /* bar height, bar mode label width */
|
||||
extern int screen, sx, sy, sw, sh; /* screen geometry */
|
||||
extern int wax, way, wah, waw; /* windowarea geometry */
|
||||
extern unsigned int master, nmaster; /* master percent, number of master clients */
|
||||
extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
|
||||
extern void (*handler[LASTEvent])(XEvent *); /* event handler */
|
||||
extern void (*arrange)(Arg *); /* arrange function, indicates mode */
|
||||
extern void (*arrange)(void); /* arrange function, indicates mode */
|
||||
extern Atom wmatom[WMLast], netatom[NetLast];
|
||||
extern Bool running, issel, maximized, *seltag; /* seltag is array of Bool */
|
||||
extern Client *clients, *sel, *stack; /* global cleint list and stack */
|
||||
extern Bool running, selscreen, *seltag; /* seltag is array of Bool */
|
||||
extern Client *clients, *sel, *stack; /* global client list and stack */
|
||||
extern Cursor cursor[CurLast];
|
||||
extern DC dc; /* global draw context */
|
||||
extern Display *dpy;
|
||||
extern Window root, barwin;
|
||||
|
||||
/* client.c */
|
||||
extern void ban(Client *c); /* ban c from screen */
|
||||
extern void configure(Client *c); /* send synthetic configure event */
|
||||
extern void focus(Client *c); /* focus c, c may be NULL */
|
||||
extern Client *getclient(Window w); /* return client of w */
|
||||
extern Client *getctitle(Window w); /* return client of title window */
|
||||
extern void gravitate(Client *c, Bool invert); /* gravitate c */
|
||||
extern void killclient(Arg *arg); /* kill c nicely */
|
||||
extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
|
||||
extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize c*/
|
||||
extern void updatesize(Client *c); /* update the size structs of c */
|
||||
extern void resize(Client *c, Bool sizehints); /* resize c*/
|
||||
extern void updatesizehints(Client *c); /* update the size hint variables of c */
|
||||
extern void updatetitle(Client *c); /* update the name of c */
|
||||
extern void togglemax(Arg *arg); /* (un)maximize c */
|
||||
extern void unmanage(Client *c); /* destroy c */
|
||||
|
||||
/* draw.c */
|
||||
extern void drawall(); /* draw all visible client titles and the bar */
|
||||
extern void drawstatus(); /* draw the bar */
|
||||
extern void drawtitle(Client *c); /* draw title of c */
|
||||
extern void drawstatus(void); /* draw the bar */
|
||||
extern unsigned long getcolor(const char *colstr); /* return color of colstr */
|
||||
extern void setfont(const char *fontstr); /* set the font for DC */
|
||||
extern unsigned int textw(const char *text); /* return the width of text in px*/
|
||||
|
||||
/* event.c */
|
||||
extern void grabkeys(); /* grab all keys defined in config.h */
|
||||
extern void procevent(); /* process pending X events */
|
||||
extern void grabkeys(void); /* grab all keys defined in config.h */
|
||||
extern void procevent(void); /* process pending X events */
|
||||
|
||||
/* main.c */
|
||||
extern int getproto(Window w); /* return protocol mask of WMProtocols property of w */
|
||||
@ -139,7 +128,7 @@ extern void sendevent(Window w, Atom a, long value); /* send synthetic event to
|
||||
extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
|
||||
|
||||
/* tag.c */
|
||||
extern void initrregs(); /* initialize regexps of rules defined in config.h */
|
||||
extern void initrregs(void); /* initialize regexps of rules defined in config.h */
|
||||
extern Client *getnext(Client *c); /* returns next visible client */
|
||||
extern Client *getprev(Client *c); /* returns previous visible client */
|
||||
extern void settags(Client *c, Client *trans); /* sets tags of c */
|
||||
@ -149,20 +138,20 @@ extern void toggletag(Arg *arg); /* toggles c tags with arg's index */
|
||||
/* util.c */
|
||||
extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */
|
||||
extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
|
||||
extern void *erealloc(void *ptr, unsigned int size); /* reallocates memory, exits on error */
|
||||
extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */
|
||||
|
||||
/* view.c */
|
||||
extern void detach(Client *c); /* detaches c from global client list */
|
||||
extern void dofloat(Arg *arg); /* arranges all windows floating, arg is ignored */
|
||||
extern void dotile(Arg *arg); /* arranges all windows, arg is ignored */
|
||||
extern void dofloat(void); /* arranges all windows floating */
|
||||
extern void dotile(void); /* arranges all windows tiled */
|
||||
extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
|
||||
extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */
|
||||
extern void incnmaster(Arg *arg); /* increments nmaster with arg's index value */
|
||||
extern Bool isvisible(Client *c); /* returns True if client is visible */
|
||||
extern void resizecol(Arg *arg); /* resizes the master width with arg's index value */
|
||||
extern void restack(); /* restores z layers of all clients */
|
||||
extern void resizemaster(Arg *arg); /* resizes the master percent with arg's index value */
|
||||
extern void restack(void); /* restores z layers of all clients */
|
||||
extern void togglefloat(Arg *arg); /* toggles focusesd client between floating/non-floating state */
|
||||
extern void togglemode(Arg *arg); /* toggles global arrange function (dotile/dofloat) */
|
||||
extern void toggleview(Arg *arg); /* toggles the tag with arg's index (in)visible */
|
||||
extern void view(Arg *arg); /* views the tag with arg's index */
|
||||
extern void viewall(Arg *arg); /* views all tags, arg is ignored */
|
||||
extern void zoom(Arg *arg); /* zooms the focused client to master column, arg is ignored */
|
||||
extern void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */
|
||||
|
159
event.c
159
event.c
@ -1,5 +1,4 @@
|
||||
/*
|
||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
@ -19,6 +18,7 @@ typedef struct {
|
||||
KEYS
|
||||
|
||||
#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
|
||||
#define MOUSEMASK (BUTTONMASK | PointerMotionMask)
|
||||
|
||||
static void
|
||||
movemouse(Client *c) {
|
||||
@ -32,24 +32,34 @@ movemouse(Client *c) {
|
||||
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
||||
None, cursor[CurMove], CurrentTime) != GrabSuccess)
|
||||
return;
|
||||
c->ismax = False;
|
||||
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
|
||||
for(;;) {
|
||||
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
|
||||
XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
|
||||
switch (ev.type) {
|
||||
default:
|
||||
break;
|
||||
case ButtonRelease:
|
||||
resize(c, True);
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
return;
|
||||
case ConfigureRequest:
|
||||
case Expose:
|
||||
handler[Expose](&ev);
|
||||
case MapRequest:
|
||||
handler[ev.type](&ev);
|
||||
break;
|
||||
case MotionNotify:
|
||||
XSync(dpy, False);
|
||||
c->x = ocx + (ev.xmotion.x - x1);
|
||||
c->y = ocy + (ev.xmotion.y - y1);
|
||||
resize(c, False, TopLeft);
|
||||
if(abs(wax + c->x) < SNAP)
|
||||
c->x = wax;
|
||||
else if(abs((wax + waw) - (c->x + c->w + 2 * c->border)) < SNAP)
|
||||
c->x = wax + waw - c->w - 2 * c->border;
|
||||
if(abs(way - c->y) < SNAP)
|
||||
c->y = way;
|
||||
else if(abs((way + wah) - (c->y + c->h + 2 * c->border)) < SNAP)
|
||||
c->y = way + wah - c->h - 2 * c->border;
|
||||
resize(c, False);
|
||||
break;
|
||||
case ButtonRelease:
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -58,7 +68,6 @@ static void
|
||||
resizemouse(Client *c) {
|
||||
int ocx, ocy;
|
||||
int nw, nh;
|
||||
Corner sticky;
|
||||
XEvent ev;
|
||||
|
||||
ocx = c->x;
|
||||
@ -66,32 +75,28 @@ resizemouse(Client *c) {
|
||||
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);
|
||||
c->ismax = False;
|
||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
|
||||
for(;;) {
|
||||
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
|
||||
XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask , &ev);
|
||||
switch(ev.type) {
|
||||
default:
|
||||
break;
|
||||
case ButtonRelease:
|
||||
resize(c, True);
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
return;
|
||||
case ConfigureRequest:
|
||||
case Expose:
|
||||
handler[Expose](&ev);
|
||||
case MapRequest:
|
||||
handler[ev.type](&ev);
|
||||
break;
|
||||
case MotionNotify:
|
||||
XSync(dpy, False);
|
||||
if((nw = abs(ocx - ev.xmotion.x)))
|
||||
c->w = abs(ocx - ev.xmotion.x);
|
||||
if((nh = abs(ocy - ev.xmotion.y)))
|
||||
c->h = abs(ocy - ev.xmotion.y);
|
||||
c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
|
||||
c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
|
||||
if(ocx <= ev.xmotion.x)
|
||||
sticky = (ocy <= ev.xmotion.y) ? TopLeft : BotLeft;
|
||||
else
|
||||
sticky = (ocy <= ev.xmotion.y) ? TopRight : BotRight;
|
||||
resize(c, True, sticky);
|
||||
nw = ev.xmotion.x - ocx - 2 * c->border + 1;
|
||||
c->w = nw > 0 ? nw : 1;
|
||||
nh = ev.xmotion.y - ocy - 2 * c->border + 1;
|
||||
c->h = nh > 0 ? nh : 1;
|
||||
resize(c, True);
|
||||
break;
|
||||
case ButtonRelease:
|
||||
XUngrabPointer(dpy, CurrentTime);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,45 +128,39 @@ buttonpress(XEvent *e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(ev->x < x + bmw) {
|
||||
if(ev->button == Button1)
|
||||
if(ev->x < x + bmw)
|
||||
switch(ev->button) {
|
||||
case Button1:
|
||||
togglemode(NULL);
|
||||
break;
|
||||
case Button4:
|
||||
a.i = 1;
|
||||
incnmaster(&a);
|
||||
break;
|
||||
case Button5:
|
||||
a.i = -1;
|
||||
incnmaster(&a);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if((c = getclient(ev->window))) {
|
||||
focus(c);
|
||||
if(maximized || CLEANMASK(ev->state) != MODKEY)
|
||||
if(CLEANMASK(ev->state) != MODKEY)
|
||||
return;
|
||||
if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) {
|
||||
restack(c);
|
||||
restack();
|
||||
movemouse(c);
|
||||
}
|
||||
else if(ev->button == Button2)
|
||||
zoom(NULL);
|
||||
else if(ev->button == Button3 && (arrange == dofloat || c->isfloat)) {
|
||||
restack(c);
|
||||
else if(ev->button == Button3 && (arrange == dofloat || c->isfloat) &&
|
||||
!c->isfixed) {
|
||||
restack();
|
||||
resizemouse(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@ -170,12 +169,7 @@ configurerequest(XEvent *e) {
|
||||
XWindowChanges wc;
|
||||
|
||||
if((c = getclient(ev->window))) {
|
||||
if((c == sel) && !c->isfloat && (arrange != dofloat) && maximized) {
|
||||
synconfig(c, sx, sy + bh, sw - 2, sh - 2 - bh, ev->border_width);
|
||||
XSync(dpy, False);
|
||||
return;
|
||||
}
|
||||
gravitate(c, True);
|
||||
c->ismax = False;
|
||||
if(ev->value_mask & CWX)
|
||||
c->x = ev->x;
|
||||
if(ev->value_mask & CWY)
|
||||
@ -186,7 +180,6 @@ configurerequest(XEvent *e) {
|
||||
c->h = ev->height;
|
||||
if(ev->value_mask & CWBorderWidth)
|
||||
c->border = ev->border_width;
|
||||
gravitate(c, False);
|
||||
wc.x = c->x;
|
||||
wc.y = c->y;
|
||||
wc.width = c->w;
|
||||
@ -195,12 +188,15 @@ configurerequest(XEvent *e) {
|
||||
if(newmask)
|
||||
XConfigureWindow(dpy, c->win, newmask, &wc);
|
||||
else
|
||||
synconfig(c, c->x, c->y, c->w, c->h, c->border);
|
||||
configure(c);
|
||||
XSync(dpy, False);
|
||||
if(c->isfloat)
|
||||
resize(c, False, TopLeft);
|
||||
if(c->isfloat) {
|
||||
resize(c, False);
|
||||
if(!isvisible(c))
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
}
|
||||
else
|
||||
arrange(NULL);
|
||||
arrange();
|
||||
}
|
||||
else {
|
||||
wc.x = ev->x;
|
||||
@ -231,32 +227,28 @@ enternotify(XEvent *e) {
|
||||
|
||||
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
|
||||
return;
|
||||
|
||||
if(((c = getclient(ev->window)) || (c = getctitle(ev->window))) && isvisible(c))
|
||||
if((c = getclient(ev->window)) && isvisible(c))
|
||||
focus(c);
|
||||
else if(ev->window == root) {
|
||||
issel = True;
|
||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||
drawall();
|
||||
selscreen = True;
|
||||
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||
focus(c);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
expose(XEvent *e) {
|
||||
Client *c;
|
||||
XExposeEvent *ev = &e->xexpose;
|
||||
|
||||
if(ev->count == 0) {
|
||||
if(barwin == ev->window)
|
||||
drawstatus();
|
||||
else if((c = getctitle(ev->window)))
|
||||
drawtitle(c);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
keypress(XEvent *e) {
|
||||
static unsigned int len = sizeof(key) / sizeof(key[0]);
|
||||
static unsigned int len = sizeof key / sizeof key[0];
|
||||
unsigned int i;
|
||||
KeySym keysym;
|
||||
XKeyEvent *ev = &e->xkey;
|
||||
@ -268,7 +260,6 @@ keypress(XEvent *e) {
|
||||
{
|
||||
if(key[i].func)
|
||||
key[i].func(&key[i].arg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -278,8 +269,8 @@ leavenotify(XEvent *e) {
|
||||
XCrossingEvent *ev = &e->xcrossing;
|
||||
|
||||
if((ev->window == root) && !ev->same_screen) {
|
||||
issel = False;
|
||||
drawall();
|
||||
selscreen = False;
|
||||
focus(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,13 +290,11 @@ maprequest(XEvent *e) {
|
||||
|
||||
if(!XGetWindowAttributes(dpy, ev->window, &wa))
|
||||
return;
|
||||
|
||||
if(wa.override_redirect) {
|
||||
XSelectInput(dpy, ev->window,
|
||||
(StructureNotifyMask | PropertyChangeMask));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!getclient(ev->window))
|
||||
manage(ev->window, &wa);
|
||||
}
|
||||
@ -318,7 +307,6 @@ propertynotify(XEvent *e) {
|
||||
|
||||
if(ev->state == PropertyDelete)
|
||||
return; /* ignore */
|
||||
|
||||
if((c = getclient(ev->window))) {
|
||||
if(ev->atom == wmatom[WMProtocols]) {
|
||||
c->proto = getproto(c->win);
|
||||
@ -329,15 +317,16 @@ propertynotify(XEvent *e) {
|
||||
case XA_WM_TRANSIENT_FOR:
|
||||
XGetTransientForHint(dpy, c->win, &trans);
|
||||
if(!c->isfloat && (c->isfloat = (trans != 0)))
|
||||
arrange(NULL);
|
||||
arrange();
|
||||
break;
|
||||
case XA_WM_NORMAL_HINTS:
|
||||
updatesize(c);
|
||||
updatesizehints(c);
|
||||
break;
|
||||
}
|
||||
if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
|
||||
updatetitle(c);
|
||||
drawtitle(c);
|
||||
if(c == sel)
|
||||
drawstatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -368,8 +357,8 @@ void (*handler[LASTEvent]) (XEvent *) = {
|
||||
};
|
||||
|
||||
void
|
||||
grabkeys() {
|
||||
static unsigned int len = sizeof(key) / sizeof(key[0]);
|
||||
grabkeys(void) {
|
||||
static unsigned int len = sizeof key / sizeof key[0];
|
||||
unsigned int i;
|
||||
KeyCode code;
|
||||
|
||||
@ -388,7 +377,7 @@ grabkeys() {
|
||||
}
|
||||
|
||||
void
|
||||
procevent() {
|
||||
procevent(void) {
|
||||
XEvent ev;
|
||||
|
||||
while(XPending(dpy)) {
|
||||
|
116
main.c
116
main.c
@ -1,10 +1,10 @@
|
||||
/*
|
||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
|
||||
#include "dwm.h"
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -17,14 +17,13 @@
|
||||
|
||||
/* extern */
|
||||
|
||||
char stext[1024];
|
||||
char stext[256];
|
||||
Bool *seltag;
|
||||
int bx, by, bw, bh, bmw, mw, screen, sx, sy, sw, sh;
|
||||
unsigned int ntags, numlockmask;
|
||||
int bh, bmw, screen, sx, sy, sw, sh, wax, way, waw, wah;
|
||||
unsigned int master, nmaster, ntags, numlockmask;
|
||||
Atom wmatom[WMLast], netatom[NetLast];
|
||||
Bool running = True;
|
||||
Bool issel = True;
|
||||
Bool maximized = False;
|
||||
Bool selscreen = True;
|
||||
Client *clients = NULL;
|
||||
Client *sel = NULL;
|
||||
Client *stack = NULL;
|
||||
@ -39,11 +38,11 @@ static int (*xerrorxlib)(Display *, XErrorEvent *);
|
||||
static Bool otherwm, readin;
|
||||
|
||||
static void
|
||||
cleanup() {
|
||||
cleanup(void) {
|
||||
close(STDIN_FILENO);
|
||||
while(sel) {
|
||||
resize(sel, True, TopLeft);
|
||||
unmanage(sel);
|
||||
while(stack) {
|
||||
resize(stack, True);
|
||||
unmanage(stack);
|
||||
}
|
||||
if(dc.font.set)
|
||||
XFreeFontSet(dpy, dc.font.set);
|
||||
@ -53,13 +52,16 @@ cleanup() {
|
||||
XFreePixmap(dpy, dc.drawable);
|
||||
XFreeGC(dpy, dc.gc);
|
||||
XDestroyWindow(dpy, barwin);
|
||||
XFreeCursor(dpy, cursor[CurNormal]);
|
||||
XFreeCursor(dpy, cursor[CurResize]);
|
||||
XFreeCursor(dpy, cursor[CurMove]);
|
||||
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||
XSync(dpy, False);
|
||||
free(seltag);
|
||||
}
|
||||
|
||||
static void
|
||||
scan() {
|
||||
scan(void) {
|
||||
unsigned int i, num;
|
||||
Window *wins, d1, d2;
|
||||
XWindowAttributes wa;
|
||||
@ -80,7 +82,7 @@ scan() {
|
||||
}
|
||||
|
||||
static void
|
||||
setup() {
|
||||
setup(void) {
|
||||
int i, j;
|
||||
unsigned int mask;
|
||||
Window w;
|
||||
@ -94,12 +96,12 @@ setup() {
|
||||
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
||||
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
|
||||
PropModeReplace, (unsigned char *) netatom, NetLast);
|
||||
|
||||
/* init cursors */
|
||||
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
|
||||
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
|
||||
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
|
||||
|
||||
/* init modifier map */
|
||||
numlockmask = 0;
|
||||
modmap = XGetModifierMapping(dpy);
|
||||
for (i = 0; i < 8; i++) {
|
||||
for (j = 0; j < modmap->max_keypermod; j++) {
|
||||
@ -107,53 +109,54 @@ setup() {
|
||||
numlockmask = (1 << i);
|
||||
}
|
||||
}
|
||||
XFree(modmap);
|
||||
|
||||
XFreeModifiermap(modmap);
|
||||
/* select for events */
|
||||
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
||||
| EnterWindowMask | LeaveWindowMask;
|
||||
wa.cursor = cursor[CurNormal];
|
||||
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
|
||||
|
||||
grabkeys();
|
||||
initrregs();
|
||||
|
||||
for(ntags = 0; tags[ntags]; ntags++);
|
||||
seltag = emallocz(sizeof(Bool) * ntags);
|
||||
seltag[0] = True;
|
||||
|
||||
/* style */
|
||||
dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR);
|
||||
dc.norm[ColBG] = getcolor(NORMBGCOLOR);
|
||||
dc.norm[ColFG] = getcolor(NORMFGCOLOR);
|
||||
dc.sel[ColBorder] = getcolor(SELBORDERCOLOR);
|
||||
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);
|
||||
/* geometry */
|
||||
sx = sy = 0;
|
||||
sw = DisplayWidth(dpy, screen);
|
||||
sh = DisplayHeight(dpy, screen);
|
||||
mw = (sw * MASTERW) / 100;
|
||||
|
||||
bx = by = 0;
|
||||
bw = sw;
|
||||
master = MASTER;
|
||||
nmaster = NMASTER;
|
||||
bmw = textw(TILESYMBOL) > textw(FLOATSYMBOL) ? textw(TILESYMBOL) : textw(FLOATSYMBOL);
|
||||
/* bar */
|
||||
dc.h = bh = dc.font.height + 2;
|
||||
wa.override_redirect = 1;
|
||||
wa.background_pixmap = ParentRelative;
|
||||
wa.event_mask = ButtonPressMask | ExposureMask;
|
||||
barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen),
|
||||
barwin = XCreateWindow(dpy, root, sx, sy, sw, bh, 0, DefaultDepth(dpy, screen),
|
||||
CopyFromParent, DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||
XDefineCursor(dpy, barwin, cursor[CurNormal]);
|
||||
XMapRaised(dpy, barwin);
|
||||
|
||||
strcpy(stext, "dwm-"VERSION);
|
||||
/* windowarea */
|
||||
wax = sx;
|
||||
way = sy + bh;
|
||||
wah = sh - bh;
|
||||
waw = sw;
|
||||
/* pixmap for everything */
|
||||
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
|
||||
dc.gc = XCreateGC(dpy, root, 0, 0);
|
||||
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
||||
|
||||
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
||||
strcpy(stext, "dwm-"VERSION);
|
||||
/* multihead support */
|
||||
selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -205,8 +208,7 @@ quit(Arg *arg) {
|
||||
readin = running = False;
|
||||
}
|
||||
|
||||
/*
|
||||
* There's no way to check accesses to destroyed windows, thus those cases are
|
||||
/* There's no way to check accesses to destroyed windows, thus those cases are
|
||||
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
|
||||
* default error handler, which may call exit.
|
||||
*/
|
||||
@ -228,30 +230,28 @@ xerror(Display *dpy, XErrorEvent *ee) {
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
char *p;
|
||||
int r, xfd;
|
||||
fd_set rd;
|
||||
|
||||
if(argc == 2 && !strncmp("-v", argv[1], 3)) {
|
||||
fputs("dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
|
||||
fputs("dwm-"VERSION", (C)opyright MMVI-MMVII Anselm R. Garbe\n", stdout);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
else if(argc != 1)
|
||||
eprint("usage: dwm [-v]\n");
|
||||
|
||||
setlocale(LC_CTYPE, "");
|
||||
dpy = XOpenDisplay(0);
|
||||
if(!dpy)
|
||||
eprint("dwm: cannot open display\n");
|
||||
|
||||
xfd = ConnectionNumber(dpy);
|
||||
screen = DefaultScreen(dpy);
|
||||
root = RootWindow(dpy, screen);
|
||||
|
||||
otherwm = False;
|
||||
XSetErrorHandler(xerrorstart);
|
||||
/* this causes an error if some other window manager is running */
|
||||
XSelectInput(dpy, root, SubstructureRedirectMask);
|
||||
XSync(dpy, False);
|
||||
|
||||
if(otherwm)
|
||||
eprint("dwm: another window manager is already running\n");
|
||||
|
||||
@ -259,7 +259,6 @@ main(int argc, char *argv[]) {
|
||||
XSetErrorHandler(NULL);
|
||||
xerrorxlib = XSetErrorHandler(xerror);
|
||||
XSync(dpy, False);
|
||||
|
||||
setup();
|
||||
drawstatus();
|
||||
scan();
|
||||
@ -273,25 +272,34 @@ main(int argc, char *argv[]) {
|
||||
if(readin)
|
||||
FD_SET(STDIN_FILENO, &rd);
|
||||
FD_SET(xfd, &rd);
|
||||
r = select(xfd + 1, &rd, NULL, NULL, NULL);
|
||||
if((r == -1) && (errno == EINTR))
|
||||
if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) {
|
||||
if(errno == EINTR)
|
||||
continue;
|
||||
if(r > 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");
|
||||
eprint("select failed\n");
|
||||
}
|
||||
if(FD_ISSET(STDIN_FILENO, &rd)) {
|
||||
switch(r = read(STDIN_FILENO, stext, sizeof stext - 1)) {
|
||||
case -1:
|
||||
strncpy(stext, strerror(errno), sizeof stext - 1);
|
||||
stext[sizeof stext - 1] = '\0';
|
||||
readin = False;
|
||||
break;
|
||||
case 0:
|
||||
strncpy(stext, "EOF", 4);
|
||||
readin = False;
|
||||
break;
|
||||
default:
|
||||
for(stext[r] = '\0', p = stext + strlen(stext) - 1; p >= stext && *p == '\n'; *p-- = '\0');
|
||||
for(p = stext + strlen(stext) - 1; p >= stext && *p != '\n'; --p);
|
||||
if(p > stext)
|
||||
strncpy(stext, p + 1, sizeof stext);
|
||||
}
|
||||
drawstatus();
|
||||
}
|
||||
}
|
||||
else if(r < 0)
|
||||
eprint("select failed\n");
|
||||
if(FD_ISSET(xfd, &rd))
|
||||
procevent();
|
||||
}
|
||||
cleanup();
|
||||
XCloseDisplay(dpy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
28
tag.c
28
tag.c
@ -1,5 +1,4 @@
|
||||
/*
|
||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
@ -45,26 +44,25 @@ getprev(Client *c) {
|
||||
}
|
||||
|
||||
void
|
||||
initrregs() {
|
||||
initrregs(void) {
|
||||
unsigned int i;
|
||||
regex_t *reg;
|
||||
|
||||
if(rreg)
|
||||
return;
|
||||
len = sizeof(rule) / sizeof(rule[0]);
|
||||
len = sizeof rule / sizeof rule[0];
|
||||
rreg = emallocz(len * sizeof(RReg));
|
||||
|
||||
for(i = 0; i < len; i++) {
|
||||
if(rule[i].clpattern) {
|
||||
reg = emallocz(sizeof(regex_t));
|
||||
if(regcomp(reg, rule[i].clpattern, 0))
|
||||
if(regcomp(reg, rule[i].clpattern, REG_EXTENDED))
|
||||
free(reg);
|
||||
else
|
||||
rreg[i].clregex = reg;
|
||||
}
|
||||
if(rule[i].tpattern) {
|
||||
reg = emallocz(sizeof(regex_t));
|
||||
if(regcomp(reg, rule[i].tpattern, 0))
|
||||
if(regcomp(reg, rule[i].tpattern, REG_EXTENDED))
|
||||
free(reg);
|
||||
else
|
||||
rreg[i].tregex = reg;
|
||||
@ -85,10 +83,10 @@ settags(Client *c, Client *trans) {
|
||||
c->tags[i] = trans->tags[i];
|
||||
}
|
||||
else if(XGetClassHint(dpy, c->win, &ch)) {
|
||||
snprintf(prop, sizeof(prop), "%s:%s:%s",
|
||||
snprintf(prop, sizeof prop, "%s:%s:%s",
|
||||
ch.res_class ? ch.res_class : "",
|
||||
ch.res_name ? ch.res_name : "", c->name);
|
||||
for(i = 0; !matched && i < len; i++)
|
||||
for(i = 0; i < len; i++)
|
||||
if(rreg[i].clregex && !regexec(rreg[i].clregex, prop, 1, &tmp, 0)) {
|
||||
c->isfloat = rule[i].isfloat;
|
||||
for(j = 0; rreg[i].tregex && j < ntags; j++) {
|
||||
@ -106,7 +104,6 @@ settags(Client *c, Client *trans) {
|
||||
if(!matched)
|
||||
for(i = 0; i < ntags; i++)
|
||||
c->tags[i] = seltag[i];
|
||||
for(c->weight = 0; c->weight < ntags && !c->tags[c->weight]; c->weight++);
|
||||
}
|
||||
|
||||
void
|
||||
@ -115,12 +112,11 @@ tag(Arg *arg) {
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
|
||||
for(i = 0; i < ntags; i++)
|
||||
sel->tags[i] = False;
|
||||
sel->tags[i] = (arg->i == -1) ? True : False;
|
||||
if(arg->i >= 0 && arg->i < ntags)
|
||||
sel->tags[arg->i] = True;
|
||||
sel->weight = arg->i;
|
||||
arrange(NULL);
|
||||
arrange();
|
||||
}
|
||||
|
||||
void
|
||||
@ -129,11 +125,9 @@ toggletag(Arg *arg) {
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
|
||||
sel->tags[arg->i] = !sel->tags[arg->i];
|
||||
for(i = 0; i < ntags && !sel->tags[i]; i++);
|
||||
if(i == ntags)
|
||||
sel->tags[arg->i] = True;
|
||||
sel->weight = (i == ntags) ? arg->i : i;
|
||||
arrange(NULL);
|
||||
arrange();
|
||||
}
|
||||
|
15
util.c
15
util.c
@ -1,5 +1,4 @@
|
||||
/*
|
||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
@ -30,24 +29,16 @@ eprint(const char *errstr, ...) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void *
|
||||
erealloc(void *ptr, unsigned int size) {
|
||||
void *res = realloc(ptr, size);
|
||||
if(!res)
|
||||
eprint("fatal: could not malloc() %u bytes\n", size);
|
||||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
spawn(Arg *arg) {
|
||||
static char *shell = NULL;
|
||||
|
||||
if(!shell && !(shell = getenv("SHELL")))
|
||||
shell = "/bin/sh";
|
||||
|
||||
if(!arg->cmd)
|
||||
return;
|
||||
/* the double-fork construct avoids zombie processes */
|
||||
/* The double-fork construct avoids zombie processes and keeps the code
|
||||
* clean from stupid signal handlers. */
|
||||
if(fork() == 0) {
|
||||
if(fork() == 0) {
|
||||
if(dpy)
|
||||
|
232
view.c
232
view.c
@ -1,50 +1,43 @@
|
||||
/*
|
||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dwm.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/* static */
|
||||
|
||||
static Client *
|
||||
minclient() {
|
||||
Client *c, *min;
|
||||
|
||||
if((clients && clients->isfloat) || arrange == dofloat)
|
||||
return clients; /* don't touch floating order */
|
||||
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;
|
||||
}
|
||||
|
||||
static Client *
|
||||
nexttiled(Client *c) {
|
||||
for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
|
||||
return c;
|
||||
}
|
||||
|
||||
static void
|
||||
togglemax(Client *c) {
|
||||
XEvent ev;
|
||||
|
||||
if(c->isfixed)
|
||||
return;
|
||||
|
||||
if((c->ismax = !c->ismax)) {
|
||||
c->rx = c->x; c->x = wax;
|
||||
c->ry = c->y; c->y = way;
|
||||
c->rw = c->w; c->w = waw - 2 * BORDERPX;
|
||||
c->rh = c->h; c->h = wah - 2 * BORDERPX;
|
||||
}
|
||||
else {
|
||||
c->x = c->rx;
|
||||
c->y = c->ry;
|
||||
c->w = c->rw;
|
||||
c->h = c->rh;
|
||||
}
|
||||
resize(c, True);
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
}
|
||||
|
||||
/* extern */
|
||||
|
||||
void (*arrange)(Arg *) = DEFMODE;
|
||||
void (*arrange)(void) = DEFMODE;
|
||||
|
||||
void
|
||||
detach(Client *c) {
|
||||
@ -58,17 +51,15 @@ detach(Client *c) {
|
||||
}
|
||||
|
||||
void
|
||||
dofloat(Arg *arg) {
|
||||
dofloat(void) {
|
||||
Client *c;
|
||||
|
||||
maximized = False;
|
||||
|
||||
for(c = clients; c; c = c->next) {
|
||||
if(isvisible(c)) {
|
||||
resize(c, True, TopLeft);
|
||||
resize(c, True);
|
||||
}
|
||||
else
|
||||
ban(c);
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
}
|
||||
if(!sel || !isvisible(sel)) {
|
||||
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||
@ -78,61 +69,47 @@ dofloat(Arg *arg) {
|
||||
}
|
||||
|
||||
void
|
||||
dotile(Arg *arg) {
|
||||
int h, i, n, w;
|
||||
dotile(void) {
|
||||
unsigned int i, n, mw, mh, tw, th;
|
||||
Client *c;
|
||||
|
||||
maximized = False;
|
||||
|
||||
w = sw - mw;
|
||||
for(n = 0, c = clients; c; c = c->next)
|
||||
if(isvisible(c) && !c->isfloat)
|
||||
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
|
||||
n++;
|
||||
/* window geoms */
|
||||
mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
|
||||
mw = (n > nmaster) ? (waw * master) / 1000 : waw;
|
||||
th = (n > nmaster) ? wah / (n - nmaster) : 0;
|
||||
tw = waw - mw;
|
||||
|
||||
if(n > 1)
|
||||
h = (sh - bh) / (n - 1);
|
||||
else
|
||||
h = sh - bh;
|
||||
|
||||
for(i = 0, c = clients; c; c = c->next) {
|
||||
for(i = 0, c = clients; c; c = c->next)
|
||||
if(isvisible(c)) {
|
||||
if(c->isfloat) {
|
||||
resize(c, True, TopLeft);
|
||||
resize(c, True);
|
||||
continue;
|
||||
}
|
||||
if(n == 1) {
|
||||
c->x = sx;
|
||||
c->y = sy + bh;
|
||||
c->w = sw - 2;
|
||||
c->h = sh - 2 - bh;
|
||||
c->ismax = False;
|
||||
c->x = wax;
|
||||
c->y = way;
|
||||
if(i < nmaster) {
|
||||
c->y += i * mh;
|
||||
c->w = mw - 2 * BORDERPX;
|
||||
c->h = mh - 2 * BORDERPX;
|
||||
}
|
||||
else if(i == 0) {
|
||||
c->x = sx;
|
||||
c->y = sy + bh;
|
||||
c->w = mw - 2;
|
||||
c->h = sh - 2 - bh;
|
||||
else { /* tile window */
|
||||
c->x += mw;
|
||||
c->w = tw - 2 * BORDERPX;
|
||||
if(th > bh) {
|
||||
c->y += (i - nmaster) * th;
|
||||
c->h = th - 2 * BORDERPX;
|
||||
}
|
||||
else if(h > bh) {
|
||||
c->x = sx + mw;
|
||||
c->y = sy + (i - 1) * h + bh;
|
||||
c->w = w - 2;
|
||||
if(i + 1 == n)
|
||||
c->h = sh - c->y - 2;
|
||||
else
|
||||
c->h = h - 2;
|
||||
else /* fallback if th < bh */
|
||||
c->h = wah - 2 * BORDERPX;
|
||||
}
|
||||
else { /* fallback if h < bh */
|
||||
c->x = sx + mw;
|
||||
c->y = sy + bh;
|
||||
c->w = w - 2;
|
||||
c->h = sh - 2 - bh;
|
||||
}
|
||||
resize(c, False, TopLeft);
|
||||
resize(c, False);
|
||||
i++;
|
||||
}
|
||||
else
|
||||
ban(c);
|
||||
}
|
||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||
if(!sel || !isvisible(sel)) {
|
||||
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||
focus(c);
|
||||
@ -146,7 +123,6 @@ focusnext(Arg *arg) {
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
|
||||
if(!(c = getnext(sel->next)))
|
||||
c = getnext(clients);
|
||||
if(c) {
|
||||
@ -161,7 +137,6 @@ focusprev(Arg *arg) {
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
|
||||
if(!(c = getprev(sel->prev))) {
|
||||
for(c = clients; c && c->next; c = c->next);
|
||||
c = getprev(c);
|
||||
@ -172,6 +147,17 @@ focusprev(Arg *arg) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
incnmaster(Arg *arg) {
|
||||
if((arrange == dofloat) || (nmaster + arg->i < 1) || (wah / (nmaster + arg->i) < bh))
|
||||
return;
|
||||
nmaster += arg->i;
|
||||
if(sel)
|
||||
arrange();
|
||||
else
|
||||
drawstatus();
|
||||
}
|
||||
|
||||
Bool
|
||||
isvisible(Client *c) {
|
||||
unsigned int i;
|
||||
@ -183,57 +169,53 @@ isvisible(Client *c) {
|
||||
}
|
||||
|
||||
void
|
||||
resizecol(Arg *arg) {
|
||||
unsigned int n;
|
||||
Client *c;
|
||||
|
||||
for(n = 0, c = clients; c; c = c->next)
|
||||
if(isvisible(c) && !c->isfloat)
|
||||
n++;
|
||||
if(!sel || sel->isfloat || n < 2 || (arrange != dotile) || maximized)
|
||||
return;
|
||||
|
||||
if(sel == getnext(clients)) {
|
||||
if(mw + arg->i > sw - 100 || mw + arg->i < 100)
|
||||
return;
|
||||
mw += arg->i;
|
||||
}
|
||||
resizemaster(Arg *arg) {
|
||||
if(arg->i == 0)
|
||||
master = MASTER;
|
||||
else {
|
||||
if(mw - arg->i > sw - 100 || mw - arg->i < 100)
|
||||
if(master + arg->i > 950 || master + arg->i < 50)
|
||||
return;
|
||||
mw -= arg->i;
|
||||
master += arg->i;
|
||||
}
|
||||
arrange(NULL);
|
||||
arrange();
|
||||
}
|
||||
|
||||
void
|
||||
restack() {
|
||||
restack(void) {
|
||||
Client *c;
|
||||
XEvent ev;
|
||||
|
||||
if(!sel) {
|
||||
drawstatus();
|
||||
if(!sel)
|
||||
return;
|
||||
}
|
||||
if(sel->isfloat || arrange == dofloat) {
|
||||
if(sel->isfloat || arrange == dofloat)
|
||||
XRaiseWindow(dpy, sel->win);
|
||||
XRaiseWindow(dpy, sel->twin);
|
||||
}
|
||||
if(arrange != dofloat)
|
||||
if(arrange != dofloat) {
|
||||
if(!sel->isfloat)
|
||||
XLowerWindow(dpy, sel->win);
|
||||
for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
|
||||
XLowerWindow(dpy, c->twin);
|
||||
if(c == sel)
|
||||
continue;
|
||||
XLowerWindow(dpy, c->win);
|
||||
}
|
||||
drawall();
|
||||
}
|
||||
XSync(dpy, False);
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
}
|
||||
|
||||
void
|
||||
togglefloat(Arg *arg) {
|
||||
if (!sel || arrange == dofloat)
|
||||
return;
|
||||
sel->isfloat = !sel->isfloat;
|
||||
arrange();
|
||||
}
|
||||
|
||||
void
|
||||
togglemode(Arg *arg) {
|
||||
arrange = (arrange == dofloat) ? dotile : dofloat;
|
||||
if(sel)
|
||||
arrange(NULL);
|
||||
arrange();
|
||||
else
|
||||
drawstatus();
|
||||
}
|
||||
@ -246,8 +228,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);
|
||||
arrange();
|
||||
}
|
||||
|
||||
void
|
||||
@ -255,20 +236,10 @@ view(Arg *arg) {
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < ntags; i++)
|
||||
seltag[i] = False;
|
||||
seltag[i] = (arg->i == -1) ? True : False;
|
||||
if(arg->i >= 0 && arg->i < ntags)
|
||||
seltag[arg->i] = True;
|
||||
reorder();
|
||||
arrange(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
viewall(Arg *arg) {
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < ntags; i++)
|
||||
seltag[i] = True;
|
||||
reorder();
|
||||
arrange(NULL);
|
||||
arrange();
|
||||
}
|
||||
|
||||
void
|
||||
@ -276,11 +247,14 @@ zoom(Arg *arg) {
|
||||
unsigned int n;
|
||||
Client *c;
|
||||
|
||||
for(n = 0, c = clients; c; c = c->next)
|
||||
if(isvisible(c) && !c->isfloat)
|
||||
n++;
|
||||
if(!sel || sel->isfloat || n < 2 || (arrange != dotile) || maximized)
|
||||
if(!sel)
|
||||
return;
|
||||
if(sel->isfloat || (arrange == dofloat)) {
|
||||
togglemax(sel);
|
||||
return;
|
||||
}
|
||||
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
|
||||
n++;
|
||||
|
||||
if((c = sel) == nexttiled(clients))
|
||||
if(!(c = nexttiled(c->next)))
|
||||
@ -291,5 +265,5 @@ zoom(Arg *arg) {
|
||||
c->next = clients;
|
||||
clients = c;
|
||||
focus(c);
|
||||
arrange(NULL);
|
||||
arrange();
|
||||
}
|
||||
|
Reference in New Issue
Block a user