mirror of
https://github.com/0intro/wmii
synced 2025-03-21 14:13:09 +03:00
Revamp color handling. Fixes issue #188.
This commit is contained in:
parent
abefbf048d
commit
fd930e89a6
@ -6,6 +6,7 @@ syntax: regexp
|
|||||||
\.(aux|idx|ilg|ind|log|toc)$
|
\.(aux|idx|ilg|ind|log|toc)$
|
||||||
^cmd/(stfo|osd|wiwarp|setfocus)(/|$)
|
^cmd/(stfo|osd|wiwarp|setfocus)(/|$)
|
||||||
^(pkg|src)/
|
^(pkg|src)/
|
||||||
|
^doxy
|
||||||
/bak/
|
/bak/
|
||||||
_dummy\.h$
|
_dummy\.h$
|
||||||
syntax: glob
|
syntax: glob
|
||||||
|
@ -33,7 +33,7 @@ client_manage(XWindow w) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wa.background_pixel = tray.selcolors.bg.pixel;
|
wa.background_pixel = pixelvalue(tray.selcolors.bg);
|
||||||
size = max(tray.iconsize / 4, 4);
|
size = max(tray.iconsize / 4, 4);
|
||||||
|
|
||||||
c->indicator = createwindow(tray.win, Rect(0, 0, size, size), scr.depth,
|
c->indicator = createwindow(tray.win, Rect(0, 0, size, size), scr.depth,
|
||||||
|
@ -78,7 +78,7 @@ gethsep(Rectangle r) {
|
|||||||
Window *w;
|
Window *w;
|
||||||
WinAttr wa;
|
WinAttr wa;
|
||||||
|
|
||||||
wa.background_pixel = def.normcolor.border.pixel;
|
wa.background_pixel = pixelvalue(def.normcolor.border);
|
||||||
w = createwindow(&scr.root, r, scr.depth, InputOutput, &wa, CWBackPixel);
|
w = createwindow(&scr.root, r, scr.depth, InputOutput, &wa, CWBackPixel);
|
||||||
mapwin(w);
|
mapwin(w);
|
||||||
raisewin(w);
|
raisewin(w);
|
||||||
|
@ -34,7 +34,7 @@ typedef enum WindowType WindowType;
|
|||||||
typedef XSetWindowAttributes WinAttr;
|
typedef XSetWindowAttributes WinAttr;
|
||||||
|
|
||||||
typedef union ClientMessageData ClientMessageData;
|
typedef union ClientMessageData ClientMessageData;
|
||||||
typedef struct Color Color;
|
typedef XRenderColor Color;
|
||||||
typedef struct CTuple CTuple;
|
typedef struct CTuple CTuple;
|
||||||
typedef struct ErrorCode ErrorCode;
|
typedef struct ErrorCode ErrorCode;
|
||||||
typedef struct Ewmh Ewmh;
|
typedef struct Ewmh Ewmh;
|
||||||
@ -56,11 +56,6 @@ union ClientMessageData {
|
|||||||
long l[5];
|
long l[5];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Color {
|
|
||||||
ulong pixel;
|
|
||||||
XRenderColor render;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CTuple {
|
struct CTuple {
|
||||||
Color bg;
|
Color bg;
|
||||||
Color fg;
|
Color fg;
|
||||||
@ -274,8 +269,9 @@ Font* loadfont(const char*);
|
|||||||
void lowerwin(Window*);
|
void lowerwin(Window*);
|
||||||
int mapwin(Window*);
|
int mapwin(Window*);
|
||||||
void movewin(Window*, Point);
|
void movewin(Window*, Point);
|
||||||
bool namedcolor(char *name, Color*);
|
bool parsecolor(const char *name, Color*);
|
||||||
bool parsekey(char*, int*, char**);
|
bool parsekey(char*, int*, char**);
|
||||||
|
ulong pixelvalue(Color);
|
||||||
int pointerscreen(void);
|
int pointerscreen(void);
|
||||||
bool pophandler(Window*, Handlers*);
|
bool pophandler(Window*, Handlers*);
|
||||||
void pushhandler(Window*, Handlers*, void*);
|
void pushhandler(Window*, Handlers*, void*);
|
||||||
|
@ -89,13 +89,12 @@ OBJ=\
|
|||||||
x11/initdisplay \
|
x11/initdisplay \
|
||||||
x11/sendevent \
|
x11/sendevent \
|
||||||
x11/sendmessage \
|
x11/sendmessage \
|
||||||
x11/setgccol \
|
|
||||||
x11/sync \
|
x11/sync \
|
||||||
x11/x11 \
|
x11/x11 \
|
||||||
x11/xatom \
|
x11/xatom \
|
||||||
x11/xft \
|
x11/xft \
|
||||||
x11/colors/loadcolor \
|
x11/colors/loadcolor \
|
||||||
x11/colors/namedcolor \
|
x11/colors/parsecolor \
|
||||||
x11/colors/xftcolor \
|
x11/colors/xftcolor \
|
||||||
x11/drawing/border \
|
x11/drawing/border \
|
||||||
x11/drawing/drawline \
|
x11/drawing/drawline \
|
||||||
@ -103,6 +102,7 @@ OBJ=\
|
|||||||
x11/drawing/drawstring \
|
x11/drawing/drawstring \
|
||||||
x11/drawing/fill \
|
x11/drawing/fill \
|
||||||
x11/drawing/fillpoly \
|
x11/drawing/fillpoly \
|
||||||
|
x11/drawing/setgccol \
|
||||||
x11/focus/getfocus \
|
x11/focus/getfocus \
|
||||||
x11/focus/setfocus \
|
x11/focus/setfocus \
|
||||||
x11/geometry/XRect \
|
x11/geometry/XRect \
|
||||||
|
@ -12,7 +12,7 @@ loadcolor(CTuple *c, const char *str) {
|
|||||||
memcpy(c->colstr, str, sizeof c->colstr);
|
memcpy(c->colstr, str, sizeof c->colstr);
|
||||||
|
|
||||||
buf[7] = buf[15] = buf[23] = '\0';
|
buf[7] = buf[15] = buf[23] = '\0';
|
||||||
return namedcolor(buf, &c->fg)
|
return parsecolor(buf, &c->fg)
|
||||||
&& namedcolor(buf+8, &c->bg)
|
&& parsecolor(buf+8, &c->bg)
|
||||||
&& namedcolor(buf+16, &c->border);
|
&& parsecolor(buf+16, &c->border);
|
||||||
}
|
}
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
/* Copyright ©2007-2010 Kris Maglione <maglione.k at Gmail>
|
|
||||||
* See LICENSE file for license details.
|
|
||||||
*/
|
|
||||||
#include "../x11.h"
|
|
||||||
|
|
||||||
bool
|
|
||||||
namedcolor(char *name, Color *ret) {
|
|
||||||
XColor c, c2;
|
|
||||||
|
|
||||||
if(XAllocNamedColor(display, scr.colormap, name, &c, &c2)) {
|
|
||||||
*ret = (Color) {
|
|
||||||
c.pixel, {
|
|
||||||
c.red,
|
|
||||||
c.green,
|
|
||||||
c.blue,
|
|
||||||
0xffff
|
|
||||||
},
|
|
||||||
};
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
18
lib/libstuff/x11/colors/parsecolor.c
Normal file
18
lib/libstuff/x11/colors/parsecolor.c
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/* Copyright ©2007-2010 Kris Maglione <maglione.k at Gmail>
|
||||||
|
* See LICENSE file for license details.
|
||||||
|
*/
|
||||||
|
#include "../x11.h"
|
||||||
|
|
||||||
|
ulong
|
||||||
|
pixelvalue(Color c) {
|
||||||
|
return ((ulong)(c.alpha&0xff00) << 16)
|
||||||
|
| ((ulong)(c.red&0xff00) << 8)
|
||||||
|
| ((ulong)(c.green&0xff00) << 0)
|
||||||
|
| ((ulong)(c.blue&0xff00) >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
parsecolor(const char *name, Color *ret) {
|
||||||
|
|
||||||
|
return XRenderParseColor(display, (char*)(uintptr_t)name, ret);
|
||||||
|
}
|
@ -8,12 +8,6 @@ xftcolor(Color col) {
|
|||||||
XftColor *c;
|
XftColor *c;
|
||||||
|
|
||||||
c = emallocz(sizeof *c);
|
c = emallocz(sizeof *c);
|
||||||
*c = (XftColor) {
|
*c = (XftColor){ pixelvalue(col), col };
|
||||||
((col.render.alpha&0xff00) << 24)
|
|
||||||
| ((col.render.red&0xff00) << 8)
|
|
||||||
| ((col.render.green&0xff00) << 0)
|
|
||||||
| ((col.render.blue&0xff00) >> 8),
|
|
||||||
col.render
|
|
||||||
};
|
|
||||||
return freelater(c);
|
return freelater(c);
|
||||||
}
|
}
|
||||||
|
@ -15,5 +15,5 @@ border(Image *dst, Rectangle r, int w, Color col) {
|
|||||||
XSetLineAttributes(display, dst->gc, w, LineSolid, CapButt, JoinMiter);
|
XSetLineAttributes(display, dst->gc, w, LineSolid, CapButt, JoinMiter);
|
||||||
setgccol(dst, col);
|
setgccol(dst, col);
|
||||||
XDrawRectangle(display, dst->xid, dst->gc,
|
XDrawRectangle(display, dst->xid, dst->gc,
|
||||||
r.min.x, r.min.y, Dx(r), Dy(r));
|
r.min.x, r.min.y, Dx(r), Dy(r));
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/* Copyright ©2007-2010 Kris Maglione <maglione.k at Gmail>
|
/* Copyright ©2007-2010 Kris Maglione <maglione.k at Gmail>
|
||||||
* See LICENSE file for license details.
|
* See LICENSE file for license details.
|
||||||
*/
|
*/
|
||||||
#include "x11.h"
|
#include "../x11.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
setgccol(Image *dst, Color col) {
|
setgccol(Image *dst, Color c) {
|
||||||
XSetForeground(display, dst->gc, col.pixel);
|
XSetForeground(display, dst->gc, pixelvalue(c));
|
||||||
}
|
}
|
@ -8,7 +8,7 @@ setborder(Window *w, int width, Color col) {
|
|||||||
|
|
||||||
assert(w->type == WWindow);
|
assert(w->type == WWindow);
|
||||||
if(width)
|
if(width)
|
||||||
XSetWindowBorder(display, w->xid, col.pixel);
|
XSetWindowBorder(display, w->xid, pixelvalue(col));
|
||||||
if(width != w->border)
|
if(width != w->border)
|
||||||
configwin(w, w->r, width);
|
configwin(w, w->r, width);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user