hit it with the knf stick.

This commit is contained in:
oga 2008-04-15 20:24:41 +00:00
parent 3a94c57afc
commit 75182c6d9c
20 changed files with 441 additions and 432 deletions

View File

@ -44,8 +44,6 @@ struct client_ctx;
TAILQ_HEAD(cycle_entry_q, client_ctx); TAILQ_HEAD(cycle_entry_q, client_ctx);
/* #define CYCLE_FOREACH_MRU(cy, ctx) TAILQ_FOREACH((ctx), */
struct screen_ctx; struct screen_ctx;
struct fontdesc { struct fontdesc {
@ -249,7 +247,6 @@ struct keybinding {
struct cmd { struct cmd {
TAILQ_ENTRY(cmd) entry; TAILQ_ENTRY(cmd) entry;
int flags; int flags;
#define CMD_STATIC 0x01 /* static configuration in conf.c */
char image[MAXPATHLEN]; char image[MAXPATHLEN];
char label[256]; char label[256];
/* (argv) */ /* (argv) */
@ -266,8 +263,8 @@ struct conf {
char conf_path[MAXPATHLEN]; char conf_path[MAXPATHLEN];
struct cmd_q cmdq; struct cmd_q cmdq;
int flags;
#define CONF_STICKY_GROUPS 0x0001 #define CONF_STICKY_GROUPS 0x0001
int flags;
char termpath[MAXPATHLEN]; char termpath[MAXPATHLEN];
char lockpath[MAXPATHLEN]; char lockpath[MAXPATHLEN];
@ -314,7 +311,8 @@ struct mwm_hints {
#define MWM_DECOR_ALL (1 << 0) #define MWM_DECOR_ALL (1 << 0)
#define MWM_DECOR_BORDER (1 << 1) #define MWM_DECOR_BORDER (1 << 1)
int input_keycodetrans(KeyCode, u_int, enum ctltype *, char *, int); int input_keycodetrans(KeyCode, u_int, enum ctltype *,
char *, int);
int x_errorhandler(Display *, XErrorEvent *); int x_errorhandler(Display *, XErrorEvent *);
void x_setup(char *display_name); void x_setup(char *display_name);
@ -377,10 +375,12 @@ void xev_handle_clientmessage(struct xevent *, XEvent *);
xev_register(xev_new(a, b, c, d, e)); \ xev_register(xev_new(a, b, c, d, e)); \
} while (0) } while (0)
void xev_reconfig(struct client_ctx *); /* XXX should be xu_ */ /* XXX should be xu_ */
void xev_reconfig(struct client_ctx *);
void xev_init(void); void xev_init(void);
struct xevent *xev_new(Window *, Window *, int, void (*)(struct xevent *, XEvent *), void *); struct xevent *xev_new(Window *, Window *, int,
void (*)(struct xevent *, XEvent *), void *);
void xev_register(struct xevent *); void xev_register(struct xevent *);
void xev_loop(void); void xev_loop(void);
@ -393,7 +393,8 @@ void xu_ptr_setpos(Window, int, int);
void xu_ptr_getpos(Window, int *, int *); void xu_ptr_getpos(Window, int *, int *);
void xu_key_grab(Window, int, int); void xu_key_grab(Window, int, int);
void xu_sendmsg(struct client_ctx *, Atom, long); void xu_sendmsg(struct client_ctx *, Atom, long);
int xu_getprop(struct client_ctx *, Atom, Atom, long, u_char **); int xu_getprop(struct client_ctx *, Atom, Atom, long,
u_char **);
char *xu_getstrprop(struct client_ctx *, Atom atm); char *xu_getstrprop(struct client_ctx *, Atom atm);
void xu_setstate(struct client_ctx *, int); void xu_setstate(struct client_ctx *, int);
int xu_getstate(struct client_ctx *, int *); int xu_getstate(struct client_ctx *, int *);
@ -428,12 +429,13 @@ void screen_infomsg(char *);
void conf_setup(struct conf *, const char *); void conf_setup(struct conf *, const char *);
int conf_get_int(struct client_ctx *, enum conftype); int conf_get_int(struct client_ctx *, enum conftype);
void conf_client(struct client_ctx *); void conf_client(struct client_ctx *);
void conf_bindkey(struct conf *, void (*)(struct client_ctx *, void *), void conf_bindkey(struct conf *,
void (*)(struct client_ctx *, void *),
int, int, int, void *); int, int, int, void *);
void conf_bindname(struct conf *, char *, char *); void conf_bindname(struct conf *, char *, char *);
void conf_unbind(struct conf *, struct keybinding *); void conf_unbind(struct conf *, struct keybinding *);
int conf_changed(char *); int conf_changed(char *);
void conf_reload(struct conf *c); void conf_reload(struct conf *);
char *conf_get_str(struct client_ctx *, enum conftype); char *conf_get_str(struct client_ctx *, enum conftype);
void kbfunc_client_lower(struct client_ctx *, void *); void kbfunc_client_lower(struct client_ctx *, void *);
@ -441,7 +443,7 @@ void kbfunc_client_raise(struct client_ctx *, void *);
void kbfunc_client_search(struct client_ctx *, void *); void kbfunc_client_search(struct client_ctx *, void *);
void kbfunc_client_hide(struct client_ctx *, void *); void kbfunc_client_hide(struct client_ctx *, void *);
void kbfunc_client_cycle(struct client_ctx *, void *); void kbfunc_client_cycle(struct client_ctx *, void *);
void kbfunc_client_rcycle(struct client_ctx *cc, void *arg); void kbfunc_client_rcycle(struct client_ctx *, void *);
void kbfunc_cmdexec(struct client_ctx *, void *); void kbfunc_cmdexec(struct client_ctx *, void *);
void kbfunc_client_label(struct client_ctx *, void *); void kbfunc_client_label(struct client_ctx *, void *);
void kbfunc_client_delete(struct client_ctx *, void *); void kbfunc_client_delete(struct client_ctx *, void *);
@ -458,18 +460,21 @@ void kbfunc_menu_search(struct client_ctx *, void *);
void kbfunc_exec(struct client_ctx *, void *); void kbfunc_exec(struct client_ctx *, void *);
void kbfunc_ptrmove(struct client_ctx *, void *); void kbfunc_ptrmove(struct client_ctx *, void *);
void kbfunc_ssh(struct client_ctx *, void *); void kbfunc_ssh(struct client_ctx *, void *);
void kbfunc_term(struct client_ctx *cc, void *arg); void kbfunc_term(struct client_ctx *, void *);
void kbfunc_lock(struct client_ctx *cc, void *arg); void kbfunc_lock(struct client_ctx *, void *);
void search_init(struct screen_ctx *); void search_init(struct screen_ctx *);
struct menu *search_start(struct menu_q *menuq, struct menu *search_start(struct menu_q *menuq,
void (*match)(struct menu_q *, struct menu_q *, char *), void (*match)(struct menu_q *, struct menu_q *, char *),
void (*print)(struct menu *mi, int), void (*print)(struct menu *mi, int),
char *, int); char *, int);
void search_match_client(struct menu_q *, struct menu_q *, char *); void search_match_client(struct menu_q *, struct menu_q *,
char *);
void search_print_client(struct menu *mi, int list); void search_print_client(struct menu *mi, int list);
void search_match_text(struct menu_q *, struct menu_q *, char *); void search_match_text(struct menu_q *, struct menu_q *,
void search_match_exec(struct menu_q *, struct menu_q *, char *); char *);
void search_match_exec(struct menu_q *, struct menu_q *,
char *);
void group_init(void); void group_init(void);
void group_hidetoggle(int); void group_hidetoggle(int);
@ -482,16 +487,14 @@ void group_sticky_toggle_enter(struct client_ctx *);
void group_sticky_toggle_exit(struct client_ctx *); void group_sticky_toggle_exit(struct client_ctx *);
void group_autogroup(struct client_ctx *); void group_autogroup(struct client_ctx *);
void notification_init(struct screen_ctx *); void font_init(struct screen_ctx *);
struct fontdesc *font_get(struct screen_ctx *, const char *);
void font_init(struct screen_ctx *sc); int font_width(struct fontdesc *, const char *, int);
struct fontdesc *font_get(struct screen_ctx *sc, const char *name); void font_draw(struct fontdesc *, const char *, int,
int font_width(struct fontdesc *fdp, const char *text, int len); Drawable, int, int);
void font_draw(struct fontdesc *fdp, const char *text, int len, int font_ascent(struct fontdesc *);
Drawable d, int x, int y); int font_descent(struct fontdesc *);
int font_ascent(struct fontdesc *fdp); struct fontdesc *font_getx(struct screen_ctx *, const char *);
int font_descent(struct fontdesc *fdp);
struct fontdesc *font_getx(struct screen_ctx *sc, const char *name);
#define CCTOSC(cc) (cc->sc) #define CCTOSC(cc) (cc->sc)

View File

@ -154,7 +154,8 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
XShapeSelectInput(X_Dpy, cc->win, ShapeNotifyMask); XShapeSelectInput(X_Dpy, cc->win, ShapeNotifyMask);
r = XShapeGetRectangles(X_Dpy, cc->win, ShapeBounding, &n, &tmp); r = XShapeGetRectangles(X_Dpy, cc->win, ShapeBounding,
&n, &tmp);
if (n > 1) if (n > 1)
XShapeCombineShape(X_Dpy, cc->pwin, ShapeBounding, XShapeCombineShape(X_Dpy, cc->pwin, ShapeBounding,
0, 0, /* XXX border */ 0, 0, /* XXX border */
@ -671,7 +672,7 @@ client__cycle(struct client_ctx *cc,
break; break;
} while (cc != save); } while (cc != save);
return cc != save ? cc : NULL; return (cc != save ? cc : NULL);
} }
void void

3
conf.c
View File

@ -166,8 +166,7 @@ conf_setup(struct conf *c, const char *conffile)
snprintf(c->conf_path, sizeof(c->conf_path), "%s/%s", home, snprintf(c->conf_path, sizeof(c->conf_path), "%s/%s", home,
CONFFILE); CONFFILE);
} } else
else
snprintf(c->conf_path, sizeof(c->conf_path), "%s", conffile); snprintf(c->conf_path, sizeof(c->conf_path), "%s", conffile);
conf_init(c); conf_init(c);

1
cwmrc
View File

@ -25,4 +25,3 @@
#bind CM-r "label" #bind CM-r "label"
#bind CS-Return "xterm -e top" #bind CS-Return "xterm -e top"
#bind 4-o "unmap" #bind 4-o "unmap"

10
cwmrc.5
View File

@ -15,7 +15,7 @@
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\" .\"
.\" The following requests are required for all man pages. .\" The following requests are required for all man pages.
.Dd $Mdocdate: March 23 2008 $ .Dd $Mdocdate: April 15 2008 $
.Dt CWMRC 1 .Dt CWMRC 1
.Os .Os
.Sh NAME .Sh NAME
@ -90,8 +90,8 @@ will cause any instances of
to not have borders. to not have borders.
.It Ic bind Ar keys Ar command .It Ic bind Ar keys Ar command
Cause the creation of keyboard shortcuts. Cause the creation of keyboard shortcuts.
The default shortcuts will always be created. In case of conflict, The default shortcuts will always be created.
user-defined shortcuts take precidence. In case of conflict, user-defined shortcuts take precidence.
The modifier keys come first, followed by a ``-''. The modifier keys come first, followed by a ``-''.
The following modifiers are recognised: The following modifiers are recognised:
.Bl -tag -width Ds .Bl -tag -width Ds
@ -117,8 +117,8 @@ structure in
.Pa conf.c , .Pa conf.c ,
or, alternatively it should be the commandline that is wished to be executed. or, alternatively it should be the commandline that is wished to be executed.
A special case is the ``unmap'' keyword, which causes any bindings using the A special case is the ``unmap'' keyword, which causes any bindings using the
named shortcut to be removed. This can be used to remove a binding which conflicts named shortcut to be removed.
with an application. This can be used to remove a binding which conflicts with an application.
.Pp .Pp
For example, to cause For example, to cause
.Ic C-M-r .Ic C-M-r

7
font.c
View File

@ -27,7 +27,7 @@ HASH_GENERATE(fonthash, fontdesc, node, fontdesc_cmp);
int int
fontdesc_cmp(struct fontdesc *a, struct fontdesc *b) fontdesc_cmp(struct fontdesc *a, struct fontdesc *b)
{ {
return strcmp(a->name, b->name); return (strcmp(a->name, b->name));
} }
/* /*
@ -130,13 +130,13 @@ font_draw(struct fontdesc *fdp, const char *text, int len,
int int
font_ascent(struct fontdesc *fdp) font_ascent(struct fontdesc *fdp)
{ {
return fdp->fn->ascent; return (fdp->fn->ascent);
} }
int int
font_descent(struct fontdesc *fdp) font_descent(struct fontdesc *fdp)
{ {
return fdp->fn->descent; return (fdp->fn->descent);
} }
static XftFont * static XftFont *
@ -156,4 +156,3 @@ _make_font(struct screen_ctx *sc, struct fontdesc *fdp)
return (fn); return (fn);
} }

5
grab.c
View File

@ -334,7 +334,8 @@ grab_label(struct client_ctx *cc)
} }
case Expose: case Expose:
snprintf(dispstr, sizeof(dispstr), "label>%s", labelstr); snprintf(dispstr, sizeof(dispstr), "label>%s",
labelstr);
dx = font_width(font, dispstr, strlen(dispstr)); dx = font_width(font, dispstr, strlen(dispstr));
dy = fontheight; dy = fontheight;
@ -397,5 +398,5 @@ menu_calc_entry(int x, int y, int width, int height, int noentries)
entry < 0 || entry >= noentries) entry < 0 || entry >= noentries)
entry = -1; entry = -1;
return entry; return (entry);
} }

2
hash.h
View File

@ -52,7 +52,7 @@ struct type *name##_HASH_TREE_FIND(struct name *head, struct type *find) \
{ \ { \
struct name##_HASH_TREE *bucket = \ struct name##_HASH_TREE *bucket = \
&head->buckets[(*head->hashfn)(find) % HASH_NBUCKETS(head)]; \ &head->buckets[(*head->hashfn)(find) % HASH_NBUCKETS(head)]; \
return SPLAY_FIND(name##_HASH_TREE, bucket, find); \ return (SPLAY_FIND(name##_HASH_TREE, bucket, find)); \
} \ } \
void name##_HASH_TREE_INSERT(struct name *head, struct type *insert) \ void name##_HASH_TREE_INSERT(struct name *head, struct type *insert) \
{ \ { \

19
parse.y
View File

@ -40,6 +40,7 @@ static struct file {
int lineno; int lineno;
int errors; int errors;
} *file; } *file;
struct file *pushfile(const char *); struct file *pushfile(const char *);
int popfile(void); int popfile(void);
int yyparse(void); int yyparse(void);
@ -548,36 +549,42 @@ parse_config(const char *filename, struct conf *xconf)
xconf->flags = conf->flags; xconf->flags = conf->flags;
for (cmd = TAILQ_FIRST(&conf->cmdq); cmd != NULL; cmd = cmdnext) { for (cmd = TAILQ_FIRST(&conf->cmdq); cmd != NULL;
cmd = cmdnext) {
cmdnext = TAILQ_NEXT(cmd, entry); cmdnext = TAILQ_NEXT(cmd, entry);
TAILQ_REMOVE(&conf->cmdq, cmd, entry); TAILQ_REMOVE(&conf->cmdq, cmd, entry);
TAILQ_INSERT_TAIL(&xconf->cmdq, cmd, entry); TAILQ_INSERT_TAIL(&xconf->cmdq, cmd, entry);
} }
for (kb = TAILQ_FIRST(&conf->keybindingq); kb != NULL; kb = kbnext) { for (kb = TAILQ_FIRST(&conf->keybindingq); kb != NULL;
kb = kbnext) {
kbnext = TAILQ_NEXT(kb, entry); kbnext = TAILQ_NEXT(kb, entry);
TAILQ_REMOVE(&conf->keybindingq, kb, entry); TAILQ_REMOVE(&conf->keybindingq, kb, entry);
TAILQ_INSERT_TAIL(&xconf->keybindingq, kb, entry); TAILQ_INSERT_TAIL(&xconf->keybindingq, kb, entry);
} }
for (ag = TAILQ_FIRST(&conf->autogroupq); ag != NULL; ag = agnext) { for (ag = TAILQ_FIRST(&conf->autogroupq); ag != NULL;
ag = agnext) {
agnext = TAILQ_NEXT(ag, entry); agnext = TAILQ_NEXT(ag, entry);
TAILQ_REMOVE(&conf->autogroupq, ag, entry); TAILQ_REMOVE(&conf->autogroupq, ag, entry);
TAILQ_INSERT_TAIL(&xconf->autogroupq, ag, entry); TAILQ_INSERT_TAIL(&xconf->autogroupq, ag, entry);
} }
for (wm = TAILQ_FIRST(&conf->ignoreq); wm != NULL; wm = wmnext) { for (wm = TAILQ_FIRST(&conf->ignoreq); wm != NULL;
wm = wmnext) {
wmnext = TAILQ_NEXT(wm, entry); wmnext = TAILQ_NEXT(wm, entry);
TAILQ_REMOVE(&conf->ignoreq, wm, entry); TAILQ_REMOVE(&conf->ignoreq, wm, entry);
TAILQ_INSERT_TAIL(&xconf->ignoreq, wm, entry); TAILQ_INSERT_TAIL(&xconf->ignoreq, wm, entry);
} }
strlcpy(xconf->termpath, conf->termpath, sizeof(xconf->termpath)); strlcpy(xconf->termpath, conf->termpath,
strlcpy(xconf->lockpath, conf->lockpath, sizeof(xconf->lockpath)); sizeof(xconf->termpath));
strlcpy(xconf->lockpath, conf->lockpath,
sizeof(xconf->lockpath));
xconf->DefaultFontName = conf->DefaultFontName; xconf->DefaultFontName = conf->DefaultFontName;

View File

@ -76,7 +76,6 @@ screen_updatestackingorder(void)
void void
screen_init(void) screen_init(void)
{ {
struct screen_ctx *sc = screen_current(); struct screen_ctx *sc = screen_current();
sc->cycle_client = NULL; sc->cycle_client = NULL;

18
util.c
View File

@ -65,28 +65,30 @@ exec_wm(char *argstr)
warn(args[0]); warn(args[0]);
} }
int dirent_isdir(char *filename) { int
dirent_isdir(char *filename)
{
struct stat buffer; struct stat buffer;
int return_value; int return_value;
return_value = stat(filename, &buffer); return_value = stat(filename, &buffer);
if (return_value == -1) if (return_value == -1)
return 0; return (0);
else else
return S_ISDIR(buffer.st_mode); return (S_ISDIR(buffer.st_mode));
} }
int dirent_islink(char *filename) { int
dirent_islink(char *filename)
{
struct stat buffer; struct stat buffer;
int return_value; int return_value;
return_value = lstat(filename, &buffer); return_value = lstat(filename, &buffer);
if (return_value == -1) if (return_value == -1)
return 0; return (0);
else else
return S_ISLNK(buffer.st_mode); return (S_ISLNK(buffer.st_mode));
} }

View File

@ -50,9 +50,8 @@ xev_handle_maprequest(struct xevent *xev, XEvent *ee)
XGetWindowAttributes(X_Dpy, e->window, &xattr); XGetWindowAttributes(X_Dpy, e->window, &xattr);
cc = client_new(e->window, screen_fromroot(xattr.root), 1); cc = client_new(e->window, screen_fromroot(xattr.root), 1);
sc = CCTOSC(cc); sc = CCTOSC(cc);
} else { } else
cc->beepbeep = 1; cc->beepbeep = 1;
}
#ifdef notyet /* XXX - possibly, we shouldn't map if #ifdef notyet /* XXX - possibly, we shouldn't map if
* the window is withdrawn. */ * the window is withdrawn. */