[wiki] [sites] wiki updated

From: <hg_AT_suckless.org>
Date: Fri, 26 Feb 2010 17:39:23 +0000 (UTC)

changeset: 462:2f4262cc578f
tag: tip
user: Rafael Garcia <rafael.garcia.gallego_AT_gmail.com>
date: Fri Feb 26 18:39:15 2010 +0100
files: dwm.suckless.org/patches/dwm-r1507-focusatom.diff dwm.suckless.org/patches/focusatom.md
description:
Add focusatom patch and wiki page.


diff -r d3a624d4b3b9 -r 2f4262cc578f dwm.suckless.org/patches/dwm-r1507-focusatom.diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwm.suckless.org/patches/dwm-r1507-focusatom.diff Fri Feb 26 18:39:15 2010 +0100
_AT_@ -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
+_AT_@ -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);
+_AT_@ -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];
+_AT_@ -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;
+
+_AT_@ -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))) {
+_AT_@ -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 -r d3a624d4b3b9 -r 2f4262cc578f dwm.suckless.org/patches/focusatom.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwm.suckless.org/patches/focusatom.md Fri Feb 26 18:39:15 2010 +0100
_AT_@ -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
+ _AT_@ -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_AT_gmail.com>
+
Received on Fri Feb 26 2010 - 18:39:23 CET

This archive was generated by hypermail 2.3.0 : Thu Sep 13 2012 - 19:31:09 CEST