Factor out some common code. Delete some stale code.

This commit is contained in:
Kris Maglione 2010-05-29 14:10:31 -04:00
parent fb1e4189d4
commit 7344423cc4
6 changed files with 32 additions and 39 deletions

View File

@ -7,7 +7,6 @@
#include "dat.h"
#include <X11/Xproto.h>
#include <locale.h>
#include <stdio.h>
#include <strings.h>
#include <unistd.h>
#include <bio.h>
@ -32,27 +31,6 @@ errfmt(Fmt *f) {
return fmtstrcpy(f, ixp_errbuf());
}
/* Stubs. */
void
debug(int flag, const char *fmt, ...) {
va_list ap;
USED(flag);
va_start(ap, fmt);
vfprint(2, fmt, ap);
va_end(ap);
}
void dprint(long, char*, ...);
void dprint(long mask, char *fmt, ...) {
va_list ap;
USED(mask);
va_start(ap, fmt);
vfprint(2, fmt, ap);
va_end(ap);
}
static inline void
splice(Item *i) {
i->next->prev = i->prev;
@ -272,14 +250,7 @@ main(int argc, char *argv[]) {
ixp_listen(&srv, ConnectionNumber(display), nil, event_fdready, event_fdclosed);
ontop = !strcmp(readctl("bar on "), "top");
loadcolor(&cnorm, readctl("normcolors "));
loadcolor(&csel, readctl("focuscolors "));
font = loadfont(readctl("font "));
if(!font)
fatal("Can't load font %q", readctl("font "));
sscanf(readctl("fontpad "), "%d %d %d %d",
&font->pad.min.x, &font->pad.max.x,
&font->pad.min.x, &font->pad.max.y);
client_readconfig(&cnorm, &csel, &font);
cmplbuf = Bfdopen(0, OREAD);
items = populate_list(cmplbuf, false);

View File

@ -190,14 +190,7 @@ main(int argc, char *argv[]) {
if(tray.edge == 0)
tray.edge = West | (!strcmp(readctl("bar on "), "top") ? North : South);
loadcolor(&tray.normcolors, readctl("normcolors "));
loadcolor(&tray.selcolors, readctl("focuscolors "));
tray.font = loadfont(readctl("font "));
if(!tray.font)
fatal("Can't load font %q", readctl("font "));
sscanf(readctl("fontpad "), "%d %d %d %d",
&tray.font->pad.min.x, &tray.font->pad.max.x,
&tray.font->pad.min.x, &tray.font->pad.max.y);
client_readconfig(&tray.normcolors, &tray.selcolors, &tray.font);
if(tray.iconsize == 0) /* Default to wmii's bar size. */
tray.iconsize = labelh(tray.font) - 2 * tray.padding;

View File

@ -16,6 +16,8 @@ void xext_event(XEvent*);
void xext_init(void);
Rectangle* xinerama_screens(int*);
void client_readconfig(CTuple*, CTuple*, Font**);
#define event_handle(w, fn, ev) \
_event_handle(w, offsetof(Handlers, fn), (XEvent*)ev)

View File

@ -8,6 +8,7 @@ PACKAGES += $(X11PACKAGES) xext xrandr xrender xinerama
OBJ=\
buffer \
clientutil \
client_readconfig \
event/buttonpress \
event/buttonrelease \
event/clientmessage \

View File

@ -0,0 +1,24 @@
/* Copyright ©2009-2010 Kris Maglione <maglione.k at Gmail>
* See LICENSE file for license details.
*/
#include <ixp.h>
#include <stuff/clientutil.h>
#include <stuff/util.h>
#include <stuff/x.h>
#include <stdio.h>
void
client_readconfig(CTuple *norm, CTuple *focus, Font **font) {
if(norm)
loadcolor(norm, readctl("normcolors "));
if(focus)
loadcolor(focus, readctl("focuscolors "));
*font = loadfont(readctl("font "));
if(!*font)
fatal("Can't load font %q", readctl("font "));
sscanf(readctl("fontpad "), "%d %d %d %d",
&(*font)->pad.min.x, &(*font)->pad.max.x,
&(*font)->pad.min.x, &(*font)->pad.max.y);
}

View File

@ -1,3 +1,6 @@
/* Copyright ©2009-2010 Kris Maglione <maglione.k at Gmail>
* See LICENSE file for license details.
*/
#define IXP_NO_P9_
#define IXP_P9_STRUCTS
#define CLIENTEXTERN
@ -50,4 +53,3 @@ client_init(char* address) {
if(client == nil)
fatal("can't mount wmii filesystem: %r\n");
}