sites

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

commit f7f5f6a67264d4a522a0126cf0305c2f7087ee03
parent df1b3f7c3977396a7c1a762299c1d1ec2ffd0765
Author: Chris Down <chris@chrisdown.name>
Date:   Mon, 29 Mar 2021 12:01:58 +0000

[dwm][patch] Add destroyfocus

Diffstat:
Adwm.suckless.org/patches/destroyfocus/dwm-destroyfocus-20210329-61bb8b2.diff | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckless.org/patches/destroyfocus/index.md | 18++++++++++++++++++
2 files changed, 76 insertions(+), 0 deletions(-)

diff --git a/dwm.suckless.org/patches/destroyfocus/dwm-destroyfocus-20210329-61bb8b2.diff b/dwm.suckless.org/patches/destroyfocus/dwm-destroyfocus-20210329-61bb8b2.diff @@ -0,0 +1,58 @@ +From 464e7eee34bce7ff4365fc3be75275cc157608a6 Mon Sep 17 00:00:00 2001 +From: Chris Down <chris@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 +@@ -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); +@@ -653,6 +654,8 @@ destroynotify(XEvent *e) + + if ((c = wintoclient(ev->window))) + unmanage(c, 1); ++ ++ focus(getclientundermouse()); + } + + void +@@ -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 @@ -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@chrisdown.name>