From 92d477d24b8f157e511b5d17ecea88ae592d0539 Mon Sep 17 00:00:00 2001 From: Patryk Niedźwiedziński Date: Sat, 12 Sep 2020 21:37:41 +0200 Subject: Patch dwm --- pkgs/dwm/default.nix | 5 ++- pkgs/dwm/dwm-center.diff | 83 ++++++++++++++++++++++++++++++++++++++++++++++ pkgs/dwm/dwm-telegram.diff | 12 +++++-- 3 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 pkgs/dwm/dwm-center.diff diff --git a/pkgs/dwm/default.nix b/pkgs/dwm/default.nix index aa7ca15..780f5ec 100644 --- a/pkgs/dwm/default.nix +++ b/pkgs/dwm/default.nix @@ -15,7 +15,10 @@ stdenv.mkDerivation rec { prePatch = ''sed -i "s@/usr/local@$out@" config.mk''; - patches = [ ./dwm-telegram.diff ]; + patches = [ + ./dwm-center.diff + ./dwm-telegram.diff + ]; buildPhase = " make "; diff --git a/pkgs/dwm/dwm-center.diff b/pkgs/dwm/dwm-center.diff new file mode 100644 index 0000000..ce14f9d --- /dev/null +++ b/pkgs/dwm/dwm-center.diff @@ -0,0 +1,83 @@ +diff --git a/config.h b/config.h +index 771e7a1..6c880c2 100644 +--- a/config.h ++++ b/config.h +@@ -45,12 +45,12 @@ static const Rule rules[] = { + * WM_CLASS(STRING) = instance, class + * WM_NAME(STRING) = title + */ +- /* class instance title tags mask isfloating isterminal noswallow monitor */ +- { "Gimp", NULL, NULL, 1 << 8, 0, 0, 0, -1 }, +- { "St", NULL, NULL, 0, 0, 1, 0, -1 }, +- { NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, +- { NULL, "spterm", NULL, SPTAG(0), 1, 1, 0, -1 }, +- { NULL, "spcalc", NULL, SPTAG(1), 1, 1, 0, -1 }, ++ /* class instance title tags mask iscentered isfloating isterminal noswallow monitor */ ++ { "Gimp", NULL, NULL, 1 << 8, 0, 0, 0, 0, -1 }, ++ { "St", NULL, NULL, 0, 0, 0, 1, 0, -1 }, ++ { NULL, NULL, "Event Tester", 0, 0, 0, 0, 1, -1 }, ++ { NULL, "spterm", NULL, SPTAG(0), 0, 1, 1, 0, -1 }, ++ { NULL, "spcalc", NULL, SPTAG(1), 0, 1, 1, 0, -1 }, + }; + + /* layout(s) */ +diff --git a/dwm.c b/dwm.c +index 2e43282..4220f87 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -119,7 +119,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, isterminal, noswallow, issticky; ++ int isfixed, iscentered, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow, issticky; + pid_t pid; + Client *next; + Client *snext; +@@ -170,6 +170,7 @@ typedef struct { + const char *instance; + const char *title; + unsigned int tags; ++ int iscentered; + int isfloating; + int isterminal; + int noswallow; +@@ -348,6 +349,7 @@ applyrules(Client *c) + XClassHint ch = { NULL, NULL }; + + /* rule matching */ ++ c->iscentered = 0; + c->isfloating = 0; + c->tags = 0; + XGetClassHint(dpy, c->win, &ch); +@@ -361,6 +363,7 @@ applyrules(Client *c) + && (!r->instance || strstr(instance, r->instance))) + { + c->isterminal = r->isterminal; ++ c->iscentered = r->iscentered; + c->isfloating = r->isfloating; + c->noswallow = r->noswallow; + c->tags |= r->tags; +@@ -1250,6 +1253,10 @@ manage(Window w, XWindowAttributes *wa) + updatewindowtype(c); + updatesizehints(c); + updatewmhints(c); ++ if (c->iscentered) { ++ c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2; ++ c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2; ++ } + XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask); + grabbuttons(c, 0); + if (!c->isfloating) +@@ -2339,8 +2346,10 @@ updatewindowtype(Client *c) + + if (state == netatom[NetWMFullscreen]) + setfullscreen(c, 1); +- if (wtype == netatom[NetWMWindowTypeDialog]) ++ if (wtype == netatom[NetWMWindowTypeDialog]) { ++ c->iscentered = 1; + c->isfloating = 1; ++ } + } + + void diff --git a/pkgs/dwm/dwm-telegram.diff b/pkgs/dwm/dwm-telegram.diff index 5dca1a8..d548bbb 100644 --- a/pkgs/dwm/dwm-telegram.diff +++ b/pkgs/dwm/dwm-telegram.diff @@ -1,8 +1,16 @@ diff --git a/config.h b/config.h -index 771e7a1..d8fd17c 100644 +index 6c880c2..0d9eaf8 100644 --- a/config.h +++ b/config.h -@@ -154,7 +154,7 @@ static Key keys[] = { +@@ -51,6 +51,7 @@ static const Rule rules[] = { + { NULL, NULL, "Event Tester", 0, 0, 0, 0, 1, -1 }, + { NULL, "spterm", NULL, SPTAG(0), 0, 1, 1, 0, -1 }, + { NULL, "spcalc", NULL, SPTAG(1), 0, 1, 1, 0, -1 }, ++ { NULL, "telegram-desktop", NULL, 0, 1, 1, 0, 0, -1 }, + }; + + /* layout(s) */ +@@ -154,7 +155,7 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_bracketleft, spawn, SHCMD("mpc seek -60") }, { MODKEY, XK_bracketright, spawn, SHCMD("mpc seek +10") }, { MODKEY|ShiftMask, XK_bracketright, spawn, SHCMD("mpc seek +60") }, -- cgit 1.4.1