|
|
@ -13,60 +13,105 @@ |
|
|
|
|
|
|
|
|
|
|
|
static void (*arrange)(Arg *) = floating; |
|
|
|
static void (*arrange)(Arg *) = floating; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
center(Client *c) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static Client * |
|
|
|
static Client * |
|
|
|
next(Client *c) |
|
|
|
next(Client *c) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for(c = c->next; c && !c->tags[tsel]; c = c->next); |
|
|
|
for(; c && !c->tags[tsel]; c = c->next); |
|
|
|
return c; |
|
|
|
return c; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static Client * |
|
|
|
void |
|
|
|
prev(Client *c) |
|
|
|
zoom(Arg *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for(c = c->prev; c && !c->tags[tsel]; c = c->prev); |
|
|
|
Client **l; |
|
|
|
return c; |
|
|
|
|
|
|
|
|
|
|
|
if(!sel) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(l = &clients; *l && *l != sel; l = &(*l)->next); |
|
|
|
|
|
|
|
*l = sel->next; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sel->next = clients; /* pop */ |
|
|
|
|
|
|
|
clients = sel; |
|
|
|
|
|
|
|
arrange(NULL); |
|
|
|
|
|
|
|
center(sel); |
|
|
|
|
|
|
|
focus(sel); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
max(Arg *arg) |
|
|
|
max(Arg *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(!csel) |
|
|
|
if(!sel) |
|
|
|
return; |
|
|
|
return; |
|
|
|
csel->x = sx; |
|
|
|
sel->x = sx; |
|
|
|
csel->y = sy; |
|
|
|
sel->y = sy; |
|
|
|
csel->w = sw - 2 * csel->border; |
|
|
|
sel->w = sw - 2 * sel->border; |
|
|
|
csel->h = sh - 2 * csel->border; |
|
|
|
sel->h = sh - 2 * sel->border; |
|
|
|
craise(csel); |
|
|
|
craise(sel); |
|
|
|
resize(csel); |
|
|
|
resize(sel); |
|
|
|
discard_events(EnterWindowMask); |
|
|
|
discard_events(EnterWindowMask); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
view(Arg *arg) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
tsel = arg->i; |
|
|
|
|
|
|
|
arrange(NULL); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
tag(Arg *arg) |
|
|
|
tag(Arg *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(!csel) |
|
|
|
int i, n; |
|
|
|
|
|
|
|
if(!sel) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if(arg->i == tsel) |
|
|
|
if(arg->i == tsel) { |
|
|
|
|
|
|
|
for(n = i = 0; i < TLast; i++) |
|
|
|
|
|
|
|
if(sel->tags[i]) |
|
|
|
|
|
|
|
n++; |
|
|
|
|
|
|
|
if(n < 2) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(csel->tags[arg->i]) |
|
|
|
if(sel->tags[arg->i]) |
|
|
|
csel->tags[arg->i] = NULL; /* toggle tag */ |
|
|
|
sel->tags[arg->i] = NULL; /* toggle tag */ |
|
|
|
else |
|
|
|
else |
|
|
|
csel->tags[arg->i] = tags[arg->i]; |
|
|
|
sel->tags[arg->i] = tags[arg->i]; |
|
|
|
arrange(NULL); |
|
|
|
arrange(NULL); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
ban_client(Client *c) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); |
|
|
|
|
|
|
|
XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
floating(Arg *arg) |
|
|
|
floating(Arg *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Client *c; |
|
|
|
Client *c; |
|
|
|
|
|
|
|
|
|
|
|
arrange = floating; |
|
|
|
arrange = floating; |
|
|
|
if(!csel) |
|
|
|
for(c = clients; c; c = c->next) { |
|
|
|
return; |
|
|
|
if(c->tags[tsel]) |
|
|
|
for(c = csel; c; c = next(c)) |
|
|
|
|
|
|
|
resize(c); |
|
|
|
resize(c); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
ban_client(c); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(sel && !sel->tags[tsel]) { |
|
|
|
|
|
|
|
if((sel = next(clients))) { |
|
|
|
|
|
|
|
craise(sel); |
|
|
|
|
|
|
|
focus(sel); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
discard_events(EnterWindowMask); |
|
|
|
discard_events(EnterWindowMask); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -78,9 +123,8 @@ tiling(Arg *arg) |
|
|
|
float rt, fd; |
|
|
|
float rt, fd; |
|
|
|
|
|
|
|
|
|
|
|
arrange = tiling; |
|
|
|
arrange = tiling; |
|
|
|
if(!csel) |
|
|
|
for(n = 0, c = clients; c; c = next(c->next), n++); |
|
|
|
return; |
|
|
|
if(n) { |
|
|
|
for(n = 0, c = csel; c; c = next(c), n++); |
|
|
|
|
|
|
|
rt = sqrt(n); |
|
|
|
rt = sqrt(n); |
|
|
|
if(modff(rt, &fd) < 0.5) |
|
|
|
if(modff(rt, &fd) < 0.5) |
|
|
|
rows = floor(rt); |
|
|
|
rows = floor(rt); |
|
|
@ -93,8 +137,12 @@ tiling(Arg *arg) |
|
|
|
|
|
|
|
|
|
|
|
gw = (sw - 2) / cols; |
|
|
|
gw = (sw - 2) / cols; |
|
|
|
gh = (sh - 2) / rows; |
|
|
|
gh = (sh - 2) / rows; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
cols = rows = gw = gh = 0; |
|
|
|
|
|
|
|
|
|
|
|
for(i = j = 0, c = csel; c; c = next(c)) { |
|
|
|
for(i = j = 0, c = clients; c; c = c->next) { |
|
|
|
|
|
|
|
if(c->tags[tsel]) { |
|
|
|
c->x = i * gw; |
|
|
|
c->x = i * gw; |
|
|
|
c->y = j * gh; |
|
|
|
c->y = j * gh; |
|
|
|
c->w = gw; |
|
|
|
c->w = gw; |
|
|
@ -105,6 +153,15 @@ tiling(Arg *arg) |
|
|
|
i = 0; |
|
|
|
i = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
ban_client(c); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(sel && !sel->tags[tsel]) { |
|
|
|
|
|
|
|
if((sel = next(clients))) { |
|
|
|
|
|
|
|
craise(sel); |
|
|
|
|
|
|
|
focus(sel); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
discard_events(EnterWindowMask); |
|
|
|
discard_events(EnterWindowMask); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -113,14 +170,12 @@ prevc(Arg *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Client *c; |
|
|
|
Client *c; |
|
|
|
|
|
|
|
|
|
|
|
if(!csel) |
|
|
|
if(!sel) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if(!(c = prev(csel))) |
|
|
|
if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) { |
|
|
|
c = prev(cend); |
|
|
|
|
|
|
|
if(c) { |
|
|
|
|
|
|
|
craise(c); |
|
|
|
craise(c); |
|
|
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2); |
|
|
|
center(c); |
|
|
|
focus(c); |
|
|
|
focus(c); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -130,15 +185,15 @@ nextc(Arg *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Client *c; |
|
|
|
Client *c; |
|
|
|
|
|
|
|
|
|
|
|
if(!csel) |
|
|
|
if(!sel) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if(!(c = next(csel))) |
|
|
|
if(!(c = next(sel->next))) |
|
|
|
c = next(cstart); |
|
|
|
c = next(clients); |
|
|
|
|
|
|
|
|
|
|
|
if(c) { |
|
|
|
if(c) { |
|
|
|
craise(c); |
|
|
|
craise(c); |
|
|
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2); |
|
|
|
center(c); |
|
|
|
|
|
|
|
c->revert = sel; |
|
|
|
focus(c); |
|
|
|
focus(c); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -146,14 +201,12 @@ nextc(Arg *arg) |
|
|
|
void |
|
|
|
void |
|
|
|
ckill(Arg *arg) |
|
|
|
ckill(Arg *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Client *c = csel; |
|
|
|
if(!sel) |
|
|
|
|
|
|
|
|
|
|
|
if(!c) |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
if(c->proto & WM_PROTOCOL_DELWIN) |
|
|
|
if(sel->proto & WM_PROTOCOL_DELWIN) |
|
|
|
send_message(c->win, wm_atom[WMProtocols], wm_atom[WMDelete]); |
|
|
|
send_message(sel->win, wm_atom[WMProtocols], wm_atom[WMDelete]); |
|
|
|
else |
|
|
|
else |
|
|
|
XKillClient(dpy, c->win); |
|
|
|
XKillClient(dpy, sel->win); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
@ -256,12 +309,12 @@ lower(Client *c) |
|
|
|
void |
|
|
|
void |
|
|
|
focus(Client *c) |
|
|
|
focus(Client *c) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(csel && csel != c) { |
|
|
|
if(sel && sel != c) { |
|
|
|
XSetWindowBorder(dpy, csel->win, dc.bg); |
|
|
|
XSetWindowBorder(dpy, sel->win, dc.bg); |
|
|
|
XMapWindow(dpy, csel->title); |
|
|
|
XMapWindow(dpy, sel->title); |
|
|
|
draw_client(csel); |
|
|
|
draw_client(sel); |
|
|
|
} |
|
|
|
} |
|
|
|
csel = c; |
|
|
|
sel = c; |
|
|
|
XUnmapWindow(dpy, c->title); |
|
|
|
XUnmapWindow(dpy, c->title); |
|
|
|
XSetWindowBorder(dpy, c->win, dc.fg); |
|
|
|
XSetWindowBorder(dpy, c->win, dc.fg); |
|
|
|
draw_client(c); |
|
|
|
draw_client(c); |
|
|
@ -273,7 +326,7 @@ focus(Client *c) |
|
|
|
void |
|
|
|
void |
|
|
|
manage(Window w, XWindowAttributes *wa) |
|
|
|
manage(Window w, XWindowAttributes *wa) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Client *c; |
|
|
|
Client *c, **l; |
|
|
|
XSetWindowAttributes twa; |
|
|
|
XSetWindowAttributes twa; |
|
|
|
|
|
|
|
|
|
|
|
c = emallocz(sizeof(Client)); |
|
|
|
c = emallocz(sizeof(Client)); |
|
|
@ -284,6 +337,7 @@ manage(Window w, XWindowAttributes *wa) |
|
|
|
c->h = wa->height; |
|
|
|
c->h = wa->height; |
|
|
|
c->th = th; |
|
|
|
c->th = th; |
|
|
|
c->border = 1; |
|
|
|
c->border = 1; |
|
|
|
|
|
|
|
c->proto = win_proto(c->win); |
|
|
|
update_size(c); |
|
|
|
update_size(c); |
|
|
|
XSelectInput(dpy, c->win, |
|
|
|
XSelectInput(dpy, c->win, |
|
|
|
StructureNotifyMask | PropertyChangeMask | EnterWindowMask); |
|
|
|
StructureNotifyMask | PropertyChangeMask | EnterWindowMask); |
|
|
@ -300,13 +354,9 @@ manage(Window w, XWindowAttributes *wa) |
|
|
|
|
|
|
|
|
|
|
|
update_name(c); |
|
|
|
update_name(c); |
|
|
|
|
|
|
|
|
|
|
|
if(!cstart) |
|
|
|
for(l = &clients; *l; l = &(*l)->next); |
|
|
|
cstart = cend = c; |
|
|
|
c->next = *l; /* *l == nil */ |
|
|
|
else { |
|
|
|
*l = c; |
|
|
|
cend->next = c; |
|
|
|
|
|
|
|
c->prev = cend; |
|
|
|
|
|
|
|
cend = c; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
XSetWindowBorderWidth(dpy, c->win, 1); |
|
|
|
XSetWindowBorderWidth(dpy, c->win, 1); |
|
|
|
XMapRaised(dpy, c->win); |
|
|
|
XMapRaised(dpy, c->win); |
|
|
@ -318,7 +368,7 @@ manage(Window w, XWindowAttributes *wa) |
|
|
|
XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask, |
|
|
|
XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask, |
|
|
|
GrabModeAsync, GrabModeSync, None, None); |
|
|
|
GrabModeAsync, GrabModeSync, None, None); |
|
|
|
arrange(NULL); |
|
|
|
arrange(NULL); |
|
|
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2); |
|
|
|
center(c); |
|
|
|
focus(c); |
|
|
|
focus(c); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -420,26 +470,21 @@ dummy_error_handler(Display *dsply, XErrorEvent *err) |
|
|
|
void |
|
|
|
void |
|
|
|
unmanage(Client *c) |
|
|
|
unmanage(Client *c) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
Client **l; |
|
|
|
|
|
|
|
|
|
|
|
XGrabServer(dpy); |
|
|
|
XGrabServer(dpy); |
|
|
|
XSetErrorHandler(dummy_error_handler); |
|
|
|
XSetErrorHandler(dummy_error_handler); |
|
|
|
|
|
|
|
|
|
|
|
XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
|
|
|
XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
|
|
|
XDestroyWindow(dpy, c->title); |
|
|
|
XDestroyWindow(dpy, c->title); |
|
|
|
|
|
|
|
|
|
|
|
if(c->prev) { |
|
|
|
for(l = &clients; *l && *l != c; l = &(*l)->next); |
|
|
|
c->prev->next = c->next; |
|
|
|
*l = c->next; |
|
|
|
if(csel == c) |
|
|
|
for(l = &clients; *l; l = &(*l)->next) |
|
|
|
csel = c->prev; |
|
|
|
if((*l)->revert == c) |
|
|
|
} |
|
|
|
(*l)->revert = NULL; |
|
|
|
if(c->next) { |
|
|
|
if(sel == c) |
|
|
|
c->next->prev = c->prev; |
|
|
|
sel = sel->revert ? sel->revert : clients; |
|
|
|
if(csel == c) |
|
|
|
|
|
|
|
csel = c->next; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(cstart == c) |
|
|
|
|
|
|
|
cstart = c->next; |
|
|
|
|
|
|
|
if(cend == c) |
|
|
|
|
|
|
|
cend = c->prev; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
free(c); |
|
|
|
free(c); |
|
|
|
|
|
|
|
|
|
|
@ -447,15 +492,15 @@ unmanage(Client *c) |
|
|
|
XSetErrorHandler(error_handler); |
|
|
|
XSetErrorHandler(error_handler); |
|
|
|
XUngrabServer(dpy); |
|
|
|
XUngrabServer(dpy); |
|
|
|
arrange(NULL); |
|
|
|
arrange(NULL); |
|
|
|
if(csel) |
|
|
|
if(sel) |
|
|
|
focus(csel); |
|
|
|
focus(sel); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Client * |
|
|
|
Client * |
|
|
|
gettitle(Window w) |
|
|
|
gettitle(Window w) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Client *c; |
|
|
|
Client *c; |
|
|
|
for(c = cstart; c; c = c->next) |
|
|
|
for(c = clients; c; c = c->next) |
|
|
|
if(c->title == w) |
|
|
|
if(c->title == w) |
|
|
|
return c; |
|
|
|
return c; |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
@ -465,7 +510,7 @@ Client * |
|
|
|
getclient(Window w) |
|
|
|
getclient(Window w) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Client *c; |
|
|
|
Client *c; |
|
|
|
for(c = cstart; c; c = c->next) |
|
|
|
for(c = clients; c; c = c->next) |
|
|
|
if(c->win == w) |
|
|
|
if(c->win == w) |
|
|
|
return c; |
|
|
|
return c; |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
@ -475,7 +520,7 @@ void |
|
|
|
draw_client(Client *c) |
|
|
|
draw_client(Client *c) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
if(c == csel) |
|
|
|
if(c == sel) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
dc.x = dc.y = 0; |
|
|
|
dc.x = dc.y = 0; |
|
|
|