[hackers] [wmii] Factor out some common code. Delete some stale code. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Sat, 29 May 2010 18:10:45 +0000 (UTC)

changeset: 2673:41b5c6cce5db
tag: tip
user: Kris Maglione <kris_AT_suckless.org>
date: Sat May 29 14:10:31 2010 -0400
files: cmd/menu/main.c cmd/tray/main.c include/stuff/x.h lib/libstuff/Makefile lib/libstuff/client_readconfig.c lib/libstuff/clientutil.c
description:
Factor out some common code. Delete some stale code.

diff -r ebaaa575a7c4 -r 41b5c6cce5db cmd/menu/main.c
--- a/cmd/menu/main.c Sat May 29 11:54:38 2010 -0400
+++ b/cmd/menu/main.c Sat May 29 14:10:31 2010 -0400
@@ -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 @@
         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 @@
         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);
diff -r ebaaa575a7c4 -r 41b5c6cce5db cmd/tray/main.c
--- a/cmd/tray/main.c Sat May 29 11:54:38 2010 -0400
+++ b/cmd/tray/main.c Sat May 29 14:10:31 2010 -0400
@@ -190,14 +190,7 @@
         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;
diff -r ebaaa575a7c4 -r 41b5c6cce5db include/stuff/x.h
--- a/include/stuff/x.h Sat May 29 11:54:38 2010 -0400
+++ b/include/stuff/x.h Sat May 29 14:10:31 2010 -0400
@@ -16,6 +16,8 @@
 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)
 
diff -r ebaaa575a7c4 -r 41b5c6cce5db lib/libstuff/Makefile
--- a/lib/libstuff/Makefile Sat May 29 11:54:38 2010 -0400
+++ b/lib/libstuff/Makefile Sat May 29 14:10:31 2010 -0400
@@ -8,6 +8,7 @@
 OBJ=\
             buffer \
         clientutil \
+ client_readconfig \
         event/buttonpress \
         event/buttonrelease \
         event/clientmessage \
diff -r ebaaa575a7c4 -r 41b5c6cce5db lib/libstuff/client_readconfig.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libstuff/client_readconfig.c Sat May 29 14:10:31 2010 -0400
@@ -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);
+}
+
diff -r ebaaa575a7c4 -r 41b5c6cce5db lib/libstuff/clientutil.c
--- a/lib/libstuff/clientutil.c Sat May 29 11:54:38 2010 -0400
+++ b/lib/libstuff/clientutil.c Sat May 29 14:10:31 2010 -0400
@@ -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 @@
         if(client == nil)
                 fatal("can't mount wmii filesystem: %r\n");
 }
-
Received on Sat May 29 2010 - 18:10:45 UTC

This archive was generated by hypermail 2.2.0 : Sat May 29 2010 - 18:12:04 UTC