Compare commits
147 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
2511b5c675 | |||
28aba061ec | |||
8e37c78ce3 | |||
ca68975ff8 | |||
529be52fea | |||
ca65478c89 | |||
a1e9362d38 | |||
cbfc69e310 | |||
1d7674bb22 | |||
e6cc22396a | |||
868159fd0a | |||
b597fa4637 | |||
d2d394eccf | |||
438beeabde | |||
281f0981a6 | |||
6ff346bed9 | |||
0925dd588c | |||
6f20315dff | |||
2e68f22118 | |||
8aa860d270 | |||
15abade272 | |||
7ab8c87281 | |||
4ff8f71643 | |||
d22abeee86 | |||
a33150eb4b | |||
fd00b3a186 | |||
e8389a4cc0 | |||
6078d756bc | |||
57c49fe867 | |||
c60de1acd4 | |||
69b738c097 | |||
da0b2a2f31 | |||
2378a558a2 | |||
f18ed615ae | |||
f6656fffb4 | |||
aaad7bfd15 | |||
0915da8842 | |||
0d0e8bde13 | |||
838a1ff950 | |||
e1315fd40c | |||
52a3ab1042 | |||
a82e7b765e | |||
0ed0fa4d5b | |||
ec85fddb9a | |||
3a1343a245 | |||
9066ee2eb4 | |||
40bd21ce63 | |||
4633fbec61 | |||
25060031a5 | |||
c7ae6334b7 | |||
eac04882b4 | |||
6499fc4f93 | |||
04f27a5438 | |||
1b3903d6e9 | |||
cc05093b0d | |||
6436dd4438 | |||
26c50c780e |
10
.hgtags
10
.hgtags
@ -10,5 +10,11 @@ fae61afa861755636c4a1070694209ace8efbb6c 0.9
|
|||||||
bbc98e77ae89a7c9232a5be0835f60ea00d8036e 1.0
|
bbc98e77ae89a7c9232a5be0835f60ea00d8036e 1.0
|
||||||
44a55e6e46bf6c231780b09d919977d6f01083de 1.1
|
44a55e6e46bf6c231780b09d919977d6f01083de 1.1
|
||||||
e3179ce2b90451d2807cd53b589d768412b8666b 1.2
|
e3179ce2b90451d2807cd53b589d768412b8666b 1.2
|
||||||
6413ea66b1c2496cfc2173fe58df67cb965eb1da 1.3
|
f5f5cbf016a94b48a8fe9c47f0736e96d166d5d4 1.3
|
||||||
dd44dc937e8b0a46abf1a15a333dba5304e4fe89 1.3
|
3cff9403766bf83a9fc2a0aef230115d68de2a8e 1.4
|
||||||
|
728c9089b079721b43c3347124639a29baa22a97 1.5
|
||||||
|
ad3fa2d185426c51fd5deceae809770363f8d33c 1.6
|
||||||
|
4dbdb61c8b8ce21dee5c7050a6b103855964ed20 1.7
|
||||||
|
d5ad819f2a66a40fa75dd2e44429f3bfc884d07b 1.7.1
|
||||||
|
c71952fa3c7ca848ec38a6923b5c6d0e18fff431 1.8
|
||||||
|
a5567a0d30112822db2627a04a2e7aa3b6c38148 1.9
|
||||||
|
4
README
4
README
@ -1,5 +1,5 @@
|
|||||||
dwm - dynamic window manager
|
dwm - dynamic window manager
|
||||||
----------------------------
|
============================
|
||||||
dwm is an extremely fast, small, and dynamic window manager for X.
|
dwm is an extremely fast, small, and dynamic window manager for X.
|
||||||
|
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ like this in your .xinitrc:
|
|||||||
|
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
echo `date` `uptime | sed 's/.*://; s/,//g'`
|
echo `date` `uptime | sed 's/.*,//'`
|
||||||
sleep 1
|
sleep 1
|
||||||
done | dwm
|
done | dwm
|
||||||
|
|
||||||
|
222
client.c
222
client.c
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
#include "dwm.h"
|
#include "dwm.h"
|
||||||
@ -11,11 +10,17 @@
|
|||||||
/* static functions */
|
/* static functions */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
grabbuttons(Client *c, Bool focus)
|
detachstack(Client *c) {
|
||||||
{
|
Client **tc;
|
||||||
|
for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
|
||||||
|
*tc = c->snext;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
grabbuttons(Client *c, Bool focused) {
|
||||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||||
|
|
||||||
if(focus) {
|
if(focused) {
|
||||||
XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
|
XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
GrabModeAsync, GrabModeSync, None, None);
|
||||||
XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK,
|
XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK,
|
||||||
@ -46,51 +51,47 @@ grabbuttons(Client *c, Bool focus)
|
|||||||
else
|
else
|
||||||
XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
|
XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
|
||||||
GrabModeAsync, GrabModeSync, None, None);
|
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
|
static int
|
||||||
xerrordummy(Display *dsply, XErrorEvent *ee)
|
xerrordummy(Display *dsply, XErrorEvent *ee) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* extern functions */
|
/* extern functions */
|
||||||
|
|
||||||
void
|
void
|
||||||
ban(Client *c)
|
ban(Client *c) {
|
||||||
{
|
|
||||||
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
|
||||||
XMoveWindow(dpy, c->twin, c->tx + 2 * sw, c->ty);
|
XMoveWindow(dpy, c->twin, c->tx + 2 * sw, c->ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
focus(Client *c)
|
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;
|
Client *old;
|
||||||
|
|
||||||
if(!issel)
|
if(!issel || (c && !isvisible(c)))
|
||||||
return;
|
return;
|
||||||
if(!sel)
|
if(!sel)
|
||||||
sel = c;
|
sel = c;
|
||||||
else if(sel != c) {
|
else if(sel != c) {
|
||||||
if(maximized)
|
|
||||||
togglemax(NULL);
|
|
||||||
old = sel;
|
old = sel;
|
||||||
sel = c;
|
sel = c;
|
||||||
if(old) {
|
if(old) {
|
||||||
@ -99,6 +100,9 @@ focus(Client *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(c) {
|
if(c) {
|
||||||
|
detachstack(c);
|
||||||
|
c->snext = stack;
|
||||||
|
stack = c;
|
||||||
grabbuttons(c, True);
|
grabbuttons(c, True);
|
||||||
drawtitle(c);
|
drawtitle(c);
|
||||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||||
@ -108,8 +112,7 @@ focus(Client *c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Client *
|
Client *
|
||||||
getclient(Window w)
|
getclient(Window w) {
|
||||||
{
|
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
for(c = clients; c; c = c->next)
|
for(c = clients; c; c = c->next)
|
||||||
@ -119,8 +122,7 @@ getclient(Window w)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Client *
|
Client *
|
||||||
getctitle(Window w)
|
getctitle(Window w) {
|
||||||
{
|
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
for(c = clients; c; c = c->next)
|
for(c = clients; c; c = c->next)
|
||||||
@ -130,8 +132,7 @@ getctitle(Window w)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gravitate(Client *c, Bool invert)
|
gravitate(Client *c, Bool invert) {
|
||||||
{
|
|
||||||
int dx = 0, dy = 0;
|
int dx = 0, dy = 0;
|
||||||
|
|
||||||
switch(c->grav) {
|
switch(c->grav) {
|
||||||
@ -154,7 +155,6 @@ gravitate(Client *c, Bool invert)
|
|||||||
dy = -(c->h);
|
dy = -(c->h);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (c->grav) {
|
switch (c->grav) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -175,7 +175,6 @@ gravitate(Client *c, Bool invert)
|
|||||||
dx = -(c->w + c->border);
|
dx = -(c->w + c->border);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(invert) {
|
if(invert) {
|
||||||
dx = -dx;
|
dx = -dx;
|
||||||
dy = -dy;
|
dy = -dy;
|
||||||
@ -185,8 +184,7 @@ gravitate(Client *c, Bool invert)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
killclient(Arg *arg)
|
killclient(Arg *arg) {
|
||||||
{
|
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
if(sel->proto & PROTODELWIN)
|
if(sel->proto & PROTODELWIN)
|
||||||
@ -196,34 +194,29 @@ killclient(Arg *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
manage(Window w, XWindowAttributes *wa)
|
manage(Window w, XWindowAttributes *wa) {
|
||||||
{
|
Client *c;
|
||||||
unsigned int i;
|
|
||||||
Client *c, *tc;
|
|
||||||
Window trans;
|
Window trans;
|
||||||
XSetWindowAttributes twa;
|
XSetWindowAttributes twa;
|
||||||
|
|
||||||
c = emallocz(sizeof(Client));
|
c = emallocz(sizeof(Client));
|
||||||
c->tags = emallocz(ntags * sizeof(Bool));
|
c->tags = emallocz(ntags * sizeof(Bool));
|
||||||
c->win = w;
|
c->win = w;
|
||||||
|
c->border = 0;
|
||||||
c->x = c->tx = wa->x;
|
c->x = c->tx = wa->x;
|
||||||
c->y = c->ty = wa->y;
|
c->y = c->ty = wa->y;
|
||||||
c->w = c->tw = wa->width;
|
c->w = c->tw = wa->width;
|
||||||
c->h = wa->height;
|
c->h = wa->height;
|
||||||
c->th = bh;
|
c->th = bh;
|
||||||
|
updatesize(c);
|
||||||
c->border = 0;
|
if(c->x + c->w + 2 * BORDERPX > sw)
|
||||||
setsize(c);
|
c->x = sw - c->w - 2 * BORDERPX;
|
||||||
|
if(c->x < sx)
|
||||||
if(c->x + c->w + 2 > sw)
|
c->x = sx;
|
||||||
c->x = sw - c->w - 2;
|
if(c->y + c->h + 2 * BORDERPX > sh)
|
||||||
if(c->x < 0)
|
c->y = sh - c->h - 2 * BORDERPX;
|
||||||
c->x = 0;
|
|
||||||
if(c->y + c->h + 2 > sh)
|
|
||||||
c->y = sh - c->h - 2;
|
|
||||||
if(c->h != sh && c->y < bh)
|
if(c->h != sh && c->y < bh)
|
||||||
c->y = bh;
|
c->y = bh;
|
||||||
|
|
||||||
c->proto = getproto(c->win);
|
c->proto = getproto(c->win);
|
||||||
XSelectInput(dpy, c->win,
|
XSelectInput(dpy, c->win,
|
||||||
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
||||||
@ -231,40 +224,31 @@ manage(Window w, XWindowAttributes *wa)
|
|||||||
twa.override_redirect = 1;
|
twa.override_redirect = 1;
|
||||||
twa.background_pixmap = ParentRelative;
|
twa.background_pixmap = ParentRelative;
|
||||||
twa.event_mask = ExposureMask | EnterWindowMask;
|
twa.event_mask = ExposureMask | EnterWindowMask;
|
||||||
|
|
||||||
c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
|
c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
|
||||||
0, DefaultDepth(dpy, screen), CopyFromParent,
|
0, DefaultDepth(dpy, screen), CopyFromParent,
|
||||||
DefaultVisual(dpy, screen),
|
DefaultVisual(dpy, screen),
|
||||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
||||||
|
|
||||||
grabbuttons(c, False);
|
grabbuttons(c, False);
|
||||||
if((tc = getclient(trans))) /* inherit tags */
|
updatetitle(c);
|
||||||
for(i = 0; i < ntags; i++)
|
settags(c, getclient(trans));
|
||||||
c->tags[i] = tc->tags[i];
|
|
||||||
else
|
|
||||||
settags(c);
|
|
||||||
if(!c->isfloat)
|
if(!c->isfloat)
|
||||||
c->isfloat = trans
|
c->isfloat = trans || c->isfixed;
|
||||||
|| (c->maxw && c->minw &&
|
resizetitle(c);
|
||||||
c->maxw == c->minw && c->maxh == c->minh);
|
|
||||||
|
|
||||||
if(clients)
|
if(clients)
|
||||||
clients->prev = c;
|
clients->prev = c;
|
||||||
c->next = clients;
|
c->next = clients;
|
||||||
clients = c;
|
c->snext = stack;
|
||||||
|
stack = clients = c;
|
||||||
settitle(c);
|
|
||||||
ban(c);
|
ban(c);
|
||||||
XMapWindow(dpy, c->win);
|
XMapWindow(dpy, c->win);
|
||||||
XMapWindow(dpy, c->twin);
|
XMapWindow(dpy, c->twin);
|
||||||
if(isvisible(c))
|
if(isvisible(c))
|
||||||
focus(c);
|
focus(c);
|
||||||
arrange(NULL);
|
arrange();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
resize(Client *c, Bool sizehints, Corner sticky)
|
resize(Client *c, Bool sizehints, Corner sticky) {
|
||||||
{
|
|
||||||
int bottom = c->y + c->h;
|
int bottom = c->y + c->h;
|
||||||
int right = c->x + c->w;
|
int right = c->x + c->w;
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
@ -287,7 +271,15 @@ resize(Client *c, Bool sizehints, Corner sticky)
|
|||||||
c->x = right - c->w;
|
c->x = right - c->w;
|
||||||
if(sticky == BotLeft || sticky == BotRight)
|
if(sticky == BotLeft || sticky == BotRight)
|
||||||
c->y = bottom - c->h;
|
c->y = bottom - c->h;
|
||||||
|
/* offscreen appearance fixes */
|
||||||
|
if(c->x + c->w < sx)
|
||||||
|
c->x = sx;
|
||||||
|
if(c->y + c->h < bh)
|
||||||
|
c->y = bh;
|
||||||
|
if(c->x > sw)
|
||||||
|
c->x = sw - c->w;
|
||||||
|
if(c->y > sh)
|
||||||
|
c->y = sh - c->h;
|
||||||
resizetitle(c);
|
resizetitle(c);
|
||||||
wc.x = c->x;
|
wc.x = c->x;
|
||||||
wc.y = c->y;
|
wc.y = c->y;
|
||||||
@ -296,14 +288,27 @@ resize(Client *c, Bool sizehints, Corner sticky)
|
|||||||
if(c->w == sw && c->h == sh)
|
if(c->w == sw && c->h == sh)
|
||||||
wc.border_width = 0;
|
wc.border_width = 0;
|
||||||
else
|
else
|
||||||
wc.border_width = 1;
|
wc.border_width = BORDERPX;
|
||||||
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
|
XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
|
||||||
|
configure(c);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
setsize(Client *c)
|
resizetitle(Client *c) {
|
||||||
{
|
c->tw = textw(c->name);
|
||||||
|
if(c->tw > c->w)
|
||||||
|
c->tw = c->w + 2 * BORDERPX;
|
||||||
|
c->tx = c->x + c->w - c->tw + 2 * BORDERPX;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
updatesize(Client *c) {
|
||||||
long msize;
|
long msize;
|
||||||
XSizeHints size;
|
XSizeHints size;
|
||||||
|
|
||||||
@ -334,6 +339,8 @@ setsize(Client *c)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
c->minw = c->minh = 0;
|
c->minw = c->minh = 0;
|
||||||
|
c->isfixed = (c->maxw && c->minw && c->maxh && c->minh &&
|
||||||
|
c->maxw == c->minw && c->maxh == c->minh);
|
||||||
if(c->flags & PWinGravity)
|
if(c->flags & PWinGravity)
|
||||||
c->grav = size.win_gravity;
|
c->grav = size.win_gravity;
|
||||||
else
|
else
|
||||||
@ -341,8 +348,7 @@ setsize(Client *c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
settitle(Client *c)
|
updatetitle(Client *c) {
|
||||||
{
|
|
||||||
char **list = NULL;
|
char **list = NULL;
|
||||||
int n;
|
int n;
|
||||||
XTextProperty name;
|
XTextProperty name;
|
||||||
@ -365,71 +371,27 @@ settitle(Client *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
XFree(name.value);
|
XFree(name.value);
|
||||||
resizetitle(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
togglemax(Arg *arg)
|
unmanage(Client *c) {
|
||||||
{
|
Client *nc;
|
||||||
int ox, oy, ow, oh;
|
|
||||||
Client *c;
|
|
||||||
XEvent ev;
|
|
||||||
|
|
||||||
if(!sel)
|
/* The server grab construct avoids race conditions. */
|
||||||
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 *tc, *fc;
|
|
||||||
Window trans;
|
|
||||||
XGrabServer(dpy);
|
XGrabServer(dpy);
|
||||||
XSetErrorHandler(xerrordummy);
|
XSetErrorHandler(xerrordummy);
|
||||||
|
|
||||||
detach(c);
|
detach(c);
|
||||||
|
detachstack(c);
|
||||||
if(sel == c) {
|
if(sel == c) {
|
||||||
XGetTransientForHint(dpy, c->win, &trans);
|
for(nc = stack; nc && !isvisible(nc); nc = nc->snext);
|
||||||
if(trans && (tc = getclient(trans)) && isvisible(tc))
|
focus(nc);
|
||||||
fc = tc;
|
|
||||||
else
|
|
||||||
fc = getnext(clients);
|
|
||||||
focus(fc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||||
XDestroyWindow(dpy, c->twin);
|
XDestroyWindow(dpy, c->twin);
|
||||||
|
|
||||||
free(c->tags);
|
free(c->tags);
|
||||||
free(c);
|
free(c);
|
||||||
|
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
XSetErrorHandler(xerror);
|
XSetErrorHandler(xerror);
|
||||||
XUngrabServer(dpy);
|
XUngrabServer(dpy);
|
||||||
arrange(NULL);
|
arrange();
|
||||||
}
|
}
|
||||||
|
31
config.arg.h
31
config.arg.h
@ -1,39 +1,40 @@
|
|||||||
/*
|
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TAGS \
|
#define TAGS \
|
||||||
const char *tags[] = { "dev", "work", "net", "fnord", NULL };
|
const char *tags[] = { "dev", "work", "net", "fnord", NULL };
|
||||||
|
|
||||||
#define DEFMODE dotile /* dofloat */
|
#define DEFMODE dotile /* dofloat */
|
||||||
#define FLOATSYMBOL "><>"
|
#define FLOATSYMBOL "><>"
|
||||||
#define TILESYMBOL "[]="
|
#define TILESYMBOL "[]="
|
||||||
|
|
||||||
#define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
|
#define FONT "-*-terminus-medium-*-*-*-14-*-*-*-*-*-*-*"
|
||||||
#define SELBGCOLOR "#333366"
|
|
||||||
#define SELFGCOLOR "#eeeeee"
|
|
||||||
#define NORMBGCOLOR "#333333"
|
#define NORMBGCOLOR "#333333"
|
||||||
#define NORMFGCOLOR "#dddddd"
|
#define NORMFGCOLOR "#dddddd"
|
||||||
|
#define SELBGCOLOR "#333366"
|
||||||
|
#define SELFGCOLOR "#eeeeee"
|
||||||
#define STATUSBGCOLOR "#222222"
|
#define STATUSBGCOLOR "#222222"
|
||||||
#define STATUSFGCOLOR "#9999cc"
|
#define STATUSFGCOLOR "#9999cc"
|
||||||
|
|
||||||
|
#define MASTER 600 /* per thousand */
|
||||||
#define MODKEY Mod1Mask
|
#define MODKEY Mod1Mask
|
||||||
#define MASTERW 60 /* percent */
|
#define SNAP 40 /* pixel */
|
||||||
|
|
||||||
#define KEYS \
|
#define KEYS \
|
||||||
static Key key[] = { \
|
static Key key[] = { \
|
||||||
/* modifier key function arguments */ \
|
/* modifier key function arguments */ \
|
||||||
{ MODKEY|ShiftMask, XK_Return, spawn, \
|
{ MODKEY|ShiftMask, XK_Return, spawn, \
|
||||||
{ .cmd = "exec uxterm -bg '#111111' -fg '#eeeeee' -cr '#eeeeee' +sb -fn '"FONT"'" } }, \
|
{ .cmd = "exec urxvtc -tr -bg black -fg '#eeeeee' -cr '#eeeeee' +sb -fn '"FONT"'" } }, \
|
||||||
{ MODKEY, XK_p, spawn, \
|
{ MODKEY, XK_p, spawn, \
|
||||||
{ .cmd = "exe=\"$(IFS=:; for dir in $PATH; do " \
|
{ .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \
|
||||||
"for file in \"$dir\"/*; do [ -x \"$file\" ] && echo \"${file##*/}\"; done; " \
|
" | dmenu -font '"FONT"' -normbg '"NORMBGCOLOR"' -normfg '"NORMFGCOLOR"' " \
|
||||||
"done | sort -u | dmenu)\" && exec \"$exe\"" } }, \
|
"-selbg '"SELBGCOLOR"' -selfg '"SELFGCOLOR"')\" && exec $exe" } }, \
|
||||||
{ MODKEY, XK_j, focusnext, { 0 } }, \
|
{ MODKEY, XK_j, focusnext, { 0 } }, \
|
||||||
{ MODKEY, XK_k, focusprev, { 0 } }, \
|
{ MODKEY, XK_k, focusprev, { 0 } }, \
|
||||||
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
||||||
{ MODKEY, XK_m, togglemax, { 0 } }, \
|
{ MODKEY, XK_g, resizecol, { .i = 15 } }, \
|
||||||
|
{ MODKEY, XK_s, resizecol, { .i = -15 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
|
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
|
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
||||||
@ -60,7 +61,7 @@ static Key key[] = { \
|
|||||||
static Rule rule[] = { \
|
static Rule rule[] = { \
|
||||||
/* class:instance:title regex tags regex isfloat */ \
|
/* class:instance:title regex tags regex isfloat */ \
|
||||||
{ "Firefox.*", "net", False }, \
|
{ "Firefox.*", "net", False }, \
|
||||||
{ "Gimp.*", NULL, True}, \
|
{ "Gimp.*", NULL, True }, \
|
||||||
{ "MPlayer.*", NULL, True}, \
|
{ "MPlayer.*", NULL, True }, \
|
||||||
{ "Acroread.*", NULL, True}, \
|
{ "Acroread.*", NULL, True }, \
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -7,19 +6,20 @@
|
|||||||
const char *tags[] = { "1", "2", "3", "4", "5", NULL };
|
const char *tags[] = { "1", "2", "3", "4", "5", NULL };
|
||||||
|
|
||||||
#define DEFMODE dotile /* dofloat */
|
#define DEFMODE dotile /* dofloat */
|
||||||
#define FLOATSYMBOL "~"
|
#define FLOATSYMBOL "><>"
|
||||||
#define TILESYMBOL "#"
|
#define TILESYMBOL "[]="
|
||||||
|
|
||||||
#define FONT "fixed"
|
#define FONT "fixed"
|
||||||
#define SELBGCOLOR "#666699"
|
|
||||||
#define SELFGCOLOR "#eeeeee"
|
|
||||||
#define NORMBGCOLOR "#333366"
|
#define NORMBGCOLOR "#333366"
|
||||||
#define NORMFGCOLOR "#cccccc"
|
#define NORMFGCOLOR "#cccccc"
|
||||||
|
#define SELBGCOLOR "#666699"
|
||||||
|
#define SELFGCOLOR "#eeeeee"
|
||||||
#define STATUSBGCOLOR "#dddddd"
|
#define STATUSBGCOLOR "#dddddd"
|
||||||
#define STATUSFGCOLOR "#222222"
|
#define STATUSFGCOLOR "#222222"
|
||||||
|
|
||||||
|
#define MASTER 600 /* per thousand */
|
||||||
#define MODKEY Mod1Mask
|
#define MODKEY Mod1Mask
|
||||||
#define MASTERW 60 /* percent */
|
#define SNAP 20 /* pixel */
|
||||||
|
|
||||||
#define KEYS \
|
#define KEYS \
|
||||||
static Key key[] = { \
|
static Key key[] = { \
|
||||||
@ -28,7 +28,8 @@ static Key key[] = { \
|
|||||||
{ MODKEY, XK_Tab, focusnext, { 0 } }, \
|
{ MODKEY, XK_Tab, focusnext, { 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \
|
{ MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \
|
||||||
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
||||||
{ MODKEY, XK_m, togglemax, { 0 } }, \
|
{ MODKEY, XK_g, resizecol, { .i = 15 } }, \
|
||||||
|
{ MODKEY, XK_s, resizecol, { .i = -15 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
|
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
|
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
||||||
@ -61,5 +62,5 @@ static Key key[] = { \
|
|||||||
static Rule rule[] = { \
|
static Rule rule[] = { \
|
||||||
/* class:instance:title regex tags regex isfloat */ \
|
/* class:instance:title regex tags regex isfloat */ \
|
||||||
{ "Firefox.*", "2", False }, \
|
{ "Firefox.*", "2", False }, \
|
||||||
{ "Gimp.*", NULL, True}, \
|
{ "Gimp.*", NULL, True }, \
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# dwm version
|
# dwm version
|
||||||
VERSION = 1.3
|
VERSION = 2.0
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
|
45
draw.c
45
draw.c
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
#include "dwm.h"
|
#include "dwm.h"
|
||||||
@ -10,8 +9,7 @@
|
|||||||
/* static */
|
/* static */
|
||||||
|
|
||||||
static unsigned int
|
static unsigned int
|
||||||
textnw(const char *text, unsigned int len)
|
textnw(const char *text, unsigned int len) {
|
||||||
{
|
|
||||||
XRectangle r;
|
XRectangle r;
|
||||||
|
|
||||||
if(dc.font.set) {
|
if(dc.font.set) {
|
||||||
@ -22,8 +20,7 @@ textnw(const char *text, unsigned int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
drawtext(const char *text, unsigned long col[ColLast], Bool highlight)
|
drawtext(const char *text, unsigned long col[ColLast], Bool highlight) {
|
||||||
{
|
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
static char buf[256];
|
static char buf[256];
|
||||||
unsigned int len, olen;
|
unsigned int len, olen;
|
||||||
@ -32,21 +29,17 @@ drawtext(const char *text, unsigned long col[ColLast], Bool highlight)
|
|||||||
|
|
||||||
XSetForeground(dpy, dc.gc, col[ColBG]);
|
XSetForeground(dpy, dc.gc, col[ColBG]);
|
||||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||||
|
|
||||||
if(!text)
|
if(!text)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
w = 0;
|
w = 0;
|
||||||
olen = len = strlen(text);
|
olen = len = strlen(text);
|
||||||
if(len >= sizeof(buf))
|
if(len >= sizeof(buf))
|
||||||
len = sizeof(buf) - 1;
|
len = sizeof(buf) - 1;
|
||||||
memcpy(buf, text, len);
|
memcpy(buf, text, len);
|
||||||
buf[len] = 0;
|
buf[len] = 0;
|
||||||
|
|
||||||
h = dc.font.ascent + dc.font.descent;
|
h = dc.font.ascent + dc.font.descent;
|
||||||
y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
|
y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
|
||||||
x = dc.x + (h / 2);
|
x = dc.x + (h / 2);
|
||||||
|
|
||||||
/* shorten text if necessary */
|
/* shorten text if necessary */
|
||||||
while(len && (w = textnw(buf, len)) > dc.w - h)
|
while(len && (w = textnw(buf, len)) > dc.w - h)
|
||||||
buf[--len] = 0;
|
buf[--len] = 0;
|
||||||
@ -58,7 +51,6 @@ drawtext(const char *text, unsigned long col[ColLast], Bool highlight)
|
|||||||
if(len > 3)
|
if(len > 3)
|
||||||
buf[len - 3] = '.';
|
buf[len - 3] = '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(w > dc.w)
|
if(w > dc.w)
|
||||||
return; /* too long */
|
return; /* too long */
|
||||||
gcv.foreground = col[ColFG];
|
gcv.foreground = col[ColFG];
|
||||||
@ -74,7 +66,7 @@ drawtext(const char *text, unsigned long col[ColLast], Bool highlight)
|
|||||||
if(highlight) {
|
if(highlight) {
|
||||||
r.x = dc.x + 2;
|
r.x = dc.x + 2;
|
||||||
r.y = dc.y + 2;
|
r.y = dc.y + 2;
|
||||||
r.width = r.height = 3;
|
r.width = r.height = (h + 2) / 4;
|
||||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,8 +74,7 @@ drawtext(const char *text, unsigned long col[ColLast], Bool highlight)
|
|||||||
/* extern */
|
/* extern */
|
||||||
|
|
||||||
void
|
void
|
||||||
drawall()
|
drawall(void) {
|
||||||
{
|
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
for(c = clients; c; c = getnext(c->next))
|
for(c = clients; c; c = getnext(c->next))
|
||||||
@ -92,12 +83,10 @@ drawall()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drawstatus()
|
drawstatus(void) {
|
||||||
{
|
|
||||||
int i, x;
|
int i, x;
|
||||||
|
|
||||||
dc.x = dc.y = 0;
|
dc.x = dc.y = 0;
|
||||||
|
|
||||||
for(i = 0; i < ntags; i++) {
|
for(i = 0; i < ntags; i++) {
|
||||||
dc.w = textw(tags[i]);
|
dc.w = textw(tags[i]);
|
||||||
if(seltag[i])
|
if(seltag[i])
|
||||||
@ -106,10 +95,8 @@ drawstatus()
|
|||||||
drawtext(tags[i], dc.norm, sel && sel->tags[i]);
|
drawtext(tags[i], dc.norm, sel && sel->tags[i]);
|
||||||
dc.x += dc.w;
|
dc.x += dc.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
dc.w = bmw;
|
dc.w = bmw;
|
||||||
drawtext(arrange == dotile ? TILESYMBOL : FLOATSYMBOL, dc.status, False);
|
drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.status, False);
|
||||||
|
|
||||||
x = dc.x + dc.w;
|
x = dc.x + dc.w;
|
||||||
dc.w = textw(stext);
|
dc.w = textw(stext);
|
||||||
dc.x = bx + bw - dc.w;
|
dc.x = bx + bw - dc.w;
|
||||||
@ -118,7 +105,6 @@ drawstatus()
|
|||||||
dc.w = bw - x;
|
dc.w = bw - x;
|
||||||
}
|
}
|
||||||
drawtext(stext, dc.status, False);
|
drawtext(stext, dc.status, False);
|
||||||
|
|
||||||
if((dc.w = dc.x - x) > bh) {
|
if((dc.w = dc.x - x) > bh) {
|
||||||
dc.x = x;
|
dc.x = x;
|
||||||
if(sel)
|
if(sel)
|
||||||
@ -131,15 +117,13 @@ drawstatus()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drawtitle(Client *c)
|
drawtitle(Client *c) {
|
||||||
{
|
|
||||||
if(c == sel && issel) {
|
if(c == sel && issel) {
|
||||||
drawstatus();
|
drawstatus();
|
||||||
XUnmapWindow(dpy, c->twin);
|
XUnmapWindow(dpy, c->twin);
|
||||||
XSetWindowBorder(dpy, c->win, dc.sel[ColBG]);
|
XSetWindowBorder(dpy, c->win, dc.sel[ColBG]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
XSetWindowBorder(dpy, c->win, dc.norm[ColBG]);
|
XSetWindowBorder(dpy, c->win, dc.norm[ColBG]);
|
||||||
XMapWindow(dpy, c->twin);
|
XMapWindow(dpy, c->twin);
|
||||||
dc.x = dc.y = 0;
|
dc.x = dc.y = 0;
|
||||||
@ -150,18 +134,17 @@ drawtitle(Client *c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned long
|
unsigned long
|
||||||
getcolor(const char *colstr)
|
getcolor(const char *colstr) {
|
||||||
{
|
|
||||||
Colormap cmap = DefaultColormap(dpy, screen);
|
Colormap cmap = DefaultColormap(dpy, screen);
|
||||||
XColor color;
|
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;
|
return color.pixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
setfont(const char *fontstr)
|
setfont(const char *fontstr) {
|
||||||
{
|
|
||||||
char **missing, *def;
|
char **missing, *def;
|
||||||
int i, n;
|
int i, n;
|
||||||
|
|
||||||
@ -183,7 +166,6 @@ setfont(const char *fontstr)
|
|||||||
XFontSetExtents *font_extents;
|
XFontSetExtents *font_extents;
|
||||||
XFontStruct **xfonts;
|
XFontStruct **xfonts;
|
||||||
char **font_names;
|
char **font_names;
|
||||||
|
|
||||||
dc.font.ascent = dc.font.descent = 0;
|
dc.font.ascent = dc.font.descent = 0;
|
||||||
font_extents = XExtentsOfFontSet(dc.font.set);
|
font_extents = XExtentsOfFontSet(dc.font.set);
|
||||||
n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
|
n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
|
||||||
@ -211,7 +193,6 @@ setfont(const char *fontstr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
textw(const char *text)
|
textw(const char *text) {
|
||||||
{
|
|
||||||
return textnw(text, strlen(text)) + dc.font.height;
|
return textnw(text, strlen(text)) + dc.font.height;
|
||||||
}
|
}
|
||||||
|
137
dwm.1
137
dwm.1
@ -5,28 +5,25 @@ dwm \- dynamic window manager
|
|||||||
.B dwm
|
.B dwm
|
||||||
.RB [ \-v ]
|
.RB [ \-v ]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.B dwm
|
dwm is a dynamic window manager for X. It manages windows in tiling and
|
||||||
is a dynamic window manager for X. It manages windows in tiling and floating
|
floating modes. Either mode can be applied dynamically, optimizing the
|
||||||
modes. Either mode can be applied dynamically, optimizing the environment for
|
environment for the application in use and the task performed.
|
||||||
the application in use and the task performed.
|
|
||||||
.P
|
.P
|
||||||
In tiling mode windows are managed in a master and stacking column. The master
|
In tiling mode windows are managed in a master and stacking area. The master
|
||||||
column contains the window which currently needs most attention, whereas the
|
area contains the window which currently needs most attention, whereas the
|
||||||
stacking column contains all other windows. In floating mode windows can be
|
stacking area contains all other windows. In floating mode windows can be
|
||||||
resized and moved freely. Dialog windows are always managed floating,
|
resized and moved freely. Dialog windows are always managed floating,
|
||||||
regardless of the mode selected.
|
regardless of the mode selected.
|
||||||
.P
|
.P
|
||||||
Windows are grouped by tags. Each window can be tagged with one or multiple
|
Windows are grouped by tags. Each window can be tagged with one or multiple
|
||||||
tags. Selecting a certain tag for viewing will display all windows with that
|
tags. Selecting certain tags displays all windows with these tags.
|
||||||
tag.
|
|
||||||
.P
|
.P
|
||||||
.B dwm
|
dwm contains a small status bar which displays all available tags, the mode,
|
||||||
contains a small status bar which displays all available tags, the mode, the
|
the title of the focused window, and the text read from standard input. The
|
||||||
title of the focused window, and the text read from standard input. The tags of
|
selected tags are highlighted with a different color, the tags of the focused
|
||||||
the focused window are highlighted with a small point.
|
window are highlighted with a small point.
|
||||||
.P
|
.P
|
||||||
.B dwm
|
dwm draws a 1-pixel border around windows to indicate the focus state.
|
||||||
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.
|
Unfocused windows contain a small bar in front of them displaying their title.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
@ -39,30 +36,17 @@ prints version information to standard output, then exits.
|
|||||||
is read and displayed in the status text area.
|
is read and displayed in the status text area.
|
||||||
.TP
|
.TP
|
||||||
.B Button1
|
.B Button1
|
||||||
click on a tag label views all windows with that
|
click on a tag label to display all windows with that tag, click on the mode
|
||||||
.BR tag ,
|
label toggles between tiling and floating mode.
|
||||||
click on the mode label toggles between
|
|
||||||
.B tiled
|
|
||||||
and
|
|
||||||
.B floating
|
|
||||||
mode.
|
|
||||||
.TP
|
.TP
|
||||||
.B Button3
|
.B Button3
|
||||||
click on a tag label adds/removes all windows with that
|
click on a tag label adds/removes all windows with that tag to/from the view.
|
||||||
.B tag
|
|
||||||
to/from the view.
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Button1
|
.B Mod1-Button1
|
||||||
click on a tag label applies that
|
click on a tag label applies that tag to the focused window.
|
||||||
.B tag
|
|
||||||
to the focused
|
|
||||||
.BR window .
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Button3
|
.B Mod1-Button3
|
||||||
click on a tag label adds/removes that
|
click on a tag label adds/removes that tag to/from the focused window.
|
||||||
.B tag
|
|
||||||
to/from the focused
|
|
||||||
.BR window .
|
|
||||||
.SS Keyboard commands
|
.SS Keyboard commands
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Shift-Return
|
.B Mod1-Shift-Return
|
||||||
@ -70,102 +54,69 @@ Start
|
|||||||
.BR xterm (1).
|
.BR xterm (1).
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Tab
|
.B Mod1-Tab
|
||||||
Focus next
|
Focus next window.
|
||||||
.BR window .
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Shift-Tab
|
.B Mod1-Shift-Tab
|
||||||
Focus previous
|
Focus previous window.
|
||||||
.BR window .
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Return
|
.B Mod1-Return
|
||||||
Zoom current
|
Zooms/cycles current window to/from master area (tiling mode), toggles maximization current window (floating mode).
|
||||||
.B window
|
|
||||||
to the
|
|
||||||
.B master
|
|
||||||
column
|
|
||||||
.RB ( tiling
|
|
||||||
mode only).
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-m
|
.B Mod1-g
|
||||||
Maximize current
|
Grow current area (tiling mode only).
|
||||||
.BR window .
|
.TP
|
||||||
|
.B Mod1-s
|
||||||
|
Shrink current area (tiling mode only).
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Shift-[1..n]
|
.B Mod1-Shift-[1..n]
|
||||||
Apply
|
Apply
|
||||||
.B nth tag
|
.RB nth
|
||||||
to current
|
tag to current window.
|
||||||
.BR window .
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Control-Shift-[1..n]
|
.B Mod1-Control-Shift-[1..n]
|
||||||
Add/remove
|
Add/remove
|
||||||
.B nth tag
|
.B nth
|
||||||
to/from current
|
tag to/from current window.
|
||||||
.BR window .
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Shift-c
|
.B Mod1-Shift-c
|
||||||
Close focused
|
Close focused window.
|
||||||
.B window.
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-space
|
.B Mod1-space
|
||||||
Toggle between
|
Toggle between tiling and floating mode (affects all windows).
|
||||||
.B tiled
|
|
||||||
and
|
|
||||||
.B floating
|
|
||||||
mode (affects
|
|
||||||
.BR "all windows" ).
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-[1..n]
|
.B Mod1-[1..n]
|
||||||
View all windows with
|
View all windows with
|
||||||
.BR "tag n" .
|
.BR nth
|
||||||
|
tag.
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-0
|
.B Mod1-0
|
||||||
View all windows with any
|
View all windows with any tag.
|
||||||
.BR "tag" .
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Control-[1..n]
|
.B Mod1-Control-[1..n]
|
||||||
Add/remove all windows with
|
Add/remove all windows with
|
||||||
.B tag n
|
.BR nth
|
||||||
to/from the view.
|
tag to/from the view.
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Shift-q
|
.B Mod1-Shift-q
|
||||||
Quit
|
Quit dwm.
|
||||||
.B dwm.
|
|
||||||
.SS Mouse commands
|
.SS Mouse commands
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Button1
|
.B Mod1-Button1
|
||||||
Move current
|
Move current window while dragging (floating mode only).
|
||||||
.B window
|
|
||||||
while dragging
|
|
||||||
.RB ( floating
|
|
||||||
mode only).
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Button2
|
.B Mod1-Button2
|
||||||
Zoom current
|
Zoom current window to the master area (tiling mode only).
|
||||||
.B window
|
|
||||||
to the
|
|
||||||
.B master
|
|
||||||
column
|
|
||||||
.RB ( tiling
|
|
||||||
mode only).
|
|
||||||
.TP
|
.TP
|
||||||
.B Mod1-Button3
|
.B Mod1-Button3
|
||||||
Resize current
|
Resize current window while dragging (floating mode only).
|
||||||
.B window
|
|
||||||
while dragging
|
|
||||||
.RB ( floating
|
|
||||||
mode only).
|
|
||||||
.SH CUSTOMIZATION
|
.SH CUSTOMIZATION
|
||||||
.B dwm
|
dwm is customized by creating a custom config.h and (re)compiling the source
|
||||||
is customized by creating a custom config.h and (re)compiling the source
|
|
||||||
code. This keeps it fast, secure and simple.
|
code. This keeps it fast, secure and simple.
|
||||||
.SH CAVEATS
|
.SH CAVEATS
|
||||||
The status bar may display
|
The status bar may display
|
||||||
.B broken pipe
|
.BR "broken pipe"
|
||||||
when
|
when dwm has been started by
|
||||||
.B dwm
|
|
||||||
has been started by
|
|
||||||
.BR xdm (1),
|
.BR xdm (1),
|
||||||
because it closes standard output before executing
|
because it closes standard output before executing dwm.
|
||||||
.BR dwm .
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR dmenu (1)
|
.BR dmenu (1)
|
||||||
|
182
dwm.h
182
dwm.h
@ -1,6 +1,34 @@
|
|||||||
/*
|
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* 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 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 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 (_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().
|
||||||
|
*
|
||||||
|
* To understand everything else, start reading main.c:main().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -8,26 +36,23 @@
|
|||||||
|
|
||||||
/* mask shorthands, used in event.c and client.c */
|
/* mask shorthands, used in event.c and client.c */
|
||||||
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
|
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
|
||||||
#define MOUSEMASK (BUTTONMASK | PointerMotionMask)
|
/* other stuff used in different places */
|
||||||
|
#define BORDERPX 1
|
||||||
#define PROTODELWIN 1
|
#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 */
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
const char *cmd;
|
const char *cmd;
|
||||||
int i;
|
int i;
|
||||||
} Arg;
|
} Arg; /* argument type */
|
||||||
|
|
||||||
/* atoms */
|
|
||||||
enum { NetSupported, NetWMName, NetLast };
|
|
||||||
enum { WMProtocols, WMDelete, WMLast };
|
|
||||||
|
|
||||||
/* cursor */
|
|
||||||
enum { CurNormal, CurResize, CurMove, CurLast };
|
|
||||||
|
|
||||||
/* color */
|
|
||||||
enum { ColFG, ColBG, ColLast };
|
|
||||||
|
|
||||||
/* window corners */
|
|
||||||
typedef enum { TopLeft, TopRight, BotLeft, BotRight } Corner;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int ascent;
|
int ascent;
|
||||||
@ -37,7 +62,7 @@ typedef struct {
|
|||||||
XFontStruct *xfont;
|
XFontStruct *xfont;
|
||||||
} Fnt;
|
} Fnt;
|
||||||
|
|
||||||
typedef struct { /* draw context */
|
typedef struct {
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
unsigned long norm[ColLast];
|
unsigned long norm[ColLast];
|
||||||
unsigned long sel[ColLast];
|
unsigned long sel[ColLast];
|
||||||
@ -45,96 +70,101 @@ typedef struct { /* draw context */
|
|||||||
Drawable drawable;
|
Drawable drawable;
|
||||||
Fnt font;
|
Fnt font;
|
||||||
GC gc;
|
GC gc;
|
||||||
} DC;
|
} DC; /* draw context */
|
||||||
|
|
||||||
typedef struct Client Client;
|
typedef struct Client Client;
|
||||||
struct Client {
|
struct Client {
|
||||||
char name[256];
|
char name[256];
|
||||||
int proto;
|
int proto;
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
int tx, ty, tw, th; /* title */
|
int rx, ry, rw, rh; /* revert geometry */
|
||||||
|
int tx, ty, tw, th; /* title window geometry */
|
||||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||||
int grav;
|
int grav;
|
||||||
long flags;
|
long flags;
|
||||||
unsigned int border, weight;
|
unsigned int border, weight;
|
||||||
Bool isfloat;
|
Bool isfloat, isfixed, ismax;
|
||||||
Bool *tags;
|
Bool *tags;
|
||||||
Client *next;
|
Client *next;
|
||||||
Client *prev;
|
Client *prev;
|
||||||
|
Client *snext;
|
||||||
Window win;
|
Window win;
|
||||||
Window twin;
|
Window twin;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const char *tags[];
|
extern const char *tags[]; /* all tags */
|
||||||
extern char stext[1024];
|
extern char stext[1024]; /* status text */
|
||||||
extern int bx, by, bw, bh, bmw, mw, screen, sx, sy, sw, sh;
|
extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */
|
||||||
extern unsigned int ntags, numlockmask;
|
extern int screen, sx, sy, sw, sh; /* screen geometry */
|
||||||
extern void (*handler[LASTEvent])(XEvent *);
|
extern unsigned int master, ntags, numlockmask; /* master percent, number of tags, dynamic lock mask */
|
||||||
extern void (*arrange)(Arg *);
|
extern void (*handler[LASTEvent])(XEvent *); /* event handler */
|
||||||
|
extern void (*arrange)(void); /* arrange function, indicates mode */
|
||||||
extern Atom wmatom[WMLast], netatom[NetLast];
|
extern Atom wmatom[WMLast], netatom[NetLast];
|
||||||
extern Bool running, issel, maximized, *seltag;
|
extern Bool running, issel, *seltag; /* seltag is array of Bool */
|
||||||
extern Client *clients, *sel;
|
extern Client *clients, *sel, *stack; /* global client list and stack */
|
||||||
extern Cursor cursor[CurLast];
|
extern Cursor cursor[CurLast];
|
||||||
extern DC dc;
|
extern DC dc; /* global draw context */
|
||||||
extern Display *dpy;
|
extern Display *dpy;
|
||||||
extern Window root, barwin;
|
extern Window root, barwin;
|
||||||
|
|
||||||
/* client.c */
|
/* client.c */
|
||||||
extern void ban(Client *c);
|
extern void ban(Client *c); /* ban c from screen */
|
||||||
extern void focus(Client *c);
|
extern void configure(Client *c); /* send synthetic configure event */
|
||||||
extern Client *getclient(Window w);
|
extern void focus(Client *c); /* focus c, c may be NULL */
|
||||||
extern Client *getctitle(Window w);
|
extern Client *getclient(Window w); /* return client of w */
|
||||||
extern void gravitate(Client *c, Bool invert);
|
extern Client *getctitle(Window w); /* return client of title window */
|
||||||
extern void killclient(Arg *arg);
|
extern void gravitate(Client *c, Bool invert); /* gravitate c */
|
||||||
extern void manage(Window w, XWindowAttributes *wa);
|
extern void killclient(Arg *arg); /* kill c nicely */
|
||||||
extern void resize(Client *c, Bool sizehints, Corner sticky);
|
extern void manage(Window w, XWindowAttributes *wa); /* manage new client */
|
||||||
extern void setsize(Client *c);
|
extern void resize(Client *c, Bool sizehints, Corner sticky); /* resize c*/
|
||||||
extern void settitle(Client *c);
|
extern void resizetitle(Client *c); /* resizes c->twin correctly */
|
||||||
extern void togglemax(Arg *arg);
|
extern void updatesize(Client *c); /* update the size structs of c */
|
||||||
extern void unmanage(Client *c);
|
extern void updatetitle(Client *c); /* update the name of c */
|
||||||
|
extern void unmanage(Client *c); /* destroy c */
|
||||||
|
|
||||||
/* draw.c */
|
/* draw.c */
|
||||||
extern void drawall();
|
extern void drawall(void); /* draw all visible client titles and the bar */
|
||||||
extern void drawstatus();
|
extern void drawstatus(void); /* draw the bar */
|
||||||
extern void drawtitle(Client *c);
|
extern void drawtitle(Client *c); /* draw title of c */
|
||||||
extern unsigned long getcolor(const char *colstr);
|
extern unsigned long getcolor(const char *colstr); /* return color of colstr */
|
||||||
extern void setfont(const char *fontstr);
|
extern void setfont(const char *fontstr); /* set the font for DC */
|
||||||
extern unsigned int textw(const char *text);
|
extern unsigned int textw(const char *text); /* return the width of text in px*/
|
||||||
|
|
||||||
/* event.c */
|
/* event.c */
|
||||||
extern void grabkeys();
|
extern void grabkeys(void); /* grab all keys defined in config.h */
|
||||||
extern void procevent();
|
extern void procevent(void); /* process pending X events */
|
||||||
|
|
||||||
/* main.c */
|
/* main.c */
|
||||||
extern int getproto(Window w);
|
extern int getproto(Window w); /* return protocol mask of WMProtocols property of w */
|
||||||
extern void quit(Arg *arg);
|
extern void quit(Arg *arg); /* quit dwm nicely */
|
||||||
extern void sendevent(Window w, Atom a, long value);
|
extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
|
||||||
extern int xerror(Display *dsply, XErrorEvent *ee);
|
extern int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
|
||||||
|
|
||||||
/* tag.c */
|
/* tag.c */
|
||||||
extern void initrregs();
|
extern void initrregs(void); /* initialize regexps of rules defined in config.h */
|
||||||
extern Client *getnext(Client *c);
|
extern Client *getnext(Client *c); /* returns next visible client */
|
||||||
extern Client *getprev(Client *c);
|
extern Client *getprev(Client *c); /* returns previous visible client */
|
||||||
extern void settags(Client *c);
|
extern void settags(Client *c, Client *trans); /* sets tags of c */
|
||||||
extern void tag(Arg *arg);
|
extern void tag(Arg *arg); /* tags c with arg's index */
|
||||||
extern void toggletag(Arg *arg);
|
extern void toggletag(Arg *arg); /* toggles c tags with arg's index */
|
||||||
|
|
||||||
/* util.c */
|
/* util.c */
|
||||||
extern void *emallocz(unsigned int size);
|
extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */
|
||||||
extern void eprint(const char *errstr, ...);
|
extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
|
||||||
extern void *erealloc(void *ptr, unsigned int size);
|
extern void *erealloc(void *ptr, unsigned int size); /* reallocates memory, exits on error */
|
||||||
extern void spawn(Arg *arg);
|
extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */
|
||||||
|
|
||||||
/* view.c */
|
/* view.c */
|
||||||
extern void detach(Client *c);
|
extern void detach(Client *c); /* detaches c from global client list */
|
||||||
extern void dofloat(Arg *arg);
|
extern void dofloat(void); /* arranges all windows floating */
|
||||||
extern void dotile(Arg *arg);
|
extern void dotile(void); /* arranges all windows tiled */
|
||||||
extern void focusnext(Arg *arg);
|
extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
|
||||||
extern void focusprev(Arg *arg);
|
extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */
|
||||||
extern Bool isvisible(Client *c);
|
extern Bool isvisible(Client *c); /* returns True if client is visible */
|
||||||
extern void restack();
|
extern void resizecol(Arg *arg); /* resizes the master percent with arg's index value */
|
||||||
extern void togglemode(Arg *arg);
|
extern void restack(void); /* restores z layers of all clients */
|
||||||
extern void toggleview(Arg *arg);
|
extern void togglemode(Arg *arg); /* toggles global arrange function (dotile/dofloat) */
|
||||||
extern void view(Arg *arg);
|
extern void toggleview(Arg *arg); /* toggles the tag with arg's index (in)visible */
|
||||||
extern void viewall(Arg *arg);
|
extern void view(Arg *arg); /* views the tag with arg's index */
|
||||||
extern void zoom(Arg *arg);
|
extern void viewall(Arg *arg); /* views all tags, arg is ignored */
|
||||||
|
extern void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */
|
||||||
|
147
event.c
147
event.c
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
#include "dwm.h"
|
#include "dwm.h"
|
||||||
@ -19,10 +18,10 @@ typedef struct {
|
|||||||
KEYS
|
KEYS
|
||||||
|
|
||||||
#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
|
#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
|
||||||
|
#define MOUSEMASK (BUTTONMASK | PointerMotionMask)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
movemouse(Client *c)
|
movemouse(Client *c) {
|
||||||
{
|
|
||||||
int x1, y1, ocx, ocy, di;
|
int x1, y1, ocx, ocy, di;
|
||||||
unsigned int dui;
|
unsigned int dui;
|
||||||
Window dummy;
|
Window dummy;
|
||||||
@ -33,11 +32,15 @@ movemouse(Client *c)
|
|||||||
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
||||||
None, cursor[CurMove], CurrentTime) != GrabSuccess)
|
None, cursor[CurMove], CurrentTime) != GrabSuccess)
|
||||||
return;
|
return;
|
||||||
|
c->ismax = False;
|
||||||
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
|
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
|
||||||
for(;;) {
|
for(;;) {
|
||||||
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
|
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
|
||||||
switch (ev.type) {
|
switch (ev.type) {
|
||||||
default: break;
|
case ButtonRelease:
|
||||||
|
resize(c, True, TopLeft);
|
||||||
|
XUngrabPointer(dpy, CurrentTime);
|
||||||
|
return;
|
||||||
case Expose:
|
case Expose:
|
||||||
handler[Expose](&ev);
|
handler[Expose](&ev);
|
||||||
break;
|
break;
|
||||||
@ -45,18 +48,22 @@ movemouse(Client *c)
|
|||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
c->x = ocx + (ev.xmotion.x - x1);
|
c->x = ocx + (ev.xmotion.x - x1);
|
||||||
c->y = ocy + (ev.xmotion.y - y1);
|
c->y = ocy + (ev.xmotion.y - y1);
|
||||||
|
if(abs(sx + c->x) < SNAP)
|
||||||
|
c->x = sx;
|
||||||
|
else if(abs((sx + sw) - (c->x + c->w)) < SNAP)
|
||||||
|
c->x = sw - c->w - 2 * BORDERPX;
|
||||||
|
if(abs((sy + bh) - c->y) < SNAP)
|
||||||
|
c->y = sy + bh;
|
||||||
|
else if(abs((sy + sh) - (c->y + c->h)) < SNAP)
|
||||||
|
c->y = sh - c->h - 2 * BORDERPX;
|
||||||
resize(c, False, TopLeft);
|
resize(c, False, TopLeft);
|
||||||
break;
|
break;
|
||||||
case ButtonRelease:
|
|
||||||
XUngrabPointer(dpy, CurrentTime);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
resizemouse(Client *c)
|
resizemouse(Client *c) {
|
||||||
{
|
|
||||||
int ocx, ocy;
|
int ocx, ocy;
|
||||||
int nw, nh;
|
int nw, nh;
|
||||||
Corner sticky;
|
Corner sticky;
|
||||||
@ -65,22 +72,26 @@ resizemouse(Client *c)
|
|||||||
ocx = c->x;
|
ocx = c->x;
|
||||||
ocy = c->y;
|
ocy = c->y;
|
||||||
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
||||||
None, cursor[CurResize], CurrentTime) != GrabSuccess)
|
None, cursor[CurResize], CurrentTime) != GrabSuccess)
|
||||||
return;
|
return;
|
||||||
|
c->ismax = False;
|
||||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
|
||||||
for(;;) {
|
for(;;) {
|
||||||
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
|
XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
|
||||||
switch(ev.type) {
|
switch(ev.type) {
|
||||||
default: break;
|
case ButtonRelease:
|
||||||
|
resize(c, True, TopLeft);
|
||||||
|
XUngrabPointer(dpy, CurrentTime);
|
||||||
|
return;
|
||||||
case Expose:
|
case Expose:
|
||||||
handler[Expose](&ev);
|
handler[Expose](&ev);
|
||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
if((nw = abs(ocx - ev.xmotion.x)))
|
if((nw = abs(ocx - ev.xmotion.x)))
|
||||||
c->w = abs(ocx - ev.xmotion.x);
|
c->w = nw;
|
||||||
if((nh = abs(ocy - ev.xmotion.y)))
|
if((nh = abs(ocy - ev.xmotion.y)))
|
||||||
c->h = abs(ocy - ev.xmotion.y);
|
c->h = nh;
|
||||||
c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
|
c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
|
||||||
c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
|
c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
|
||||||
if(ocx <= ev.xmotion.x)
|
if(ocx <= ev.xmotion.x)
|
||||||
@ -89,16 +100,12 @@ resizemouse(Client *c)
|
|||||||
sticky = (ocy <= ev.xmotion.y) ? TopRight : BotRight;
|
sticky = (ocy <= ev.xmotion.y) ? TopRight : BotRight;
|
||||||
resize(c, True, sticky);
|
resize(c, True, sticky);
|
||||||
break;
|
break;
|
||||||
case ButtonRelease:
|
|
||||||
XUngrabPointer(dpy, CurrentTime);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
buttonpress(XEvent *e)
|
buttonpress(XEvent *e) {
|
||||||
{
|
|
||||||
int x;
|
int x;
|
||||||
Arg a;
|
Arg a;
|
||||||
Client *c;
|
Client *c;
|
||||||
@ -124,60 +131,36 @@ buttonpress(XEvent *e)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ev->x < x + bmw) {
|
if((ev->x < x + bmw) && (ev->button == Button1))
|
||||||
if(ev->button == Button1)
|
togglemode(NULL);
|
||||||
togglemode(NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if((c = getclient(ev->window))) {
|
else if((c = getclient(ev->window))) {
|
||||||
focus(c);
|
focus(c);
|
||||||
if(maximized || CLEANMASK(ev->state) != MODKEY)
|
if(CLEANMASK(ev->state) != MODKEY)
|
||||||
return;
|
return;
|
||||||
if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) {
|
if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) {
|
||||||
restack(c);
|
restack();
|
||||||
movemouse(c);
|
movemouse(c);
|
||||||
}
|
}
|
||||||
else if(ev->button == Button2)
|
else if(ev->button == Button2)
|
||||||
zoom(NULL);
|
zoom(NULL);
|
||||||
else if(ev->button == Button3 && (arrange == dofloat || c->isfloat)) {
|
else if(ev->button == Button3 && (arrange == dofloat || c->isfloat) &&
|
||||||
restack(c);
|
!c->isfixed) {
|
||||||
|
restack();
|
||||||
resizemouse(c);
|
resizemouse(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
synconfig(Client *c, int x, int y, int w, int h, unsigned int border)
|
configurerequest(XEvent *e) {
|
||||||
{
|
|
||||||
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;
|
unsigned long newmask;
|
||||||
Client *c;
|
Client *c;
|
||||||
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
|
|
||||||
if((c = getclient(ev->window))) {
|
if((c = getclient(ev->window))) {
|
||||||
if((c == sel) && !c->isfloat && (arrange != dofloat) && maximized) {
|
c->ismax = False;
|
||||||
synconfig(c, sx, sy + bh, sw - 2, sh - 2 - bh, ev->border_width);
|
|
||||||
XSync(dpy, False);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
gravitate(c, True);
|
gravitate(c, True);
|
||||||
if(ev->value_mask & CWX)
|
if(ev->value_mask & CWX)
|
||||||
c->x = ev->x;
|
c->x = ev->x;
|
||||||
@ -198,12 +181,15 @@ configurerequest(XEvent *e)
|
|||||||
if(newmask)
|
if(newmask)
|
||||||
XConfigureWindow(dpy, c->win, newmask, &wc);
|
XConfigureWindow(dpy, c->win, newmask, &wc);
|
||||||
else
|
else
|
||||||
synconfig(c, c->x, c->y, c->w, c->h, c->border);
|
configure(c);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
if(c->isfloat)
|
if(c->isfloat) {
|
||||||
resize(c, False, TopLeft);
|
resize(c, False, TopLeft);
|
||||||
|
if(!isvisible(c))
|
||||||
|
ban(c);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
arrange(NULL);
|
arrange();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wc.x = ev->x;
|
wc.x = ev->x;
|
||||||
@ -219,8 +205,7 @@ configurerequest(XEvent *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
destroynotify(XEvent *e)
|
destroynotify(XEvent *e) {
|
||||||
{
|
|
||||||
Client *c;
|
Client *c;
|
||||||
XDestroyWindowEvent *ev = &e->xdestroywindow;
|
XDestroyWindowEvent *ev = &e->xdestroywindow;
|
||||||
|
|
||||||
@ -229,15 +214,13 @@ destroynotify(XEvent *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
enternotify(XEvent *e)
|
enternotify(XEvent *e) {
|
||||||
{
|
|
||||||
Client *c;
|
Client *c;
|
||||||
XCrossingEvent *ev = &e->xcrossing;
|
XCrossingEvent *ev = &e->xcrossing;
|
||||||
|
|
||||||
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
|
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
|
||||||
return;
|
return;
|
||||||
|
if(((c = getclient(ev->window)) || (c = getctitle(ev->window))) && isvisible(c))
|
||||||
if((c = getclient(ev->window)) || (c = getctitle(ev->window)))
|
|
||||||
focus(c);
|
focus(c);
|
||||||
else if(ev->window == root) {
|
else if(ev->window == root) {
|
||||||
issel = True;
|
issel = True;
|
||||||
@ -247,8 +230,7 @@ enternotify(XEvent *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
expose(XEvent *e)
|
expose(XEvent *e) {
|
||||||
{
|
|
||||||
Client *c;
|
Client *c;
|
||||||
XExposeEvent *ev = &e->xexpose;
|
XExposeEvent *ev = &e->xexpose;
|
||||||
|
|
||||||
@ -261,8 +243,7 @@ expose(XEvent *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
keypress(XEvent *e)
|
keypress(XEvent *e) {
|
||||||
{
|
|
||||||
static unsigned int len = sizeof(key) / sizeof(key[0]);
|
static unsigned int len = sizeof(key) / sizeof(key[0]);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
KeySym keysym;
|
KeySym keysym;
|
||||||
@ -270,8 +251,8 @@ keypress(XEvent *e)
|
|||||||
|
|
||||||
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
||||||
for(i = 0; i < len; i++) {
|
for(i = 0; i < len; i++) {
|
||||||
if(keysym == key[i].keysym &&
|
if(keysym == key[i].keysym
|
||||||
CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
|
&& CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
|
||||||
{
|
{
|
||||||
if(key[i].func)
|
if(key[i].func)
|
||||||
key[i].func(&key[i].arg);
|
key[i].func(&key[i].arg);
|
||||||
@ -281,8 +262,7 @@ keypress(XEvent *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
leavenotify(XEvent *e)
|
leavenotify(XEvent *e) {
|
||||||
{
|
|
||||||
XCrossingEvent *ev = &e->xcrossing;
|
XCrossingEvent *ev = &e->xcrossing;
|
||||||
|
|
||||||
if((ev->window == root) && !ev->same_screen) {
|
if((ev->window == root) && !ev->same_screen) {
|
||||||
@ -292,8 +272,7 @@ leavenotify(XEvent *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mappingnotify(XEvent *e)
|
mappingnotify(XEvent *e) {
|
||||||
{
|
|
||||||
XMappingEvent *ev = &e->xmapping;
|
XMappingEvent *ev = &e->xmapping;
|
||||||
|
|
||||||
XRefreshKeyboardMapping(ev);
|
XRefreshKeyboardMapping(ev);
|
||||||
@ -302,34 +281,29 @@ mappingnotify(XEvent *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
maprequest(XEvent *e)
|
maprequest(XEvent *e) {
|
||||||
{
|
|
||||||
static XWindowAttributes wa;
|
static XWindowAttributes wa;
|
||||||
XMapRequestEvent *ev = &e->xmaprequest;
|
XMapRequestEvent *ev = &e->xmaprequest;
|
||||||
|
|
||||||
if(!XGetWindowAttributes(dpy, ev->window, &wa))
|
if(!XGetWindowAttributes(dpy, ev->window, &wa))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(wa.override_redirect) {
|
if(wa.override_redirect) {
|
||||||
XSelectInput(dpy, ev->window,
|
XSelectInput(dpy, ev->window,
|
||||||
(StructureNotifyMask | PropertyChangeMask));
|
(StructureNotifyMask | PropertyChangeMask));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!getclient(ev->window))
|
if(!getclient(ev->window))
|
||||||
manage(ev->window, &wa);
|
manage(ev->window, &wa);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
propertynotify(XEvent *e)
|
propertynotify(XEvent *e) {
|
||||||
{
|
|
||||||
Client *c;
|
Client *c;
|
||||||
Window trans;
|
Window trans;
|
||||||
XPropertyEvent *ev = &e->xproperty;
|
XPropertyEvent *ev = &e->xproperty;
|
||||||
|
|
||||||
if(ev->state == PropertyDelete)
|
if(ev->state == PropertyDelete)
|
||||||
return; /* ignore */
|
return; /* ignore */
|
||||||
|
|
||||||
if((c = getclient(ev->window))) {
|
if((c = getclient(ev->window))) {
|
||||||
if(ev->atom == wmatom[WMProtocols]) {
|
if(ev->atom == wmatom[WMProtocols]) {
|
||||||
c->proto = getproto(c->win);
|
c->proto = getproto(c->win);
|
||||||
@ -340,22 +314,22 @@ propertynotify(XEvent *e)
|
|||||||
case XA_WM_TRANSIENT_FOR:
|
case XA_WM_TRANSIENT_FOR:
|
||||||
XGetTransientForHint(dpy, c->win, &trans);
|
XGetTransientForHint(dpy, c->win, &trans);
|
||||||
if(!c->isfloat && (c->isfloat = (trans != 0)))
|
if(!c->isfloat && (c->isfloat = (trans != 0)))
|
||||||
arrange(NULL);
|
arrange();
|
||||||
break;
|
break;
|
||||||
case XA_WM_NORMAL_HINTS:
|
case XA_WM_NORMAL_HINTS:
|
||||||
setsize(c);
|
updatesize(c);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
|
if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
|
||||||
settitle(c);
|
updatetitle(c);
|
||||||
|
resizetitle(c);
|
||||||
drawtitle(c);
|
drawtitle(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unmapnotify(XEvent *e)
|
unmapnotify(XEvent *e) {
|
||||||
{
|
|
||||||
Client *c;
|
Client *c;
|
||||||
XUnmapEvent *ev = &e->xunmap;
|
XUnmapEvent *ev = &e->xunmap;
|
||||||
|
|
||||||
@ -380,8 +354,7 @@ void (*handler[LASTEvent]) (XEvent *) = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
grabkeys()
|
grabkeys(void) {
|
||||||
{
|
|
||||||
static unsigned int len = sizeof(key) / sizeof(key[0]);
|
static unsigned int len = sizeof(key) / sizeof(key[0]);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
KeyCode code;
|
KeyCode code;
|
||||||
@ -401,8 +374,7 @@ grabkeys()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
procevent()
|
procevent(void) {
|
||||||
{
|
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
while(XPending(dpy)) {
|
while(XPending(dpy)) {
|
||||||
@ -411,4 +383,3 @@ procevent()
|
|||||||
(handler[ev.type])(&ev); /* call handler */
|
(handler[ev.type])(&ev); /* call handler */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
78
main.c
78
main.c
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -19,14 +18,14 @@
|
|||||||
|
|
||||||
char stext[1024];
|
char stext[1024];
|
||||||
Bool *seltag;
|
Bool *seltag;
|
||||||
int bx, by, bw, bh, bmw, mw, screen, sx, sy, sw, sh;
|
int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh;
|
||||||
unsigned int ntags, numlockmask;
|
unsigned int master, ntags, numlockmask;
|
||||||
Atom wmatom[WMLast], netatom[NetLast];
|
Atom wmatom[WMLast], netatom[NetLast];
|
||||||
Bool running = True;
|
Bool running = True;
|
||||||
Bool issel = True;
|
Bool issel = True;
|
||||||
Bool maximized = False;
|
|
||||||
Client *clients = NULL;
|
Client *clients = NULL;
|
||||||
Client *sel = NULL;
|
Client *sel = NULL;
|
||||||
|
Client *stack = NULL;
|
||||||
Cursor cursor[CurLast];
|
Cursor cursor[CurLast];
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
DC dc = {0};
|
DC dc = {0};
|
||||||
@ -38,8 +37,7 @@ static int (*xerrorxlib)(Display *, XErrorEvent *);
|
|||||||
static Bool otherwm, readin;
|
static Bool otherwm, readin;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cleanup()
|
cleanup(void) {
|
||||||
{
|
|
||||||
close(STDIN_FILENO);
|
close(STDIN_FILENO);
|
||||||
while(sel) {
|
while(sel) {
|
||||||
resize(sel, True, TopLeft);
|
resize(sel, True, TopLeft);
|
||||||
@ -55,11 +53,11 @@ cleanup()
|
|||||||
XDestroyWindow(dpy, barwin);
|
XDestroyWindow(dpy, barwin);
|
||||||
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
|
free(seltag);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
scan()
|
scan(void) {
|
||||||
{
|
|
||||||
unsigned int i, num;
|
unsigned int i, num;
|
||||||
Window *wins, d1, d2;
|
Window *wins, d1, d2;
|
||||||
XWindowAttributes wa;
|
XWindowAttributes wa;
|
||||||
@ -80,8 +78,7 @@ scan()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup()
|
setup(void) {
|
||||||
{
|
|
||||||
int i, j;
|
int i, j;
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
Window w;
|
Window w;
|
||||||
@ -95,12 +92,11 @@ setup()
|
|||||||
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
||||||
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
|
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
|
||||||
PropModeReplace, (unsigned char *) netatom, NetLast);
|
PropModeReplace, (unsigned char *) netatom, NetLast);
|
||||||
|
|
||||||
/* init cursors */
|
/* init cursors */
|
||||||
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
|
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
|
||||||
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
|
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
|
||||||
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
|
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
|
||||||
|
/* init modifier map */
|
||||||
modmap = XGetModifierMapping(dpy);
|
modmap = XGetModifierMapping(dpy);
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
for (j = 0; j < modmap->max_keypermod; j++) {
|
for (j = 0; j < modmap->max_keypermod; j++) {
|
||||||
@ -109,18 +105,16 @@ setup()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
XFree(modmap);
|
XFree(modmap);
|
||||||
|
/* select for events */
|
||||||
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask | EnterWindowMask | LeaveWindowMask;
|
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
||||||
|
| EnterWindowMask | LeaveWindowMask;
|
||||||
wa.cursor = cursor[CurNormal];
|
wa.cursor = cursor[CurNormal];
|
||||||
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
|
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
|
||||||
|
|
||||||
grabkeys();
|
grabkeys();
|
||||||
initrregs();
|
initrregs();
|
||||||
|
|
||||||
for(ntags = 0; tags[ntags]; ntags++);
|
for(ntags = 0; tags[ntags]; ntags++);
|
||||||
seltag = emallocz(sizeof(Bool) * ntags);
|
seltag = emallocz(sizeof(Bool) * ntags);
|
||||||
seltag[0] = True;
|
seltag[0] = True;
|
||||||
|
|
||||||
/* style */
|
/* style */
|
||||||
dc.norm[ColBG] = getcolor(NORMBGCOLOR);
|
dc.norm[ColBG] = getcolor(NORMBGCOLOR);
|
||||||
dc.norm[ColFG] = getcolor(NORMFGCOLOR);
|
dc.norm[ColFG] = getcolor(NORMFGCOLOR);
|
||||||
@ -129,13 +123,13 @@ setup()
|
|||||||
dc.status[ColBG] = getcolor(STATUSBGCOLOR);
|
dc.status[ColBG] = getcolor(STATUSBGCOLOR);
|
||||||
dc.status[ColFG] = getcolor(STATUSFGCOLOR);
|
dc.status[ColFG] = getcolor(STATUSFGCOLOR);
|
||||||
setfont(FONT);
|
setfont(FONT);
|
||||||
|
/* geometry */
|
||||||
bmw = textw(FLOATSYMBOL) > textw(TILESYMBOL) ? textw(FLOATSYMBOL) : textw(TILESYMBOL);
|
bmw = textw(TILESYMBOL) > textw(FLOATSYMBOL) ? textw(TILESYMBOL) : textw(FLOATSYMBOL);
|
||||||
sx = sy = 0;
|
sx = sy = 0;
|
||||||
sw = DisplayWidth(dpy, screen);
|
sw = DisplayWidth(dpy, screen);
|
||||||
sh = DisplayHeight(dpy, screen);
|
sh = DisplayHeight(dpy, screen);
|
||||||
mw = (sw * MASTERW) / 100;
|
master = MASTER;
|
||||||
|
/* bar */
|
||||||
bx = by = 0;
|
bx = by = 0;
|
||||||
bw = sw;
|
bw = sw;
|
||||||
dc.h = bh = dc.font.height + 2;
|
dc.h = bh = dc.font.height + 2;
|
||||||
@ -147,13 +141,13 @@ setup()
|
|||||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||||
XDefineCursor(dpy, barwin, cursor[CurNormal]);
|
XDefineCursor(dpy, barwin, cursor[CurNormal]);
|
||||||
XMapRaised(dpy, barwin);
|
XMapRaised(dpy, barwin);
|
||||||
|
strcpy(stext, "dwm-"VERSION);
|
||||||
|
/* pixmap for everything */
|
||||||
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
|
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
|
||||||
dc.gc = XCreateGC(dpy, root, 0, 0);
|
dc.gc = XCreateGC(dpy, root, 0, 0);
|
||||||
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
||||||
|
/* multihead support */
|
||||||
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
||||||
strcpy(stext, "dwm-"VERSION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -161,8 +155,7 @@ setup()
|
|||||||
* is already running.
|
* is already running.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
xerrorstart(Display *dsply, XErrorEvent *ee)
|
xerrorstart(Display *dsply, XErrorEvent *ee) {
|
||||||
{
|
|
||||||
otherwm = True;
|
otherwm = True;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -170,8 +163,7 @@ xerrorstart(Display *dsply, XErrorEvent *ee)
|
|||||||
/* extern */
|
/* extern */
|
||||||
|
|
||||||
int
|
int
|
||||||
getproto(Window w)
|
getproto(Window w) {
|
||||||
{
|
|
||||||
int i, format, protos, status;
|
int i, format, protos, status;
|
||||||
unsigned long extra, res;
|
unsigned long extra, res;
|
||||||
Atom *protocols, real;
|
Atom *protocols, real;
|
||||||
@ -189,8 +181,7 @@ getproto(Window w)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sendevent(Window w, Atom a, long value)
|
sendevent(Window w, Atom a, long value) {
|
||||||
{
|
|
||||||
XEvent e;
|
XEvent e;
|
||||||
|
|
||||||
e.type = ClientMessage;
|
e.type = ClientMessage;
|
||||||
@ -204,35 +195,32 @@ sendevent(Window w, Atom a, long value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
quit(Arg *arg)
|
quit(Arg *arg) {
|
||||||
{
|
|
||||||
readin = running = False;
|
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
|
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
|
||||||
* default error handler, which calls exit().
|
* default error handler, which may call exit.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xerror(Display *dpy, XErrorEvent *ee)
|
xerror(Display *dpy, XErrorEvent *ee) {
|
||||||
{
|
|
||||||
if(ee->error_code == BadWindow
|
if(ee->error_code == BadWindow
|
||||||
|| (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
|
|| (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
|
||||||
|| (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
|
|| (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
|
||||||
|| (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable)
|
|| (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable)
|
||||||
|| (ee->request_code == X_PolySegment && ee->error_code == BadDrawable)
|
|| (ee->request_code == X_PolySegment && ee->error_code == BadDrawable)
|
||||||
|| (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch)
|
|| (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch)
|
||||||
|| (ee->request_code == X_GrabKey && ee->error_code == BadAccess))
|
|| (ee->request_code == X_GrabKey && ee->error_code == BadAccess)
|
||||||
|
|| (ee->request_code == X_CopyArea && ee->error_code == BadDrawable))
|
||||||
return 0;
|
return 0;
|
||||||
fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
|
fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
|
||||||
ee->request_code, ee->error_code);
|
ee->request_code, ee->error_code);
|
||||||
return xerrorxlib(dpy, ee); /* may call exit() */
|
return xerrorxlib(dpy, ee); /* may call exit */
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[]) {
|
||||||
{
|
|
||||||
int r, xfd;
|
int r, xfd;
|
||||||
fd_set rd;
|
fd_set rd;
|
||||||
|
|
||||||
@ -242,21 +230,17 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if(argc != 1)
|
else if(argc != 1)
|
||||||
eprint("usage: dwm [-v]\n");
|
eprint("usage: dwm [-v]\n");
|
||||||
|
|
||||||
dpy = XOpenDisplay(0);
|
dpy = XOpenDisplay(0);
|
||||||
if(!dpy)
|
if(!dpy)
|
||||||
eprint("dwm: cannot open display\n");
|
eprint("dwm: cannot open display\n");
|
||||||
|
|
||||||
xfd = ConnectionNumber(dpy);
|
xfd = ConnectionNumber(dpy);
|
||||||
screen = DefaultScreen(dpy);
|
screen = DefaultScreen(dpy);
|
||||||
root = RootWindow(dpy, screen);
|
root = RootWindow(dpy, screen);
|
||||||
|
|
||||||
otherwm = False;
|
otherwm = False;
|
||||||
XSetErrorHandler(xerrorstart);
|
XSetErrorHandler(xerrorstart);
|
||||||
/* this causes an error if some other window manager is running */
|
/* this causes an error if some other window manager is running */
|
||||||
XSelectInput(dpy, root, SubstructureRedirectMask);
|
XSelectInput(dpy, root, SubstructureRedirectMask);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
|
|
||||||
if(otherwm)
|
if(otherwm)
|
||||||
eprint("dwm: another window manager is already running\n");
|
eprint("dwm: another window manager is already running\n");
|
||||||
|
|
||||||
@ -264,7 +248,6 @@ main(int argc, char *argv[])
|
|||||||
XSetErrorHandler(NULL);
|
XSetErrorHandler(NULL);
|
||||||
xerrorxlib = XSetErrorHandler(xerror);
|
xerrorxlib = XSetErrorHandler(xerror);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
drawstatus();
|
drawstatus();
|
||||||
scan();
|
scan();
|
||||||
@ -297,6 +280,5 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
cleanup();
|
cleanup();
|
||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
41
tag.c
41
tag.c
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
#include "dwm.h"
|
#include "dwm.h"
|
||||||
@ -33,22 +32,19 @@ static unsigned int len = 0;
|
|||||||
/* extern */
|
/* extern */
|
||||||
|
|
||||||
Client *
|
Client *
|
||||||
getnext(Client *c)
|
getnext(Client *c) {
|
||||||
{
|
|
||||||
for(; c && !isvisible(c); c = c->next);
|
for(; c && !isvisible(c); c = c->next);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *
|
Client *
|
||||||
getprev(Client *c)
|
getprev(Client *c) {
|
||||||
{
|
|
||||||
for(; c && !isvisible(c); c = c->prev);
|
for(; c && !isvisible(c); c = c->prev);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
initrregs()
|
initrregs(void) {
|
||||||
{
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
regex_t *reg;
|
regex_t *reg;
|
||||||
|
|
||||||
@ -56,7 +52,6 @@ initrregs()
|
|||||||
return;
|
return;
|
||||||
len = sizeof(rule) / sizeof(rule[0]);
|
len = sizeof(rule) / sizeof(rule[0]);
|
||||||
rreg = emallocz(len * sizeof(RReg));
|
rreg = emallocz(len * sizeof(RReg));
|
||||||
|
|
||||||
for(i = 0; i < len; i++) {
|
for(i = 0; i < len; i++) {
|
||||||
if(rule[i].clpattern) {
|
if(rule[i].clpattern) {
|
||||||
reg = emallocz(sizeof(regex_t));
|
reg = emallocz(sizeof(regex_t));
|
||||||
@ -76,15 +71,18 @@ initrregs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
settags(Client *c)
|
settags(Client *c, Client *trans) {
|
||||||
{
|
|
||||||
char prop[512];
|
char prop[512];
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
regmatch_t tmp;
|
regmatch_t tmp;
|
||||||
Bool matched = False;
|
Bool matched = trans != NULL;
|
||||||
XClassHint ch;
|
XClassHint ch;
|
||||||
|
|
||||||
if(XGetClassHint(dpy, c->win, &ch)) {
|
if(matched) {
|
||||||
|
for(i = 0; i < ntags; i++)
|
||||||
|
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_class ? ch.res_class : "",
|
||||||
ch.res_name ? ch.res_name : "", c->name);
|
ch.res_name ? ch.res_name : "", c->name);
|
||||||
@ -106,35 +104,32 @@ settags(Client *c)
|
|||||||
if(!matched)
|
if(!matched)
|
||||||
for(i = 0; i < ntags; i++)
|
for(i = 0; i < ntags; i++)
|
||||||
c->tags[i] = seltag[i];
|
c->tags[i] = seltag[i];
|
||||||
for(i = 0; i < ntags && !c->tags[i]; i++);
|
for(c->weight = 0; c->weight < ntags && !c->tags[c->weight]; c->weight++);
|
||||||
c->weight = i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tag(Arg *arg)
|
tag(Arg *arg) {
|
||||||
{
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(i = 0; i < ntags; i++)
|
for(i = 0; i < ntags; i++)
|
||||||
sel->tags[i] = False;
|
sel->tags[i] = False;
|
||||||
sel->tags[arg->i] = True;
|
sel->tags[arg->i] = True;
|
||||||
arrange(NULL);
|
sel->weight = arg->i;
|
||||||
|
arrange();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
toggletag(Arg *arg)
|
toggletag(Arg *arg) {
|
||||||
{
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sel->tags[arg->i] = !sel->tags[arg->i];
|
sel->tags[arg->i] = !sel->tags[arg->i];
|
||||||
for(i = 0; i < ntags && !sel->tags[i]; i++);
|
for(i = 0; i < ntags && !sel->tags[i]; i++);
|
||||||
if(i == ntags)
|
if(i == ntags)
|
||||||
sel->tags[arg->i] = True;
|
sel->tags[arg->i] = True;
|
||||||
arrange(NULL);
|
sel->weight = (i == ntags) ? arg->i : i;
|
||||||
|
arrange();
|
||||||
}
|
}
|
||||||
|
20
util.c
20
util.c
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
#include "dwm.h"
|
#include "dwm.h"
|
||||||
@ -12,8 +11,7 @@
|
|||||||
/* extern */
|
/* extern */
|
||||||
|
|
||||||
void *
|
void *
|
||||||
emallocz(unsigned int size)
|
emallocz(unsigned int size) {
|
||||||
{
|
|
||||||
void *res = calloc(1, size);
|
void *res = calloc(1, size);
|
||||||
|
|
||||||
if(!res)
|
if(!res)
|
||||||
@ -22,8 +20,7 @@ emallocz(unsigned int size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
eprint(const char *errstr, ...)
|
eprint(const char *errstr, ...) {
|
||||||
{
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, errstr);
|
va_start(ap, errstr);
|
||||||
@ -33,25 +30,24 @@ eprint(const char *errstr, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
erealloc(void *ptr, unsigned int size)
|
erealloc(void *ptr, unsigned int size) {
|
||||||
{
|
|
||||||
void *res = realloc(ptr, size);
|
void *res = realloc(ptr, size);
|
||||||
|
|
||||||
if(!res)
|
if(!res)
|
||||||
eprint("fatal: could not malloc() %u bytes\n", size);
|
eprint("fatal: could not malloc() %u bytes\n", size);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spawn(Arg *arg)
|
spawn(Arg *arg) {
|
||||||
{
|
|
||||||
static char *shell = NULL;
|
static char *shell = NULL;
|
||||||
|
|
||||||
if(!shell && !(shell = getenv("SHELL")))
|
if(!shell && !(shell = getenv("SHELL")))
|
||||||
shell = "/bin/sh";
|
shell = "/bin/sh";
|
||||||
|
|
||||||
if(!arg->cmd)
|
if(!arg->cmd)
|
||||||
return;
|
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(fork() == 0) {
|
if(fork() == 0) {
|
||||||
if(dpy)
|
if(dpy)
|
||||||
|
264
view.c
264
view.c
@ -1,27 +1,30 @@
|
|||||||
/*
|
/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
#include "dwm.h"
|
#include "dwm.h"
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
|
||||||
static Client *
|
static Client *
|
||||||
minclient()
|
minclient(void) {
|
||||||
{
|
|
||||||
Client *c, *min;
|
Client *c, *min;
|
||||||
|
|
||||||
|
if((clients && clients->isfloat) || arrange == dofloat)
|
||||||
|
return clients; /* don't touch floating order */
|
||||||
for(min = c = clients; c; c = c->next)
|
for(min = c = clients; c; c = c->next)
|
||||||
if(c->weight < min->weight)
|
if(c->weight < min->weight)
|
||||||
min = c;
|
min = c;
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Client *
|
||||||
|
nexttiled(Client *c) {
|
||||||
|
for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
reorder()
|
reorder(void) {
|
||||||
{
|
|
||||||
Client *c, *newclients, *tail;
|
Client *c, *newclients, *tail;
|
||||||
|
|
||||||
newclients = tail = NULL;
|
newclients = tail = NULL;
|
||||||
@ -38,13 +41,35 @@ reorder()
|
|||||||
clients = newclients;
|
clients = newclients;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
togglemax(Client *c) {
|
||||||
|
XEvent ev;
|
||||||
|
|
||||||
|
if(c->isfixed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if((c->ismax = !c->ismax)) {
|
||||||
|
c->rx = c->x; c->x = sx;
|
||||||
|
c->ry = c->y; c->y = bh;
|
||||||
|
c->rw = c->w; c->w = sw - 2 * BORDERPX;
|
||||||
|
c->rh = c->h; c->h = sh - bh - 2 * BORDERPX;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
c->x = c->rx;
|
||||||
|
c->y = c->ry;
|
||||||
|
c->w = c->rw;
|
||||||
|
c->h = c->rh;
|
||||||
|
}
|
||||||
|
resize(c, True, TopLeft);
|
||||||
|
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||||
|
}
|
||||||
|
|
||||||
/* extern */
|
/* extern */
|
||||||
|
|
||||||
void (*arrange)(Arg *) = DEFMODE;
|
void (*arrange)(void) = DEFMODE;
|
||||||
|
|
||||||
void
|
void
|
||||||
detach(Client *c)
|
detach(Client *c) {
|
||||||
{
|
|
||||||
if(c->prev)
|
if(c->prev)
|
||||||
c->prev->next = c->next;
|
c->prev->next = c->next;
|
||||||
if(c->next)
|
if(c->next)
|
||||||
@ -55,12 +80,9 @@ detach(Client *c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dofloat(Arg *arg)
|
dofloat(void) {
|
||||||
{
|
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
maximized = False;
|
|
||||||
|
|
||||||
for(c = clients; c; c = c->next) {
|
for(c = clients; c; c = c->next) {
|
||||||
if(isvisible(c)) {
|
if(isvisible(c)) {
|
||||||
resize(c, True, TopLeft);
|
resize(c, True, TopLeft);
|
||||||
@ -68,81 +90,76 @@ dofloat(Arg *arg)
|
|||||||
else
|
else
|
||||||
ban(c);
|
ban(c);
|
||||||
}
|
}
|
||||||
if(!sel || !isvisible(sel))
|
if(!sel || !isvisible(sel)) {
|
||||||
focus(getnext(clients));
|
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||||
|
focus(c);
|
||||||
|
}
|
||||||
restack();
|
restack();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dotile(Arg *arg)
|
dotile(void) {
|
||||||
{
|
unsigned int i, n, mpx, stackw, stackh, th;
|
||||||
int h, i, n, w;
|
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
maximized = False;
|
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
|
||||||
|
n++;
|
||||||
w = sw - mw;
|
mpx = (sw * master) / 1000;
|
||||||
for(n = 0, c = clients; c; c = c->next)
|
stackw = sw - mpx;
|
||||||
if(isvisible(c) && !c->isfloat)
|
stackh = sh - bh;
|
||||||
n++;
|
th = stackh;
|
||||||
|
|
||||||
if(n > 1)
|
if(n > 1)
|
||||||
h = (sh - bh) / (n - 1);
|
th /= (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(isvisible(c)) {
|
||||||
if(c->isfloat) {
|
if(c->isfloat) {
|
||||||
resize(c, True, TopLeft);
|
resize(c, True, TopLeft);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(n == 1) {
|
c->ismax = False;
|
||||||
c->x = sx;
|
c->x = sx;
|
||||||
c->y = sy + bh;
|
c->y = sy + bh;
|
||||||
c->w = sw - 2;
|
if(n == 1) { /* only 1 window */
|
||||||
c->h = sh - 2 - bh;
|
c->w = sw - 2 * BORDERPX;
|
||||||
|
c->h = sh - 2 * BORDERPX - bh;
|
||||||
}
|
}
|
||||||
else if(i == 0) {
|
else if(i == 0) { /* master window */
|
||||||
c->x = sx;
|
c->w = mpx - 2 * BORDERPX;
|
||||||
c->y = sy + bh;
|
c->h = sh - bh - 2 * BORDERPX;
|
||||||
c->w = mw - 2;
|
|
||||||
c->h = sh - 2 - bh;
|
|
||||||
}
|
}
|
||||||
else if(h > bh) {
|
else { /* tile window */
|
||||||
c->x = sx + mw;
|
c->x += mpx;
|
||||||
c->y = sy + (i - 1) * h + bh;
|
c->w = stackw - 2 * BORDERPX;
|
||||||
c->w = w - 2;
|
if(th > bh) {
|
||||||
if(i + 1 == n)
|
c->y = sy + (i - 1) * th + bh;
|
||||||
c->h = sh - c->y - 2;
|
if(i + 1 == n)
|
||||||
else
|
c->h = sh - c->y - 2 * BORDERPX;
|
||||||
c->h = h - 2;
|
else
|
||||||
}
|
c->h = th - 2 * BORDERPX;
|
||||||
else { /* fallback if h < bh */
|
}
|
||||||
c->x = sx + mw;
|
else /* fallback if th < bh */
|
||||||
c->y = sy + bh;
|
c->h = stackh - 2 * BORDERPX;
|
||||||
c->w = w - 2;
|
|
||||||
c->h = sh - 2 - bh;
|
|
||||||
}
|
}
|
||||||
resize(c, False, TopLeft);
|
resize(c, False, TopLeft);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ban(c);
|
ban(c);
|
||||||
|
|
||||||
|
if(!sel || !isvisible(sel)) {
|
||||||
|
for(c = stack; c && !isvisible(c); c = c->snext);
|
||||||
|
focus(c);
|
||||||
}
|
}
|
||||||
if(!sel || !isvisible(sel))
|
|
||||||
focus(getnext(clients));
|
|
||||||
restack();
|
restack();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
focusnext(Arg *arg)
|
focusnext(Arg *arg) {
|
||||||
{
|
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!(c = getnext(sel->next)))
|
if(!(c = getnext(sel->next)))
|
||||||
c = getnext(clients);
|
c = getnext(clients);
|
||||||
if(c) {
|
if(c) {
|
||||||
@ -152,13 +169,11 @@ focusnext(Arg *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
focusprev(Arg *arg)
|
focusprev(Arg *arg) {
|
||||||
{
|
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!(c = getprev(sel->prev))) {
|
if(!(c = getprev(sel->prev))) {
|
||||||
for(c = clients; c && c->next; c = c->next);
|
for(c = clients; c && c->next; c = c->next);
|
||||||
c = getprev(c);
|
c = getprev(c);
|
||||||
@ -170,8 +185,7 @@ focusprev(Arg *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
isvisible(Client *c)
|
isvisible(Client *c) {
|
||||||
{
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for(i = 0; i < ntags; i++)
|
for(i = 0; i < ntags; i++)
|
||||||
@ -181,70 +195,69 @@ isvisible(Client *c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
restack()
|
resizecol(Arg *arg) {
|
||||||
{
|
unsigned int n;
|
||||||
static unsigned int nwins = 0;
|
Client *c;
|
||||||
static Window *wins = NULL;
|
|
||||||
unsigned int f, fi, m, mi, n;
|
for(n = 0, c = clients; c; c = c->next)
|
||||||
|
if(isvisible(c) && !c->isfloat)
|
||||||
|
n++;
|
||||||
|
if(!sel || sel->isfloat || n < 2 || (arrange == dofloat))
|
||||||
|
return;
|
||||||
|
if(sel == getnext(clients)) {
|
||||||
|
if(master + arg->i > 950 || master + arg->i < 50)
|
||||||
|
return;
|
||||||
|
master += arg->i;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(master - arg->i > 950 || master - arg->i < 50)
|
||||||
|
return;
|
||||||
|
master -= arg->i;
|
||||||
|
}
|
||||||
|
arrange();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
restack(void) {
|
||||||
Client *c;
|
Client *c;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
for(f = 0, m = 0, c = clients; c; c = c->next)
|
if(!sel) {
|
||||||
if(isvisible(c)) {
|
|
||||||
if(c->isfloat || arrange == dofloat)
|
|
||||||
f++;
|
|
||||||
else
|
|
||||||
m++;
|
|
||||||
}
|
|
||||||
if(!(n = 2 * (f + m))) {
|
|
||||||
drawstatus();
|
drawstatus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(nwins < n) {
|
|
||||||
nwins = n;
|
|
||||||
wins = erealloc(wins, nwins * sizeof(Window));
|
|
||||||
}
|
|
||||||
|
|
||||||
fi = 0;
|
|
||||||
mi = 2 * f;
|
|
||||||
if(sel->isfloat || arrange == dofloat) {
|
if(sel->isfloat || arrange == dofloat) {
|
||||||
wins[fi++] = sel->twin;
|
XRaiseWindow(dpy, sel->win);
|
||||||
wins[fi++] = sel->win;
|
XRaiseWindow(dpy, sel->twin);
|
||||||
}
|
}
|
||||||
else {
|
if(arrange != dofloat) {
|
||||||
wins[mi++] = sel->twin;
|
if(!sel->isfloat) {
|
||||||
wins[mi++] = sel->win;
|
XLowerWindow(dpy, sel->twin);
|
||||||
}
|
XLowerWindow(dpy, sel->win);
|
||||||
for(c = clients; c; c = c->next)
|
|
||||||
if(isvisible(c) && c != sel) {
|
|
||||||
if(c->isfloat || arrange == dofloat) {
|
|
||||||
wins[fi++] = c->twin;
|
|
||||||
wins[fi++] = c->win;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
wins[mi++] = c->twin;
|
|
||||||
wins[mi++] = c->win;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
XRestackWindows(dpy, wins, n);
|
for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
|
||||||
|
if(c == sel)
|
||||||
|
continue;
|
||||||
|
XLowerWindow(dpy, c->twin);
|
||||||
|
XLowerWindow(dpy, c->win);
|
||||||
|
}
|
||||||
|
}
|
||||||
drawall();
|
drawall();
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
togglemode(Arg *arg)
|
togglemode(Arg *arg) {
|
||||||
{
|
|
||||||
arrange = (arrange == dofloat) ? dotile : dofloat;
|
arrange = (arrange == dofloat) ? dotile : dofloat;
|
||||||
if(sel)
|
if(sel)
|
||||||
arrange(NULL);
|
arrange();
|
||||||
else
|
else
|
||||||
drawstatus();
|
drawstatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
toggleview(Arg *arg)
|
toggleview(Arg *arg) {
|
||||||
{
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
seltag[arg->i] = !seltag[arg->i];
|
seltag[arg->i] = !seltag[arg->i];
|
||||||
@ -252,47 +265,54 @@ toggleview(Arg *arg)
|
|||||||
if(i == ntags)
|
if(i == ntags)
|
||||||
seltag[arg->i] = True; /* cannot toggle last view */
|
seltag[arg->i] = True; /* cannot toggle last view */
|
||||||
reorder();
|
reorder();
|
||||||
arrange(NULL);
|
arrange();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
view(Arg *arg)
|
view(Arg *arg) {
|
||||||
{
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for(i = 0; i < ntags; i++)
|
for(i = 0; i < ntags; i++)
|
||||||
seltag[i] = False;
|
seltag[i] = False;
|
||||||
seltag[arg->i] = True;
|
seltag[arg->i] = True;
|
||||||
reorder();
|
reorder();
|
||||||
arrange(NULL);
|
arrange();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
viewall(Arg *arg)
|
viewall(Arg *arg) {
|
||||||
{
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for(i = 0; i < ntags; i++)
|
for(i = 0; i < ntags; i++)
|
||||||
seltag[i] = True;
|
seltag[i] = True;
|
||||||
reorder();
|
reorder();
|
||||||
arrange(NULL);
|
arrange();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zoom(Arg *arg)
|
zoom(Arg *arg) {
|
||||||
{
|
unsigned int n;
|
||||||
Client *c = sel;
|
Client *c;
|
||||||
|
|
||||||
if(!c || (arrange != dotile) || c->isfloat || maximized)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
|
if(sel->isfloat || (arrange == dofloat)) {
|
||||||
if(c == getnext(clients))
|
togglemax(sel);
|
||||||
if(!(c = getnext(c->next)))
|
return;
|
||||||
|
}
|
||||||
|
for(n = 0, c = clients; c; c = c->next)
|
||||||
|
if(isvisible(c) && !c->isfloat)
|
||||||
|
n++;
|
||||||
|
if(n < 2 || (arrange == dofloat))
|
||||||
|
return;
|
||||||
|
if((c = sel) == nexttiled(clients))
|
||||||
|
if(!(c = nexttiled(c->next)))
|
||||||
return;
|
return;
|
||||||
detach(c);
|
detach(c);
|
||||||
|
if(clients)
|
||||||
|
clients->prev = c;
|
||||||
c->next = clients;
|
c->next = clients;
|
||||||
clients->prev = c;
|
|
||||||
clients = c;
|
clients = c;
|
||||||
focus(c);
|
focus(c);
|
||||||
arrange(NULL);
|
arrange();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user