sites

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

commit 8099f2cbd223c943bbe24e22fb3c543897fee5a3
parent 027095d43fb80f712358c5aab9093c1eec043861
Author: Shvedov Yury <shved@lvk.cs.msu.su>
Date:   Sun, 22 Jun 2014 10:54:51 +0400

Merge branch 'xkb'

Diffstat:
Mdwm.suckless.org/patches/dwm-6.1-xkb.diff | 131++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
Mdwm.suckless.org/patches/xkb.md | 21+++++++++++++++------
2 files changed, 105 insertions(+), 47 deletions(-)

diff --git a/dwm.suckless.org/patches/dwm-6.1-xkb.diff b/dwm.suckless.org/patches/dwm-6.1-xkb.diff @@ -1,11 +1,20 @@ -Author: Yury Shvedov <shved@lvk.cs.msu.su> -URL: http://dwm.suckless.org/patches/xkb -Implements a xxkb-like behaviour. - diff --git a/config.def.h b/config.def.h -index 875885b..2dd24c6 100644 +index 875885b..780ff6f 100644 --- a/config.def.h +++ b/config.def.h +@@ -21,9 +21,9 @@ static const Rule rules[] = { + * WM_CLASS(STRING) = instance, class + * WM_NAME(STRING) = title + */ +- /* class instance title tags mask isfloating monitor */ +- { "Gimp", NULL, NULL, 0, True, -1 }, +- { "Firefox", NULL, NULL, 1 << 8, False, -1 }, ++ /* class instance title tags mask isfloating monitor xkb_layout */ ++ { "Gimp", NULL, NULL, 0, True, -1, 0 }, ++ { "Firefox", NULL, NULL, 1 << 8, False, -1, -1 }, + }; + + /* layout(s) */ @@ -31,6 +31,13 @@ static const float mfact = 0.55; /* factor of master area size [0.05..0.95] static const int nmaster = 1; /* number of clients in master area */ static const Bool resizehints = True; /* True means respect size hints in tiled resizals */ @@ -21,7 +30,7 @@ index 875885b..2dd24c6 100644 /* symbol arrange function */ { "[]=", tile }, /* first entry is default */ diff --git a/dwm.c b/dwm.c -index 1bbb4b3..35bd4d7 100644 +index 1bbb4b3..ec39eef 100644 --- a/dwm.c +++ b/dwm.c @@ -36,6 +36,7 @@ @@ -54,7 +63,23 @@ index 1bbb4b3..35bd4d7 100644 }; typedef struct { -@@ -165,6 +174,7 @@ static void drawbar(Monitor *m); +@@ -138,6 +147,7 @@ typedef struct { + unsigned int tags; + Bool isfloating; + int monitor; ++ int xkb_layout; + } Rule; + + /* function declarations */ +@@ -157,6 +167,7 @@ static void configure(Client *c); + static void configurenotify(XEvent *e); + static void configurerequest(XEvent *e); + static Monitor *createmon(void); ++static XkbInfo *createxkb(Window w); + static void destroynotify(XEvent *e); + static void detach(Client *c); + static void detachstack(Client *c); +@@ -165,6 +176,7 @@ static void drawbar(Monitor *m); static void drawbars(void); static void enternotify(XEvent *e); static void expose(XEvent *e); @@ -62,7 +87,7 @@ index 1bbb4b3..35bd4d7 100644 static void focus(Client *c); static void focusin(XEvent *e); static void focusmon(const Arg *arg); -@@ -231,6 +241,7 @@ static Monitor *wintomon(Window w); +@@ -231,6 +243,7 @@ static Monitor *wintomon(Window w); static int xerror(Display *dpy, XErrorEvent *ee); static int xerrordummy(Display *dpy, XErrorEvent *ee); static int xerrorstart(Display *dpy, XErrorEvent *ee); @@ -70,7 +95,7 @@ index 1bbb4b3..35bd4d7 100644 static void zoom(const Arg *arg); /* variables */ -@@ -241,6 +252,7 @@ static int sw, sh; /* X display screen geometry width, height */ +@@ -241,6 +254,7 @@ static int sw, sh; /* X display screen geometry width, height */ static int bh, blw = 0; /* bar geometry */ static int (*xerrorxlib)(Display *, XErrorEvent *); static unsigned int numlockmask = 0; @@ -78,7 +103,7 @@ index 1bbb4b3..35bd4d7 100644 static void (*handler[LASTEvent]) (XEvent *) = { [ButtonPress] = buttonpress, [ClientMessage] = clientmessage, -@@ -266,6 +278,8 @@ static Drw *drw; +@@ -266,6 +280,8 @@ static Drw *drw; static Fnt *fnt; static Monitor *mons, *selmon; static Window root; @@ -87,7 +112,43 @@ index 1bbb4b3..35bd4d7 100644 /* configuration, allows nested code to access above variables */ #include "config.h" -@@ -693,6 +707,7 @@ dirtomon(int dir) { +@@ -299,6 +315,9 @@ applyrules(Client *c) { + for(m = mons; m && m->num != r->monitor; m = m->next); + if(m) + c->mon = m; ++ if(r->xkb_layout > -1 ) { ++ c->xkb->group = r->xkb_layout; ++ } + } + } + if(ch.res_class) +@@ -644,6 +663,25 @@ createmon(void) { + strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); + return m; + } ++static XkbInfo * ++createxkb(Window w){ ++ XkbInfo *xkb; ++ ++ xkb = malloc(sizeof *xkb); ++ if (xkb == NULL) { ++ die("fatal: could not malloc() %u bytes\n", sizeof *xkb); ++ } ++ xkb->group = xkbGlobal.group; ++ xkb->w = w; ++ xkb->next = xkbSaved; ++ if (xkbSaved != NULL) { ++ xkbSaved->prev = xkb; ++ } ++ xkb->prev = NULL; ++ xkbSaved = xkb; ++ ++ return xkb; ++} + + void + destroynotify(XEvent *e) { +@@ -693,6 +731,7 @@ dirtomon(int dir) { void drawbar(Monitor *m) { int x, xx, w; @@ -95,7 +156,7 @@ index 1bbb4b3..35bd4d7 100644 unsigned int i, occ = 0, urg = 0; Client *c; -@@ -718,14 +733,23 @@ drawbar(Monitor *m) { +@@ -718,14 +757,23 @@ drawbar(Monitor *m) { if(m == selmon) { /* status is only drawn on selected monitor */ w = TEXTW(stext); x = m->ww - w; @@ -119,7 +180,7 @@ index 1bbb4b3..35bd4d7 100644 if((w = x - xx) > bh) { x = xx; if(m->sel) { -@@ -777,6 +801,18 @@ expose(XEvent *e) { +@@ -777,6 +825,18 @@ expose(XEvent *e) { drawbar(m); } @@ -138,7 +199,7 @@ index 1bbb4b3..35bd4d7 100644 void focus(Client *c) { if(!c || !ISVISIBLE(c)) -@@ -1008,6 +1044,7 @@ manage(Window w, XWindowAttributes *wa) { +@@ -1008,11 +1068,20 @@ manage(Window w, XWindowAttributes *wa) { Client *c, *t = NULL; Window trans = None; XWindowChanges wc; @@ -146,32 +207,20 @@ index 1bbb4b3..35bd4d7 100644 if(!(c = calloc(1, sizeof(Client)))) die("fatal: could not malloc() %u bytes\n", sizeof(Client)); -@@ -1038,6 +1075,24 @@ manage(Window w, XWindowAttributes *wa) { - && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); - c->bw = borderpx; - -+ /* Set current xkb state */ + c->win = w; + updatetitle(c); ++ ++ /* Setting current xkb state must be before applyrules */ + xkb = findxkb(c->win); + if (xkb == NULL) { -+ xkb = malloc(sizeof *xkb); -+ if (xkb == NULL) { -+ die("fatal: could not malloc() %u bytes\n", sizeof *xkb); -+ } -+ xkb->group = xkbGlobal.group; -+ xkb->w = c->win; -+ xkb->next = xkbSaved; -+ if (xkbSaved != NULL) { -+ xkbSaved->prev = xkb; -+ } -+ xkb->prev = NULL; -+ xkbSaved = xkb; ++ xkb = createxkb(c->win); + } + c->xkb = xkb; + - wc.border_width = c->bw; - XConfigureWindow(dpy, w, CWBorderWidth, &wc); - XSetWindowBorder(dpy, w, scheme[SchemeNorm].border->rgb); -@@ -1344,8 +1399,14 @@ run(void) { + if(XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) { + c->mon = t->mon; + c->tags = t->tags; +@@ -1344,8 +1413,14 @@ run(void) { /* main event loop */ XSync(dpy, False); while(running && !XNextEvent(dpy, &ev)) @@ -186,7 +235,7 @@ index 1bbb4b3..35bd4d7 100644 } void -@@ -1428,6 +1489,7 @@ setfocus(Client *c) { +@@ -1428,6 +1503,7 @@ setfocus(Client *c) { XChangeProperty(dpy, root, netatom[NetActiveWindow], XA_WINDOW, 32, PropModeReplace, (unsigned char *) &(c->win), 1); @@ -194,7 +243,7 @@ index 1bbb4b3..35bd4d7 100644 } sendevent(c, wmatom[WMTakeFocus]); } -@@ -1490,6 +1552,7 @@ setmfact(const Arg *arg) { +@@ -1490,6 +1566,7 @@ setmfact(const Arg *arg) { void setup(void) { XSetWindowAttributes wa; @@ -202,7 +251,7 @@ index 1bbb4b3..35bd4d7 100644 /* clean up any zombies immediately */ sigchld(0); -@@ -1541,6 +1604,16 @@ setup(void) { +@@ -1541,6 +1618,16 @@ setup(void) { |EnterWindowMask|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask; XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa); XSelectInput(dpy, root, wa.event_mask); @@ -219,7 +268,7 @@ index 1bbb4b3..35bd4d7 100644 grabkeys(); focus(NULL); } -@@ -1687,6 +1760,7 @@ void +@@ -1687,6 +1774,7 @@ void unmanage(Client *c, Bool destroyed) { Monitor *m = c->mon; XWindowChanges wc; @@ -227,7 +276,7 @@ index 1bbb4b3..35bd4d7 100644 /* The server grab construct avoids race conditions. */ detach(c); -@@ -1702,6 +1776,18 @@ unmanage(Client *c, Bool destroyed) { +@@ -1702,6 +1790,18 @@ unmanage(Client *c, Bool destroyed) { XSetErrorHandler(xerror); XUngrabServer(dpy); } @@ -246,7 +295,7 @@ index 1bbb4b3..35bd4d7 100644 free(c); focus(NULL); updateclientlist(); -@@ -2030,6 +2116,23 @@ xerrorstart(Display *dpy, XErrorEvent *ee) { +@@ -2030,6 +2130,23 @@ xerrorstart(Display *dpy, XErrorEvent *ee) { return -1; } diff --git a/dwm.suckless.org/patches/xkb.md b/dwm.suckless.org/patches/xkb.md @@ -7,11 +7,20 @@ client's xkb status and restores it when client became focused. Applying -------- -Firstly you have to configure xkb as you need as described here: -http://www.x.org/archive/X11R7.5/doc/input/XKB-Config.html -The patch depends on two variables: showxkb flag defines, should patch show -current xkb group on the bar; xkb_layouts array defines the text, which will -appear on the bar according to current group if showxkb set to TRUE. +Firstly you have to configure xkb as you need as described +[here](http://www.x.org/archive/X11R7.5/doc/input/XKB-Config.html). +The patch depends on two variables: + + * `showxkb` flag defines, should patch show current xkb group on + the bar or not; + + * `xkb_layouts` array defines the text, which will appear on the + bar according to current group if `showxkb` set to `TRUE`. + +There is new field in Rule struckture, by witch you can specify +default xkb layout for window (see config.def.h for details). +This could be useful with dmenu_run, but unfortunately for some reasons +rules can't be applied to dmenu. Download -------- @@ -21,4 +30,4 @@ Download Author ------ - * Yury Shvedov - shved at lvk dot cs dot msu dot su (or mestofel13 at gmail dot com). + * Yury Shvedov - [shved AT lvk DOT cs DOT msu DOT su](mailto:shved@lvk.cs.msu.su) (or [mestofel13 AT gmail DOT com](mailto:mestofel13@gmail.com)).