commit 1ad35b21552a3c1da0407c2664b1d26c9e17d0f2
Author: parazyd <[email protected]>
Date:   Wed Oct 26 11:10:33 2022 +0200

    [dwm] Add windowmap patch.

diff --git a/dwm.suckless.org/patches/windowmap/dwm-windowmap-20221026.diff 
b/dwm.suckless.org/patches/windowmap/dwm-windowmap-20221026.diff
new file mode 100644
index 00000000..db04e417
--- /dev/null
+++ b/dwm.suckless.org/patches/windowmap/dwm-windowmap-20221026.diff
@@ -0,0 +1,83 @@
+diff --git a/dwm.c b/dwm.c
+index e5efb6a..eaf0333 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -228,6 +228,9 @@ static void updatetitle(Client *c);
+ static void updatewindowtype(Client *c);
+ static void updatewmhints(Client *c);
+ static void view(const Arg *arg);
++static void window_set_state(Display *dpy, Window win, long state);
++static void window_map(Display *dpy, Client *c, int deiconify);
++static void window_unmap(Display *dpy, Window win, Window root, int iconify);
+ static Client *wintoclient(Window w);
+ static Monitor *wintomon(Window w);
+ static int xerror(Display *dpy, XErrorEvent *ee);
+@@ -1617,14 +1620,12 @@ showhide(Client *c)
+               return;
+       if (ISVISIBLE(c)) {
+               /* show clients top down */
+-              XMoveWindow(dpy, c->win, c->x, c->y);
+-              if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && 
!c->isfullscreen)
+-                      resize(c, c->x, c->y, c->w, c->h, 0);
++              window_map(dpy, c, 1);
+               showhide(c->snext);
+       } else {
+               /* hide clients bottom up */
+               showhide(c->snext);
+-              XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y);
++              window_unmap(dpy, c->win, root, 1);
+       }
+ }
+ 
+@@ -2032,6 +2033,51 @@ updatewmhints(Client *c)
+       }
+ }
+ 
++void
++window_set_state(Display *dpy, Window win, long state)
++{
++      long data[] = { state, None };
++
++      XChangeProperty(dpy, win, wmatom[WMState], wmatom[WMState], 32,
++              PropModeReplace, (unsigned char*)data, 2);
++}
++
++void
++window_map(Display *dpy, Client *c, int deiconify)
++{
++      Window win = c->win;
++
++      if (deiconify)
++              window_set_state(dpy, win, NormalState);
++
++      XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
++      XSetInputFocus(dpy, win, RevertToPointerRoot, CurrentTime);
++      XMapWindow(dpy, win);
++}
++
++void
++window_unmap(Display *dpy, Window win, Window root, int iconify)
++{
++      static XWindowAttributes ca, ra;
++
++      XGrabServer(dpy);
++      XGetWindowAttributes(dpy, root, &ra);
++      XGetWindowAttributes(dpy, win, &ca);
++
++      /* Prevent UnmapNotify events */
++      XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask);
++      XSelectInput(dpy, win, ca.your_event_mask & ~StructureNotifyMask);
++
++      XUnmapWindow(dpy, win);
++
++      if (iconify)
++              window_set_state(dpy, win, IconicState);
++
++      XSelectInput(dpy, root, ra.your_event_mask);
++      XSelectInput(dpy, win, ca.your_event_mask);
++      XUngrabServer(dpy);
++}
++
+ void
+ view(const Arg *arg)
+ {
diff --git a/dwm.suckless.org/patches/windowmap/index.md 
b/dwm.suckless.org/patches/windowmap/index.md
new file mode 100644
index 00000000..b7a7256d
--- /dev/null
+++ b/dwm.suckless.org/patches/windowmap/index.md
@@ -0,0 +1,18 @@
+windowmap
+=========
+
+Description
+-----------
+
+The windowmap patch makes the windows get mapped or unmapped in Xorg.
+This results in certain behaviour being enabled, for example when you
+use a compositor like picom - your windows will fade in and out when
+you switch dwm tags.
+
+Download
+--------
+* [dwm-windowmap-20221026.diff](dwm-windowmap-20221026.diff)
+
+Authors
+-------
+* Ivan J. <[email protected]>


Reply via email to