[hackers] [wmii] Experimental demand-loading of Xft. Removed hard dependency. || Kris Maglione

From: <hg_AT_suckless.org>
Date: Sat, 22 May 2010 23:04:54 +0000 (UTC)

changeset: 2624:8b7a7f94c967
user: Kris Maglione <kris_AT_suckless.org>
date: Sat May 22 18:58:37 2010 -0400
files: PKGBUILD cmd/menu/main.c cmd/wmii/fns.h cmd/wmii/screen.c cmd/wmii9menu.c cmd/wmiir.c config.mk include/stuff/base.h include/stuff/x11.h libstuff/Makefile libstuff/map.c libstuff/util/_die.c libstuff/util/backtrace.c libstuff/util/doublefork.c libstuff/util/emalloc.c libstuff/util/erealloc.c libstuff/util/fatal.c libstuff/util/freelater.c libstuff/util/getlong.c libstuff/util/getulong.c libstuff/util/join.c libstuff/util/mfatal.c libstuff/util/pathsearch.c libstuff/util/refree.c libstuff/util/spawn3.c libstuff/util/spawn3l.c libstuff/util/vector.c libstuff/x11/colors/loadcolor.c libstuff/x11/drawing/drawstring.c libstuff/x11/images/freeimage.c libstuff/x11/images/xftdrawable.c libstuff/x11/insanity/sethints.c libstuff/x11/properties/changeprop_string.c libstuff/x11/properties/changeprop_textlist.c libstuff/x11/properties/strlistdup.c libstuff/x11/text/freefont.c libstuff/x11/text/loadfont.c libstuff/x11/text/textextents_l.c libstuff/x11/text/textwidth.c libstuff/x11/windows/destroywindow.c libst
uff/x11/xft.c libwmii_hack/hack.c util/compile
description:
Experimental demand-loading of Xft. Removed hard dependency.

diff -r 352a9234d713 -r 8b7a7f94c967 PKGBUILD
--- a/PKGBUILD Sat May 22 16:09:21 2010 -0400
+++ b/PKGBUILD Sat May 22 18:58:37 2010 -0400
@@ -6,11 +6,12 @@
 url="http://wmii.suckless.org"
 license=("MIT")
 arch=("i686" "x86_64")
-depends=("libx11" "libxinerama" "libxrandr" "libxft")
+depends=("libx11" "libxinerama" "libxrandr")
 makedepends=("mercurial")
 optdepends=("plan9port: for use of the alternative plan9port wmiirc" \
         "python: for use of the alternative Python wmiirc" \
- "ruby-rumai: for use of the alternative Ruby wmiirc")
+ "ruby-rumai: for use of the alternative Ruby wmiirc" \
+ "libxft: for anti-aliased font support")
 provides=("wmii")
 conflicts=("wmii")
 source=()
diff -r 352a9234d713 -r 8b7a7f94c967 cmd/menu/main.c
--- a/cmd/menu/main.c Sat May 22 16:09:21 2010 -0400
+++ b/cmd/menu/main.c Sat May 22 18:58:37 2010 -0400
@@ -7,6 +7,7 @@
 #include "dat.h"
 #include <X11/Xproto.h>
 #include <locale.h>
+#include <stdio.h>
 #include <strings.h>
 #include <unistd.h>
 #include <bio.h>
diff -r 352a9234d713 -r 8b7a7f94c967 cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Sat May 22 16:09:21 2010 -0400
+++ b/cmd/wmii/fns.h Sat May 22 18:58:37 2010 -0400
@@ -2,6 +2,8 @@
  * See LICENSE file for license details.
  */
 
+#include <setjmp.h>
+
 #ifdef VARARGCK
 # pragma varargck argpos debug 2
 # pragma varargck argpos dprint 1
diff -r 352a9234d713 -r 8b7a7f94c967 cmd/wmii/screen.c
--- a/cmd/wmii/screen.c Sat May 22 16:09:21 2010 -0400
+++ b/cmd/wmii/screen.c Sat May 22 18:58:37 2010 -0400
@@ -3,7 +3,6 @@
  */
 #include "dat.h"
 #include <math.h>
-#include <stdlib.h>
 #include "fns.h"
 
 #ifdef notdef
diff -r 352a9234d713 -r 8b7a7f94c967 cmd/wmii9menu.c
--- a/cmd/wmii9menu.c Sat May 22 16:09:21 2010 -0400
+++ b/cmd/wmii9menu.c Sat May 22 18:58:37 2010 -0400
@@ -42,7 +42,6 @@
 #include <stdarg.h>
 #include <stdbool.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
 #include <stuff/clientutil.h>
diff -r 352a9234d713 -r 8b7a7f94c967 cmd/wmiir.c
--- a/cmd/wmiir.c Sat May 22 16:09:21 2010 -0400
+++ b/cmd/wmiir.c Sat May 22 18:58:37 2010 -0400
@@ -4,7 +4,6 @@
 #define IXP_NO_P9_
 #define IXP_P9_STRUCTS
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
diff -r 352a9234d713 -r 8b7a7f94c967 config.mk
--- a/config.mk Sat May 22 16:09:21 2010 -0400
+++ b/config.mk Sat May 22 18:58:37 2010 -0400
@@ -20,21 +20,24 @@
 CFLAGS += $(DEBUGCFLAGS) -O0
 LDFLAGS += -g
 
-SOLDFLAGS += $(LDFLAGS)
-SHARED = -shared -Wl,-soname=$(SONAME)
-STATIC = -static
-
 # Compiler, Linker. Linker should usually *not* be ld.
 CC = cc -c
 LD = cc
 # Archiver
 AR = ar crs
 
-X11PACKAGES = xft
+X11PACKAGES = x11 xinerama xrender
 INCX11 = $$(pkg-config --cflags $(X11PACKAGES))
-LIBICONV = # Leave blank if your libc includes iconv (glibc does)
 LIBIXP = $(LIBDIR)/libixp.a
 
+# Enable RTLD. Only necessary for Xft support.
+CFLAGS += -DHAVE_RTLD
+LDFLAGS += -ldl # Comment this out on BSD systems.
+
+SOLDFLAGS += $(LDFLAGS)
+SHARED = -shared -Wl,-soname=$(SONAME)
+STATIC = -static
+
 # Your make shell. By default, the first found of /bin/dash, /bin/ksh,
 # /bin/sh. Except with bsdmake, which assumes /bin/sh is sane. bash and zsh
 # are painfully slow, and should be avoided.
@@ -50,9 +53,7 @@
 #CC=pcc -c
 #LD=pcc
 
-# *BSD
-#LIBICONV = -L/usr/local/lib -liconv
-# +Darwin
+# Darwin
 #STATIC = # Darwin doesn't like static linking
 #SHARED = -dynamiclib
 #SOEXT = dylib
diff -r 352a9234d713 -r 8b7a7f94c967 include/stuff/base.h
--- a/include/stuff/base.h Sat May 22 16:09:21 2010 -0400
+++ b/include/stuff/base.h Sat May 22 18:58:37 2010 -0400
@@ -2,6 +2,8 @@
 #define _XOPEN_SOURCE 600
 
 #include <stdbool.h>
+#include <stdlib.h>
+#include <stdint.h>
 
 #ifndef nil
 #define nil ((void*)0)
diff -r 352a9234d713 -r 8b7a7f94c967 include/stuff/x11.h
--- a/include/stuff/x11.h Sat May 22 16:09:21 2010 -0400
+++ b/include/stuff/x11.h Sat May 22 18:58:37 2010 -0400
@@ -7,7 +7,6 @@
 #include <stuff/geom.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
-#include <X11/Xft/Xft.h>
 #include <X11/extensions/Xrender.h>
 #ifdef _X11_VISIBLE
 # include <X11/Xatom.h>
@@ -44,6 +43,10 @@
 typedef struct WinHints WinHints;
 typedef struct Window Image;
 typedef struct Window Window;
+typedef struct Xft Xft;
+typedef struct XftColor XftColor;
+typedef void XftDraw;
+typedef struct XftFont XftFont;
 
 struct Color {
         ulong pixel;
@@ -138,6 +141,30 @@
         int depth;
 };
 
+struct Xft {
+ XftDraw* (*drawcreate)(Display*, Drawable, Visual*, Colormap);
+ void (*drawdestroy)(XftDraw*);
+ XftFont* (*fontopen)(Display*, int, const char*);
+ XftFont* (*fontopenname)(Display*, int, const char*);
+ XftFont* (*fontclose)(Display*, XftFont*);
+ void (*textextents)(Display*, XftFont*, char*, int len, XGlyphInfo*);
+ void (*drawstring)(Display*, XftColor*, XftFont*, int x, int y, char*, int len);
+};
+
+struct XftColor {
+ ulong pixel;
+ XRenderColor color;
+};
+
+struct XftFont {
+ int ascent;
+ int descent;
+ int height;
+ int max_advance_width;
+ void* charset;
+ void* pattern;
+};
+
 struct Screen {
         int screen;
         Window root;
@@ -165,6 +192,7 @@
 extern const Point ZP;
 extern const Rectangle ZR;
 extern Window* pointerwin;
+extern Xft* xft;
 
 XRectangle XRect(Rectangle r);
 
@@ -205,6 +233,7 @@
 ulong getproperty(Window*, char *prop, char *type, Atom *actual, ulong offset, uchar **ret, ulong length);
 int grabkeyboard(Window*);
 int grabpointer(Window*, Window *confine, Cursor, int mask);
+bool havexft(void);
 void initdisplay(void);
 KeyCode keycode(char*);
 uint labelh(Font*);
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/Makefile
--- a/libstuff/Makefile Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/Makefile Sat May 22 18:58:37 2010 -0400
@@ -86,6 +86,7 @@
         x11/sync \
         x11/x11 \
         x11/xatom \
+ x11/xft \
         x11/colors/loadcolor \
         x11/colors/namedcolor \
         x11/colors/xftcolor \
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/map.c
--- a/libstuff/map.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/map.c Sat May 22 18:58:37 2010 -0400
@@ -1,6 +1,5 @@
 /* Written by Kris Maglione */
 /* Public domain */
-#include <stdlib.h>
 #include <string.h>
 #include <stuff/util.h>
 
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/util/_die.c
--- a/libstuff/util/_die.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/util/_die.c Sat May 22 18:58:37 2010 -0400
@@ -2,7 +2,6 @@
 /* Public domain */
 #include <sys/types.h>
 #include <signal.h>
-#include <stdlib.h>
 #include <unistd.h>
 #include <fmt.h>
 #include "util.h"
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/util/backtrace.c
--- a/libstuff/util/backtrace.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/util/backtrace.c Sat May 22 18:58:37 2010 -0400
@@ -6,7 +6,6 @@
 #include <sys/wait.h>
 #include <fcntl.h>
 #include <signal.h>
-#include <stdlib.h>
 
 #include <bio.h>
 #include <plan9.h>
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/util/doublefork.c
--- a/libstuff/util/doublefork.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/util/doublefork.c Sat May 22 18:58:37 2010 -0400
@@ -2,7 +2,6 @@
  * See LICENSE file for license details.
  */
 #include <sys/wait.h>
-#include <stdlib.h>
 #include <unistd.h>
 #include "util.h"
 
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/util/emalloc.c
--- a/libstuff/util/emalloc.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/util/emalloc.c Sat May 22 18:58:37 2010 -0400
@@ -1,6 +1,5 @@
 /* Written by Kris Maglione <maglione.k at Gmail> */
 /* Public domain */
-#include <stdlib.h>
 #include "util.h"
 
 void *
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/util/erealloc.c
--- a/libstuff/util/erealloc.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/util/erealloc.c Sat May 22 18:58:37 2010 -0400
@@ -1,6 +1,5 @@
 /* Written by Kris Maglione <maglione.k at Gmail> */
 /* Public domain */
-#include <stdlib.h>
 #include "util.h"
 
 void *
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/util/fatal.c
--- a/libstuff/util/fatal.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/util/fatal.c Sat May 22 18:58:37 2010 -0400
@@ -1,6 +1,5 @@
 /* Written by Kris Maglione <maglione.k at Gmail> */
 /* Public domain */
-#include <stdlib.h>
 #include <fmt.h>
 #include "util.h"
 
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/util/freelater.c
--- a/libstuff/util/freelater.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/util/freelater.c Sat May 22 18:58:37 2010 -0400
@@ -1,6 +1,5 @@
 /* Written by Kris Maglione <maglione.k at Gmail> */
 /* Public domain */
-#include <stdlib.h>
 #include "util.h"
 
 void*
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/util/getlong.c
--- a/libstuff/util/getlong.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/util/getlong.c Sat May 22 18:58:37 2010 -0400
@@ -1,7 +1,6 @@
 /* Copyright ©2008-2010 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
-#include <stdlib.h>
 #include <string.h>
 #include <stuff/util.h>
 
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/util/getulong.c
--- a/libstuff/util/getulong.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/util/getulong.c Sat May 22 18:58:37 2010 -0400
@@ -1,7 +1,6 @@
 /* Copyright ©2008-2010 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
-#include <stdlib.h>
 #include <string.h>
 #include <stuff/util.h>
 
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/util/join.c
--- a/libstuff/util/join.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/util/join.c Sat May 22 18:58:37 2010 -0400
@@ -1,7 +1,6 @@
 /* Copyright ©2008-2010 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
-#include <stdlib.h>
 #include <fmt.h>
 #include "util.h"
 
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/util/mfatal.c
--- a/libstuff/util/mfatal.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/util/mfatal.c Sat May 22 18:58:37 2010 -0400
@@ -1,6 +1,5 @@
 /* Written by Kris Maglione <maglione.k at Gmail> */
 /* Public domain */
-#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include "util.h"
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/util/pathsearch.c
--- a/libstuff/util/pathsearch.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/util/pathsearch.c Sat May 22 18:58:37 2010 -0400
@@ -1,7 +1,6 @@
 /* Copyright ©2008-2010 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
-#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include <fmt.h>
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/util/refree.c
--- a/libstuff/util/refree.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/util/refree.c Sat May 22 18:58:37 2010 -0400
@@ -1,7 +1,6 @@
 /* Copyright ©2008-2010 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
-#include <stdlib.h>
 #include "util.h"
 
 void
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/util/spawn3.c
--- a/libstuff/util/spawn3.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/util/spawn3.c Sat May 22 18:58:37 2010 -0400
@@ -2,7 +2,6 @@
  * See LICENSE file for license details.
  */
 #include <errno.h>
-#include <stdlib.h>
 #include <unistd.h>
 #include "util.h"
 
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/util/spawn3l.c
--- a/libstuff/util/spawn3l.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/util/spawn3l.c Sat May 22 18:58:37 2010 -0400
@@ -1,7 +1,6 @@
 /* Copyright ©2008-2010 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
-#include <stdlib.h>
 #include <fmt.h>
 #include "util.h"
 
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/util/vector.c
--- a/libstuff/util/vector.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/util/vector.c Sat May 22 18:58:37 2010 -0400
@@ -1,7 +1,6 @@
 /* Copyright ©2008-2010 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
-#include <stdlib.h>
 #include <string.h>
 #include "util.h"
 
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/x11/colors/loadcolor.c
--- a/libstuff/x11/colors/loadcolor.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/x11/colors/loadcolor.c Sat May 22 18:58:37 2010 -0400
@@ -1,6 +1,7 @@
 /* Copyright ©2007-2010 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
+#include <string.h>
 #include "../x11.h"
 
 bool
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/x11/drawing/drawstring.c
--- a/libstuff/x11/drawing/drawstring.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/x11/drawing/drawstring.c Sat May 22 18:58:37 2010 -0400
@@ -1,6 +1,7 @@
 /* Copyright ©2007-2010 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
+#include <string.h>
 #include "../x11.h"
 
 uint
@@ -69,9 +70,9 @@
                                 buf, len);
                 break;
         case FXft:
- XftDrawStringUtf8(xftdrawable(dst), xftcolor(col),
- font->font.xft,
- x, y, (uchar*)buf, len);
+ xft->drawstring(xftdrawable(dst), xftcolor(col),
+ font->font.xft,
+ x, y, buf, len);
                 break;
         case FX11:
                 XSetFont(display, dst->gc, font->font.x11->fid);
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/x11/images/freeimage.c
--- a/libstuff/x11/images/freeimage.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/x11/images/freeimage.c Sat May 22 18:58:37 2010 -0400
@@ -11,7 +11,7 @@
         assert(img->type == WImage);
 
         if(img->xft)
- XftDrawDestroy(img->xft);
+ xft->drawdestroy(img->xft);
         XFreePixmap(display, img->xid);
         XFreeGC(display, img->gc);
         free(img);
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/x11/images/xftdrawable.c
--- a/libstuff/x11/images/xftdrawable.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/x11/images/xftdrawable.c Sat May 22 18:58:37 2010 -0400
@@ -6,6 +6,6 @@
 XftDraw*
 xftdrawable(Image *img) {
         if(img->xft == nil)
- img->xft = XftDrawCreate(display, img->xid, img->visual, img->colormap);
+ img->xft = xft->drawcreate(display, img->xid, img->visual, img->colormap);
         return img->xft;
 }
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/x11/insanity/sethints.c
--- a/libstuff/x11/insanity/sethints.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/x11/insanity/sethints.c Sat May 22 18:58:37 2010 -0400
@@ -1,6 +1,7 @@
 /* Copyright ©2007-2010 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
+#include <string.h>
 #include "../x11.h"
 
 void
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/x11/properties/changeprop_string.c
--- a/libstuff/x11/properties/changeprop_string.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/x11/properties/changeprop_string.c Sat May 22 18:58:37 2010 -0400
@@ -1,6 +1,7 @@
 /* Copyright ©2007-2010 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
+#include <string.h>
 #include "../x11.h"
 
 void
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/x11/properties/changeprop_textlist.c
--- a/libstuff/x11/properties/changeprop_textlist.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/x11/properties/changeprop_textlist.c Sat May 22 18:58:37 2010 -0400
@@ -1,6 +1,7 @@
 /* Copyright ©2007-2010 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
+#include <string.h>
 #include "../x11.h"
 
 void
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/x11/properties/strlistdup.c
--- a/libstuff/x11/properties/strlistdup.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/x11/properties/strlistdup.c Sat May 22 18:58:37 2010 -0400
@@ -1,6 +1,7 @@
 /* Copyright ©2007-2010 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
+#include <string.h>
 #include "../x11.h"
 
 char**
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/x11/text/freefont.c
--- a/libstuff/x11/text/freefont.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/x11/text/freefont.c Sat May 22 18:58:37 2010 -0400
@@ -10,7 +10,7 @@
                 XFreeFontSet(display, f->font.set);
                 break;
         case FXft:
- XftFontClose(display, f->font.xft);
+ xft->fontclose(display, f->font.xft);
                 break;
         case FX11:
                 XFreeFont(display, f->font.x11);
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/x11/text/loadfont.c
--- a/libstuff/x11/text/loadfont.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/x11/text/loadfont.c Sat May 22 18:58:37 2010 -0400
@@ -1,6 +1,7 @@
 /* Copyright ©2007-2010 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
+#include <string.h>
 #include "../x11.h"
 
 Font*
@@ -17,9 +18,12 @@
         if(!strncmp(f->name, "xft:", 4)) {
                 f->type = FXft;
 
- f->font.xft = XftFontOpenXlfd(display, scr.screen, f->name + 4);
+ if(!havexft())
+ goto error;
+
+ f->font.xft = xft->fontopen(display, scr.screen, f->name + 4);
                 if(!f->font.xft)
- f->font.xft = XftFontOpenName(display, scr.screen, f->name + 4);
+ f->font.xft = xft->fontopenname(display, scr.screen, f->name + 4);
                 if(!f->font.xft)
                         goto error;
 
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/x11/text/textextents_l.c
--- a/libstuff/x11/text/textextents_l.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/x11/text/textextents_l.c Sat May 22 18:58:37 2010 -0400
@@ -18,7 +18,7 @@
                 *offset = Xutf8TextExtents(font->font.set, text, len, &r, nil);
                 return Rect(r.x, -r.y - r.height, r.x + r.width, -r.y);
         case FXft:
- XftTextExtentsUtf8(display, font->font.xft, (uchar*)text, len, &i);
+ xft->textextents(display, font->font.xft, text, len, &i);
                 *offset = i.xOff;
                 return Rect(-i.x, i.y - i.height, -i.x + i.width, i.y);
         case FX11:
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/x11/text/textwidth.c
--- a/libstuff/x11/text/textwidth.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/x11/text/textwidth.c Sat May 22 18:58:37 2010 -0400
@@ -1,6 +1,7 @@
 /* Copyright ©2007-2010 Kris Maglione <maglione.k at Gmail>
  * See LICENSE file for license details.
  */
+#include <string.h>
 #include "../x11.h"
 
 uint
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/x11/windows/destroywindow.c
--- a/libstuff/x11/windows/destroywindow.c Sat May 22 16:09:21 2010 -0400
+++ b/libstuff/x11/windows/destroywindow.c Sat May 22 18:58:37 2010 -0400
@@ -8,7 +8,7 @@
         assert(w->type == WWindow);
         sethandler(w, nil);
         if(w->xft)
- XftDrawDestroy(w->xft);
+ xft->drawdestroy(w->xft);
         if(w->gc)
                 XFreeGC(display, w->gc);
         XDestroyWindow(display, w->xid);
diff -r 352a9234d713 -r 8b7a7f94c967 libstuff/x11/xft.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libstuff/x11/xft.c Sat May 22 18:58:37 2010 -0400
@@ -0,0 +1,39 @@
+/* Copyright ©2010 Kris Maglione <maglione.k at Gmail>
+ * See LICENSE file for license details.
+ */
+#include <stuff/x.h>
+#include <stuff/util.h>
+
+Xft *xft;
+
+#ifdef HAVE_RTLD
+#include <dlfcn.h>
+
+bool
+havexft(void) {
+ void *libxft;
+
+ if(xft == nil) {
+ libxft = dlopen("libXft.so", RTLD_LAZY);
+ if(libxft == nil)
+ return false;
+ xft = emalloc(sizeof *xft);
+ *(void**)(uintptr_t)&xft->drawcreate = dlsym(libxft, "XftDrawCreate");
+ *(void**)(uintptr_t)&xft->drawdestroy = dlsym(libxft, "XftDrawDestroy");
+ *(void**)(uintptr_t)&xft->fontopen = dlsym(libxft, "XftFontOpenXlfd");
+ *(void**)(uintptr_t)&xft->fontopenname = dlsym(libxft, "XftFontOpenName");
+ *(void**)(uintptr_t)&xft->fontclose = dlsym(libxft, "XftFontClose");
+ *(void**)(uintptr_t)&xft->textextents = dlsym(libxft, "XftTextExtentsUtf8");
+ *(void**)(uintptr_t)&xft->drawstring = dlsym(libxft, "XftDrawStringUtf8");
+ }
+ return xft && xft->drawcreate && xft->drawdestroy && xft->fontopen
+ && xft->fontopenname && xft->fontclose && xft->textextents && xft->drawstring;
+}
+
+#else
+bool
+havexft(void) {
+ return false;
+}
+#endif
+
diff -r 352a9234d713 -r 8b7a7f94c967 libwmii_hack/hack.c
--- a/libwmii_hack/hack.c Sat May 22 16:09:21 2010 -0400
+++ b/libwmii_hack/hack.c Sat May 22 18:58:37 2010 -0400
@@ -4,7 +4,6 @@
 #include "hack.h"
 #include <dlfcn.h>
 #include <stdbool.h>
-#include <stdlib.h>
 #include <stdio.h>
 #include <sys/time.h>
 #include <sys/types.h>
diff -r 352a9234d713 -r 8b7a7f94c967 util/compile
--- a/util/compile Sat May 22 16:09:21 2010 -0400
+++ b/util/compile Sat May 22 18:58:37 2010 -0400
@@ -17,7 +17,7 @@
 [ $? -eq 0 ] || echo $CC -o $outfile $CFLAGS $@ >&2
 
 base=$(echo $BASE | sed 's/,/\\,/g')
-re='\([^[:space:]/]*\..:[0-9]\)'
+re='\([^[:space:]/][^[:space:]]*\..:[0-9]\)'
 
 undup() { # GCC is crap.
         awk '
Received on Sat May 22 2010 - 23:04:54 UTC

This archive was generated by hypermail 2.2.0 : Sat May 22 2010 - 23:12:03 UTC