2wm

dual window manager prototype (minimalist dwm with no tags, just one view)
git clone git://git.suckless.org/2wm
Log | Files | Refs | README | LICENSE

commit 23de0f108a1f13652f6451a25e56db26c232afcb
parent 7315d432b1b2ce19e187ecd1a7098a9df2241eb8
Author: Anselm R. Garbe <arg@suckless.org>
Date:   Mon, 12 Feb 2007 13:22:51 +0100

removed tag.c
Diffstat:
2wm.h | 12+++++-------
Makefile | 2+-
config.default.h | 1+
tag.c | 88-------------------------------------------------------------------------------
view.c | 80+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 87 insertions(+), 96 deletions(-)

diff --git a/2wm.h b/2wm.h @@ -65,19 +65,17 @@ extern void quit(Arg *arg); /* quit 2wm nicely */ extern void sendevent(Window w, Atom a, long value); /* send synthetic event to w */ extern int xerror(Display *dsply, XErrorEvent *ee); /* 2wm's X error handler */ -/* tag.c */ -extern void initrregs(void); /* initialize regexps of rules defined in config.h */ -extern Client *getnext(Client *c); /* returns next visible client */ -extern Client *getprev(Client *c); /* returns previous visible client */ -extern void setvisible(Client *c, Client *trans);/* sets visibility of c */ -extern void togglevisible(Arg *arg); /* toggles c tags with arg's index */ - /* util.c */ extern void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */ extern void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */ extern void spawn(Arg *arg); /* forks a new subprocess with to arg's cmd */ /* view.c */ +extern void initrregs(void); /* initialize regexps of rules defined in config.h */ +extern Client *getnext(Client *c); /* returns next visible client */ +extern Client *getprev(Client *c); /* returns previous visible client */ +extern void setvisible(Client *c, Client *trans);/* sets visibility of c */ +extern void togglevisible(Arg *arg); /* toggles c tags with arg's index */ extern void detach(Client *c); /* detaches c from global client list */ extern void arrange(void); /* arranges all windows tiled */ extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ diff --git a/Makefile b/Makefile @@ -3,7 +3,7 @@ include config.mk -SRC = client.c event.c main.c tag.c util.c view.c +SRC = client.c event.c main.c util.c view.c OBJ = ${SRC:.c=.o} all: options 2wm diff --git a/config.default.h b/config.default.h @@ -26,6 +26,7 @@ static Key key[] = { \ { MODKEY, XK_g, resizemaster, { .i = 15 } }, \ { MODKEY, XK_s, resizemaster, { .i = -15 } }, \ { MODKEY, XK_i, incnmaster, { .i = 1 } }, \ + { MODKEY, XK_r, incnmaster, { .i = -1 } }, \ { MODKEY, XK_d, togglevisible, { .i = -1 } }, \ { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \ { MODKEY, XK_space, toggleview, { 0 } }, \ diff --git a/tag.c b/tag.c @@ -1,88 +0,0 @@ -/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com> - * See LICENSE file for license details. - */ -#include "2wm.h" -#include <regex.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <X11/Xutil.h> - - -typedef struct { regex_t *regex; } RReg; - -/* static */ - -FLOATS - -static RReg *rreg = NULL; -static unsigned int len = 0; - -/* extern */ - -Client * -getnext(Client *c) { - for(; c && c->visible != visible; c = c->next); - return c; -} - -Client * -getprev(Client *c) { - for(; c && c->visible != visible; c = c->prev); - return c; -} - -void -initrregs(void) { - unsigned int i; - regex_t *reg; - - if(rreg) - return; - for(len = 0; floats[len]; len++); - rreg = emallocz(len * sizeof(RReg)); - for(i = 0; i < len; i++) { - if(floats[i]) { - reg = emallocz(sizeof(regex_t)); - if(regcomp(reg, floats[i], REG_EXTENDED)) - free(reg); - else - rreg[i].regex = reg; - } - } -} - -void -setvisible(Client *c, Client *trans) { - char prop[512]; - unsigned int i; - regmatch_t tmp; - XClassHint ch = { 0 }; - - if(trans) - c->visible = trans->visible; - else { - XGetClassHint(dpy, c->win, &ch); - snprintf(prop, sizeof prop, "%s:%s:%s", - ch.res_class ? ch.res_class : "", - ch.res_name ? ch.res_name : "", c->name); - for(i = 0; i < len; i++) - if(rreg[i].regex && !regexec(rreg[i].regex, prop, 1, &tmp, 0)) { - c->isfloat = True; - break; - } - if(ch.res_class) - XFree(ch.res_class); - if(ch.res_name) - XFree(ch.res_name); - } -} - -void -togglevisible(Arg *arg) { - if(!sel) - return; - sel->visible = !sel->visible; - arrange(); -} diff --git a/view.c b/view.c @@ -2,10 +2,24 @@ * See LICENSE file for license details. */ #include "2wm.h" +#include <regex.h> #include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <X11/Xutil.h> + + +typedef struct { regex_t *regex; } RReg; /* static */ +FLOATS + +static RReg *rreg = NULL; +static unsigned int len = 0; + + static Client * nexttiled(Client *c) { for(c = getnext(c); c && c->isfloat; c = getnext(c->next)); @@ -37,6 +51,72 @@ togglemax(Client *c) { /* extern */ +Client * +getnext(Client *c) { + for(; c && c->visible != visible; c = c->next); + return c; +} + +Client * +getprev(Client *c) { + for(; c && c->visible != visible; c = c->prev); + return c; +} + +void +initrregs(void) { + unsigned int i; + regex_t *reg; + + if(rreg) + return; + for(len = 0; floats[len]; len++); + rreg = emallocz(len * sizeof(RReg)); + for(i = 0; i < len; i++) { + if(floats[i]) { + reg = emallocz(sizeof(regex_t)); + if(regcomp(reg, floats[i], REG_EXTENDED)) + free(reg); + else + rreg[i].regex = reg; + } + } +} + +void +setvisible(Client *c, Client *trans) { + char prop[512]; + unsigned int i; + regmatch_t tmp; + XClassHint ch = { 0 }; + + if(trans) + c->visible = trans->visible; + else { + XGetClassHint(dpy, c->win, &ch); + snprintf(prop, sizeof prop, "%s:%s:%s", + ch.res_class ? ch.res_class : "", + ch.res_name ? ch.res_name : "", c->name); + for(i = 0; i < len; i++) + if(rreg[i].regex && !regexec(rreg[i].regex, prop, 1, &tmp, 0)) { + c->isfloat = True; + break; + } + if(ch.res_class) + XFree(ch.res_class); + if(ch.res_name) + XFree(ch.res_name); + } +} + +void +togglevisible(Arg *arg) { + if(!sel) + return; + sel->visible = !sel->visible; + arrange(); +} + void detach(Client *c) { if(c->prev)