commit e574dfff180e79c9ca538e5610336f8a127227ea
parent 8eeaa8f6761a0400599d010da14e6402210de7e1
Author: arg <arg@mig29>
Date: Wed, 13 Dec 2006 10:55:19 +0100
fixed UTF-8 issues, moved parse_color to draw.c
Diffstat:
4 files changed, 22 insertions(+), 31 deletions(-)
diff --git a/draw.c b/draw.c
@@ -5,7 +5,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <locale.h>
unsigned int
textwidth_l(BlitzFont *font, char *text, unsigned int len) {
@@ -28,18 +27,13 @@ loadfont(Blitz *blitz, BlitzFont *font) {
char **missing = NULL, *def = "?";
int n;
- setlocale(LC_ALL, "");
if(font->set)
XFreeFontSet(blitz->dpy, font->set);
font->set = XCreateFontSet(blitz->dpy, fontname, &missing, &n, &def);
if(missing) {
while(n--)
- fprintf(stderr, "liblitz: missing fontset: %s\n", missing[n]);
+ fprintf(stderr, "wmii: missing fontset: %s\n", missing[n]);
XFreeStringList(missing);
-/* if(font->set) {
- XFreeFontSet(blitz->dpy, font->set);
- font->set = NULL;
- }*/
}
if(font->set) {
XFontSetExtents *font_extents;
@@ -63,11 +57,7 @@ loadfont(Blitz *blitz, BlitzFont *font) {
font->xfont = NULL;
font->xfont = XLoadQueryFont(blitz->dpy, fontname);
if (!font->xfont) {
- fontname = "fixed";
- font->xfont = XLoadQueryFont(blitz->dpy, fontname);
- }
- if (!font->xfont) {
- fprintf(stderr, "%s", "liblitz: error, cannot load 'fixed' font\n");
+ fprintf(stderr, "%s", "wmii: error, cannot load 'fixed' font\n");
exit(1);
}
font->ascent = font->xfont->ascent;
@@ -211,3 +201,20 @@ loadcolor(Blitz *blitz, BlitzColor *c) {
c->border = xloadcolor(blitz, &c->colstr[16]);
return 0;
}
+
+char *
+parse_colors(char **buf, int *buflen, BlitzColor *col) {
+ unsigned int i;
+ if(*buflen < 23 || 3 != sscanf(*buf, "#%06x #%06x #%06x", &i,&i,&i))
+ return "bad value";
+ (*buflen) -= 23;
+ bcopy(*buf, col->colstr, 23);
+ loadcolor(&blz, col);
+
+ (*buf) += 23;
+ if(**buf == '\n' || **buf == ' ') {
+ (*buf)++;
+ (*buflen)--;
+ }
+ return NULL;
+}
diff --git a/fs.c b/fs.c
@@ -224,24 +224,6 @@ data_to_cstring(P9Req *r) {
r->ifcall.data[i - 1] = '\0';
}
-/* This should be moved to liblitz */
-char *
-parse_colors(char **buf, int *buflen, BlitzColor *col) {
- unsigned int i;
- if(*buflen < 23 || 3 != sscanf(*buf, "#%06x #%06x #%06x", &i,&i,&i))
- return Ebadvalue;
- (*buflen) -= 23;
- bcopy(*buf, col->colstr, 23);
- loadcolor(&blz, col);
-
- (*buf) += 23;
- if(**buf == '\n' || **buf == ' ') {
- (*buf)++;
- (*buflen)--;
- }
- return NULL;
-}
-
char *
message_root(char *message)
{
diff --git a/main.c b/main.c
@@ -4,6 +4,7 @@
#include "wmii.h"
#include <errno.h>
#include <fcntl.h>
+#include <locale.h>
#include <pwd.h>
#include <stdarg.h>
#include <stdlib.h>
@@ -208,6 +209,7 @@ main(int argc, char *argv[]) {
}
}
starting = True;
+ setlocale(LC_CTYPE, "");
blz.dpy = XOpenDisplay(0);
if(!blz.dpy)
ixp_eprint("wmiiwm: cannot open dpy\n");
diff --git a/wmii.h b/wmii.h
@@ -7,7 +7,6 @@
#include <regex.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
-#include <X11/Xlocale.h>
#include <ixp.h>
@@ -310,6 +309,7 @@ extern unsigned int textwidth(BlitzFont *font, char *text);
extern unsigned int textwidth_l(BlitzFont *font, char *text, unsigned int len);
extern void loadfont(Blitz *blitz, BlitzFont *font);
extern unsigned int labelh(BlitzFont *font);
+extern char *parse_colors(char **buf, int *buflen, BlitzColor *col);
/* event.c */
extern void check_x_event(IXPConn *c);