sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit df7efdf2901e78024ee9bebff78052daa38378bf
parent b5fdaf6563586994b3ef0bb75e5d8d155c4992fb
Author: Rafael Garcia <rafael.garcia.gallego@gmail.com>
Date:   Fri, 26 Feb 2010 18:39:15 +0100

Add focusatom patch and wiki page.
Diffstat:
Adwm.suckless.org/patches/dwm-r1507-focusatom.diff | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckless.org/patches/focusatom.md | 42++++++++++++++++++++++++++++++++++++++++++
2 files changed, 112 insertions(+), 0 deletions(-)

diff --git a/dwm.suckless.org/patches/dwm-r1507-focusatom.diff b/dwm.suckless.org/patches/dwm-r1507-focusatom.diff @@ -0,0 +1,70 @@ +diff -r 72e52c5333ef dwm.c +--- a/dwm.c Wed Nov 25 13:56:17 2009 +0000 ++++ b/dwm.c Thu Feb 25 23:41:45 2010 +0100 +@@ -177,6 +177,7 @@ + static void enternotify(XEvent *e); + static void expose(XEvent *e); + static void focus(Client *c); ++static void focusatomchange(void); + static void focusin(XEvent *e); + static void focusmon(const Arg *arg); + static void focusstack(const Arg *arg); +@@ -262,6 +263,7 @@ + [UnmapNotify] = unmapnotify + }; + static Atom wmatom[WMLast], netatom[NetLast]; ++static Atom focusatom; + static Bool otherwm; + static Bool running = True; + static Cursor cursor[CurLast]; +@@ -834,6 +836,33 @@ + } + + void ++focusatomchange() { ++ int format, status; ++ unsigned long n, extra; ++ unsigned char *p = NULL; ++ Atom real; ++ Client *c; ++ Monitor *m; ++ Window *w; ++ ++ status = XGetWindowProperty(dpy, root, focusatom, 0L, 32L, True, XA_CARDINAL, &real, &format, &n, &extra, &p); ++ if(status!=Success || n==0) return; ++ if((w = (Window*)p) && (m = wintomon(*w)) && m != selmon) { ++ unfocus(selmon->sel); ++ selmon = m; ++ } ++ if((c = wintoclient(*w))) { ++ if (!ISVISIBLE(c)) { ++ c->mon->seltags ^= 1; /* toggle sel tagset */ ++ c->mon->tagset[c->mon->seltags] = c->tags & TAGMASK; ++ } ++ focus(c); ++ arrange(c->mon); ++ } ++ XFree(p); ++} ++ ++void + focusin(XEvent *e) { /* there are some broken focus acquiring clients */ + XFocusChangeEvent *ev = &e->xfocus; + +@@ -1264,6 +1293,8 @@ + + if((ev->window == root) && (ev->atom == XA_WM_NAME)) + updatestatus(); ++ else if((ev->window == root) && (ev->atom == focusatom)) ++ focusatomchange(); + else if(ev->state == PropertyDelete) + return; /* ignore */ + else if((c = wintoclient(ev->window))) { +@@ -1493,6 +1524,7 @@ + wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False); + netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); + netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); ++ focusatom = XInternAtom(dpy, "_DWM_FOCUS", False); + /* init cursors */ + cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); + cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); diff --git a/dwm.suckless.org/patches/focusatom.md b/dwm.suckless.org/patches/focusatom.md @@ -0,0 +1,42 @@ +# FOCUS SETTING ATOM + +## Description + +With this patch, dwm monitors the content of the `_DWM_FOCUS` property in the +root window (a 32-bit cardinal) and sets the focus accordingly, selecting the +client tags and monitor if needed. + +## Usage + +After patching, you can use a modified verwion of lsw to print the window id: + + diff -up lsw-0.1/lsw.c lsw.new/lsw.c + --- lsw-0.1/lsw.c 2006-10-13 11:09:18.000000000 +0200 + +++ lsw.new/lsw.c 2010-02-23 15:15:41.468637549 +0100 + @@ -63,7 +63,7 @@ main(int argc, char *argv[]) { + continue; + getname(wins[i]); + if(buf[0]) + - fprintf(stdout, "%s\n", buf); + + fprintf(stdout, "%s - %i\n", buf, wins[i]); + } + } + if(wins) + +And then call dmenu to choose a window by title, xprop to set it: + + win="$(lsw | grep -v ^\<unknown\> | dmenu | awk '{print $NF}')" + test $win && xprop -root -f _DWM_FOCUS 32c -set _DWM_FOCUS $win + +## Notes + +* May not be extremely portable + +## Download + +* [dwm-r1507-focusatom.diff](dwm-r1507-focusatom.diff) (2057 bytes) (20100226) + +## Author + +* Rafael Garcia - <rafael.garcia.gallego@gmail.com> +