sites

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

commit eaf93dde13c4982832766171041ae45f4606b3fa
parent ff0e4d43d449771d3cbf57cf764f632229ee3132
Author: rouchage <zdavitashvili0@gmail.com>
Date:   Sun, 25 Apr 2021 18:00:54 +0400

~added centerFirstWindow patch

Diffstat:
Adwm.suckless.org/patches/centerFirstWindow/dwm-centerFirstWindow-6.2.diff | 67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckless.org/patches/centerFirstWindow/index.md | 43+++++++++++++++++++++++++++++++++++++++++++
2 files changed, 110 insertions(+), 0 deletions(-)

diff --git a/dwm.suckless.org/patches/centerFirstWindow/dwm-centerFirstWindow-6.2.diff b/dwm.suckless.org/patches/centerFirstWindow/dwm-centerFirstWindow-6.2.diff @@ -0,0 +1,67 @@ +diff -up dwm-6.2-orig/config.def.h dwm-6.2-modd/config.def.h +--- dwm-6.2-orig/config.def.h 2019-02-02 16:55:28.000000000 +0400 ++++ dwm-6.2-modd/config.def.h 2021-04-25 16:05:22.569759243 +0400 +@@ -26,9 +26,10 @@ static const Rule rules[] = { + * WM_CLASS(STRING) = instance, class + * WM_NAME(STRING) = title + */ +- /* class instance title tags mask isfloating monitor */ +- { "Gimp", NULL, NULL, 0, 1, -1 }, +- { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, ++ /* class instance title tags mask isfloating CenterThisWindow? monitor */ ++ { "Xfce4-terminal", NULL, NULL, 0, 0, 1, -1 }, ++ { "Gimp", NULL, NULL, 0, 1, 0, -1 }, ++ { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1 }, + }; + + /* layout(s) */ +diff -up dwm-6.2-orig/dwm.c dwm-6.2-modd/dwm.c +--- dwm-6.2-orig/dwm.c 2019-02-02 16:55:28.000000000 +0400 ++++ dwm-6.2-modd/dwm.c 2021-04-25 16:06:15.368310756 +0400 +@@ -92,7 +92,7 @@ struct Client { + int basew, baseh, incw, inch, maxw, maxh, minw, minh; + int bw, oldbw; + unsigned int tags; +- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; ++ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, CenterThisWindow; + Client *next; + Client *snext; + Monitor *mon; +@@ -138,6 +138,7 @@ typedef struct { + const char *title; + unsigned int tags; + int isfloating; ++ int CenterThisWindow; + int monitor; + } Rule; + +@@ -286,6 +287,7 @@ applyrules(Client *c) + + /* rule matching */ + c->isfloating = 0; ++ c->CenterThisWindow = 0; + c->tags = 0; + XGetClassHint(dpy, c->win, &ch); + class = ch.res_class ? ch.res_class : broken; +@@ -298,6 +300,7 @@ applyrules(Client *c) + && (!r->instance || strstr(instance, r->instance))) + { + c->isfloating = r->isfloating; ++ c->CenterThisWindow = r->CenterThisWindow; + c->tags |= r->tags; + for (m = mons; m && m->num != r->monitor; m = m->next); + if (m) +@@ -1694,6 +1697,13 @@ tile(Monitor *m) + resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); + ty += HEIGHT(c); + } ++ ++ if (n == 1 && selmon->sel->CenterThisWindow) ++ resizeclient(selmon->sel, ++ (selmon->mw - selmon->mw * 0.5) / 2, ++ (selmon->mh - selmon->mh * 0.5) / 2, ++ selmon->mw * 0.5, ++ selmon->mh * 0.5); + } + + void diff --git a/dwm.suckless.org/patches/centerFirstWindow/index.md b/dwm.suckless.org/patches/centerFirstWindow/index.md @@ -0,0 +1,42 @@ +centerFirstWindow +============== + +Description +----------- +This patch centers window if it is a single window opened. +When any other window opens, then they tile normally, +and if all other windows will close, it will center again. + +It is usefull for apps like - terminal, if you don't want that it cover all of master area, +when no other apps are open. + +Usage +----- +It can be enabled for any window in config file, by setting `CenterThisWindow` to `1`: + /* class instance title tags mask isfloating CenterThisWindow? monitor */ + { "Xfce4-terminal", NULL, NULL, 0, 0, 1, -1 }, + +With one and two clients in master respectively this results in: + + +-----------------------------+ +-----------------------------+ + | | | +------------+ +----------+ | + | | | | | | | | + | | | | | | | | + | +-------------+ | | | | | | | + | | Single | | | | Terminal | | Terminal | | + | | Terminal | | | | Window 1 | | Window 2 | | + | | Window | | | | | | | | + | +-------------+ | | | | | | | + | | | | | | | | + | | | | | | | | + | | | +------------+ +----------+ | + +-----------------------------+ +-----------------------------+ + +Download +-------- +* [dwm-centerFirstWindow-6.2.diff](dwm-centerFirstWindow-6.2.diff) + +Authors +------- +* ზურა დავითაშვილი - <zdavitashvili0@gmail.com> +* Part of code is taken from reddit post from `johannesthyssen` +\ No newline at end of file