sites

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

commit a9b772c2785a9828a700f1672508f6fed36af7fa
parent 4b3fcb045de9742ead9e474c69f469ecd206859d
Author: blatzfab <fabianblatz@gmail.com>
Date:   Sun, 12 Jun 2022 18:46:19 +0200

[dwm][clientopacity] correct enum element order within patch

Diffstat:
Ddwm.suckless.org/patches/clientopacity/dwm-clientopacity-20201012-61bb8b2.diff | 166-------------------------------------------------------------------------------
Adwm.suckless.org/patches/clientopacity/dwm-clientopacity-20220612-d3f93c7.diff | 166+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdwm.suckless.org/patches/clientopacity/index.md | 2+-
3 files changed, 167 insertions(+), 167 deletions(-)

diff --git a/dwm.suckless.org/patches/clientopacity/dwm-clientopacity-20201012-61bb8b2.diff b/dwm.suckless.org/patches/clientopacity/dwm-clientopacity-20201012-61bb8b2.diff @@ -1,166 +0,0 @@ -From e5db0708b4da80eee897588b96d6098243406075 Mon Sep 17 00:00:00 2001 -From: Fabian Blatz <fabian.blatz@gmail.com> -Date: Mon, 12 Oct 2020 11:26:51 +0000 -Subject: [PATCH] adds opacity on a per client basis - ---- - config.def.h | 10 +++++++--- - dwm.c | 37 ++++++++++++++++++++++++++++++++++++- - 2 files changed, 43 insertions(+), 4 deletions(-) - -diff --git a/config.def.h b/config.def.h -index 1c0b587..7addf50 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -5,6 +5,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */ - static const unsigned int snap = 32; /* snap pixel */ - static const int showbar = 1; /* 0 means no bar */ - static const int topbar = 1; /* 0 means bottom bar */ -+static const double defaultopacity = 0.75; - static const char *fonts[] = { "monospace:size=10" }; - static const char dmenufont[] = "monospace:size=10"; - static const char col_gray1[] = "#222222"; -@@ -26,9 +27,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 opacity monitor */ -+ { "Gimp", NULL, NULL, 0, 1, 1.0, -1 }, -+ { "Firefox", NULL, NULL, 1 << 8, 0, 1.0, -1 }, -+ { "St", NULL, NULL, 0, 0, defaultopacity, -1}, - }; - - /* layout(s) */ -@@ -84,6 +86,8 @@ static Key keys[] = { - { MODKEY, XK_period, focusmon, {.i = +1 } }, - { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, - { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, -+ { MODKEY|ShiftMask, XK_KP_Add, changeopacity, {.f = +0.1}}, -+ { MODKEY|ShiftMask, XK_KP_Subtract, changeopacity, {.f = -0.1}}, - TAGKEYS( XK_1, 0) - TAGKEYS( XK_2, 1) - TAGKEYS( XK_3, 2) -diff --git a/dwm.c b/dwm.c -index 664c527..15014c0 100644 ---- a/dwm.c -+++ b/dwm.c -@@ -62,7 +62,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ - enum { SchemeNorm, SchemeSel }; /* color schemes */ - enum { NetSupported, NetWMName, NetWMState, NetWMCheck, - NetWMFullscreen, NetActiveWindow, NetWMWindowType, -- NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ -+ NetWMWindowTypeDialog, NetClientList, NetLast, NetWMWindowsOpacity }; /* EWMH atoms */ - enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ - enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, - ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ -@@ -95,6 +95,7 @@ struct Client { - int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; - Client *next; - Client *snext; -+ double opacity; - Monitor *mon; - Window win; - }; -@@ -138,6 +139,7 @@ typedef struct { - const char *title; - unsigned int tags; - int isfloating; -+ double opacity; - int monitor; - } Rule; - -@@ -149,6 +151,7 @@ static void arrangemon(Monitor *m); - static void attach(Client *c); - static void attachstack(Client *c); - static void buttonpress(XEvent *e); -+static void changeopacity(const Arg *arg); - static void checkotherwm(void); - static void cleanup(void); - static void cleanupmon(Monitor *mon); -@@ -185,6 +188,7 @@ static void monocle(Monitor *m); - static void motionnotify(XEvent *e); - static void movemouse(const Arg *arg); - static Client *nexttiled(Client *c); -+static void opacity(Client *c, double opacity); - static void pop(Client *); - static void propertynotify(XEvent *e); - static void quit(const Arg *arg); -@@ -288,6 +292,7 @@ applyrules(Client *c) - /* rule matching */ - c->isfloating = 0; - c->tags = 0; -+ c->opacity = defaultopacity; - XGetClassHint(dpy, c->win, &ch); - class = ch.res_class ? ch.res_class : broken; - instance = ch.res_name ? ch.res_name : broken; -@@ -300,6 +305,7 @@ applyrules(Client *c) - { - c->isfloating = r->isfloating; - c->tags |= r->tags; -+ c->opacity = r->opacity; - for (m = mons; m && m->num != r->monitor; m = m->next); - if (m) - c->mon = m; -@@ -456,6 +462,21 @@ buttonpress(XEvent *e) - buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg); - } - -+void -+changeopacity(const Arg *arg) -+{ -+ if (!selmon->sel) -+ return; -+ selmon->sel->opacity+=arg->f; -+ if(selmon->sel->opacity > 1.0) -+ selmon->sel->opacity = 1.0; -+ -+ if(selmon->sel->opacity < 0) -+ selmon->sel->opacity = 0; -+ -+ opacity(selmon->sel, selmon->sel->opacity); -+} -+ - void - checkotherwm(void) - { -@@ -1039,6 +1060,7 @@ manage(Window w, XWindowAttributes *wa) - c->mon = selmon; - applyrules(c); - } -+ opacity(c, c->opacity); - - if (c->x + WIDTH(c) > c->mon->mx + c->mon->mw) - c->x = c->mon->mx + c->mon->mw - WIDTH(c); -@@ -1200,6 +1222,18 @@ nexttiled(Client *c) - return c; - } - -+void -+opacity(Client *c, double opacity) -+{ -+ if(opacity >= 0 && opacity <= 1) { -+ unsigned long real_opacity[] = { opacity * 0xffffffff }; -+ XChangeProperty(dpy, c->win, netatom[NetWMWindowsOpacity], XA_CARDINAL, -+ 32, PropModeReplace, (unsigned char *)real_opacity, -+ 1); -+ } else -+ XDeleteProperty(dpy, c->win, netatom[NetWMWindowsOpacity]); -+} -+ - void - pop(Client *c) - { -@@ -1563,6 +1597,7 @@ setup(void) - netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); - netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False); - netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False); -+ netatom[NetWMWindowsOpacity] = XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False); - /* init cursors */ - cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr); - cursor[CurResize] = drw_cur_create(drw, XC_sizing); --- -2.28.0 - diff --git a/dwm.suckless.org/patches/clientopacity/dwm-clientopacity-20220612-d3f93c7.diff b/dwm.suckless.org/patches/clientopacity/dwm-clientopacity-20220612-d3f93c7.diff @@ -0,0 +1,166 @@ +From d59a5a5409e4078c2c1b5ead786e1312d431c9a8 Mon Sep 17 00:00:00 2001 +From: blatzfab <fabian.blatz@hansgrohe.com> +Date: Sun, 12 Jun 2022 18:42:28 +0200 +Subject: [PATCH] [PATCH] adds opacity on a per client basis + +--- + config.def.h | 10 +++++++--- + dwm.c | 37 ++++++++++++++++++++++++++++++++++++- + 2 files changed, 43 insertions(+), 4 deletions(-) + +diff --git a/config.def.h b/config.def.h +index a2ac963..4b6903c 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -5,6 +5,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */ + static const unsigned int snap = 32; /* snap pixel */ + static const int showbar = 1; /* 0 means no bar */ + static const int topbar = 1; /* 0 means bottom bar */ ++static const double defaultopacity = 0.75; + static const char *fonts[] = { "monospace:size=10" }; + static const char dmenufont[] = "monospace:size=10"; + static const char col_gray1[] = "#222222"; +@@ -26,9 +27,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 opacity monitor */ ++ { "Gimp", NULL, NULL, 0, 1, 1.0, -1 }, ++ { "Firefox", NULL, NULL, 1 << 8, 0, 1.0, -1 }, ++ { "St", NULL, NULL, 0, 0, defaultopacity, -1}, + }; + + /* layout(s) */ +@@ -85,6 +87,8 @@ static Key keys[] = { + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, ++ { MODKEY|ShiftMask, XK_KP_Add, changeopacity, {.f = +0.1}}, ++ { MODKEY|ShiftMask, XK_KP_Subtract, changeopacity, {.f = -0.1}}, + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) +diff --git a/dwm.c b/dwm.c +index 5646a5c..591dff9 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -62,7 +62,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ + enum { SchemeNorm, SchemeSel }; /* color schemes */ + enum { NetSupported, NetWMName, NetWMState, NetWMCheck, + NetWMFullscreen, NetActiveWindow, NetWMWindowType, +- NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ ++ NetWMWindowTypeDialog, NetClientList, NetWMWindowsOpacity, NetLast }; /* EWMH atoms */ + enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ + enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, + ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ +@@ -95,6 +95,7 @@ struct Client { + int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; + Client *next; + Client *snext; ++ double opacity; + Monitor *mon; + Window win; + }; +@@ -138,6 +139,7 @@ typedef struct { + const char *title; + unsigned int tags; + int isfloating; ++ double opacity; + int monitor; + } Rule; + +@@ -149,6 +151,7 @@ static void arrangemon(Monitor *m); + static void attach(Client *c); + static void attachstack(Client *c); + static void buttonpress(XEvent *e); ++static void changeopacity(const Arg *arg); + static void checkotherwm(void); + static void cleanup(void); + static void cleanupmon(Monitor *mon); +@@ -185,6 +188,7 @@ static void monocle(Monitor *m); + static void motionnotify(XEvent *e); + static void movemouse(const Arg *arg); + static Client *nexttiled(Client *c); ++static void opacity(Client *c, double opacity); + static void pop(Client *); + static void propertynotify(XEvent *e); + static void quit(const Arg *arg); +@@ -288,6 +292,7 @@ applyrules(Client *c) + /* rule matching */ + c->isfloating = 0; + c->tags = 0; ++ c->opacity = defaultopacity; + XGetClassHint(dpy, c->win, &ch); + class = ch.res_class ? ch.res_class : broken; + instance = ch.res_name ? ch.res_name : broken; +@@ -300,6 +305,7 @@ applyrules(Client *c) + { + c->isfloating = r->isfloating; + c->tags |= r->tags; ++ c->opacity = r->opacity; + for (m = mons; m && m->num != r->monitor; m = m->next); + if (m) + c->mon = m; +@@ -458,6 +464,21 @@ buttonpress(XEvent *e) + buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg); + } + ++void ++changeopacity(const Arg *arg) ++{ ++ if (!selmon->sel) ++ return; ++ selmon->sel->opacity+=arg->f; ++ if(selmon->sel->opacity > 1.0) ++ selmon->sel->opacity = 1.0; ++ ++ if(selmon->sel->opacity < 0) ++ selmon->sel->opacity = 0; ++ ++ opacity(selmon->sel, selmon->sel->opacity); ++} ++ + void + checkotherwm(void) + { +@@ -1045,6 +1066,7 @@ manage(Window w, XWindowAttributes *wa) + c->mon = selmon; + applyrules(c); + } ++ opacity(c, c->opacity); + + if (c->x + WIDTH(c) > c->mon->mx + c->mon->mw) + c->x = c->mon->mx + c->mon->mw - WIDTH(c); +@@ -1206,6 +1228,18 @@ nexttiled(Client *c) + return c; + } + ++void ++opacity(Client *c, double opacity) ++{ ++ if(opacity >= 0 && opacity <= 1) { ++ unsigned long real_opacity[] = { opacity * 0xffffffff }; ++ XChangeProperty(dpy, c->win, netatom[NetWMWindowsOpacity], XA_CARDINAL, ++ 32, PropModeReplace, (unsigned char *)real_opacity, ++ 1); ++ } else ++ XDeleteProperty(dpy, c->win, netatom[NetWMWindowsOpacity]); ++} ++ + void + pop(Client *c) + { +@@ -1569,6 +1603,7 @@ setup(void) + netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); + netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False); + netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False); ++ netatom[NetWMWindowsOpacity] = XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False); + /* init cursors */ + cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr); + cursor[CurResize] = drw_cur_create(drw, XC_sizing); +-- +2.36.1 + diff --git a/dwm.suckless.org/patches/clientopacity/index.md b/dwm.suckless.org/patches/clientopacity/index.md @@ -15,7 +15,7 @@ It is based on the transparency patch of Christop Lohmann. Download -------- -* [dwm-clientopacity-20201012-61bb8b2.diff](dwm-clientopacity-20201012-61bb8b2.diff) +* [dwm-clientopacity-20220612-d3f93c7.diff](dwm-clientopacity-20220612-d3f93c7.diff) Authors -------