fix floating rules
This commit is contained in:
parent
a442c9b501
commit
93f9157de3
45
config.h
45
config.h
|
@ -79,16 +79,16 @@ static const Rule rules[] = {
|
|||
* WM_NAME(STRING) = title
|
||||
* If X, Y, W or H are between 0 and 1 (inclusive), their values interpreted as percentages of the current monitor resolution.
|
||||
* If X or Y are negative, they are subtracted from the current monitor resolution and then that value is interpreted.
|
||||
class instance title scratch key tags mask isfloating isterminal noswallow x, y, w, h borderpx */
|
||||
{ NULL, NULL, "Event Tester", 0, 0, 0, 0, 1, 0, 0, 0, 0, -1 },
|
||||
{ "Xournalpp", "xournalpp", NULL, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1 },
|
||||
{ "Zathura", "org.pwmt.zathura", NULL, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1 },
|
||||
{ NULL, "kitty", NULL, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1 },
|
||||
{ "Qalculate-gtk", NULL, NULL, 'q', 0, 1, 0, 0, .5, .5, 722, 512, -1 },
|
||||
// { NULL, "spterm", NULL, 't', 0, 1, 1, 0, .5, .5, 1, 1, -1 },
|
||||
{ NULL, "splf", NULL, 'l', 0, 1, 0, 0, .5, .5, .8, .8, -1 },
|
||||
{ NULL, "sphtop", NULL, 'h', 0, 1, 0, 0, .5, .5, .8, .8, -1 },
|
||||
{ NULL, "spmix", NULL, 'm', 0, 1, 0, 0, -4, -4, 900, 600, -1 },
|
||||
class instance title scratch key tags mask isfloating isterminal noswallow x, y, w, h borderpx */
|
||||
{ NULL, NULL, "Event Tester", 0, 0, 0, 0, 1, 0, 0, 0, 0, -1 },
|
||||
{ "Xournalpp", "xournalpp", NULL, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1 },
|
||||
{ "Zathura", "org.pwmt.zathura", NULL, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1 },
|
||||
{ NULL, "kitty", NULL, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1 },
|
||||
{ "Qalculate-gtk", NULL, NULL, 'q', 0, 1, 0, 0, .5, .5, 722, 512, -1 },
|
||||
{ NULL, "sphelp", NULL, 'n', 0, 1, 1, 0, .5, .5, .3, .8, -1 },
|
||||
{ NULL, "splf", NULL, 'l', 0, 1, 0, 0, .5, .5, .8, .8, -1 },
|
||||
{ NULL, "sphtop", NULL, 'h', 0, 1, 0, 0, .5, .5, .8, .8, -1 },
|
||||
{ NULL, "spmix", NULL, 'm', 0, 1, 0, 0, -4, -4, 900, 600, -1 },
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
|
@ -125,7 +125,8 @@ static const Layout layouts[] = {
|
|||
static const char *spqalc[] = { "q", "qalculate-gtk", NULL };
|
||||
static const char *splf[] = { "l", TERMINAL, "--name", "splf", "-d", "~", "-e", "lf", NULL };
|
||||
static const char *sphtop[] = { "h", TERMINAL, "--name", "sphtop", "-e", "htop", NULL };
|
||||
static const char *spmix[] = { "m", "/bin/sh", "-c", "$TERMINAL --name spmix -e pulsemixer; pkill -RTMIN+10 dwmblocks" };
|
||||
static const char *spmix[] = { "m", "/bin/sh", "-c", TERMINAL "--name spmix -e pulsemixer; pkill -RTMIN+10 dwmblocks" };
|
||||
static const char *sphelp[] = { "n", TERMINAL, "--name", "sphelp", "-e", "/bin/sh", "-c", "lowdown -Tterm /usr/local/share/dwm/dwm.md | less" };
|
||||
|
||||
/* Xresources preferences to load at startup */
|
||||
ResourcePref resources[] = {
|
||||
|
@ -153,7 +154,7 @@ ResourcePref resources[] = {
|
|||
|
||||
static const Key keys[] = {
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XK_F1, spawn, SHCMD("groff -mom /usr/local/share/dwm/keybinds.mom -Tpdf | zathura -") },
|
||||
{ MODKEY, XK_F1, togglescratch, {.v = sphelp} },
|
||||
// { MODKEY, XK_F2, spawn, {.v = (const char *[]){NULL}} },
|
||||
{ MODKEY, XK_F3, togglescratch, {.v = spmix} },
|
||||
// { MODKEY, XK_F4, spawn, {.v = (const char *[]){NULL}} },
|
||||
|
@ -183,15 +184,15 @@ static const Key keys[] = {
|
|||
// { MODKEY, XK_bracketright, spawn, {.v = (const char *[]){NULL}} },
|
||||
// { MODKEY | ShiftMask, XK_bracketright, spawn, {.v = (const char *[]){NULL}} },
|
||||
{ MODKEY, XK_BackSpace, spawn, {.v = (const char *[]){"sysact", NULL}} },
|
||||
{ MODKEY | ShiftMask, XK_BackSpace, spawn, {.v = (const char *[]){"sysact", NULL}} },
|
||||
// { MODKEY | ShiftMask, XK_BackSpace, spawn, {.v = (const char *[]){NULL}} },
|
||||
{ MODKEY, XK_Tab, focusstack, {.i = 0} },
|
||||
{ MODKEY | ShiftMask, XK_Tab, pushstack, {.i = 0} },
|
||||
{ MODKEY, XK_apostrophe, killclient, {0} },
|
||||
// { MODKEY | ShiftMask, XK_apostrophe, spawn, {.v = (const char *[]){NULL}} },
|
||||
{ MODKEY, XK_comma, focusmon, {.i = -1} },
|
||||
{ MODKEY | ShiftMask, XK_comma, tagmon, {.i = -1} },
|
||||
{ MODKEY, XK_period, focusmon, {.i = +1} },
|
||||
{ MODKEY | ShiftMask, XK_period, tagmon, {.i = +1} },
|
||||
{ MODKEY, XK_comma, focusmon, {.i = -1} },
|
||||
{ MODKEY | ShiftMask, XK_comma, tagmon, {.i = -1} },
|
||||
{ MODKEY, XK_period, focusmon, {.i = +1} },
|
||||
{ MODKEY | ShiftMask, XK_period, tagmon, {.i = +1} },
|
||||
{ MODKEY, XK_p, togglefullscr, {0} },
|
||||
// { MODKEY | ShiftMask, XK_p, setlayout, {.v = (const char *[]){NULL}} },
|
||||
// { MODKEY, XK_y, spawn, {.v = (const char *[]){NULL}} },
|
||||
|
@ -215,7 +216,7 @@ static const Key keys[] = {
|
|||
{ MODKEY, XK_o, togglescratch, {.v = sphtop} },
|
||||
{ MODKEY | ShiftMask, XK_o, spawn, {.v = (const char *[]){TERMINAL, "-e", "htop", NULL}} },
|
||||
{ MODKEY, XK_e, togglescratch, {.v = splf} },
|
||||
{ MODKEY | ShiftMask, XK_e, spawn, {.v = (const char *[]){TERMINAL, "-d", "~", "-e", "lf", NULL}} },
|
||||
{ MODKEY | ShiftMask, XK_e, spawn, SHCMD(TERMINAL "-e $SHELL -c \"lf; $SHELL\"")},
|
||||
{ MODKEY, XK_u, spawn, {.v = (const char *[]){BROWSER, NULL}} },
|
||||
{ MODKEY | ShiftMask, XK_u, spawn, {.v = (const char *[]){TERMINAL, "-e", "sudo", "nmtui", NULL}} },
|
||||
// { MODKEY, XK_i, spawn, {.v = (const char *[]){NULL}} },
|
||||
|
@ -225,7 +226,7 @@ static const Key keys[] = {
|
|||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
// { MODKEY | ShiftMask, XK_h, spawn, {.v = (const char *[]){NULL}} },
|
||||
{ MODKEY, XK_t, spawn, {.v = (const char *[]){"dmenu_run", NULL}} },
|
||||
{ MODKEY | ShiftMask, XK_t, spawn, {.v = (const char *[]){NULL}} },
|
||||
// { MODKEY | ShiftMask, XK_t, spawn, {.v = (const char *[]){NULL}} },
|
||||
{ MODKEY, XK_n, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY | ShiftMask, XK_n, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XK_s, setlayout, {.v = &layouts[2]} },
|
||||
|
@ -278,9 +279,9 @@ static const Key keys[] = {
|
|||
{ MODKEY | ShiftMask, XK_End, quit, {0} },
|
||||
// { MODKEY, XK_Page_Down, spawn, {.v = (const char *[]){NULL}} },
|
||||
// { MODKEY | ShiftMask, XK_Page_Down, spawn, {.v = (const char *[]){NULL}} },
|
||||
{ MODKEY, XK_Left, spawn, {.v = (const char *[]){"playerctl", "-p", PLAYERCTL, "previous", NULL}} },
|
||||
{ MODKEY | ShiftMask, XK_Left, spawn, {.v = (const char *[]){"playerctl", "-p", PLAYERCTL, "position", "0", NULL}} },
|
||||
{ MODKEY, XK_Right, spawn, {.v = (const char *[]){"playerctl", "-p", PLAYERCTL, "next", NULL}} },
|
||||
{ MODKEY, XK_Left, spawn, {.v = (const char *[]){"playerctl", "-p", PLAYERCTL, "previous", NULL}} },
|
||||
{ MODKEY | ShiftMask, XK_Left, spawn, {.v = (const char *[]){"playerctl", "-p", PLAYERCTL, "position", "0", NULL}} },
|
||||
{ MODKEY, XK_Right, spawn, {.v = (const char *[]){"playerctl", "-p", PLAYERCTL, "next", NULL}} },
|
||||
// { MODKEY | ShiftMask, XK_Right, spawn, {.v = (const char *[]){NULL}} },
|
||||
{ MODKEY, XK_Up, spawn, SHCMD("pamixer --allow-boost -i 5; pkill -RTMIN+10 dwmblocks") },
|
||||
{ MODKEY | ShiftMask, XK_Up, spawn, SHCMD("pamixer --allow-boost -i 20; pkill -RTMIN+10 dwmblocks") },
|
||||
|
|
163
dwm.c
163
dwm.c
|
@ -201,14 +201,14 @@ typedef struct {
|
|||
const char *class;
|
||||
const char *instance;
|
||||
const char *title;
|
||||
const char scratchkey;
|
||||
unsigned int tags;
|
||||
int isfloating;
|
||||
int isterminal;
|
||||
int noswallow;
|
||||
int monitor;
|
||||
const char scratchkey;
|
||||
int floatx, floaty, floatw, floath;
|
||||
float floatx, floaty, floatw, floath;
|
||||
int floatborderpx;
|
||||
// int monitor;
|
||||
} Rule;
|
||||
|
||||
typedef struct Systray Systray;
|
||||
|
@ -228,6 +228,7 @@ typedef struct {
|
|||
|
||||
/* function declarations */
|
||||
static void applyrules(Client *c);
|
||||
static void applyfloatrules(Client *c, const Rule *r);
|
||||
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
|
||||
static void arrange(Monitor *m);
|
||||
static void arrangemon(Monitor *m);
|
||||
|
@ -274,6 +275,7 @@ static void manage(Window w, XWindowAttributes *wa);
|
|||
static void mappingnotify(XEvent *e);
|
||||
static void maprequest(XEvent *e);
|
||||
static void monocle(Monitor *m);
|
||||
static int matchrules(Client *c);
|
||||
static void motionnotify(XEvent *e);
|
||||
static void movemouse(const Arg *arg);
|
||||
static Client *nexttiled(Client *c);
|
||||
|
@ -412,87 +414,74 @@ struct NumTags {
|
|||
|
||||
/* function implementations */
|
||||
void applyrules(Client *c) {
|
||||
const char *class, *instance;
|
||||
unsigned int i;
|
||||
unsigned int i = -1;
|
||||
const Rule *r;
|
||||
Monitor *m;
|
||||
XClassHint ch = {NULL, NULL};
|
||||
// Monitor *m;
|
||||
|
||||
/* rule matching */
|
||||
c->isfloating = 0;
|
||||
c->tags = 0;
|
||||
c->scratchkey = 0;
|
||||
XGetClassHint(dpy, c->win, &ch);
|
||||
class = ch.res_class ? ch.res_class : broken;
|
||||
instance = ch.res_name ? ch.res_name : broken;
|
||||
|
||||
for (i = 0; i < LENGTH(rules); i++) {
|
||||
i = matchrules(c);
|
||||
if (i >= 0) {
|
||||
r = &rules[i];
|
||||
if ((!r->title || strstr(c->name, r->title)) && (!r->class || strstr(class, r->class)) &&
|
||||
(!r->instance || strstr(instance, r->instance))) {
|
||||
c->isterminal = r->isterminal;
|
||||
c->noswallow = r->noswallow;
|
||||
c->isfloating = r->isfloating;
|
||||
c->tags |= r->tags;
|
||||
if (r->floatborderpx >= 0) {
|
||||
c->floatborderpx = r->floatborderpx;
|
||||
c->hasfloatbw = 1;
|
||||
}
|
||||
if (r->isfloating) {
|
||||
if (r->floatx > 1)
|
||||
c->x = r->floatx;
|
||||
else if (r->floatx > 0)
|
||||
c->x = (int)((float)c->mon->ww * r->floatx - (float)WIDTH(c) / 2);
|
||||
else if (r->floatx == 0)
|
||||
;
|
||||
else if (r->floatx > -1)
|
||||
c->x = c->mon->ww + (int)((float)c->mon->ww * r->floatx - (float)WIDTH(c) / 2);
|
||||
else
|
||||
c->x = c->mon->ww + r->floatx - WIDTH(c);
|
||||
if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww)
|
||||
c->x = c->mon->ww - WIDTH(c);
|
||||
c->x = MAX(c->x + c->mon->wx, c->mon->wx);
|
||||
|
||||
if (r->floaty > 1)
|
||||
c->y = r->floaty;
|
||||
else if (r->floaty > 0)
|
||||
c->y = (int)((float)c->mon->wh * r->floaty - (float)HEIGHT(c) / 2);
|
||||
else if (r->floaty == 0)
|
||||
;
|
||||
else if (r->floaty > -1)
|
||||
c->y = c->mon->wh + (int)((float)c->mon->wh * r->floaty - (float)HEIGHT(c) / 2);
|
||||
else
|
||||
c->y = c->mon->wh + r->floaty - HEIGHT(c);
|
||||
if (c->y + HEIGHT(c) > c->mon->wy + c->mon->wh)
|
||||
c->y = c->mon->wh - HEIGHT(c);
|
||||
c->y = MAX(c->y + c->mon->wy, c->mon->wy);
|
||||
|
||||
if (r->floatw > 1)
|
||||
c->w = r->floatw;
|
||||
else if (r->floatw > 0)
|
||||
c->w = (int)((float)c->mon->ww * r->floatw);
|
||||
c->w = MIN(c->w, c->mon->ww) - c->bw * 2;
|
||||
|
||||
if (r->floath > 1)
|
||||
c->h = r->floath;
|
||||
else if (r->floath > 0)
|
||||
c->h = (int)((float)c->mon->wh * r->floath);
|
||||
c->h = MIN(c->h, c->mon->wh) - c->bw * 2;
|
||||
}
|
||||
c->scratchkey = r->scratchkey;
|
||||
for (m = mons; m && m->num != r->monitor; m = m->next)
|
||||
;
|
||||
if (m)
|
||||
c->mon = m;
|
||||
c->isterminal = r->isterminal;
|
||||
c->noswallow = r->noswallow;
|
||||
c->isfloating = r->isfloating;
|
||||
c->tags |= r->tags;
|
||||
c->scratchkey = r->scratchkey;
|
||||
if (r->floatborderpx >= 0) {
|
||||
c->floatborderpx = r->floatborderpx;
|
||||
c->hasfloatbw = 1;
|
||||
}
|
||||
if (r->isfloating) {
|
||||
applyfloatrules(c, r);
|
||||
}
|
||||
}
|
||||
if (ch.res_class)
|
||||
XFree(ch.res_class);
|
||||
if (ch.res_name)
|
||||
XFree(ch.res_name);
|
||||
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
|
||||
}
|
||||
|
||||
void applyfloatrules(Client *c, const Rule *r) {
|
||||
if (r->floatw > 1)
|
||||
c->w = r->floatw;
|
||||
else if (r->floatw > 0)
|
||||
c->w = (int)((float)c->mon->ww * r->floatw);
|
||||
c->w = MIN(c->w, c->mon->ww) - c->bw * 2;
|
||||
|
||||
if (r->floath > 1)
|
||||
c->h = r->floath;
|
||||
else if (r->floath > 0)
|
||||
c->h = (int)((float)c->mon->wh * r->floath);
|
||||
c->h = MIN(c->h, c->mon->wh) - c->bw * 2;
|
||||
|
||||
if (r->floatx > 1)
|
||||
c->x = r->floatx;
|
||||
else if (r->floatx > 0)
|
||||
c->x = (int)((float)c->mon->ww * r->floatx - (float)WIDTH(c) / 2);
|
||||
else if (r->floatx == 0)
|
||||
;
|
||||
else if (r->floatx > -1)
|
||||
c->x = c->mon->ww + (int)((float)c->mon->ww * r->floatx - (float)WIDTH(c) / 2);
|
||||
else
|
||||
c->x = c->mon->ww + r->floatx - WIDTH(c);
|
||||
if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww)
|
||||
c->x = c->mon->ww - WIDTH(c);
|
||||
c->x = MAX(c->x + c->mon->wx, c->mon->wx);
|
||||
|
||||
if (r->floaty > 1)
|
||||
c->y = r->floaty;
|
||||
else if (r->floaty > 0)
|
||||
c->y = (int)((float)c->mon->wh * r->floaty - (float)HEIGHT(c) / 2);
|
||||
else if (r->floaty == 0)
|
||||
;
|
||||
else if (r->floaty > -1)
|
||||
c->y = c->mon->wh + (int)((float)c->mon->wh * r->floaty - (float)HEIGHT(c) / 2);
|
||||
else
|
||||
c->y = c->mon->wh + r->floaty - HEIGHT(c);
|
||||
if (c->y + HEIGHT(c) > c->mon->wy + c->mon->wh)
|
||||
c->y = c->mon->wh - HEIGHT(c);
|
||||
c->y = MAX(c->y + c->mon->wy, c->mon->wy);
|
||||
}
|
||||
|
||||
int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact) {
|
||||
int baseismin;
|
||||
Monitor *m = c->mon;
|
||||
|
@ -1765,6 +1754,32 @@ void maprequest(XEvent *e) {
|
|||
manage(ev->window, &wa);
|
||||
}
|
||||
|
||||
int matchrules(Client *c) {
|
||||
const char *class, *instance;
|
||||
unsigned int ri;
|
||||
const Rule *r;
|
||||
XClassHint ch = {NULL, NULL};
|
||||
XGetClassHint(dpy, c->win, &ch);
|
||||
class = ch.res_class ? ch.res_class : broken;
|
||||
instance = ch.res_name ? ch.res_name : broken;
|
||||
for (ri = 0; ri < LENGTH(rules); ri++) {
|
||||
r = &rules[ri];
|
||||
if ((!r->title || strstr(c->name, r->title)) && (!r->class || strstr(class, r->class)) &&
|
||||
(!r->instance || strstr(instance, r->instance))) {
|
||||
if (ch.res_class)
|
||||
XFree(ch.res_class);
|
||||
if (ch.res_name)
|
||||
XFree(ch.res_name);
|
||||
return ri;
|
||||
}
|
||||
}
|
||||
if (ch.res_class)
|
||||
XFree(ch.res_class);
|
||||
if (ch.res_name)
|
||||
XFree(ch.res_name);
|
||||
return False;
|
||||
}
|
||||
|
||||
void monocle(Monitor *m) {
|
||||
unsigned int n = 0;
|
||||
Client *c;
|
||||
|
@ -2685,7 +2700,7 @@ void updatebarpos(Monitor *m) {
|
|||
m->by = -bh;
|
||||
}
|
||||
|
||||
void updateclientlist() {
|
||||
void updateclientlist(void) {
|
||||
Client *c;
|
||||
Monitor *m;
|
||||
|
||||
|
|
Loading…
Reference in New Issue