sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 8c3d76198611f1916751a07b4eb38c5bd72b71ac
parent a7a434ff80cfeb4442afa9ea0d93b528acb4cb12
Author: MLquest8 <miskuzius@gmail.com>
Date:   Fri, 12 Jun 2020 15:39:17 +0400

[dwm][PATCH] updated xtile for 6.2

Diffstat:
Adwm.suckless.org/patches/xtile/dwm-xtile-6.2.diff | 312+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdwm.suckless.org/patches/xtile/index.md | 2++
2 files changed, 314 insertions(+), 0 deletions(-)

diff --git a/dwm.suckless.org/patches/xtile/dwm-xtile-6.2.diff b/dwm.suckless.org/patches/xtile/dwm-xtile-6.2.diff @@ -0,0 +1,312 @@ +From 9edd083970e01027483a3b34a3256824668f585a Mon Sep 17 00:00:00 2001 +From: MLquest8 <miskuzius@gmail.com> +Date: Fri, 12 Jun 2020 15:31:20 +0400 +Subject: [PATCH] xtile updated for version 6.2 + +--- + config.def.h | 15 +++++-- + dwm.c | 121 ++++++++++++++++++++++++++++++++++----------------- + 2 files changed, 94 insertions(+), 42 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 1c0b587..254e51c 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -32,7 +32,8 @@ static const Rule rules[] = { + }; + + /* layout(s) */ +-static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ ++static const int dirs[3] = { DirHor, DirVer, DirVer }; /* tiling dirs */ ++static const float facts[3] = { 1.1, 1.1, 1.1 }; /* tiling facts */ + static const int nmaster = 1; /* number of clients in master area */ + static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ + +@@ -50,6 +51,10 @@ static const Layout layouts[] = { + { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ + { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ + { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, ++#define TILEKEYS(MOD,G,M,S) \ ++ { MOD, XK_r, setdirs, {.v = (int[]) { INC(G * +1), INC(M * +1), INC(S * +1) } } }, \ ++ { MOD, XK_h, setfacts, {.v = (float[]){ INC(G * -0.1), INC(M * -0.1), INC(S * -0.1) } } }, \ ++ { MOD, XK_l, setfacts, {.v = (float[]){ INC(G * +0.1), INC(M * +0.1), INC(S * +0.1) } } }, + + /* helper for spawning shell commands in the pre dwm-5.0 fashion */ + #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } +@@ -68,8 +73,6 @@ static Key keys[] = { + { MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY, XK_i, incnmaster, {.i = +1 } }, + { MODKEY, XK_d, incnmaster, {.i = -1 } }, +- { MODKEY, XK_h, setmfact, {.f = -0.05} }, +- { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY, XK_Return, zoom, {0} }, + { MODKEY, XK_Tab, view, {0} }, + { MODKEY|ShiftMask, XK_c, killclient, {0} }, +@@ -77,6 +80,12 @@ static Key keys[] = { + { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, + { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, + { MODKEY, XK_space, setlayout, {0} }, ++ TILEKEYS(MODKEY, 1, 0, 0) ++ TILEKEYS(MODKEY|ShiftMask, 0, 1, 0) ++ TILEKEYS(MODKEY|ControlMask, 0, 0, 1) ++ TILEKEYS(MODKEY|ShiftMask|ControlMask, 1, 1, 1) ++ { MODKEY|ShiftMask, XK_t, setdirs, {.v = (int[]){ DirHor, DirVer, DirVer } } }, ++ { MODKEY|ControlMask, XK_t, setdirs, {.v = (int[]){ DirVer, DirHor, DirHor } } }, + { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY, XK_0, view, {.ui = ~0 } }, + { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, +diff --git a/dwm.c b/dwm.c +index a2943af..e43fbad 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -47,15 +47,20 @@ + /* macros */ + #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) + #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) ++#define GETINC(X) ((X) - 2000) ++#define INC(X) ((X) + 2000) + #define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \ + * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy))) ++#define ISINC(X) ((X) > 1000 && (X) < 3000) + #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) + #define LENGTH(X) (sizeof X / sizeof X[0]) ++#define MOD(N,M) ((N)%(M) < 0 ? (N)%(M) + (M) : (N)%(M)) + #define MOUSEMASK (BUTTONMASK|PointerMotionMask) + #define WIDTH(X) ((X)->w + 2 * (X)->bw) + #define HEIGHT(X) ((X)->h + 2 * (X)->bw) + #define TAGMASK ((1 << LENGTH(tags)) - 1) + #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) ++#define TRUNC(X,A,B) (MAX((A), MIN((X), (B)))) + + /* enums */ + enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ +@@ -66,6 +71,7 @@ enum { NetSupported, NetWMName, NetWMState, NetWMCheck, + enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ + enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, + ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ ++enum { DirHor, DirVer, DirRotHor, DirRotVer, DirLast }; /* tiling dirs */ + + typedef union { + int i; +@@ -74,6 +80,11 @@ typedef union { + const void *v; + } Arg; + ++typedef struct { ++ unsigned int x, y, fx, fy, n, dir; ++ float fact; ++} Area; ++ + typedef struct { + unsigned int click; + unsigned int mask; +@@ -114,7 +125,6 @@ typedef struct { + typedef struct Pertag Pertag; + struct Monitor { + char ltsymbol[16]; +- float mfact; + int nmaster; + int num; + int by; /* bar geometry */ +@@ -200,10 +210,11 @@ static void scan(void); + static int sendevent(Client *c, Atom proto); + static void sendmon(Client *c, Monitor *m); + static void setclientstate(Client *c, long state); ++static void setdirs(const Arg *arg); ++static void setfacts(const Arg *arg); + static void setfocus(Client *c); + static void setfullscreen(Client *c, int fullscreen); + static void setlayout(const Arg *arg); +-static void setmfact(const Arg *arg); + static void setup(void); + static void seturgent(Client *c, int urg); + static void showhide(Client *c); +@@ -277,7 +288,7 @@ static Window root, wmcheckwin; + struct Pertag { + unsigned int curtag, prevtag; /* current and previous tag */ + int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */ +- float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */ ++ Area areas[LENGTH(tags) + 1][3]; /* tiling areas */ + unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */ + const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */ + int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */ +@@ -526,6 +537,7 @@ clientmessage(XEvent *e) + { + XClientMessageEvent *cme = &e->xclient; + Client *c = wintoclient(cme->window); ++ int i; + + if (!c) + return; +@@ -535,6 +547,10 @@ clientmessage(XEvent *e) + setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ + || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); + } else if (cme->message_type == netatom[NetActiveWindow]) { ++ if(!ISVISIBLE(c)) { ++ for(i=0; !(c->tags & 1 << i); i++); ++ view(&(Arg){.ui = 1 << i}); ++ } + if (c != selmon->sel && !c->isurgent) + seturgent(c, 1); + } +@@ -643,11 +659,10 @@ Monitor * + createmon(void) + { + Monitor *m; +- unsigned int i; ++ unsigned int i, j; + + m = ecalloc(1, sizeof(Monitor)); + m->tagset[0] = m->tagset[1] = 1; +- m->mfact = mfact; + m->nmaster = nmaster; + m->showbar = showbar; + m->topbar = topbar; +@@ -659,7 +674,12 @@ createmon(void) + + for (i = 0; i <= LENGTH(tags); i++) { + m->pertag->nmasters[i] = m->nmaster; +- m->pertag->mfacts[i] = m->mfact; ++ ++ /* init tiling dirs and facts */ ++ for(j = 0; j < 3; j++) { ++ m->pertag->areas[i][j].dir = MIN(dirs[j], ((int[]){ 3, 1, 1 }[j])); ++ m->pertag->areas[i][j].fact = TRUNC(facts[j], 0.1, 10); ++ } + + m->pertag->ltidxs[i][0] = m->lt[0]; + m->pertag->ltidxs[i][1] = m->lt[1]; +@@ -1459,6 +1479,31 @@ setclientstate(Client *c, long state) + PropModeReplace, (unsigned char *)data, 2); + } + ++void ++setdirs(const Arg *arg) { ++ int *dirs = (int *)arg->v, i, n; ++ Area *areas = selmon->pertag->areas[selmon->pertag->curtag]; ++ ++ for(i = 0; i < 3; i++) { ++ n = (int[]){ 4, 2, 2 }[i]; ++ areas[i].dir = ISINC(dirs[i]) ? ++ MOD((int)areas[i].dir + GETINC(dirs[i]), n) : TRUNC(dirs[i], 0, n - 1); ++ } ++ arrange(selmon); ++} ++ ++void ++setfacts(const Arg *arg) { ++ float *facts = (float *)arg->v; ++ Area *areas = selmon->pertag->areas[selmon->pertag->curtag]; ++ int i; ++ ++ for(i = 0; i < 3; i++) ++ areas[i].fact = TRUNC(ISINC(facts[i]) ? ++ areas[i].fact + GETINC(facts[i]) : facts[i], 0.1, 10); ++ arrange(selmon); ++} ++ + int + sendevent(Client *c, Atom proto) + { +@@ -1538,21 +1583,6 @@ setlayout(const Arg *arg) + drawbar(selmon); + } + +-/* arg > 1.0 will set mfact absolutely */ +-void +-setmfact(const Arg *arg) +-{ +- float f; +- +- if (!arg || !selmon->lt[selmon->sellt]->arrange) +- return; +- f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0; +- if (f < 0.05 || f > 0.95) +- return; +- selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f; +- arrange(selmon); +-} +- + void + setup(void) + { +@@ -1700,29 +1730,44 @@ tagmon(const Arg *arg) + void + tile(Monitor *m) + { +- unsigned int i, n, h, mw, my, ty; + Client *c; + ++ Area *ga = m->pertag->areas[m->pertag->curtag], *ma = ga + 1, *sa = ga + 2, *a; ++ unsigned int n, i, w, h, ms, ss; ++ float f; ++ ++ /* print layout symbols */ ++ snprintf(m->ltsymbol, sizeof m->ltsymbol, "%c%c%c", ++ (char[]){ '<', '^', '>', 'v' }[ga->dir], ++ (char[]){ '-', '|' }[ma->dir], ++ (char[]){ '-', '|' }[sa->dir]); ++ ++ /* calculate number of clients */ + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + +- if (n > m->nmaster) +- mw = m->nmaster ? m->ww * m->mfact : 0; ++ ma->n = MIN(n, m->nmaster), sa->n = n - ma->n; ++ /* calculate area rectangles */ ++ f = ma->n == 0 ? 0 : (sa->n == 0 ? 1 : ga->fact / 2); ++ if(ga->dir == DirHor || ga->dir == DirRotHor) ++ ms = f * m->ww, ss = m->ww - ms, ++ ma->x = ga->dir == DirHor ? 0 : ss, ma->y = 0, ma->fx = ma->x + ms, ma->fy = m->wh, ++ sa->x = ga->dir == DirHor ? ms : 0, sa->y = 0, sa->fx = sa->x + ss, sa->fy = m->wh; + else +- mw = m->ww; +- for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) +- if (i < m->nmaster) { +- h = (m->wh - my) / (MIN(n, m->nmaster) - i); +- resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); +- if (my + HEIGHT(c) < m->wh) +- my += HEIGHT(c); +- } else { +- h = (m->wh - ty) / (n - i); +- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); +- if (ty + HEIGHT(c) < m->wh) +- ty += HEIGHT(c); +- } ++ ms = f * m->wh, ss = m->wh - ms, ++ ma->x = 0, ma->y = ga->dir == DirVer ? 0 : ss, ma->fx = m->ww, ma->fy = ma->y + ms, ++ sa->x = 0, sa->y = ga->dir == DirVer ? ms : 0, sa->fx = m->ww, sa->fy = sa->y + ss; ++ /* tile clients */ ++ for(c = nexttiled(m->clients), i = 0; i < n; c = nexttiled(c->next), i++) { ++ a = ma->n > 0 ? ma : sa; ++ f = i == 0 || ma->n == 0 ? a->fact : 1, f /= --a->n + f; ++ w = (a->dir == DirVer ? 1 : f) * (a->fx - a->x); ++ h = (a->dir == DirHor ? 1 : f) * (a->fy - a->y); ++ resize(c, m->wx + a->x, m->wy + a->y, w - 2 * c->bw, h - 2 * c->bw, False); ++ a->x += a->dir == DirHor ? w : 0; ++ a->y += a->dir == DirVer ? h : 0; ++ } + } + + void +@@ -1786,7 +1831,6 @@ toggleview(const Arg *arg) + + /* apply settings for this view */ + selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag]; +- selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag]; + selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag]; + selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt]; + selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1]; +@@ -2111,7 +2155,6 @@ view(const Arg *arg) + } + + selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag]; +- selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag]; + selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag]; + selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt]; + selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1]; +-- +2.26.2 + diff --git a/dwm.suckless.org/patches/xtile/index.md b/dwm.suckless.org/patches/xtile/index.md @@ -169,8 +169,10 @@ cfacts, [stackmfact](../stackmfact/). Download -------- +* [dwm-xtile-6.2.diff](dwm-xtile-6.2.diff) 11/06/2020 * [dwm-6.0-xtile.diff](dwm-6.0-xtile.diff) Author ------ +* MLquest8 (updated for 6.2) (miskuzius at gmail.com) * Carlos Pita (memeplex) <carlosjosepita@gmail.com>