Adding focusdir patch
This commit is contained in:
65
patch/focusdir.c
Normal file
65
patch/focusdir.c
Normal file
@ -0,0 +1,65 @@
|
||||
void
|
||||
focusdir(const Arg *arg)
|
||||
{
|
||||
Client *s = selmon->sel, *f = NULL, *c, *next;
|
||||
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
unsigned int score = -1;
|
||||
unsigned int client_score;
|
||||
int dist;
|
||||
int dirweight = 20;
|
||||
int isfloating = s->isfloating;
|
||||
|
||||
next = s->next;
|
||||
if (!next)
|
||||
next = s->mon->clients;
|
||||
for (c = next; c != s; c = next) {
|
||||
|
||||
next = c->next;
|
||||
if (!next)
|
||||
next = s->mon->clients;
|
||||
|
||||
if (!ISVISIBLE(c) || c->isfloating != isfloating) // || HIDDEN(c)
|
||||
continue;
|
||||
|
||||
switch (arg->i) {
|
||||
case 0: // left
|
||||
dist = s->x - c->x - c->w;
|
||||
client_score =
|
||||
dirweight * MIN(abs(dist), abs(dist + s->mon->ww)) +
|
||||
abs(s->y - c->y);
|
||||
break;
|
||||
case 1: // right
|
||||
dist = c->x - s->x - s->w;
|
||||
client_score =
|
||||
dirweight * MIN(abs(dist), abs(dist + s->mon->ww)) +
|
||||
abs(c->y - s->y);
|
||||
break;
|
||||
case 2: // up
|
||||
dist = s->y - c->y - c->h;
|
||||
client_score =
|
||||
dirweight * MIN(abs(dist), abs(dist + s->mon->wh)) +
|
||||
abs(s->x - c->x);
|
||||
break;
|
||||
default:
|
||||
case 3: // down
|
||||
dist = c->y - s->y - s->h;
|
||||
client_score =
|
||||
dirweight * MIN(abs(dist), abs(dist + s->mon->wh)) +
|
||||
abs(c->x - s->x);
|
||||
break;
|
||||
}
|
||||
|
||||
if (((arg->i == 0 || arg->i == 2) && client_score <= score) || client_score < score) {
|
||||
score = client_score;
|
||||
f = c;
|
||||
}
|
||||
}
|
||||
|
||||
if (f && f != s) {
|
||||
focus(f);
|
||||
restack(f->mon);
|
||||
}
|
||||
}
|
1
patch/focusdir.h
Normal file
1
patch/focusdir.h
Normal file
@ -0,0 +1 @@
|
||||
static void focusdir(const Arg *arg);
|
@ -132,6 +132,9 @@
|
||||
#if FOCUSADJACENTTAG_PATCH
|
||||
#include "focusadjacenttag.c"
|
||||
#endif
|
||||
#if FOCUSDIR_PATCH
|
||||
#include "focusdir.c"
|
||||
#endif
|
||||
#if FOCUSMASTER_PATCH
|
||||
#include "focusmaster.c"
|
||||
#endif
|
||||
|
@ -129,6 +129,9 @@
|
||||
#if FLOATPOS_PATCH
|
||||
#include "floatpos.h"
|
||||
#endif
|
||||
#if FOCUSDIR_PATCH
|
||||
#include "focusdir.h"
|
||||
#endif
|
||||
#if FOCUSADJACENTTAG_PATCH
|
||||
#include "focusadjacenttag.h"
|
||||
#endif
|
||||
|
@ -54,7 +54,7 @@ riodraw(const Arg *arg)
|
||||
c = selmon->sel;
|
||||
|
||||
if (width > 50 && height > 50 && x > -40 && y > -40 && width < selmon->mw + 40 && height < selmon->mh + 40 &&
|
||||
(abs(c->w - width) > 20 || abs(c->h - height) > 20 || abs(c->x - x) > 20 || abs(c->y - y) > 20)) {
|
||||
(abs(c->w - width) > 20 || abs(c->h - height) > 20 || abs(c->x - x) > 20 || abs(c->y - y) > 20)) {
|
||||
if ((m = recttomon(x, y, width, height)) != selmon) {
|
||||
sendmon(c, m);
|
||||
unfocus(selmon->sel, 0, NULL);
|
||||
|
Reference in New Issue
Block a user