commit aeaed5a3df1d0e64065f01238e7654cb8f5f75f0
parent 21482503cf8aa0ed95217358147632ebe256c0b4
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Thu, 2 Feb 2006 17:44:45 +0200
added Color type to liblitz, changed blitz_loadcolor to init Color types, proceeded with fs.c debugging in wm
Diffstat:
11 files changed, 153 insertions(+), 148 deletions(-)
diff --git a/cmd/wm/client.c b/cmd/wm/client.c
@@ -255,15 +255,10 @@ draw_client(Client *c)
d.font = xfont;
d.gc = c->frame.gc;
- if(c == sel_client()) {
- d.bg = def.selbg;
- d.fg = def.selfg;
- d.border = def.selborder;
- } else {
- d.bg = def.normbg;
- d.fg = def.normfg;
- d.border = def.normborder;
- }
+ if(c == sel_client())
+ d.color = def.sel;
+ else
+ d.color = def.norm;
/* draw border */
if(bw) {
diff --git a/cmd/wm/event.c b/cmd/wm/event.c
@@ -24,7 +24,7 @@ static void handle_clientmessage(XEvent * e);
void (*handler[LASTEvent]) (XEvent *);
void
-init_event_hander()
+init_x_event_handler()
{
int i;
/* init event handler */
diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c
@@ -168,6 +168,8 @@ name_to_type(char *name, unsigned char dtyp)
else if(dtyp == Dpage)
return Darea;
}
+ if(!strncmp(name, "default", 8))
+ return Ddefault;
if(!strncmp(name, "ctl", 4))
return Fctl;
if(!strncmp(name, "font", 5))
@@ -217,7 +219,7 @@ mkqid(Qid *dir, char *wname, Qid *new)
if((dir->type != IXP_QTDIR) || (type == -1))
return -1;
- new->dir = dir;
+ new->dtype = dtyp;
new->version = 0;
switch(type) {
case Droot:
@@ -319,7 +321,12 @@ xwalk(IXPConn *c)
dir = m->qid;
for(nwqid = 0; (nwqid < c->fcall->nwname)
&& !mkqid(&dir, c->fcall->wname[nwqid], &c->fcall->wqid[nwqid]); nwqid++)
+ {
+ fprintf(stderr, "dir.dtype=%d\n", dir.dtype);
dir = c->fcall->wqid[nwqid];
+ fprintf(stderr, "walk: qid_to_name()=%s qpath_type(dir.path)=%d dir.dtype=%d\n",
+ qid_to_name(&dir), qpath_type(dir.path), dir.dtype);
+ }
if(!nwqid) {
errstr = Enofile;
return -1;
@@ -567,6 +574,7 @@ xread(IXPConn *c)
else {
switch (qpath_type(m->qid.path)) {
case Droot:
+ fprintf(stderr, "%s", "Droot dir creation\n");
c->fcall->count = type_to_stat(&stat, "ctl", &m->qid);
p = ixp_enc_stat(p, &stat);
c->fcall->count += type_to_stat(&stat, "event", &m->qid);
@@ -603,6 +611,7 @@ xread(IXPConn *c)
p = ixp_enc_stat(p, &stat);
break;
case Dpage:
+ alloc_page();
c->fcall->count = type_to_stat(&stat, "ctl", &m->qid);
p = ixp_enc_stat(p, &stat);
c->fcall->count += type_to_stat(&stat, "sel", &m->qid);
@@ -670,7 +679,10 @@ xread(IXPConn *c)
memcpy(p, def.normcolor, c->fcall->count);
break;
case Fborder:
- if(qpath_type(m->qid.dir->path) == Ddefault)
+ fprintf(stderr, "Fborder: qpath_type(m->qid.path)=%d, m->qid.dtype=%d\n",
+ qpath_type(m->qid.path), m->qid.dtype);
+
+ if(m->qid.dtype == Ddefault)
snprintf(buf, sizeof(buf), "%u", def.border);
else
snprintf(buf, sizeof(buf), "%u", page[pg]->area[area]->client[cl]->frame.border);
@@ -678,7 +690,7 @@ xread(IXPConn *c)
memcpy(p, buf, c->fcall->count);
break;
case Ftitle:
- if(qpath_type(m->qid.dir->path) == Ddefault)
+ if(m->qid.dtype == Ddefault)
snprintf(buf, sizeof(buf), "%u", def.title);
else
snprintf(buf, sizeof(buf), "%u", page[pg]->area[area]->client[cl]->frame.title);
@@ -686,7 +698,7 @@ xread(IXPConn *c)
memcpy(p, buf, c->fcall->count);
break;
case Finc:
- if(qpath_type(m->qid.dir->path) == Ddefault)
+ if(m->qid.dtype == Ddefault)
snprintf(buf, sizeof(buf), "%u", def.inc);
else
snprintf(buf, sizeof(buf), "%u", page[pg]->area[area]->client[cl]->inc);
@@ -760,7 +772,7 @@ xwrite(IXPConn *c)
switch (qpath_type(m->qid.path)) {
case Fctl:
- switch(qpath_type(m->qid.dir->path)) {
+ switch(m->qid.dtype) {
case Droot:
/* TODO: /ctl commands */
break;
@@ -833,7 +845,7 @@ xwrite(IXPConn *c)
errstr = "border value out of range 0..0xffff";
return -1;
}
- if(qpath_type(m->qid.dir->path) == Ddefault)
+ if(m->qid.dtype == Ddefault)
def.border = i;
else {
page[pg]->area[area]->client[cl]->frame.border = i;
@@ -850,7 +862,7 @@ xwrite(IXPConn *c)
errstr = "title value out of range 0, 1";
return -1;
}
- if(qpath_type(m->qid.dir->path) == Ddefault)
+ if(m->qid.dtype == Ddefault)
def.border = i;
else {
page[pg]->area[area]->client[cl]->frame.border = i;
@@ -867,7 +879,7 @@ xwrite(IXPConn *c)
errstr = "increment value out of range 0, 1";
return -1;
}
- if(qpath_type(m->qid.dir->path) == Ddefault)
+ if(m->qid.dtype == Ddefault)
def.inc = i;
else {
page[pg]->area[area]->client[cl]->inc = i;
diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c
@@ -80,15 +80,10 @@ scale_rect(XRectangle * from_dim, XRectangle * to_dim,
static void
draw_pager_client(Client *c, Draw *d)
{
- if(c == sel_client()) {
- d->bg = def.selbg;
- d->fg = def.selfg;
- d->border = def.selborder;
- } else {
- d->bg = def.normbg;
- d->fg = def.normfg;
- d->border = def.normborder;
- }
+ if(c == sel_client())
+ d->color = def.sel;
+ else
+ d->color = def.norm;
d->data = c->name;
scale_rect(&rect, &initial_rect, &c->frame.rect, &d->rect);
blitz_drawlabel(dpy, d);
@@ -102,15 +97,10 @@ draw_pager_page(size_t idx, Draw *d)
char name[4];
initial_rect = d->rect;
- if(idx == sel) {
- d->bg = def.selbg;
- d->fg = def.selfg;
- d->border = def.selborder;
- } else {
- d->bg = def.normbg;
- d->fg = def.normfg;
- d->border = def.normborder;
- }
+ if(idx == sel)
+ d->color = def.sel;
+ else
+ d->color = def.norm;
snprintf(name, sizeof(name), "%d", idx + 1);
d->data = name;
blitz_drawlabel(dpy, d);
@@ -659,7 +649,7 @@ main(int argc, char *argv[])
case 'c':
checkwm = 1;
break;
- case 's':
+ case 'a':
if(i + 1 < argc)
address = argv[++i];
else
@@ -671,6 +661,7 @@ main(int argc, char *argv[])
}
}
}
+#if 0
dpy = XOpenDisplay(0);
if(!dpy) {
fprintf(stderr, "%s", "wmiiwm: cannot open display\n");
@@ -697,7 +688,7 @@ main(int argc, char *argv[])
}
XSetErrorHandler(0);
x_error_handler = XSetErrorHandler(wmii_error_handler);
-
+#endif
errstr = nil;
if(!address)
usage();
@@ -714,6 +705,11 @@ main(int argc, char *argv[])
c->close = close_ixp_conn;
srv.conn = (IXPConn **)cext_array_attach((void **)srv.conn, c,
sizeof(IXPConn *), &srv.connsz);
+
+ root_qid.type = IXP_QTDIR;
+ root_qid.version = 0;
+ root_qid.path = mkqpath(Droot, 0, 0, 0);
+#if 0
/* X server */
c = cext_emallocz(sizeof(IXPConn));
c->fd = ConnectionNumber(dpy);
@@ -721,12 +717,8 @@ main(int argc, char *argv[])
srv.conn = (IXPConn **)cext_array_attach((void **)srv.conn, c,
sizeof(IXPConn *), &srv.connsz);
- root_qid.type = IXP_QTDIR;
- root_qid.version = 0;
- root_qid.path = mkqpath(Droot, 0, 0, 0);
- root_qid.dir = nil;
-
init_event_hander();
+#endif
ndet = npage = nclient = aqsz = detsz = pagesz = clientsz = sel = 0;
page = nil;
@@ -734,14 +726,19 @@ main(int argc, char *argv[])
aq = nil;
def.font = strdup("fixed");
+ cext_strlcpy(def.selcolor, BLITZ_SEL_COLOR, sizeof(def.selcolor));
+ /*blitz_loadcolor(dpy, screen, def.selcolor, &def.sel);*/
+ cext_strlcpy(def.normcolor, BLITZ_SEL_COLOR, sizeof(def.normcolor));
+ /*blitz_loadcolor(dpy, screen, def.normcolor, &def.norm);*/
+#if 0
init_atoms();
init_cursors();
xfont = blitz_getfont(dpy, def.font);
wmii_init_lock_modifiers(dpy, &valid_mask, &num_lock_mask);
init_screen();
scan_wins();
-
+#endif
/* main event loop */
errstr = ixp_server_loop(&srv);
if(errstr)
@@ -749,7 +746,7 @@ main(int argc, char *argv[])
cleanup();
- XCloseDisplay(dpy);
+ /*XCloseDisplay(dpy);*/
return 0;
}
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -127,14 +127,10 @@ typedef struct {
char *font;
Bool title;
Bool inc;
+ Color sel;
+ Color norm;
unsigned int border;
unsigned int snap;
- unsigned int selfg;
- unsigned int selbg;
- unsigned int selborder;
- unsigned int normfg;
- unsigned int normbg;
- unsigned int normborder;
} Default;
Default def;
@@ -185,7 +181,7 @@ void resize_client(Client *c, XRectangle * r, XPoint * pt);
unsigned int tab_height(Client *c);
/* event.c */
-void init_event_hander();
+void init_x_event_handler();
void check_x_event(IXPServer *s, IXPConn *c);
/* fs.c */
diff --git a/cmd/wmiibar.c b/cmd/wmiibar.c
@@ -49,10 +49,8 @@ enum {
typedef struct {
char data[256];
- char color[24];
- unsigned long fg;
- unsigned long bg;
- unsigned long border;
+ char colstr[24];
+ Color color;
XRectangle rect;
} Item;
@@ -74,7 +72,7 @@ static char *address = nil;
static IXPServer srv = { 0 };
static Qid root_qid;
static Display *dpy;
-static int screen_num;
+static int screen;
static char *font = nil;
static XFontStruct *xfont;
static GC gc;
@@ -110,10 +108,8 @@ new_item()
{
Item *it = cext_emallocz(sizeof(Item));
if(nitem > 0) {
- cext_strlcpy(it->color, item[0]->color, sizeof(it->color));
- it->fg = item[0]->fg;
- it->bg = item[0]->bg;
- it->border = item[0]->border;
+ cext_strlcpy(it->colstr, item[0]->colstr, sizeof(it->colstr));
+ it->color = item[0]->color;
}
item = (Item **)cext_array_attach((void **)item, it, sizeof(Item *), &itemsz);
nitem++;
@@ -140,9 +136,7 @@ draw()
d.font = xfont;
if(nitem == 1) { /* /default only */
- d.fg = item[0]->fg;
- d.bg = item[0]->bg;
- d.border = item[0]->border;
+ d.color = item[0]->color;
blitz_drawlabel(dpy, &d);
}
else {
@@ -172,9 +166,7 @@ draw()
} else
item[iexpand]->rect.width = brect.width - w;
for(i = 1; i < nitem; i++) {
- d.fg = item[i]->fg;
- d.bg = item[i]->bg;
- d.border = item[i]->border;
+ d.color = item[i]->color;
if(i > 1)
item[i]->rect.x = item[i - 1]->rect.x + item[i - 1]->rect.width;
d.rect = item[i]->rect;
@@ -190,14 +182,6 @@ draw()
}
static void
-update_color(Item *it)
-{
- it->fg = blitz_loadcolor(dpy, screen_num, &it->color[0]);
- it->bg = blitz_loadcolor(dpy, screen_num, &it->color[8]);
- it->border = blitz_loadcolor(dpy, screen_num, &it->color[16]);
-}
-
-static void
update_geometry()
{
char buf[64];
@@ -208,7 +192,7 @@ update_geometry()
XSync(dpy, False);
XFreePixmap(dpy, pmap);
pmap = XCreatePixmap(dpy, win, brect.width, brect.height,
- DefaultDepth(dpy, screen_num));
+ DefaultDepth(dpy, screen));
XSync(dpy, False);
snprintf(buf, sizeof(buf), "NewGeometry %d %d %d %d\n", brect.x, brect.y, brect.width, brect.height);
do_pend_fcall(buf);
@@ -331,7 +315,7 @@ mkqid(Qid *dir, char *wname, Qid *new)
if((dir->type != IXP_QTDIR) || (type == -1))
return -1;
- new->dir = dir;
+ new->dtype = qpath_type(dir->path);
new->version = 0;
switch(type) {
case Droot:
@@ -642,8 +626,8 @@ xread(IXPConn *c)
new_item();
if(i >= nitem)
goto error_xread;
- if((c->fcall->count = strlen(item[i]->color)))
- memcpy(p, item[i]->color, c->fcall->count);
+ if((c->fcall->count = strlen(item[i]->colstr)))
+ memcpy(p, item[i]->colstr, c->fcall->count);
break;
default:
error_xread:
@@ -751,9 +735,9 @@ xwrite(IXPConn *c)
errstr = "wrong color format";
goto error_xwrite;
}
- memcpy(item[i]->color, c->fcall->data, c->fcall->count);
- item[i]->color[c->fcall->count] = 0;
- update_color(item[i]);
+ memcpy(item[i]->colstr, c->fcall->data, c->fcall->count);
+ item[i]->colstr[c->fcall->count] = 0;
+ blitz_loadcolor(dpy, screen, item[i]->colstr, &item[i]->color);
draw();
break;
default:
@@ -941,7 +925,7 @@ main(int argc, char *argv[])
exit(1);
}
XSetErrorHandler(dummy_error_handler);
- screen_num = DefaultScreen(dpy);
+ screen = DefaultScreen(dpy);
if(!address)
usage();
@@ -968,12 +952,11 @@ main(int argc, char *argv[])
root_qid.type = IXP_QTDIR;
root_qid.version = 0;
root_qid.path = mkqpath(Droot, 0);
- root_qid.dir = nil;
/* default settings */
new_item();
- cext_strlcpy(item[0]->color, BLITZ_SEL_COLOR, sizeof(item[0]->color));
- update_color(item[0]);
+ cext_strlcpy(item[0]->colstr, BLITZ_SEL_COLOR, sizeof(item[0]->colstr));
+ blitz_loadcolor(dpy, screen, item[0]->colstr, &item[0]->color);
/* X stuff */
font = strdup(BLITZ_FONT);
@@ -984,15 +967,15 @@ main(int argc, char *argv[])
| SubstructureRedirectMask | SubstructureNotifyMask;
rect.x = rect.y = 0;
- rect.width = DisplayWidth(dpy, screen_num);
- rect.height = DisplayHeight(dpy, screen_num);
+ rect.width = DisplayWidth(dpy, screen);
+ rect.height = DisplayHeight(dpy, screen);
brect = rect;
brect.height = xfont->ascent + xfont->descent + 4;
brect.y = rect.height - brect.height;
- win = XCreateWindow(dpy, RootWindow(dpy, screen_num), brect.x, brect.y,
- brect.width, brect.height, 0, DefaultDepth(dpy, screen_num),
- CopyFromParent, DefaultVisual(dpy, screen_num),
+ win = XCreateWindow(dpy, RootWindow(dpy, screen), brect.x, brect.y,
+ brect.width, brect.height, 0, DefaultDepth(dpy, screen),
+ CopyFromParent, DefaultVisual(dpy, screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
XDefineCursor(dpy, win, XCreateFontCursor(dpy, XC_left_ptr));
XSync(dpy, False);
@@ -1002,7 +985,7 @@ main(int argc, char *argv[])
gc = XCreateGC(dpy, win, 0, 0);
pmap = XCreatePixmap(dpy, win, brect.width, brect.height,
- DefaultDepth(dpy, screen_num));
+ DefaultDepth(dpy, screen));
/* main loop */
XMapRaised(dpy, win);
diff --git a/cmd/wmiikeys.c b/cmd/wmiikeys.c
@@ -47,7 +47,7 @@ static Window win;
static Window root;
static XRectangle krect;
static XRectangle rect;
-static int screen_num;
+static int screen;
static char *sockfile = nil;
static Shortcut *shortcuts = nil;
static File *files[K_LAST];
@@ -332,10 +332,10 @@ draw_shortcut_box(char *text)
d.rect.y = 0;
d.rect.width = krect.width;
d.rect.height = krect.height;
- d.bg = blitz_loadcolor(dpy, screen_num, files[K_BG_COLOR]->content);
- d.fg = blitz_loadcolor(dpy, screen_num, files[K_FG_COLOR]->content);
+ d.bg = blitz_loadcolor(dpy, screen, files[K_BG_COLOR]->content);
+ d.fg = blitz_loadcolor(dpy, screen, files[K_FG_COLOR]->content);
d.border =
- blitz_loadcolor(dpy, screen_num, files[K_BORDER_COLOR]->content);
+ blitz_loadcolor(dpy, screen, files[K_BORDER_COLOR]->content);
blitz_drawlabel(dpy, &d);
}
@@ -443,7 +443,7 @@ main(int argc, char *argv[])
exit(1);
}
XSetErrorHandler(dummy_error_handler);
- screen_num = DefaultScreen(dpy);
+ screen = DefaultScreen(dpy);
/* init */
ixps = wmii_setup_server(sockfile);
@@ -473,19 +473,19 @@ main(int argc, char *argv[])
wa.event_mask =
ExposureMask | SubstructureRedirectMask | SubstructureNotifyMask;
- root = RootWindow(dpy, screen_num);
+ root = RootWindow(dpy, screen);
rect.x = rect.y = 0;
- rect.width = DisplayWidth(dpy, screen_num);
- rect.height = DisplayHeight(dpy, screen_num);
+ rect.width = DisplayWidth(dpy, screen);
+ rect.height = DisplayHeight(dpy, screen);
krect.x = krect.y = 0;
krect.width = krect.height = 1;
wmii_init_lock_modifiers(dpy, &valid_mask, &num_lock_mask);
- win = XCreateWindow(dpy, RootWindow(dpy, screen_num), krect.x, krect.y,
+ win = XCreateWindow(dpy, RootWindow(dpy, screen), krect.x, krect.y,
krect.width, krect.height, 0, DefaultDepth(dpy,
- screen_num),
- CopyFromParent, DefaultVisual(dpy, screen_num),
+ screen),
+ CopyFromParent, DefaultVisual(dpy, screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask,
&wa);
XDefineCursor(dpy, win, XCreateFontCursor(dpy, XC_left_ptr));
diff --git a/cmd/wmiimenu.c b/cmd/wmiimenu.c
@@ -54,7 +54,7 @@ static GC gc;
static Window win;
static XRectangle rect;
static XRectangle mrect;
-static int screen_num;
+static int screen;
static char *sockfile = 0;
static File *files[M_LAST];
static size_t nitems = 0;
@@ -156,7 +156,7 @@ show()
update_items(files[M_COMMAND]->content);
draw_menu();
while(XGrabKeyboard
- (dpy, RootWindow(dpy, screen_num), True, GrabModeAsync,
+ (dpy, RootWindow(dpy, screen), True, GrabModeAsync,
GrabModeAsync, CurrentTime) != GrabSuccess)
usleep(1000);
}
@@ -310,9 +310,9 @@ draw_menu()
d.rect.x = 0;
d.rect.y = 0;
d.bg =
- blitz_loadcolor(dpy, screen_num, files[M_NORM_BG_COLOR]->content);
+ blitz_loadcolor(dpy, screen, files[M_NORM_BG_COLOR]->content);
d.border =
- blitz_loadcolor(dpy, screen_num,
+ blitz_loadcolor(dpy, screen,
files[M_NORM_BORDER_COLOR]->content);
blitz_drawlabelnoborder(dpy, &d);
@@ -320,7 +320,7 @@ draw_menu()
d.align = WEST;
d.font = font;
d.fg =
- blitz_loadcolor(dpy, screen_num,
+ blitz_loadcolor(dpy, screen,
files[M_NORM_TEXT_COLOR]->content);
d.data = files[M_COMMAND]->content;
if(cmdw && sel)
@@ -331,10 +331,10 @@ draw_menu()
d.align = CENTER;
if(sel) {
d.bg =
- blitz_loadcolor(dpy, screen_num,
+ blitz_loadcolor(dpy, screen,
files[M_NORM_BG_COLOR]->content);
d.fg =
- blitz_loadcolor(dpy, screen_num,
+ blitz_loadcolor(dpy, screen,
files[M_NORM_TEXT_COLOR]->content);
d.data = offset[OFF_PREV] ? "<" : nil;
d.rect.x = offx;
@@ -352,34 +352,34 @@ draw_menu()
/*fprintf(stderr, "%s (%d, %d, %d, %d)\n", item->name, d.rect.x, d.rect.y, d.rect.width, d.rect.height); */
if(sel == i) {
d.bg =
- blitz_loadcolor(dpy, screen_num,
+ blitz_loadcolor(dpy, screen,
files[M_SEL_BG_COLOR]->content);
d.fg =
- blitz_loadcolor(dpy, screen_num,
+ blitz_loadcolor(dpy, screen,
files[M_SEL_TEXT_COLOR]->content);
d.border =
- blitz_loadcolor(dpy, screen_num,
+ blitz_loadcolor(dpy, screen,
files[M_SEL_BORDER_COLOR]->content);
blitz_drawlabel(dpy, &d);
} else {
d.bg =
- blitz_loadcolor(dpy, screen_num,
+ blitz_loadcolor(dpy, screen,
files[M_NORM_BG_COLOR]->content);
d.fg =
- blitz_loadcolor(dpy, screen_num,
+ blitz_loadcolor(dpy, screen,
files[M_NORM_TEXT_COLOR]->content);
d.border =
- blitz_loadcolor(dpy, screen_num,
+ blitz_loadcolor(dpy, screen,
files[M_NORM_BORDER_COLOR]->content);
blitz_drawlabelnoborder(dpy, &d);
}
}
d.bg =
- blitz_loadcolor(dpy, screen_num,
+ blitz_loadcolor(dpy, screen,
files[M_NORM_BG_COLOR]->content);
d.fg =
- blitz_loadcolor(dpy, screen_num,
+ blitz_loadcolor(dpy, screen,
files[M_NORM_TEXT_COLOR]->content);
d.data = offset[OFF_NEXT] ? ">" : nil;
d.rect.x = mrect.width - seek;
@@ -560,7 +560,7 @@ update_geometry()
XFreePixmap(dpy, pmap);
pmap =
XCreatePixmap(dpy, win, mrect.width, mrect.height,
- DefaultDepth(dpy, screen_num));
+ DefaultDepth(dpy, screen));
XSync(dpy, False);
}
@@ -648,7 +648,7 @@ main(int argc, char *argv[])
fprintf(stderr, "%s", "wmiimenu: cannot open display\n");
exit(1);
}
- screen_num = DefaultScreen(dpy);
+ screen = DefaultScreen(dpy);
ixps = wmii_setup_server(sockfile);
@@ -691,16 +691,16 @@ main(int argc, char *argv[])
| SubstructureRedirectMask | SubstructureNotifyMask;
rect.x = rect.y = 0;
- rect.width = DisplayWidth(dpy, screen_num);
- rect.height = DisplayHeight(dpy, screen_num);
+ rect.width = DisplayWidth(dpy, screen);
+ rect.height = DisplayHeight(dpy, screen);
mrect = rect;
mrect.height = font->ascent + font->descent + 4;
mrect.y = rect.height - mrect.height;
- win = XCreateWindow(dpy, RootWindow(dpy, screen_num), mrect.x, mrect.y,
+ win = XCreateWindow(dpy, RootWindow(dpy, screen), mrect.x, mrect.y,
mrect.width, mrect.height, 0, DefaultDepth(dpy,
- screen_num),
- CopyFromParent, DefaultVisual(dpy, screen_num),
+ screen),
+ CopyFromParent, DefaultVisual(dpy, screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask,
&wa);
XDefineCursor(dpy, win, XCreateFontCursor(dpy, XC_xterm));
@@ -713,7 +713,7 @@ main(int argc, char *argv[])
gc = XCreateGC(dpy, win, 0, 0);
pmap =
XCreatePixmap(dpy, win, mrect.width, mrect.height,
- DefaultDepth(dpy, screen_num));
+ DefaultDepth(dpy, screen));
/* main event loop */
run_server_with_fd_support(ixps, ConnectionNumber(dpy), check_event,
diff --git a/libixp/ixp.h b/libixp/ixp.h
@@ -147,7 +147,7 @@ struct Qid {
unsigned int version;
unsigned long long path;
/* internal use only */
- Qid *dir; /* points to parent, 0 if root dir */
+ unsigned char dtype;
};
/*stat structure */
diff --git a/liblitz/blitz.h b/liblitz/blitz.h
@@ -21,24 +21,26 @@ typedef enum {
SEAST, SOUTH, SWEST
} Align;
-typedef struct Draw Draw;
-
-struct Draw {
- Drawable drawable;
- GC gc;
+typedef struct {
unsigned long bg;
unsigned long fg;
unsigned long border;
+} Color;
+
+typedef struct {
+ Drawable drawable;
+ GC gc;
+ Color color;
Align align;
XFontStruct *font;
XRectangle rect; /* relative rect */
XRectangle *notch; /* relative notch rect */
char *data;
-};
+} Draw;
/* draw.c */
XFontStruct *blitz_getfont(Display * dpy, char *fontstr);
-unsigned long blitz_loadcolor(Display * dpy, int mon, char *colstr);
+int blitz_loadcolor(Display *dpy, int mon, char *colstr, Color *c);
void blitz_drawlabel(Display * dpy, Draw * r);
void blitz_drawmeter(Display * dpy, Draw * r);
void blitz_drawlabelnoborder(Display * dpy, Draw * r);
diff --git a/liblitz/draw.c b/liblitz/draw.c
@@ -7,7 +7,8 @@
#include <string.h>
#include "blitz.h"
-XFontStruct *blitz_getfont(Display * dpy, char *fontstr)
+XFontStruct *
+blitz_getfont(Display * dpy, char *fontstr)
{
XFontStruct *font;
font = XLoadQueryFont(dpy, fontstr);
@@ -21,7 +22,8 @@ XFontStruct *blitz_getfont(Display * dpy, char *fontstr)
return font;
}
-unsigned long blitz_loadcolor(Display * dpy, int mon, char *colstr)
+static unsigned long
+xloadcolor(Display * dpy, int mon, char *colstr)
{
XColor color;
char col[8];
@@ -32,10 +34,22 @@ unsigned long blitz_loadcolor(Display * dpy, int mon, char *colstr)
return color.pixel;
}
-static void draw_bg(Display * dpy, Draw * d)
+int
+blitz_loadcolor(Display *dpy, int mon, char *colstr, Color *c)
+{
+ if(!colstr || strlen(colstr) != 23)
+ return -1;
+ c->fg = xloadcolor(dpy, mon, &colstr[0]);
+ c->bg = xloadcolor(dpy, mon, &colstr[8]);
+ c->border = xloadcolor(dpy, mon, &colstr[16]);
+ return 0;
+}
+
+static void
+draw_bg(Display * dpy, Draw * d)
{
XRectangle rect[4];
- XSetForeground(dpy, d->gc, d->bg);
+ XSetForeground(dpy, d->gc, d->color.bg);
if (!d->notch) {
XFillRectangles(dpy, d->drawable, d->gc, &d->rect, 1);
return;
@@ -56,12 +70,13 @@ static void draw_bg(Display * dpy, Draw * d)
XFillRectangles(dpy, d->drawable, d->gc, rect, 4);
}
-static void xdraw_border(Display * dpy, Draw * d)
+static void
+xdraw_border(Display * dpy, Draw * d)
{
XPoint points[5];
XSetLineAttributes(dpy, d->gc, 1, LineSolid, CapButt, JoinMiter);
- XSetForeground(dpy, d->gc, d->border);
+ XSetForeground(dpy, d->gc, d->color.border);
points[0].x = d->rect.x;
points[0].y = d->rect.y;
points[1].x = d->rect.width - 1;
@@ -75,7 +90,8 @@ static void xdraw_border(Display * dpy, Draw * d)
XDrawLines(dpy, d->drawable, d->gc, points, 5, CoordModePrevious);
}
-static void draw_text(Display * dpy, Draw * d)
+static void
+draw_text(Display * dpy, Draw * d)
{
unsigned int x, y, w, h, shortened = 0;
size_t len = 0;
@@ -121,18 +137,19 @@ static void draw_text(Display * dpy, Draw * d)
break;
}
- XSetBackground(dpy, d->gc, d->bg);
+ XSetBackground(dpy, d->gc, d->color.bg);
/*
* uncomment, if you want get an shadow effect XSetForeground(dpy,
* d->gc, BlackPixel(dpy, DefaultScreen(dpy))); XDrawString(dpy,
* d->drawable, d->gc, x + 1, y + 1, text, len);
*/
- XSetForeground(dpy, d->gc, d->fg);
+ XSetForeground(dpy, d->gc, d->color.fg);
XDrawString(dpy, d->drawable, d->gc, x, y, text, len);
}
/* draws meter */
-void blitz_drawmeter(Display * dpy, Draw * d)
+void
+blitz_drawmeter(Display * dpy, Draw * d)
{
unsigned int offy, mh, val, w = d->rect.width - 4;
@@ -146,11 +163,12 @@ void blitz_drawmeter(Display * dpy, Draw * d)
/* draw bg gradient */
mh = ((d->rect.height - 4) * val) / 100;
offy = d->rect.y + d->rect.height - 2 - mh;
- XSetForeground(dpy, d->gc, d->fg);
+ XSetForeground(dpy, d->gc, d->color.fg);
XFillRectangle(dpy, d->drawable, d->gc, d->rect.x + 2, offy, w, mh);
}
-static void xdraw_label(Display * dpy, Draw * d)
+static void
+xdraw_label(Display * dpy, Draw * d)
{
draw_bg(dpy, d);
if (d->data)
@@ -158,13 +176,15 @@ static void xdraw_label(Display * dpy, Draw * d)
}
/* draws label */
-void blitz_drawlabel(Display * dpy, Draw * d)
+void
+blitz_drawlabel(Display * dpy, Draw * d)
{
xdraw_label(dpy, d);
xdraw_border(dpy, d);
}
-void blitz_drawlabelnoborder(Display * dpy, Draw * d)
+void
+blitz_drawlabelnoborder(Display * dpy, Draw * d)
{
xdraw_label(dpy, d);
}