aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/dwm/hook.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/cmd/dwm/hook.c')
-rw-r--r--sys/cmd/dwm/hook.c109
1 files changed, 100 insertions, 9 deletions
diff --git a/sys/cmd/dwm/hook.c b/sys/cmd/dwm/hook.c
index cc96ead..9758965 100644
--- a/sys/cmd/dwm/hook.c
+++ b/sys/cmd/dwm/hook.c
@@ -24,25 +24,116 @@ focusstack(Arg *arg)
if (!selmon->sel)
return;
if (arg->i > 0) {
- for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
- if (!c)
- for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
+ for(c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
+ if(!c)
+ for(c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
} else {
- for (i = selmon->clients; i != selmon->sel; i = i->next)
- if (ISVISIBLE(i))
+ for(i = selmon->clients; i != selmon->sel; i = i->next)
+ if(ISVISIBLE(i))
c = i;
- if (!c)
- for (; i; i = i->next)
+ if(!c)
+ for(; i; i = i->next)
if (ISVISIBLE(i))
c = i;
}
- if (c) {
+ if(c) {
focus(c);
restack(selmon);
}
}
void
+focusdirection(Arg *arg)
+{
+ Monitor *m;
+ Client *it, *c;
+ int x, y, cx, cy;
+
+ if(!selmon || !selmon->sel)
+ return;
+
+ c = selmon->sel;
+ x = c->x, y = c->y;
+
+ c = nil;
+ switch(arg->i) {
+ case 'l':
+ cx = INT_MIN;
+ cy = y;
+ for(m=mons; m; m=m->next) {
+ for(it=m->clients; it; it = it->next) {
+ if(ISVISIBLE(it) && (it->x < x)) {
+ if((it->x > cx) || ((it->x == cx) && abs(y-it->y) < abs(y-cy))) {
+ c = it;
+ cx = it->x;
+ cy = it->y;
+ }
+ }
+ }
+ }
+ break;
+
+ case 'r':
+ cx = INT_MAX;
+ cy = y;
+ for(m=mons; m; m=m->next) {
+ for(it=m->clients; it; it = it->next) {
+ if(ISVISIBLE(it) && (it->x > x)) {
+ if((it->x < cx) || ((it->x == cx) && abs(y-it->y) < abs(y-cy))) {
+ c = it;
+ cx = it->x;
+ cy = it->y;
+ }
+ }
+ }
+ }
+ break;
+
+ case 'u':
+ cx = x;
+ cy = INT_MIN;
+ for(m=mons; m; m=m->next) {
+ for(it=m->clients; it; it = it->next) {
+ if(ISVISIBLE(it) && (it->y < y)) {
+ if((it->y > cy) || ((it->y == cy) && abs(x-it->x) < abs(x-cx))) {
+ c = it;
+ cx = it->x;
+ cy = it->y;
+ }
+ }
+ }
+ }
+ break;
+
+ case 'd':
+ cx = x;
+ cy = INT_MAX;
+ for(m=mons; m; m=m->next) {
+ for(it=m->clients; it; it = it->next) {
+ if(ISVISIBLE(it) && (it->y > y)) {
+ if((it->y < cy) || ((it->y == cy) && abs(x-it->x) < abs(x-cx))) {
+ c = it;
+ cx = it->x;
+ cy = it->y;
+ }
+ }
+ }
+ }
+ break;
+
+ default:
+ ;
+ }
+
+ if(c) {
+ focus(c);
+ restack(selmon);
+ if(c->mon != selmon)
+ restack(c->mon);
+ }
+}
+
+void
rotatestack(Arg *arg)
{
Client *c = nil, *f;
@@ -60,7 +151,7 @@ rotatestack(Arg *arg)
attach(c);
detachstack(c);
attachstack(c);
- }
+ }
} else {
if ((c = nexttiled(selmon->clients))) {
detach(c);