[wiki] [sites] [dwm][patch] Add destroyfocus || Chris Down

From: <git_AT_suckless.org>
Date: Mon, 29 Mar 2021 14:02:32 +0200

commit f7f5f6a67264d4a522a0126cf0305c2f7087ee03
Author: Chris Down <chris_AT_chrisdown.name>
Date: Mon Mar 29 12:01:58 2021 +0000

    [dwm][patch] Add destroyfocus

diff --git a/dwm.suckless.org/patches/destroyfocus/dwm-destroyfocus-20210329-61bb8b2.diff b/dwm.suckless.org/patches/destroyfocus/dwm-destroyfocus-20210329-61bb8b2.diff
new file mode 100644
index 00000000..17e047e9
--- /dev/null
+++ b/dwm.suckless.org/patches/destroyfocus/dwm-destroyfocus-20210329-61bb8b2.diff
_AT_@ -0,0 +1,58 @@
+From 464e7eee34bce7ff4365fc3be75275cc157608a6 Mon Sep 17 00:00:00 2001
+From: Chris Down <chris_AT_chrisdown.name>
+Date: Mon, 29 Mar 2021 11:49:13 +0000
+Subject: [PATCH] Focus client under mouse on DestroyNotify
+
+The client selected after destroy is somewhat deterministic, but not
+trivial to reason about for a user, especially for long-term windows. As
+such, apply the focus to whichever window the mouse ends up being on top
+of on destroy.
+---
+ dwm.c | 17 +++++++++++++++++
+ 1 file changed, 17 insertions(+)
+
+diff --git a/dwm.c b/dwm.c
+index 664c527..4bc877d 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -170,6 +170,7 @@ static void focusin(XEvent *e);
+ static void focusmon(const Arg *arg);
+ static void focusstack(const Arg *arg);
+ static Atom getatomprop(Client *c, Atom prop);
++static Client *getclientundermouse(void);
+ static int getrootptr(int *x, int *y);
+ static long getstate(Window w);
+ static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
+_AT_@ -653,6 +654,8 @@ destroynotify(XEvent *e)
+
+ if ((c = wintoclient(ev->window)))
+ unmanage(c, 1);
++
++ focus(getclientundermouse());
+ }
+
+ void
+_AT_@ -872,6 +875,20 @@ getatomprop(Client *c, Atom prop)
+ return atom;
+ }
+
++Client *
++getclientundermouse(void)
++{
++ int ret, di;
++ unsigned int dui;
++ Window child, dummy;
++
++ ret = XQueryPointer(dpy, root, &dummy, &child, &di, &di, &di, &di, &dui);
++ if (!ret)
++ return NULL;
++
++ return wintoclient(child);
++}
++
+ int
+ getrootptr(int *x, int *y)
+ {
+--
+2.31.1
+
diff --git a/dwm.suckless.org/patches/destroyfocus/index.md b/dwm.suckless.org/patches/destroyfocus/index.md
new file mode 100644
index 00000000..e8136fd6
--- /dev/null
+++ b/dwm.suckless.org/patches/destroyfocus/index.md
_AT_@ -0,0 +1,18 @@
+destroyfocus
+============
+
+Description
+-----------
+Focus client under mouse on DestroyNotify.
+
+The client selected after destroy is somewhat deterministic, but not trivial to
+reason about for a user, especially for long-term windows. As such, apply the
+focus to whichever window the mouse ends up being on top of on destroy.
+
+Download
+--------
+* [dwm-destroyfocus-20210329-61bb8b2.diff](dwm-destroyfocus-20210329-61bb8b2.diff)
+
+Authors
+-------
+* Chris Down - <chris_AT_chrisdown.name>
Received on Mon Mar 29 2021 - 14:02:32 CEST

This archive was generated by hypermail 2.3.0 : Mon Mar 29 2021 - 14:12:51 CEST