mirror of
https://github.com/0intro/wmii
synced 2024-12-25 21:06:57 +03:00
changed blitz_loadcolor to use Blitz type
This commit is contained in:
parent
f398f6970a
commit
acdb6c4044
@ -1365,7 +1365,7 @@ xwrite(IXPConn *c, Fcall *fcall)
|
||||
return Ebadvalue;
|
||||
memcpy(BAR(i1)->colstr, fcall->data, fcall->count);
|
||||
BAR(i1)->colstr[fcall->count] = 0;
|
||||
blitz_loadcolor(dpy, &BAR(i1)->color, screen, BAR(i1)->colstr);
|
||||
blitz_loadcolor(&blitz, &BAR(i1)->color, BAR(i1)->colstr);
|
||||
draw_bar();
|
||||
break;
|
||||
case FsFselcolors:
|
||||
@ -1374,7 +1374,7 @@ xwrite(IXPConn *c, Fcall *fcall)
|
||||
return Ebadvalue;
|
||||
memcpy(def.selcolor, fcall->data, fcall->count);
|
||||
def.selcolor[fcall->count] = 0;
|
||||
blitz_loadcolor(dpy, &def.sel, screen, def.selcolor);
|
||||
blitz_loadcolor(&blitz, &def.sel, def.selcolor);
|
||||
draw_clients();
|
||||
break;
|
||||
case FsFnormcolors:
|
||||
@ -1383,7 +1383,7 @@ xwrite(IXPConn *c, Fcall *fcall)
|
||||
return Ebadvalue;
|
||||
memcpy(def.normcolor, fcall->data, fcall->count);
|
||||
def.normcolor[fcall->count] = 0;
|
||||
blitz_loadcolor(dpy, &def.norm, screen, def.normcolor);
|
||||
blitz_loadcolor(&blitz, &def.norm, def.normcolor);
|
||||
draw_clients();
|
||||
break;
|
||||
case FsFkeys:
|
||||
|
@ -285,6 +285,7 @@ main(int argc, char *argv[])
|
||||
/* X server */
|
||||
ixp_server_open_conn(&srv, ConnectionNumber(dpy), check_x_event, nil);
|
||||
init_x_event_handler();
|
||||
blitz_init(&blitz, dpy);
|
||||
|
||||
view = nil;
|
||||
client = nil;
|
||||
@ -302,9 +303,9 @@ main(int argc, char *argv[])
|
||||
def.border = 2;
|
||||
def.colmode = Coldefault;
|
||||
cext_strlcpy(def.selcolor, BLITZ_SELCOLORS, sizeof(def.selcolor));
|
||||
blitz_loadcolor(dpy, &def.sel, screen, def.selcolor);
|
||||
blitz_loadcolor(&blitz, &def.sel, def.selcolor);
|
||||
cext_strlcpy(def.normcolor, BLITZ_NORMCOLORS, sizeof(def.normcolor));
|
||||
blitz_loadcolor(dpy, &def.norm, screen, def.normcolor);
|
||||
blitz_loadcolor(&blitz, &def.norm, def.normcolor);
|
||||
cext_strlcpy(def.grabmod, "Mod1", sizeof(def.grabmod));
|
||||
def.mod = Mod1Mask;
|
||||
|
||||
@ -345,6 +346,7 @@ main(int argc, char *argv[])
|
||||
if(errstr)
|
||||
fprintf(stderr, "wmii: fatal: %s\n", errstr);
|
||||
|
||||
blitz_deinit(&blitz);
|
||||
ixp_server_close(&srv);
|
||||
cleanup();
|
||||
XCloseDisplay(dpy);
|
||||
|
@ -237,6 +237,7 @@ Atom net_atom[NetLast];
|
||||
Cursor cursor[CurLast];
|
||||
unsigned int valid_mask;
|
||||
unsigned int num_lock_mask;
|
||||
Blitz blitz;
|
||||
void (*handler[LASTEvent]) (XEvent *);
|
||||
|
||||
|
||||
|
@ -40,6 +40,7 @@ static unsigned int curroff = 0;
|
||||
static unsigned int cmdw = 0;
|
||||
static unsigned int twidth = 0;
|
||||
static unsigned int cwidth = 0;
|
||||
static Blitz blitz = { 0 };
|
||||
static BlitzDraw draw = { 0 };
|
||||
static const int seek = 30; /* 30px */
|
||||
|
||||
@ -386,6 +387,7 @@ main(int argc, char *argv[])
|
||||
usleep(1000);
|
||||
|
||||
/* set font and colors */
|
||||
blitz_init(&blitz, dpy);
|
||||
fontstr = getenv("WMII_FONT");
|
||||
if (!fontstr)
|
||||
fontstr = strdup(BLITZ_FONT);
|
||||
@ -393,11 +395,11 @@ main(int argc, char *argv[])
|
||||
normcolstr = getenv("WMII_NORMCOLORS");
|
||||
if (!normcolstr || strlen(normcolstr) != 23)
|
||||
normcolstr = strdup(BLITZ_NORMCOLORS);
|
||||
blitz_loadcolor(dpy, &normcolor, screen, normcolstr);
|
||||
blitz_loadcolor(&blitz, &normcolor, normcolstr);
|
||||
selcolstr = getenv("WMII_SELCOLORS");
|
||||
if (!selcolstr || strlen(selcolstr) != 23)
|
||||
selcolstr = strdup(BLITZ_SELCOLORS);
|
||||
blitz_loadcolor(dpy, &selcolor, screen, selcolstr);
|
||||
blitz_loadcolor(&blitz, &selcolor, selcolstr);
|
||||
|
||||
wa.override_redirect = 1;
|
||||
wa.background_pixmap = ParentRelative;
|
||||
@ -460,6 +462,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
|
||||
blitz_deinit(&blitz);
|
||||
XUngrabKeyboard(dpy, CurrentTime);
|
||||
XFreePixmap(dpy, draw.drawable);
|
||||
XFreeGC(dpy, draw.gc);
|
||||
|
@ -52,9 +52,6 @@ typedef struct {
|
||||
unsigned int blitz_textwidth(Display *dpy, BlitzFont *font, char *text);
|
||||
void blitz_loadfont(Display *dpy, BlitzFont *font, char *fontstr);
|
||||
|
||||
/* color.c */
|
||||
int blitz_loadcolor(Display *dpy, BlitzColor *c, int mon, char *colstr);
|
||||
|
||||
/* draw.c */
|
||||
void blitz_drawlabel(Display *dpy, BlitzDraw *d);
|
||||
void blitz_drawborder(Display *dpy, BlitzDraw *d);
|
||||
@ -77,6 +74,9 @@ typedef struct {
|
||||
void blitz_init(Blitz *blitz, Display *dpy);
|
||||
void blitz_deinit(Blitz *blitz);
|
||||
|
||||
/* color.c */
|
||||
int blitz_loadcolor(Blitz *blitz, BlitzColor *c, char *colstr);
|
||||
|
||||
/* window.c */
|
||||
void blitz_create_win(Blitz *blitz, BlitzWindow *win, unsigned long mask,
|
||||
int x, int y, int w, int h);
|
||||
|
@ -9,25 +9,26 @@
|
||||
#include "blitz.h"
|
||||
|
||||
static unsigned long
|
||||
xloadcolor(Display *dpy, int mon, char *colstr)
|
||||
xloadcolor(Blitz *blitz, char *colstr)
|
||||
{
|
||||
XColor color;
|
||||
char col[8];
|
||||
|
||||
cext_strlcpy(col, colstr, sizeof(col));
|
||||
col[7] = 0;
|
||||
XAllocNamedColor(dpy, DefaultColormap(dpy, mon), col, &color, &color);
|
||||
XAllocNamedColor(blitz->display,
|
||||
DefaultColormap(blitz->display, blitz->screen), col, &color, &color);
|
||||
return color.pixel;
|
||||
}
|
||||
|
||||
int
|
||||
blitz_loadcolor(Display *dpy, BlitzColor *c, int mon, char *colstr)
|
||||
blitz_loadcolor(Blitz *blitz, BlitzColor *c, char *colstr)
|
||||
{
|
||||
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]);
|
||||
c->fg = xloadcolor(blitz, &colstr[0]);
|
||||
c->bg = xloadcolor(blitz, &colstr[8]);
|
||||
c->border = xloadcolor(blitz, &colstr[16]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user