commit d798c979b97370f028eb77a6da3361036d175633
Author: blatzfab <[email protected]>
Date:   Mon Oct 12 11:22:53 2020 +0000

    [dwm][patch][clientopacity] patch added

diff --git 
a/dwm.suckless.org/patches/clientopacity/dwm-clientopacity-20201012-61bb8b2.diff
 
b/dwm.suckless.org/patches/clientopacity/dwm-clientopacity-20201012-61bb8b2.diff
new file mode 100644
index 00000000..a1e59f7e
--- /dev/null
+++ 
b/dwm.suckless.org/patches/clientopacity/dwm-clientopacity-20201012-61bb8b2.diff
@@ -0,0 +1,166 @@
+From e5db0708b4da80eee897588b96d6098243406075 Mon Sep 17 00:00:00 2001
+From: Fabian Blatz <[email protected]>
+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/index.md 
b/dwm.suckless.org/patches/clientopacity/index.md
new file mode 100644
index 00000000..8754e4ce
--- /dev/null
+++ b/dwm.suckless.org/patches/clientopacity/index.md
@@ -0,0 +1,22 @@
+clientopacity
+=========
+
+Description
+-----------
+This patch adds a default transparency parameter to config.h, which specifies 
the
+transparency, all windows are started with. It also adds opacity to the 
ruleset, enabling to override the opacity on a per client basis.
+
+Additionally it adds some shortcuts:
+
+* MOD + Shift + Numpad_Add     -> increase opacity of current focused window
+* MOD + Shift + Numpad_Subtract -> decrease opacity of current focused window
+
+It is based on the transparency patch of Christop Lohmann.
+
+Download
+--------
+* 
[dwm-clientopacity-20201012-61bb8b2.diff](dwm-clientopacity-20201012-61bb8b2.diff)
+
+Authors
+-------
+* Fabian Blatz - fabian.blatz at gmail period com


Reply via email to