this is going to break the kernel/ building.
lots of modifications to the render API, prefixing everything, making proper names for everything. the structures are not hidden/opaque yet, but the naming scheme of the public API works much better now.
This commit is contained in:
parent
49268650b4
commit
3f32dfa87e
19 changed files with 1140 additions and 921 deletions
|
@ -13,3 +13,4 @@ theme.lo
|
||||||
Makefile.in
|
Makefile.in
|
||||||
.deps
|
.deps
|
||||||
Makefile
|
Makefile
|
||||||
|
instance.lo
|
||||||
|
|
|
@ -15,8 +15,22 @@ rendertest_LDFLAGS=-lobrender -L.
|
||||||
rendertest_SOURCES=test.c
|
rendertest_SOURCES=test.c
|
||||||
|
|
||||||
lib_LTLIBRARIES=libobrender.la
|
lib_LTLIBRARIES=libobrender.la
|
||||||
libobrender_la_SOURCES=color.c font.c gradient.c image.c mask.c render.c \
|
libobrender_la_SOURCES=\
|
||||||
theme.c
|
color.h \
|
||||||
|
color.c \
|
||||||
|
font.h \
|
||||||
|
font.c \
|
||||||
|
gradient.h \
|
||||||
|
gradient.c \
|
||||||
|
image.h \
|
||||||
|
image.c \
|
||||||
|
mask.h \
|
||||||
|
mask.c \
|
||||||
|
render.h \
|
||||||
|
render.c \
|
||||||
|
theme.c \
|
||||||
|
instance.h \
|
||||||
|
instance.c
|
||||||
|
|
||||||
|
|
||||||
noinst_HEADERS=render.h gradient.h color.h font.h mask.h image.h
|
noinst_HEADERS=render.h gradient.h color.h font.h mask.h image.h
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "../kernel/openbox.h"
|
|
||||||
|
|
||||||
XColor *pseudo_colors;
|
XColor *pseudo_colors;
|
||||||
int pseudo_bpc;
|
int pseudo_bpc;
|
||||||
|
@ -14,10 +13,12 @@ void color_allocate_gc(color_rgb *in)
|
||||||
|
|
||||||
gcv.foreground = in->pixel;
|
gcv.foreground = in->pixel;
|
||||||
gcv.cap_style = CapProjecting;
|
gcv.cap_style = CapProjecting;
|
||||||
in->gc = XCreateGC(ob_display, ob_root, GCForeground | GCCapStyle, &gcv);
|
in->gc = XCreateGC(RrDisplay(in->inst),
|
||||||
|
RrRootWindow(in->inst),
|
||||||
|
GCForeground | GCCapStyle, &gcv);
|
||||||
}
|
}
|
||||||
|
|
||||||
color_rgb *color_parse(char *colorname)
|
color_rgb *RrColorParse(const RrInstance *inst, gchar *colorname)
|
||||||
{
|
{
|
||||||
XColor xcol;
|
XColor xcol;
|
||||||
|
|
||||||
|
@ -28,45 +29,44 @@ color_rgb *color_parse(char *colorname)
|
||||||
xcol.green = 0;
|
xcol.green = 0;
|
||||||
xcol.blue = 0;
|
xcol.blue = 0;
|
||||||
xcol.pixel = 0;
|
xcol.pixel = 0;
|
||||||
if (!XParseColor(ob_display, render_colormap, colorname, &xcol)) {
|
if (!XParseColor(RrDisplay(inst), RrColormap(inst), colorname, &xcol)) {
|
||||||
g_warning("unable to parse color '%s'", colorname);
|
g_warning("unable to parse color '%s'", colorname);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return color_new(xcol.red >> 8, xcol.green >> 8, xcol.blue >> 8);
|
return RrColorNew(inst, xcol.red >> 8, xcol.green >> 8, xcol.blue >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
color_rgb *color_new(int r, int g, int b)
|
color_rgb *RrColorNew(const RrInstance *inst, gint r, gint g, gint b)
|
||||||
{
|
{
|
||||||
/* this should be replaced with something far cooler */
|
/* this should be replaced with something far cooler */
|
||||||
color_rgb *out;
|
color_rgb *out = NULL;
|
||||||
XColor xcol;
|
XColor xcol;
|
||||||
xcol.red = (r << 8) | r;
|
xcol.red = (r << 8) | r;
|
||||||
xcol.green = (g << 8) | g;
|
xcol.green = (g << 8) | g;
|
||||||
xcol.blue = (b << 8) | b;
|
xcol.blue = (b << 8) | b;
|
||||||
if (XAllocColor(ob_display, render_colormap, &xcol)) {
|
if (XAllocColor(RrDisplay(inst), RrColormap(inst), &xcol)) {
|
||||||
out = g_new(color_rgb, 1);
|
out = g_new(color_rgb, 1);
|
||||||
|
out->inst = inst;
|
||||||
out->r = xcol.red >> 8;
|
out->r = xcol.red >> 8;
|
||||||
out->g = xcol.green >> 8;
|
out->g = xcol.green >> 8;
|
||||||
out->b = xcol.blue >> 8;
|
out->b = xcol.blue >> 8;
|
||||||
out->gc = None;
|
out->gc = None;
|
||||||
out->pixel = xcol.pixel;
|
out->pixel = xcol.pixel;
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*XXX same color could be pointed to twice, this might have to be a refcount*/
|
/*XXX same color could be pointed to twice, this might have to be a refcount*/
|
||||||
|
|
||||||
void color_free(color_rgb *c)
|
void RrColorFree(color_rgb *c)
|
||||||
{
|
{
|
||||||
if (c != NULL) {
|
if (c) {
|
||||||
if (c->gc != None)
|
if (c->gc) XFreeGC(RrDisplay(c->inst), c->gc);
|
||||||
XFreeGC(ob_display, c->gc);
|
|
||||||
g_free(c);
|
g_free(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void reduce_depth(pixel32 *data, XImage *im)
|
void reduce_depth(const RrInstance *inst, pixel32 *data, XImage *im)
|
||||||
{
|
{
|
||||||
int r, g, b;
|
int r, g, b;
|
||||||
int x,y;
|
int x,y;
|
||||||
|
@ -75,17 +75,17 @@ void reduce_depth(pixel32 *data, XImage *im)
|
||||||
unsigned char *p8 = (unsigned char *)im->data;
|
unsigned char *p8 = (unsigned char *)im->data;
|
||||||
switch (im->bits_per_pixel) {
|
switch (im->bits_per_pixel) {
|
||||||
case 32:
|
case 32:
|
||||||
if ((render_red_offset != default_red_offset) ||
|
if ((RrRedOffset(inst) != default_red_offset) ||
|
||||||
(render_blue_offset != default_blue_offset) ||
|
(RrBlueOffset(inst) != default_blue_offset) ||
|
||||||
(render_green_offset != default_green_offset)) {
|
(RrGreenOffset(inst) != default_green_offset)) {
|
||||||
for (y = 0; y < im->height; y++) {
|
for (y = 0; y < im->height; y++) {
|
||||||
for (x = 0; x < im->width; x++) {
|
for (x = 0; x < im->width; x++) {
|
||||||
r = (data[x] >> default_red_offset) & 0xFF;
|
r = (data[x] >> default_red_offset) & 0xFF;
|
||||||
g = (data[x] >> default_green_offset) & 0xFF;
|
g = (data[x] >> default_green_offset) & 0xFF;
|
||||||
b = (data[x] >> default_blue_offset) & 0xFF;
|
b = (data[x] >> default_blue_offset) & 0xFF;
|
||||||
p32[x] = (r << render_red_shift)
|
p32[x] = (r << RrRedShift(inst))
|
||||||
+ (g << render_green_shift)
|
+ (g << RrGreenShift(inst))
|
||||||
+ (b << render_blue_shift);
|
+ (b << RrBlueShift(inst));
|
||||||
}
|
}
|
||||||
data += im->width;
|
data += im->width;
|
||||||
p32 += im->width;
|
p32 += im->width;
|
||||||
|
@ -96,24 +96,25 @@ void reduce_depth(pixel32 *data, XImage *im)
|
||||||
for (y = 0; y < im->height; y++) {
|
for (y = 0; y < im->height; y++) {
|
||||||
for (x = 0; x < im->width; x++) {
|
for (x = 0; x < im->width; x++) {
|
||||||
r = (data[x] >> default_red_offset) & 0xFF;
|
r = (data[x] >> default_red_offset) & 0xFF;
|
||||||
r = r >> render_red_shift;
|
r = r >> RrRedShift(inst);
|
||||||
g = (data[x] >> default_green_offset) & 0xFF;
|
g = (data[x] >> default_green_offset) & 0xFF;
|
||||||
g = g >> render_green_shift;
|
g = g >> RrGreenShift(inst);
|
||||||
b = (data[x] >> default_blue_offset) & 0xFF;
|
b = (data[x] >> default_blue_offset) & 0xFF;
|
||||||
b = b >> render_blue_shift;
|
b = b >> RrBlueShift(inst);
|
||||||
p16[x] = (r << render_red_offset)
|
p16[x] = (r << RrRedOffset(inst))
|
||||||
+ (g << render_green_offset)
|
+ (g << RrGreenOffset(inst))
|
||||||
+ (b << render_blue_offset);
|
+ (b << RrBlueOffset(inst));
|
||||||
}
|
}
|
||||||
data += im->width;
|
data += im->width;
|
||||||
p16 += im->bytes_per_line/2;
|
p16 += im->bytes_per_line/2;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
g_assert(render_visual->class != TrueColor);
|
g_assert(RrVisual(inst)->class != TrueColor);
|
||||||
for (y = 0; y < im->height; y++) {
|
for (y = 0; y < im->height; y++) {
|
||||||
for (x = 0; x < im->width; x++) {
|
for (x = 0; x < im->width; x++) {
|
||||||
p8[x] = pickColor(data[x] >> default_red_offset,
|
p8[x] = pickColor(inst,
|
||||||
|
data[x] >> default_red_offset,
|
||||||
data[x] >> default_green_offset,
|
data[x] >> default_green_offset,
|
||||||
data[x] >> default_blue_offset)->pixel;
|
data[x] >> default_blue_offset)->pixel;
|
||||||
}
|
}
|
||||||
|
@ -127,12 +128,14 @@ void reduce_depth(pixel32 *data, XImage *im)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XColor *pickColor(int r, int g, int b)
|
XColor *pickColor(const RrInstance *inst, gint r, gint g, gint b)
|
||||||
{
|
{
|
||||||
r = (r & 0xff) >> (8-pseudo_bpc);
|
r = (r & 0xff) >> (8-pseudo_bpc);
|
||||||
g = (g & 0xff) >> (8-pseudo_bpc);
|
g = (g & 0xff) >> (8-pseudo_bpc);
|
||||||
b = (b & 0xff) >> (8-pseudo_bpc);
|
b = (b & 0xff) >> (8-pseudo_bpc);
|
||||||
return &pseudo_colors[(r << (2*pseudo_bpc)) + (g << (1*pseudo_bpc)) + b];
|
return &RrPseudoColors(inst)[(r << (2*pseudo_bpc)) +
|
||||||
|
(g << (1*pseudo_bpc)) +
|
||||||
|
b];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void swap_byte_order(XImage *im)
|
static void swap_byte_order(XImage *im)
|
||||||
|
@ -171,7 +174,7 @@ static void swap_byte_order(XImage *im)
|
||||||
im->byte_order = LSBFirst;
|
im->byte_order = LSBFirst;
|
||||||
}
|
}
|
||||||
|
|
||||||
void increase_depth(pixel32 *data, XImage *im)
|
void increase_depth(const RrInstance *inst, pixel32 *data, XImage *im)
|
||||||
{
|
{
|
||||||
int r, g, b;
|
int r, g, b;
|
||||||
int x,y;
|
int x,y;
|
||||||
|
@ -186,9 +189,9 @@ void increase_depth(pixel32 *data, XImage *im)
|
||||||
case 32:
|
case 32:
|
||||||
for (y = 0; y < im->height; y++) {
|
for (y = 0; y < im->height; y++) {
|
||||||
for (x = 0; x < im->width; x++) {
|
for (x = 0; x < im->width; x++) {
|
||||||
r = (p32[x] >> render_red_offset) & 0xff;
|
r = (p32[x] >> RrRedOffset(inst)) & 0xff;
|
||||||
g = (p32[x] >> render_green_offset) & 0xff;
|
g = (p32[x] >> RrGreenOffset(inst)) & 0xff;
|
||||||
b = (p32[x] >> render_blue_offset) & 0xff;
|
b = (p32[x] >> RrBlueOffset(inst)) & 0xff;
|
||||||
data[x] = (r << default_red_offset)
|
data[x] = (r << default_red_offset)
|
||||||
+ (g << default_green_offset)
|
+ (g << default_green_offset)
|
||||||
+ (b << default_blue_offset)
|
+ (b << default_blue_offset)
|
||||||
|
@ -201,12 +204,15 @@ void increase_depth(pixel32 *data, XImage *im)
|
||||||
case 16:
|
case 16:
|
||||||
for (y = 0; y < im->height; y++) {
|
for (y = 0; y < im->height; y++) {
|
||||||
for (x = 0; x < im->width; x++) {
|
for (x = 0; x < im->width; x++) {
|
||||||
r = (p16[x] & render_red_mask) >> render_red_offset <<
|
r = (p16[x] & RrRedMask(inst)) >>
|
||||||
render_red_shift;
|
RrRedOffset(inst) <<
|
||||||
g = (p16[x] & render_green_mask) >> render_green_offset <<
|
RrRedShift(inst);
|
||||||
render_green_shift;
|
g = (p16[x] & RrGreenMask(inst)) >>
|
||||||
b = (p16[x] & render_blue_mask) >> render_blue_offset <<
|
RrGreenOffset(inst) <<
|
||||||
render_blue_shift;
|
RrGreenShift(inst);
|
||||||
|
b = (p16[x] & RrBlueMask(inst)) >>
|
||||||
|
RrBlueOffset(inst) <<
|
||||||
|
RrBlueShift(inst);
|
||||||
data[x] = (r << default_red_offset)
|
data[x] = (r << default_red_offset)
|
||||||
+ (g << default_green_offset)
|
+ (g << default_green_offset)
|
||||||
+ (b << default_blue_offset)
|
+ (b << default_blue_offset)
|
||||||
|
|
|
@ -1,25 +1,11 @@
|
||||||
#ifndef __color_h
|
#ifndef __color_h
|
||||||
#define __color_h
|
#define __color_h
|
||||||
|
|
||||||
|
#include "render.h"
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
#include <glib.h>
|
||||||
#ifdef HAVE_STDINT_H
|
|
||||||
# include <stdint.h>
|
|
||||||
#else
|
|
||||||
# ifdef HAVE_SYS_TYPES_H
|
|
||||||
# include <sys/types.h>
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_STDINT_H
|
|
||||||
typedef uint32_t pixel32;
|
|
||||||
typedef uint16_t pixel16;
|
|
||||||
#else
|
|
||||||
typedef u_int32_t pixel32;
|
|
||||||
typedef u_int16_t pixel16;
|
|
||||||
#endif /* HAVE_STDINT_H */
|
|
||||||
|
|
||||||
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
||||||
#define default_red_offset 0
|
#define default_red_offset 0
|
||||||
|
@ -35,36 +21,19 @@ typedef u_int16_t pixel16;
|
||||||
#define render_endian LSBFirst
|
#define render_endian LSBFirst
|
||||||
#endif /* G_BYTE_ORDER == G_BIG_ENDIAN */
|
#endif /* G_BYTE_ORDER == G_BIG_ENDIAN */
|
||||||
|
|
||||||
|
struct _RrColor {
|
||||||
|
const RrInstance *inst;
|
||||||
|
|
||||||
typedef struct color_rgb {
|
|
||||||
int r;
|
int r;
|
||||||
int g;
|
int g;
|
||||||
int b;
|
int b;
|
||||||
unsigned long pixel;
|
unsigned long pixel;
|
||||||
GC gc;
|
GC gc;
|
||||||
} color_rgb;
|
};
|
||||||
|
|
||||||
void color_allocate_gc(color_rgb *in);
|
void color_allocate_gc(color_rgb *in);
|
||||||
XColor *pickColor(int r, int g, int b);
|
XColor *pickColor(const RrInstance *inst, gint r, gint g, gint b);
|
||||||
color_rgb *color_parse(char *colorname);
|
void reduce_depth(const RrInstance *inst, pixel32 *data, XImage *im);
|
||||||
color_rgb *color_new(int r, int g, int b);
|
void increase_depth(const RrInstance *inst, pixel32 *data, XImage *im);
|
||||||
void color_free(color_rgb *in);
|
|
||||||
void reduce_depth(pixel32 *data, XImage *im);
|
|
||||||
void increase_depth(pixel32 *data, XImage *im);
|
|
||||||
|
|
||||||
extern int render_red_offset;
|
|
||||||
extern int render_green_offset;
|
|
||||||
extern int render_blue_offset;
|
|
||||||
|
|
||||||
extern int render_red_shift;
|
|
||||||
extern int render_green_shift;
|
|
||||||
extern int render_blue_shift;
|
|
||||||
|
|
||||||
extern int render_red_mask;
|
|
||||||
extern int render_green_mask;
|
|
||||||
extern int render_blue_mask;
|
|
||||||
|
|
||||||
extern int pseudo_bpc;
|
|
||||||
#define pseudo_ncolors() (1 << (pseudo_bpc * 3))
|
|
||||||
extern XColor *pseudo_colors;
|
|
||||||
#endif /* __color_h */
|
#endif /* __color_h */
|
||||||
|
|
|
@ -30,7 +30,7 @@ void font_startup(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void measure_height(ObFont *f)
|
static void measure_height(RrFont *f)
|
||||||
{
|
{
|
||||||
XGlyphInfo info;
|
XGlyphInfo info;
|
||||||
|
|
||||||
|
@ -40,13 +40,13 @@ static void measure_height(ObFont *f)
|
||||||
f->elipses_length = (signed) info.xOff;
|
f->elipses_length = (signed) info.xOff;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObFont *font_open(char *fontstring)
|
RrFont *font_open(char *fontstring)
|
||||||
{
|
{
|
||||||
ObFont *out;
|
RrFont *out;
|
||||||
XftFont *xf;
|
XftFont *xf;
|
||||||
|
|
||||||
if ((xf = XftFontOpenName(ob_display, ob_screen, fontstring))) {
|
if ((xf = XftFontOpenName(ob_display, ob_screen, fontstring))) {
|
||||||
out = g_new(ObFont, 1);
|
out = g_new(RrFont, 1);
|
||||||
out->xftfont = xf;
|
out->xftfont = xf;
|
||||||
measure_height(out);
|
measure_height(out);
|
||||||
return out;
|
return out;
|
||||||
|
@ -55,7 +55,7 @@ ObFont *font_open(char *fontstring)
|
||||||
g_warning(_("Trying fallback font: %s\n"), "sans");
|
g_warning(_("Trying fallback font: %s\n"), "sans");
|
||||||
|
|
||||||
if ((xf = XftFontOpenName(ob_display, ob_screen, "sans"))) {
|
if ((xf = XftFontOpenName(ob_display, ob_screen, "sans"))) {
|
||||||
out = g_new(ObFont, 1);
|
out = g_new(RrFont, 1);
|
||||||
out->xftfont = xf;
|
out->xftfont = xf;
|
||||||
measure_height(out);
|
measure_height(out);
|
||||||
return out;
|
return out;
|
||||||
|
@ -66,7 +66,7 @@ ObFont *font_open(char *fontstring)
|
||||||
exit(3); /* can't continue without a font */
|
exit(3); /* can't continue without a font */
|
||||||
}
|
}
|
||||||
|
|
||||||
void font_close(ObFont *f)
|
void font_close(RrFont *f)
|
||||||
{
|
{
|
||||||
if (f) {
|
if (f) {
|
||||||
XftFontClose(ob_display, f->xftfont);
|
XftFontClose(ob_display, f->xftfont);
|
||||||
|
@ -74,7 +74,7 @@ void font_close(ObFont *f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void font_measure_full(ObFont *f, char *str, int shadow, int offset,
|
void font_measure_full(RrFont *f, char *str, int shadow, int offset,
|
||||||
int *x, int *y)
|
int *x, int *y)
|
||||||
{
|
{
|
||||||
XGlyphInfo info;
|
XGlyphInfo info;
|
||||||
|
@ -86,24 +86,24 @@ void font_measure_full(ObFont *f, char *str, int shadow, int offset,
|
||||||
*y = info.height + (shadow ? ABS(offset) : 0);
|
*y = info.height + (shadow ? ABS(offset) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int font_measure_string(ObFont *f, char *str, int shadow, int offset)
|
int font_measure_string(RrFont *f, char *str, int shadow, int offset)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
font_measure_full (f, str, shadow, offset, &x, &y);
|
font_measure_full (f, str, shadow, offset, &x, &y);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
int font_height(ObFont *f, int shadow, int offset)
|
int font_height(RrFont *f, int shadow, int offset)
|
||||||
{
|
{
|
||||||
return f->xftfont->ascent + f->xftfont->descent + (shadow ? offset : 0);
|
return f->xftfont->ascent + f->xftfont->descent + (shadow ? offset : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int font_max_char_width(ObFont *f)
|
int font_max_char_width(RrFont *f)
|
||||||
{
|
{
|
||||||
return (signed) f->xftfont->max_advance_width;
|
return (signed) f->xftfont->max_advance_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void font_draw(XftDraw *d, TextureText *t, Rect *area)
|
void font_draw(XftDraw *d, RrTextureText *t, Rect *area)
|
||||||
{
|
{
|
||||||
int x,y,w,h;
|
int x,y,w,h;
|
||||||
XftColor c;
|
XftColor c;
|
||||||
|
@ -139,13 +139,13 @@ void font_draw(XftDraw *d, TextureText *t, Rect *area)
|
||||||
if (!l) return;
|
if (!l) return;
|
||||||
|
|
||||||
switch (t->justify) {
|
switch (t->justify) {
|
||||||
case Justify_Left:
|
case RR_JUSTIFY_LEFT:
|
||||||
x = area->x + theme_bevel;
|
x = area->x + theme_bevel;
|
||||||
break;
|
break;
|
||||||
case Justify_Right:
|
case RR_JUSTIFY_RIGHT:
|
||||||
x = area->x + (w - mw) - theme_bevel;
|
x = area->x + (w - mw) - theme_bevel;
|
||||||
break;
|
break;
|
||||||
case Justify_Center:
|
case RR_JUSTIFY_CENTER:
|
||||||
x = area->x + (w - mw) / 2;
|
x = area->x + (w - mw) / 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
#ifndef __font_h
|
#ifndef __font_h
|
||||||
#define __font_h
|
#define __font_h
|
||||||
|
#define _XFT_NO_COMPAT_ /* no Xft 1 API */
|
||||||
#include <X11/Xft/Xft.h>
|
#include <X11/Xft/Xft.h>
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "kernel/geom.h"
|
#include "kernel/geom.h"
|
||||||
|
|
||||||
|
struct _RrFont {
|
||||||
|
XftFont *xftfont;
|
||||||
|
gint elipses_length;
|
||||||
|
};
|
||||||
|
|
||||||
void font_startup(void);
|
void font_startup(void);
|
||||||
ObFont *font_open(char *fontstring);
|
RrFont *font_open(char *fontstring);
|
||||||
void font_close(ObFont *f);
|
void font_close(RrFont *f);
|
||||||
int font_measure_string(ObFont *f, char *str, int shadow, int offset);
|
int font_measure_string(RrFont *f, char *str, int shadow, int offset);
|
||||||
int font_height(ObFont *f, int shadow, int offset);
|
int font_height(RrFont *f, int shadow, int offset);
|
||||||
int font_max_char_width(ObFont *f);
|
int font_max_char_width(RrFont *f);
|
||||||
void font_draw(XftDraw *d, TextureText *t, Rect *position);
|
void font_draw(XftDraw *d, RrTextureText *t, Rect *position);
|
||||||
#endif /* __font_h */
|
#endif /* __font_h */
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
#include <glib.h>
|
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "gradient.h"
|
#include "gradient.h"
|
||||||
#include "../kernel/openbox.h"
|
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
void gradient_render(Surface *sf, int w, int h)
|
void gradient_render(RrSurface *sf, int w, int h)
|
||||||
{
|
{
|
||||||
pixel32 *data = sf->pixel_data;
|
pixel32 *data = sf->pixel_data;
|
||||||
pixel32 current;
|
pixel32 current;
|
||||||
|
@ -12,27 +11,27 @@ void gradient_render(Surface *sf, int w, int h)
|
||||||
int off, x;
|
int off, x;
|
||||||
|
|
||||||
switch (sf->grad) {
|
switch (sf->grad) {
|
||||||
case Background_Solid: /* already handled */
|
case RR_SURFACE_SOLID: /* already handled */
|
||||||
return;
|
return;
|
||||||
case Background_Vertical:
|
case RR_SURFACE_VERTICAL:
|
||||||
gradient_vertical(sf, w, h);
|
gradient_vertical(sf, w, h);
|
||||||
break;
|
break;
|
||||||
case Background_Horizontal:
|
case RR_SURFACE_HORIZONTAL:
|
||||||
gradient_horizontal(sf, w, h);
|
gradient_horizontal(sf, w, h);
|
||||||
break;
|
break;
|
||||||
case Background_Diagonal:
|
case RR_SURFACE_DIAGONAL:
|
||||||
gradient_diagonal(sf, w, h);
|
gradient_diagonal(sf, w, h);
|
||||||
break;
|
break;
|
||||||
case Background_CrossDiagonal:
|
case RR_SURFACE_CROSS_DIAGONAL:
|
||||||
gradient_crossdiagonal(sf, w, h);
|
gradient_crossdiagonal(sf, w, h);
|
||||||
break;
|
break;
|
||||||
case Background_Pyramid:
|
case RR_SURFACE_PYRAMID:
|
||||||
gradient_pyramid(sf, w, h);
|
gradient_pyramid(sf, w, h);
|
||||||
break;
|
break;
|
||||||
case Background_PipeCross:
|
case RR_SURFACE_PIPECROSS:
|
||||||
gradient_pipecross(sf, w, h);
|
gradient_pipecross(sf, w, h);
|
||||||
break;
|
break;
|
||||||
case Background_Rectangle:
|
case RR_SURFACE_RECTANGLE:
|
||||||
gradient_rectangle(sf, w, h);
|
gradient_rectangle(sf, w, h);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -40,7 +39,7 @@ void gradient_render(Surface *sf, int w, int h)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sf->relief == Flat && sf->border) {
|
if (sf->relief == RR_RELIEF_FLAT && sf->border) {
|
||||||
r = sf->border_color->r;
|
r = sf->border_color->r;
|
||||||
g = sf->border_color->g;
|
g = sf->border_color->g;
|
||||||
b = sf->border_color->b;
|
b = sf->border_color->b;
|
||||||
|
@ -57,34 +56,34 @@ void gradient_render(Surface *sf, int w, int h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sf->relief != Flat) {
|
if (sf->relief != RR_RELIEF_FLAT) {
|
||||||
if (sf->bevel == Bevel1) {
|
if (sf->bevel == RR_BEVEL_1) {
|
||||||
for (off = 1, x = 1; x < w - 1; ++x, off++)
|
for (off = 1, x = 1; x < w - 1; ++x, off++)
|
||||||
highlight(data + off,
|
highlight(data + off,
|
||||||
data + off + (h-1) * w,
|
data + off + (h-1) * w,
|
||||||
sf->relief==Raised);
|
sf->relief==RR_RELIEF_RAISED);
|
||||||
for (off = 0, x = 0; x < h; ++x, off++)
|
for (off = 0, x = 0; x < h; ++x, off++)
|
||||||
highlight(data + off * w,
|
highlight(data + off * w,
|
||||||
data + off * w + w - 1,
|
data + off * w + w - 1,
|
||||||
sf->relief==Raised);
|
sf->relief==RR_RELIEF_RAISED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sf->bevel == Bevel2) {
|
if (sf->bevel == RR_BEVEL_2) {
|
||||||
for (off = 2, x = 2; x < w - 2; ++x, off++)
|
for (off = 2, x = 2; x < w - 2; ++x, off++)
|
||||||
highlight(data + off + w,
|
highlight(data + off + w,
|
||||||
data + off + (h-2) * w,
|
data + off + (h-2) * w,
|
||||||
sf->relief==Raised);
|
sf->relief==RR_RELIEF_RAISED);
|
||||||
for (off = 1, x = 1; x < h-1; ++x, off++)
|
for (off = 1, x = 1; x < h-1; ++x, off++)
|
||||||
highlight(data + off * w + 1,
|
highlight(data + off * w + 1,
|
||||||
data + off * w + w - 2,
|
data + off * w + w - 2,
|
||||||
sf->relief==Raised);
|
sf->relief==RR_RELIEF_RAISED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void gradient_vertical(Surface *sf, int w, int h)
|
void gradient_vertical(RrSurface *sf, int w, int h)
|
||||||
{
|
{
|
||||||
pixel32 *data = sf->pixel_data;
|
pixel32 *data = sf->pixel_data;
|
||||||
pixel32 current;
|
pixel32 current;
|
||||||
|
@ -113,7 +112,7 @@ void gradient_vertical(Surface *sf, int w, int h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gradient_horizontal(Surface *sf, int w, int h)
|
void gradient_horizontal(RrSurface *sf, int w, int h)
|
||||||
{
|
{
|
||||||
pixel32 *data = sf->pixel_data;
|
pixel32 *data = sf->pixel_data;
|
||||||
pixel32 current;
|
pixel32 current;
|
||||||
|
@ -142,7 +141,7 @@ void gradient_horizontal(Surface *sf, int w, int h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gradient_diagonal(Surface *sf, int w, int h)
|
void gradient_diagonal(RrSurface *sf, int w, int h)
|
||||||
{
|
{
|
||||||
pixel32 *data = sf->pixel_data;
|
pixel32 *data = sf->pixel_data;
|
||||||
pixel32 current;
|
pixel32 current;
|
||||||
|
@ -180,7 +179,7 @@ void gradient_diagonal(Surface *sf, int w, int h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gradient_crossdiagonal(Surface *sf, int w, int h)
|
void gradient_crossdiagonal(RrSurface *sf, int w, int h)
|
||||||
{
|
{
|
||||||
pixel32 *data = sf->pixel_data;
|
pixel32 *data = sf->pixel_data;
|
||||||
pixel32 current;
|
pixel32 current;
|
||||||
|
@ -252,7 +251,7 @@ void highlight(pixel32 *x, pixel32 *y, gboolean raised)
|
||||||
+ (b << default_blue_offset);
|
+ (b << default_blue_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_bevel_colors(Appearance *l)
|
static void create_bevel_colors(RrAppearance *l)
|
||||||
{
|
{
|
||||||
int r, g, b;
|
int r, g, b;
|
||||||
|
|
||||||
|
@ -267,7 +266,7 @@ static void create_bevel_colors(Appearance *l)
|
||||||
if (g > 0xFF) g = 0xFF;
|
if (g > 0xFF) g = 0xFF;
|
||||||
if (b > 0xFF) b = 0xFF;
|
if (b > 0xFF) b = 0xFF;
|
||||||
g_assert(!l->surface.bevel_light);
|
g_assert(!l->surface.bevel_light);
|
||||||
l->surface.bevel_light = color_new(r, g, b);
|
l->surface.bevel_light = RrColorNew(l->inst, r, g, b);
|
||||||
color_allocate_gc(l->surface.bevel_light);
|
color_allocate_gc(l->surface.bevel_light);
|
||||||
|
|
||||||
/* dark color */
|
/* dark color */
|
||||||
|
@ -278,15 +277,15 @@ static void create_bevel_colors(Appearance *l)
|
||||||
b = l->surface.primary->b;
|
b = l->surface.primary->b;
|
||||||
b = (b >> 1) + (b >> 2);
|
b = (b >> 1) + (b >> 2);
|
||||||
g_assert(!l->surface.bevel_dark);
|
g_assert(!l->surface.bevel_dark);
|
||||||
l->surface.bevel_dark = color_new(r, g, b);
|
l->surface.bevel_dark = RrColorNew(l->inst, r, g, b);
|
||||||
color_allocate_gc(l->surface.bevel_dark);
|
color_allocate_gc(l->surface.bevel_dark);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gradient_solid(Appearance *l, int x, int y, int w, int h)
|
void gradient_solid(RrAppearance *l, int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
pixel32 pix;
|
pixel32 pix;
|
||||||
int i, a, b;
|
int i, a, b;
|
||||||
Surface *sp = &l->surface;
|
RrSurface *sp = &l->surface;
|
||||||
int left = x, top = y, right = x + w - 1, bottom = y + h - 1;
|
int left = x, top = y, right = x + w - 1, bottom = y + h - 1;
|
||||||
|
|
||||||
if (sp->primary->gc == None)
|
if (sp->primary->gc == None)
|
||||||
|
@ -299,46 +298,46 @@ void gradient_solid(Appearance *l, int x, int y, int w, int h)
|
||||||
for (b = 0; b < h; b++)
|
for (b = 0; b < h; b++)
|
||||||
sp->pixel_data[a + b * w] = pix;
|
sp->pixel_data[a + b * w] = pix;
|
||||||
|
|
||||||
XFillRectangle(ob_display, l->pixmap, sp->primary->gc,
|
XFillRectangle(RrDisplay(l->inst), l->pixmap, sp->primary->gc,
|
||||||
x, y, w, h);
|
x, y, w, h);
|
||||||
|
|
||||||
if (sp->interlaced) {
|
if (sp->interlaced) {
|
||||||
if (sp->secondary->gc == None)
|
if (sp->secondary->gc == None)
|
||||||
color_allocate_gc(sp->secondary);
|
color_allocate_gc(sp->secondary);
|
||||||
for (i = y; i < h; i += 2)
|
for (i = y; i < h; i += 2)
|
||||||
XDrawLine(ob_display, l->pixmap, sp->secondary->gc,
|
XDrawLine(RrDisplay(l->inst), l->pixmap, sp->secondary->gc,
|
||||||
x, i, w, i);
|
x, i, w, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (sp->relief) {
|
switch (sp->relief) {
|
||||||
case Raised:
|
case RR_RELIEF_RAISED:
|
||||||
if (!sp->bevel_dark)
|
if (!sp->bevel_dark)
|
||||||
create_bevel_colors(l);
|
create_bevel_colors(l);
|
||||||
|
|
||||||
switch (sp->bevel) {
|
switch (sp->bevel) {
|
||||||
case Bevel1:
|
case RR_BEVEL_1:
|
||||||
XDrawLine(ob_display, l->pixmap, sp->bevel_dark->gc,
|
XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_dark->gc,
|
||||||
left, bottom, right, bottom);
|
left, bottom, right, bottom);
|
||||||
XDrawLine(ob_display, l->pixmap, sp->bevel_dark->gc,
|
XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_dark->gc,
|
||||||
right, bottom, right, top);
|
right, bottom, right, top);
|
||||||
|
|
||||||
XDrawLine(ob_display, l->pixmap, sp->bevel_light->gc,
|
XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_light->gc,
|
||||||
left, top, right, top);
|
left, top, right, top);
|
||||||
XDrawLine(ob_display, l->pixmap, sp->bevel_light->gc,
|
XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_light->gc,
|
||||||
left, bottom, left, top);
|
left, bottom, left, top);
|
||||||
break;
|
break;
|
||||||
case Bevel2:
|
case RR_BEVEL_2:
|
||||||
XDrawLine(ob_display, l->pixmap,
|
XDrawLine(RrDisplay(l->inst), l->pixmap,
|
||||||
sp->bevel_dark->gc,
|
sp->bevel_dark->gc,
|
||||||
left + 1, bottom - 2, right - 2, bottom - 2);
|
left + 1, bottom - 2, right - 2, bottom - 2);
|
||||||
XDrawLine(ob_display, l->pixmap,
|
XDrawLine(RrDisplay(l->inst), l->pixmap,
|
||||||
sp->bevel_dark->gc,
|
sp->bevel_dark->gc,
|
||||||
right - 2, bottom - 2, right - 2, top + 1);
|
right - 2, bottom - 2, right - 2, top + 1);
|
||||||
|
|
||||||
XDrawLine(ob_display, l->pixmap,
|
XDrawLine(RrDisplay(l->inst), l->pixmap,
|
||||||
sp->bevel_light->gc,
|
sp->bevel_light->gc,
|
||||||
left + 1, top + 1, right - 2, top + 1);
|
left + 1, top + 1, right - 2, top + 1);
|
||||||
XDrawLine(ob_display, l->pixmap,
|
XDrawLine(RrDisplay(l->inst), l->pixmap,
|
||||||
sp->bevel_light->gc,
|
sp->bevel_light->gc,
|
||||||
left + 1, bottom - 2, left + 1, top + 1);
|
left + 1, bottom - 2, left + 1, top + 1);
|
||||||
break;
|
break;
|
||||||
|
@ -346,31 +345,31 @@ void gradient_solid(Appearance *l, int x, int y, int w, int h)
|
||||||
g_assert_not_reached(); /* unhandled BevelType */
|
g_assert_not_reached(); /* unhandled BevelType */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Sunken:
|
case RR_RELIEF_SUNKEN:
|
||||||
if (!sp->bevel_dark)
|
if (!sp->bevel_dark)
|
||||||
create_bevel_colors(l);
|
create_bevel_colors(l);
|
||||||
|
|
||||||
switch (sp->bevel) {
|
switch (sp->bevel) {
|
||||||
case Bevel1:
|
case RR_BEVEL_1:
|
||||||
XDrawLine(ob_display, l->pixmap, sp->bevel_light->gc,
|
XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_light->gc,
|
||||||
left, bottom, right, bottom);
|
left, bottom, right, bottom);
|
||||||
XDrawLine(ob_display, l->pixmap, sp->bevel_light->gc,
|
XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_light->gc,
|
||||||
right, bottom, right, top);
|
right, bottom, right, top);
|
||||||
|
|
||||||
XDrawLine(ob_display, l->pixmap, sp->bevel_dark->gc,
|
XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_dark->gc,
|
||||||
left, top, right, top);
|
left, top, right, top);
|
||||||
XDrawLine(ob_display, l->pixmap, sp->bevel_dark->gc,
|
XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_dark->gc,
|
||||||
left, bottom, left, top);
|
left, bottom, left, top);
|
||||||
break;
|
break;
|
||||||
case Bevel2:
|
case RR_BEVEL_2:
|
||||||
XDrawLine(ob_display, l->pixmap, sp->bevel_light->gc,
|
XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_light->gc,
|
||||||
left + 1, bottom - 2, right - 2, bottom - 2);
|
left + 1, bottom - 2, right - 2, bottom - 2);
|
||||||
XDrawLine(ob_display, l->pixmap, sp->bevel_light->gc,
|
XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_light->gc,
|
||||||
right - 2, bottom - 2, right - 2, top + 1);
|
right - 2, bottom - 2, right - 2, top + 1);
|
||||||
|
|
||||||
XDrawLine(ob_display, l->pixmap, sp->bevel_dark->gc,
|
XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_dark->gc,
|
||||||
left + 1, top + 1, right - 2, top + 1);
|
left + 1, top + 1, right - 2, top + 1);
|
||||||
XDrawLine(ob_display, l->pixmap, sp->bevel_dark->gc,
|
XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_dark->gc,
|
||||||
left + 1, bottom - 2, left + 1, top + 1);
|
left + 1, bottom - 2, left + 1, top + 1);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -378,11 +377,11 @@ void gradient_solid(Appearance *l, int x, int y, int w, int h)
|
||||||
g_assert_not_reached(); /* unhandled BevelType */
|
g_assert_not_reached(); /* unhandled BevelType */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Flat:
|
case RR_RELIEF_FLAT:
|
||||||
if (sp->border) {
|
if (sp->border) {
|
||||||
if (sp->border_color->gc == None)
|
if (sp->border_color->gc == None)
|
||||||
color_allocate_gc(sp->border_color);
|
color_allocate_gc(sp->border_color);
|
||||||
XDrawRectangle(ob_display, l->pixmap, sp->border_color->gc,
|
XDrawRectangle(RrDisplay(l->inst), l->pixmap, sp->border_color->gc,
|
||||||
left, top, right, bottom);
|
left, top, right, bottom);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -391,7 +390,7 @@ void gradient_solid(Appearance *l, int x, int y, int w, int h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gradient_pyramid(Surface *sf, int inw, int inh)
|
void gradient_pyramid(RrSurface *sf, int inw, int inh)
|
||||||
{
|
{
|
||||||
pixel32 *data = sf->pixel_data;
|
pixel32 *data = sf->pixel_data;
|
||||||
pixel32 *end = data + inw*inh - 1;
|
pixel32 *end = data + inw*inh - 1;
|
||||||
|
@ -436,7 +435,7 @@ void gradient_pyramid(Surface *sf, int inw, int inh)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gradient_rectangle(Surface *sf, int inw, int inh)
|
void gradient_rectangle(RrSurface *sf, int inw, int inh)
|
||||||
{
|
{
|
||||||
pixel32 *data = sf->pixel_data;
|
pixel32 *data = sf->pixel_data;
|
||||||
pixel32 *end = data + inw*inh - 1;
|
pixel32 *end = data + inw*inh - 1;
|
||||||
|
@ -484,7 +483,7 @@ void gradient_rectangle(Surface *sf, int inw, int inh)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gradient_pipecross(Surface *sf, int inw, int inh)
|
void gradient_pipecross(RrSurface *sf, int inw, int inh)
|
||||||
{
|
{
|
||||||
pixel32 *data = sf->pixel_data;
|
pixel32 *data = sf->pixel_data;
|
||||||
pixel32 *end = data + inw*inh - 1;
|
pixel32 *end = data + inw*inh - 1;
|
||||||
|
|
|
@ -3,17 +3,17 @@
|
||||||
|
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
void gradient_render(Surface *sf, int w, int h);
|
void gradient_render(RrSurface *sf, int w, int h);
|
||||||
void gradient_vertical(Surface *sf, int w, int h);
|
void gradient_vertical(RrSurface *sf, int w, int h);
|
||||||
void gradient_horizontal(Surface *sf, int w, int h);
|
void gradient_horizontal(RrSurface *sf, int w, int h);
|
||||||
void gradient_diagonal(Surface *sf, int w, int h);
|
void gradient_diagonal(RrSurface *sf, int w, int h);
|
||||||
void gradient_crossdiagonal(Surface *sf, int w, int h);
|
void gradient_crossdiagonal(RrSurface *sf, int w, int h);
|
||||||
void gradient_pyramid(Surface *sf, int w, int h);
|
void gradient_pyramid(RrSurface *sf, int w, int h);
|
||||||
void gradient_pipecross(Surface *sf, int w, int h);
|
void gradient_pipecross(RrSurface *sf, int w, int h);
|
||||||
void gradient_rectangle(Surface *sf, int w, int h);
|
void gradient_rectangle(RrSurface *sf, int w, int h);
|
||||||
void gradient_solid(Appearance *l, int x, int y, int w, int h);
|
void gradient_solid(RrAppearance *l, int x, int y, int w, int h);
|
||||||
void highlight(pixel32 *x, pixel32 *y, gboolean raised);
|
void highlight(pixel32 *x, pixel32 *y, gboolean raised);
|
||||||
|
|
||||||
void render_gl_gradient(Surface *sf, int x, int y, int w, int h);
|
void render_gl_gradient(RrSurface *sf, int x, int y, int w, int h);
|
||||||
|
|
||||||
#endif /* __gradient_h */
|
#endif /* __gradient_h */
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
#include <glib.h>
|
|
||||||
#include "../kernel/geom.h"
|
#include "../kernel/geom.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
#include "color.h"
|
||||||
|
|
||||||
void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *area)
|
#include <glib.h>
|
||||||
|
|
||||||
|
void image_draw(pixel32 *target, RrTextureRGBA *rgba, Rect *area)
|
||||||
{
|
{
|
||||||
pixel32 *draw = rgba->data;
|
pixel32 *draw = rgba->data;
|
||||||
guint c, i, e, t, sfw, sfh;
|
gint c, i, e, t, sfw, sfh;
|
||||||
sfw = area->width;
|
sfw = area->width;
|
||||||
sfh = area->height;
|
sfh = area->height;
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,6 @@
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "../kernel/geom.h"
|
#include "../kernel/geom.h"
|
||||||
|
|
||||||
void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *area);
|
void image_draw(pixel32 *target, RrTextureRGBA *rgba, Rect *area);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
247
render/instance.c
Normal file
247
render/instance.c
Normal file
|
@ -0,0 +1,247 @@
|
||||||
|
#include "render.h"
|
||||||
|
#include "instance.h"
|
||||||
|
|
||||||
|
static RrInstance *definst = NULL;
|
||||||
|
|
||||||
|
void RrTrueColorSetup (RrInstance *inst);
|
||||||
|
void RrPseudoColorSetup (RrInstance *inst);
|
||||||
|
|
||||||
|
RrInstance* RrInstanceNew (Display *display, gint screen)
|
||||||
|
{
|
||||||
|
definst = g_new (RrInstance, 1);
|
||||||
|
definst->display = display;
|
||||||
|
definst->screen = screen;
|
||||||
|
|
||||||
|
definst->depth = DefaultDepth(display, screen);
|
||||||
|
definst->visual = DefaultVisual(display, screen);
|
||||||
|
definst->colormap = DefaultColormap(display, screen);
|
||||||
|
|
||||||
|
definst->pseudo_colors = NULL;
|
||||||
|
|
||||||
|
switch (definst->visual->class) {
|
||||||
|
case TrueColor:
|
||||||
|
RrTrueColorSetup(definst);
|
||||||
|
break;
|
||||||
|
case PseudoColor:
|
||||||
|
case StaticColor:
|
||||||
|
case GrayScale:
|
||||||
|
case StaticGray:
|
||||||
|
RrPseudoColorSetup(definst);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_critical("Unsupported visual class");
|
||||||
|
g_free (definst);
|
||||||
|
return definst = NULL;
|
||||||
|
}
|
||||||
|
return definst;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RrTrueColorSetup (RrInstance *inst)
|
||||||
|
{
|
||||||
|
unsigned long red_mask, green_mask, blue_mask;
|
||||||
|
XImage *timage = NULL;
|
||||||
|
|
||||||
|
timage = XCreateImage(inst->display, inst->visual, inst->depth,
|
||||||
|
ZPixmap, 0, NULL, 1, 1, 32, 0);
|
||||||
|
g_assert(timage != NULL);
|
||||||
|
/* find the offsets for each color in the visual's masks */
|
||||||
|
inst->red_mask = red_mask = timage->red_mask;
|
||||||
|
inst->green_mask = green_mask = timage->green_mask;
|
||||||
|
inst->blue_mask = blue_mask = timage->blue_mask;
|
||||||
|
|
||||||
|
inst->red_offset = 0;
|
||||||
|
inst->green_offset = 0;
|
||||||
|
inst->blue_offset = 0;
|
||||||
|
|
||||||
|
while (! (red_mask & 1)) { inst->red_offset++; red_mask >>= 1; }
|
||||||
|
while (! (green_mask & 1)) { inst->green_offset++; green_mask >>= 1; }
|
||||||
|
while (! (blue_mask & 1)) { inst->blue_offset++; blue_mask >>= 1; }
|
||||||
|
|
||||||
|
inst->red_shift = inst->green_shift = inst->blue_shift = 8;
|
||||||
|
while (red_mask) { red_mask >>= 1; inst->red_shift--; }
|
||||||
|
while (green_mask) { green_mask >>= 1; inst->green_shift--; }
|
||||||
|
while (blue_mask) { blue_mask >>= 1; inst->blue_shift--; }
|
||||||
|
XFree(timage);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define RrPseudoNcolors(isnt) (1 << (inst->pseudo_bpc * 3))
|
||||||
|
|
||||||
|
void RrPseudoColorSetup (RrInstance *inst)
|
||||||
|
{
|
||||||
|
XColor icolors[256];
|
||||||
|
int tr, tg, tb, n, r, g, b, i, incolors, ii;
|
||||||
|
unsigned long dev;
|
||||||
|
int cpc, _ncolors;
|
||||||
|
g_message("Initializing PseudoColor RenderControl\n");
|
||||||
|
|
||||||
|
/* determine the number of colors and the bits-per-color */
|
||||||
|
inst->pseudo_bpc = 2; /* XXX THIS SHOULD BE A USER OPTION */
|
||||||
|
g_assert(inst->pseudo_bpc >= 1);
|
||||||
|
_ncolors = RrPseudoNcolors(inst);
|
||||||
|
|
||||||
|
if (_ncolors > 1 << inst->depth) {
|
||||||
|
g_warning("PseudoRenderControl: Invalid colormap size. Resizing.\n");
|
||||||
|
inst->pseudo_bpc = 1 << (inst->depth/3) >> 3;
|
||||||
|
_ncolors = 1 << (inst->pseudo_bpc * 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* build a color cube */
|
||||||
|
inst->pseudo_colors = g_new(XColor, _ncolors);
|
||||||
|
cpc = 1 << inst->pseudo_bpc; /* colors per channel */
|
||||||
|
|
||||||
|
for (n = 0, r = 0; r < cpc; r++)
|
||||||
|
for (g = 0; g < cpc; g++)
|
||||||
|
for (b = 0; b < cpc; b++, n++) {
|
||||||
|
tr = (int)(((float)(r)/(float)(cpc-1)) * 0xFF);
|
||||||
|
tg = (int)(((float)(g)/(float)(cpc-1)) * 0xFF);
|
||||||
|
tb = (int)(((float)(b)/(float)(cpc-1)) * 0xFF);
|
||||||
|
inst->pseudo_colors[n].red = tr | tr << 8;
|
||||||
|
inst->pseudo_colors[n].green = tg | tg << 8;
|
||||||
|
inst->pseudo_colors[n].blue = tb | tb << 8;
|
||||||
|
/* used to track allocation */
|
||||||
|
inst->pseudo_colors[n].flags = DoRed|DoGreen|DoBlue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* allocate the colors */
|
||||||
|
for (i = 0; i < _ncolors; i++)
|
||||||
|
if (!XAllocColor(inst->display, inst->colormap,
|
||||||
|
&inst->pseudo_colors[i]))
|
||||||
|
inst->pseudo_colors[i].flags = 0; /* mark it as unallocated */
|
||||||
|
|
||||||
|
/* try allocate any colors that failed allocation above */
|
||||||
|
|
||||||
|
/* get the allocated values from the X server
|
||||||
|
(only the first 256 XXX why!?)
|
||||||
|
*/
|
||||||
|
incolors = (((1 << inst->depth) > 256) ? 256 : (1 << inst->depth));
|
||||||
|
for (i = 0; i < incolors; i++)
|
||||||
|
icolors[i].pixel = i;
|
||||||
|
XQueryColors(inst->display, inst->colormap, icolors, incolors);
|
||||||
|
|
||||||
|
/* try match unallocated ones */
|
||||||
|
for (i = 0; i < _ncolors; i++) {
|
||||||
|
if (!inst->pseudo_colors[i].flags) { /* if it wasn't allocated... */
|
||||||
|
unsigned long closest = 0xffffffff, close = 0;
|
||||||
|
for (ii = 0; ii < incolors; ii++) {
|
||||||
|
/* find deviations */
|
||||||
|
r = (inst->pseudo_colors[i].red - icolors[ii].red) & 0xff;
|
||||||
|
g = (inst->pseudo_colors[i].green - icolors[ii].green) & 0xff;
|
||||||
|
b = (inst->pseudo_colors[i].blue - icolors[ii].blue) & 0xff;
|
||||||
|
/* find a weighted absolute deviation */
|
||||||
|
dev = (r * r) + (g * g) + (b * b);
|
||||||
|
|
||||||
|
if (dev < closest) {
|
||||||
|
closest = dev;
|
||||||
|
close = ii;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inst->pseudo_colors[i].red = icolors[close].red;
|
||||||
|
inst->pseudo_colors[i].green = icolors[close].green;
|
||||||
|
inst->pseudo_colors[i].blue = icolors[close].blue;
|
||||||
|
inst->pseudo_colors[i].pixel = icolors[close].pixel;
|
||||||
|
|
||||||
|
/* try alloc this closest color, it had better succeed! */
|
||||||
|
if (XAllocColor(inst->display, inst->colormap,
|
||||||
|
&inst->pseudo_colors[i]))
|
||||||
|
/* mark as alloced */
|
||||||
|
inst->pseudo_colors[i].flags = DoRed|DoGreen|DoBlue;
|
||||||
|
else
|
||||||
|
/* wtf has gone wrong, its already alloced for chissake! */
|
||||||
|
g_assert_not_reached();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RrInstanceFree (RrInstance *inst)
|
||||||
|
{
|
||||||
|
if (inst) {
|
||||||
|
if (inst == definst) definst = NULL;
|
||||||
|
g_free(inst->pseudo_colors);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Display* RrDisplay (const RrInstance *inst)
|
||||||
|
{
|
||||||
|
return (inst ? inst : definst)->display;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint RrScreen (const RrInstance *inst)
|
||||||
|
{
|
||||||
|
return (inst ? inst : definst)->screen;
|
||||||
|
}
|
||||||
|
|
||||||
|
Window RrRootWindow (const RrInstance *inst)
|
||||||
|
{
|
||||||
|
return RootWindow (RrDisplay (inst), RrScreen (inst));
|
||||||
|
}
|
||||||
|
|
||||||
|
Visual *RrVisual (const RrInstance *inst)
|
||||||
|
{
|
||||||
|
return (inst ? inst : definst)->visual;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint RrDepth (const RrInstance *inst)
|
||||||
|
{
|
||||||
|
return (inst ? inst : definst)->depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
Colormap RrColormap (const RrInstance *inst)
|
||||||
|
{
|
||||||
|
return (inst ? inst : definst)->colormap;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint RrRedOffset (const RrInstance *inst)
|
||||||
|
{
|
||||||
|
return (inst ? inst : definst)->red_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint RrGreenOffset (const RrInstance *inst)
|
||||||
|
{
|
||||||
|
return (inst ? inst : definst)->green_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint RrBlueOffset (const RrInstance *inst)
|
||||||
|
{
|
||||||
|
return (inst ? inst : definst)->blue_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint RrRedShift (const RrInstance *inst)
|
||||||
|
{
|
||||||
|
return (inst ? inst : definst)->red_shift;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint RrGreenShift (const RrInstance *inst)
|
||||||
|
{
|
||||||
|
return (inst ? inst : definst)->green_shift;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint RrBlueShift (const RrInstance *inst)
|
||||||
|
{
|
||||||
|
return (inst ? inst : definst)->blue_shift;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint RrRedMask (const RrInstance *inst)
|
||||||
|
{
|
||||||
|
return (inst ? inst : definst)->red_mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint RrGreenMask (const RrInstance *inst)
|
||||||
|
{
|
||||||
|
return (inst ? inst : definst)->green_mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint RrBlueMask (const RrInstance *inst)
|
||||||
|
{
|
||||||
|
return (inst ? inst : definst)->blue_mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
guint RrPseudoBPC (const RrInstance *inst)
|
||||||
|
{
|
||||||
|
return (inst ? inst : definst)->pseudo_bpc;
|
||||||
|
}
|
||||||
|
|
||||||
|
XColor *RrPseudoColors (const RrInstance *inst)
|
||||||
|
{
|
||||||
|
return (inst ? inst : definst)->pseudo_colors;
|
||||||
|
}
|
31
render/instance.h
Normal file
31
render/instance.h
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#ifndef __render_instance_h
|
||||||
|
#define __render_instance_h
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
struct _RrInstance {
|
||||||
|
Display *display;
|
||||||
|
gint screen;
|
||||||
|
|
||||||
|
Visual *visual;
|
||||||
|
gint depth;
|
||||||
|
Colormap colormap;
|
||||||
|
|
||||||
|
gint red_offset;
|
||||||
|
gint green_offset;
|
||||||
|
gint blue_offset;
|
||||||
|
|
||||||
|
gint red_shift;
|
||||||
|
gint green_shift;
|
||||||
|
gint blue_shift;
|
||||||
|
|
||||||
|
gint red_mask;
|
||||||
|
gint green_mask;
|
||||||
|
gint blue_mask;
|
||||||
|
|
||||||
|
gint pseudo_bpc;
|
||||||
|
XColor *pseudo_colors;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,57 +1,63 @@
|
||||||
|
#include "render.h"
|
||||||
|
#include "color.h"
|
||||||
#include "mask.h"
|
#include "mask.h"
|
||||||
#include "../kernel/openbox.h"
|
|
||||||
|
|
||||||
pixmap_mask *pixmap_mask_new(int w, int h, char *data)
|
RrPixmapMask *RrPixmapMaskNew(const RrInstance *inst,
|
||||||
|
gint w, gint h, const gchar *data)
|
||||||
{
|
{
|
||||||
pixmap_mask *m = g_new(pixmap_mask, 1);
|
RrPixmapMask *m = g_new(RrPixmapMask, 1);
|
||||||
m->w = w;
|
m->inst = inst;
|
||||||
m->h = h;
|
m->width = w;
|
||||||
|
m->height = h;
|
||||||
/* round up to nearest byte */
|
/* round up to nearest byte */
|
||||||
m->data = g_memdup(data, (w * h + 7) / 8);
|
m->data = g_memdup(data, (w * h + 7) / 8);
|
||||||
m->mask = XCreateBitmapFromData(ob_display, ob_root, data, w, h);
|
m->mask = XCreateBitmapFromData(RrDisplay(inst), RrRootWindow(inst),
|
||||||
|
data, w, h);
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pixmap_mask_free(pixmap_mask *m)
|
void RrPixmapMaskFree(RrPixmapMask *m)
|
||||||
{
|
{
|
||||||
if (m) {
|
if (m) {
|
||||||
XFreePixmap(ob_display, m->mask);
|
XFreePixmap(RrDisplay(m->inst), m->mask);
|
||||||
g_free(m->data);
|
g_free(m->data);
|
||||||
g_free(m);
|
g_free(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mask_draw(Pixmap p, TextureMask *m, Rect *position)
|
void RrPixmapMaskDraw(Pixmap p, const RrTextureMask *m, const Rect *area)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
if (m->mask == None) return; /* no mask given */
|
if (m->mask == None) return; /* no mask given */
|
||||||
|
|
||||||
/* set the clip region */
|
/* set the clip region */
|
||||||
x = position->x + (position->width - m->mask->w) / 2;
|
x = area->x + (area->width - m->mask->width) / 2;
|
||||||
y = position->y + (position->height - m->mask->h) / 2;
|
y = area->y + (area->height - m->mask->height) / 2;
|
||||||
|
|
||||||
if (x < 0) x = 0;
|
if (x < 0) x = 0;
|
||||||
if (y < 0) y = 0;
|
if (y < 0) y = 0;
|
||||||
|
|
||||||
XSetClipMask(ob_display, m->color->gc, m->mask->mask);
|
XSetClipMask(RrDisplay(m->mask->inst), m->color->gc, m->mask->mask);
|
||||||
XSetClipOrigin(ob_display, m->color->gc, x, y);
|
XSetClipOrigin(RrDisplay(m->mask->inst), m->color->gc, x, y);
|
||||||
|
|
||||||
/* fill in the clipped region */
|
/* fill in the clipped region */
|
||||||
XFillRectangle(ob_display, p, m->color->gc, x, y,
|
XFillRectangle(RrDisplay(m->mask->inst), p, m->color->gc, x, y,
|
||||||
x + m->mask->w, y + m->mask->h);
|
x + m->mask->width, y + m->mask->height);
|
||||||
|
|
||||||
/* unset the clip region */
|
/* unset the clip region */
|
||||||
XSetClipMask(ob_display, m->color->gc, None);
|
XSetClipMask(RrDisplay(m->mask->inst), m->color->gc, None);
|
||||||
XSetClipOrigin(ob_display, m->color->gc, 0, 0);
|
XSetClipOrigin(RrDisplay(m->mask->inst), m->color->gc, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pixmap_mask *pixmap_mask_copy(pixmap_mask *src)
|
RrPixmapMask *RrPixmapMaskCopy(const RrPixmapMask *src)
|
||||||
{
|
{
|
||||||
pixmap_mask *m = g_new(pixmap_mask, 1);
|
RrPixmapMask *m = g_new(RrPixmapMask, 1);
|
||||||
m->w = src->w;
|
m->inst = src->inst;
|
||||||
m->h = src->h;
|
m->width = src->width;
|
||||||
|
m->height = src->height;
|
||||||
/* round up to nearest byte */
|
/* round up to nearest byte */
|
||||||
m->data = g_memdup(src->data, (src->w * src->h + 7) / 8);
|
m->data = g_memdup(src->data, (src->width * src->height + 7) / 8);
|
||||||
m->mask = XCreateBitmapFromData(ob_display, ob_root, m->data, m->w, m->h);
|
m->mask = XCreateBitmapFromData(RrDisplay(m->inst), RrRootWindow(m->inst),
|
||||||
|
m->data, m->width, m->height);
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "kernel/geom.h"
|
#include "kernel/geom.h"
|
||||||
|
|
||||||
pixmap_mask *pixmap_mask_new(int w, int h, char *data);
|
RrPixmapMask *RrPixmapMaskNew(const RrInstance *inst,
|
||||||
pixmap_mask *pixmap_mask_copy(pixmap_mask *src);
|
gint w, gint h, const gchar *data);
|
||||||
void pixmap_mask_free(pixmap_mask *m);
|
void RrPixmapMaskFree(RrPixmapMask *m);
|
||||||
void mask_draw(Pixmap p, TextureMask *m, Rect *position);
|
RrPixmapMask *RrPixmapMaskCopy(const RrPixmapMask *src);
|
||||||
|
void RrPixmapMaskDraw(Pixmap p, const RrTextureMask *m, const Rect *area);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
339
render/render.c
339
render/render.c
|
@ -1,7 +1,6 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "gradient.h"
|
#include "gradient.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
|
@ -9,157 +8,16 @@
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "kernel/openbox.h"
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#ifdef HAVE_STDLIB_H
|
#ifdef HAVE_STDLIB_H
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int render_depth;
|
static void pixel32_to_pixmap(RrAppearance *l, gint x, gint y, gint w, gint h);
|
||||||
XVisualInfo render_visual_info;
|
|
||||||
|
|
||||||
Visual *render_visual;
|
void RrPaint(RrAppearance *l, Window win, gint w, gint h)
|
||||||
Colormap render_colormap;
|
|
||||||
|
|
||||||
int render_red_offset = 0, render_green_offset = 0, render_blue_offset = 0;
|
|
||||||
int render_red_shift, render_green_shift, render_blue_shift;
|
|
||||||
int render_red_mask, render_green_mask, render_blue_mask;
|
|
||||||
|
|
||||||
|
|
||||||
void render_startup(void)
|
|
||||||
{
|
|
||||||
render_depth = DefaultDepth(ob_display, ob_screen);
|
|
||||||
render_visual = DefaultVisual(ob_display, ob_screen);
|
|
||||||
render_colormap = DefaultColormap(ob_display, ob_screen);
|
|
||||||
|
|
||||||
switch (render_visual->class) {
|
|
||||||
case TrueColor:
|
|
||||||
truecolor_startup();
|
|
||||||
break;
|
|
||||||
case PseudoColor:
|
|
||||||
case StaticColor:
|
|
||||||
case GrayScale:
|
|
||||||
case StaticGray:
|
|
||||||
pseudocolor_startup();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
g_critical("unsupported visual class.\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void truecolor_startup(void)
|
|
||||||
{
|
|
||||||
unsigned long red_mask, green_mask, blue_mask;
|
|
||||||
XImage *timage = NULL;
|
|
||||||
|
|
||||||
timage = XCreateImage(ob_display, render_visual, render_depth,
|
|
||||||
ZPixmap, 0, NULL, 1, 1, 32, 0);
|
|
||||||
g_assert(timage != NULL);
|
|
||||||
/* find the offsets for each color in the visual's masks */
|
|
||||||
render_red_mask = red_mask = timage->red_mask;
|
|
||||||
render_green_mask = green_mask = timage->green_mask;
|
|
||||||
render_blue_mask = blue_mask = timage->blue_mask;
|
|
||||||
|
|
||||||
render_red_offset = 0;
|
|
||||||
render_green_offset = 0;
|
|
||||||
render_blue_offset = 0;
|
|
||||||
|
|
||||||
while (! (red_mask & 1)) { render_red_offset++; red_mask >>= 1; }
|
|
||||||
while (! (green_mask & 1)) { render_green_offset++; green_mask >>= 1; }
|
|
||||||
while (! (blue_mask & 1)) { render_blue_offset++; blue_mask >>= 1; }
|
|
||||||
|
|
||||||
render_red_shift = render_green_shift = render_blue_shift = 8;
|
|
||||||
while (red_mask) { red_mask >>= 1; render_red_shift--; }
|
|
||||||
while (green_mask) { green_mask >>= 1; render_green_shift--; }
|
|
||||||
while (blue_mask) { blue_mask >>= 1; render_blue_shift--; }
|
|
||||||
XFree(timage);
|
|
||||||
}
|
|
||||||
|
|
||||||
void pseudocolor_startup(void)
|
|
||||||
{
|
|
||||||
XColor icolors[256];
|
|
||||||
int tr, tg, tb, n, r, g, b, i, incolors, ii;
|
|
||||||
unsigned long dev;
|
|
||||||
int cpc, _ncolors;
|
|
||||||
g_message("Initializing PseudoColor RenderControl\n");
|
|
||||||
|
|
||||||
/* determine the number of colors and the bits-per-color */
|
|
||||||
pseudo_bpc = 2; /* XXX THIS SHOULD BE A USER OPTION */
|
|
||||||
g_assert(pseudo_bpc >= 1);
|
|
||||||
_ncolors = pseudo_ncolors();
|
|
||||||
|
|
||||||
if (_ncolors > 1 << render_depth) {
|
|
||||||
g_warning("PseudoRenderControl: Invalid colormap size. Resizing.\n");
|
|
||||||
pseudo_bpc = 1 << (render_depth/3) >> 3;
|
|
||||||
_ncolors = 1 << (pseudo_bpc * 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* build a color cube */
|
|
||||||
pseudo_colors = malloc(_ncolors * sizeof(XColor));
|
|
||||||
cpc = 1 << pseudo_bpc; /* colors per channel */
|
|
||||||
|
|
||||||
for (n = 0, r = 0; r < cpc; r++)
|
|
||||||
for (g = 0; g < cpc; g++)
|
|
||||||
for (b = 0; b < cpc; b++, n++) {
|
|
||||||
tr = (int)(((float)(r)/(float)(cpc-1)) * 0xFF);
|
|
||||||
tg = (int)(((float)(g)/(float)(cpc-1)) * 0xFF);
|
|
||||||
tb = (int)(((float)(b)/(float)(cpc-1)) * 0xFF);
|
|
||||||
pseudo_colors[n].red = tr | tr << 8;
|
|
||||||
pseudo_colors[n].green = tg | tg << 8;
|
|
||||||
pseudo_colors[n].blue = tb | tb << 8;
|
|
||||||
pseudo_colors[n].flags = DoRed|DoGreen|DoBlue; /* used to track
|
|
||||||
allocation */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* allocate the colors */
|
|
||||||
for (i = 0; i < _ncolors; i++)
|
|
||||||
if (!XAllocColor(ob_display, render_colormap, &pseudo_colors[i]))
|
|
||||||
pseudo_colors[i].flags = 0; /* mark it as unallocated */
|
|
||||||
|
|
||||||
/* try allocate any colors that failed allocation above */
|
|
||||||
|
|
||||||
/* get the allocated values from the X server (only the first 256 XXX why!?)
|
|
||||||
*/
|
|
||||||
incolors = (((1 << render_depth) > 256) ? 256 : (1 << render_depth));
|
|
||||||
for (i = 0; i < incolors; i++)
|
|
||||||
icolors[i].pixel = i;
|
|
||||||
XQueryColors(ob_display, render_colormap, icolors, incolors);
|
|
||||||
|
|
||||||
/* try match unallocated ones */
|
|
||||||
for (i = 0; i < _ncolors; i++) {
|
|
||||||
if (!pseudo_colors[i].flags) { /* if it wasn't allocated... */
|
|
||||||
unsigned long closest = 0xffffffff, close = 0;
|
|
||||||
for (ii = 0; ii < incolors; ii++) {
|
|
||||||
/* find deviations */
|
|
||||||
r = (pseudo_colors[i].red - icolors[ii].red) & 0xff;
|
|
||||||
g = (pseudo_colors[i].green - icolors[ii].green) & 0xff;
|
|
||||||
b = (pseudo_colors[i].blue - icolors[ii].blue) & 0xff;
|
|
||||||
/* find a weighted absolute deviation */
|
|
||||||
dev = (r * r) + (g * g) + (b * b);
|
|
||||||
|
|
||||||
if (dev < closest) {
|
|
||||||
closest = dev;
|
|
||||||
close = ii;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pseudo_colors[i].red = icolors[close].red;
|
|
||||||
pseudo_colors[i].green = icolors[close].green;
|
|
||||||
pseudo_colors[i].blue = icolors[close].blue;
|
|
||||||
pseudo_colors[i].pixel = icolors[close].pixel;
|
|
||||||
|
|
||||||
/* try alloc this closest color, it had better succeed! */
|
|
||||||
if (XAllocColor(ob_display, render_colormap, &pseudo_colors[i]))
|
|
||||||
pseudo_colors[i].flags = DoRed|DoGreen|DoBlue; /* mark as alloced */
|
|
||||||
else
|
|
||||||
g_assert(FALSE); /* wtf has gone wrong, its already alloced for
|
|
||||||
chissake! */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void paint(Window win, Appearance *l, int w, int h)
|
|
||||||
{
|
{
|
||||||
int i, transferred = 0, sw;
|
int i, transferred = 0, sw;
|
||||||
pixel32 *source, *dest;
|
pixel32 *source, *dest;
|
||||||
|
@ -173,7 +31,9 @@ void paint(Window win, Appearance *l, int w, int h)
|
||||||
|
|
||||||
if (resized) {
|
if (resized) {
|
||||||
oldp = l->pixmap; /* save to free after changing the visible pixmap */
|
oldp = l->pixmap; /* save to free after changing the visible pixmap */
|
||||||
l->pixmap = XCreatePixmap(ob_display, ob_root, w, h, render_depth);
|
l->pixmap = XCreatePixmap(RrDisplay(l->inst),
|
||||||
|
RrRootWindow(l->inst),
|
||||||
|
w, h, RrDepth(l->inst));
|
||||||
} else
|
} else
|
||||||
oldp = None;
|
oldp = None;
|
||||||
|
|
||||||
|
@ -183,14 +43,14 @@ void paint(Window win, Appearance *l, int w, int h)
|
||||||
|
|
||||||
if (l->xftdraw != NULL)
|
if (l->xftdraw != NULL)
|
||||||
XftDrawDestroy(l->xftdraw);
|
XftDrawDestroy(l->xftdraw);
|
||||||
l->xftdraw = XftDrawCreate(ob_display, l->pixmap, render_visual,
|
l->xftdraw = XftDrawCreate(RrDisplay(l->inst), l->pixmap,
|
||||||
render_colormap);
|
RrVisual(l->inst), RrColormap(l->inst));
|
||||||
g_assert(l->xftdraw != NULL);
|
g_assert(l->xftdraw != NULL);
|
||||||
|
|
||||||
g_free(l->surface.pixel_data);
|
g_free(l->surface.pixel_data);
|
||||||
l->surface.pixel_data = g_new(pixel32, w * h);
|
l->surface.pixel_data = g_new(pixel32, w * h);
|
||||||
|
|
||||||
if (l->surface.grad == Background_ParentRelative) {
|
if (l->surface.grad == RR_SURFACE_PARENTREL) {
|
||||||
g_assert (l->surface.parent);
|
g_assert (l->surface.parent);
|
||||||
g_assert (l->surface.parent->w);
|
g_assert (l->surface.parent->w);
|
||||||
|
|
||||||
|
@ -201,20 +61,20 @@ void paint(Window win, Appearance *l, int w, int h)
|
||||||
for (i = 0; i < h; i++, source += sw, dest += w) {
|
for (i = 0; i < h; i++, source += sw, dest += w) {
|
||||||
memcpy(dest, source, w * sizeof(pixel32));
|
memcpy(dest, source, w * sizeof(pixel32));
|
||||||
}
|
}
|
||||||
}
|
} else if (l->surface.grad == RR_SURFACE_SOLID)
|
||||||
else if (l->surface.grad == Background_Solid)
|
|
||||||
gradient_solid(l, 0, 0, w, h);
|
gradient_solid(l, 0, 0, w, h);
|
||||||
else gradient_render(&l->surface, w, h);
|
else
|
||||||
|
gradient_render(&l->surface, w, h);
|
||||||
|
|
||||||
RECT_SET(tarea, 0, 0, w, h);
|
RECT_SET(tarea, 0, 0, w, h);
|
||||||
if (l->surface.grad != Background_ParentRelative) {
|
if (l->surface.grad != RR_SURFACE_PARENTREL) {
|
||||||
if (l->surface.relief != Flat) {
|
if (l->surface.relief != RR_RELIEF_FLAT) {
|
||||||
switch (l->surface.bevel) {
|
switch (l->surface.bevel) {
|
||||||
case Bevel1:
|
case RR_BEVEL_1:
|
||||||
tarea.x += 1; tarea.y += 1;
|
tarea.x += 1; tarea.y += 1;
|
||||||
tarea.width -= 2; tarea.height -= 2;
|
tarea.width -= 2; tarea.height -= 2;
|
||||||
break;
|
break;
|
||||||
case Bevel2:
|
case RR_BEVEL_2:
|
||||||
tarea.x += 2; tarea.y += 2;
|
tarea.x += 2; tarea.y += 2;
|
||||||
tarea.width -= 4; tarea.height -= 4;
|
tarea.width -= 4; tarea.height -= 4;
|
||||||
break;
|
break;
|
||||||
|
@ -227,33 +87,32 @@ void paint(Window win, Appearance *l, int w, int h)
|
||||||
|
|
||||||
for (i = 0; i < l->textures; i++) {
|
for (i = 0; i < l->textures; i++) {
|
||||||
switch (l->texture[i].type) {
|
switch (l->texture[i].type) {
|
||||||
case NoTexture:
|
case RR_TEXTURE_NONE:
|
||||||
break;
|
break;
|
||||||
case Text:
|
case RR_TEXTURE_TEXT:
|
||||||
if (!transferred) {
|
if (!transferred) {
|
||||||
transferred = 1;
|
transferred = 1;
|
||||||
if (l->surface.grad != Background_Solid)
|
if (l->surface.grad != RR_SURFACE_SOLID)
|
||||||
pixel32_to_pixmap(l->surface.pixel_data,
|
pixel32_to_pixmap(l, 0, 0, w, h);
|
||||||
l->pixmap, 0, 0, w, h);
|
|
||||||
}
|
}
|
||||||
if (l->xftdraw == NULL) {
|
if (l->xftdraw == NULL) {
|
||||||
l->xftdraw = XftDrawCreate(ob_display, l->pixmap,
|
l->xftdraw = XftDrawCreate(RrDisplay(l->inst), l->pixmap,
|
||||||
render_visual, render_colormap);
|
RrVisual(l->inst),
|
||||||
|
RrColormap(l->inst));
|
||||||
}
|
}
|
||||||
font_draw(l->xftdraw, &l->texture[i].data.text, &tarea);
|
font_draw(l->xftdraw, &l->texture[i].data.text, &tarea);
|
||||||
break;
|
break;
|
||||||
case Bitmask:
|
case RR_TEXTURE_MASK:
|
||||||
if (!transferred) {
|
if (!transferred) {
|
||||||
transferred = 1;
|
transferred = 1;
|
||||||
if (l->surface.grad != Background_Solid)
|
if (l->surface.grad != RR_SURFACE_SOLID)
|
||||||
pixel32_to_pixmap(l->surface.pixel_data,
|
pixel32_to_pixmap(l, 0, 0, w, h);
|
||||||
l->pixmap, 0, 0, w, h);
|
|
||||||
}
|
}
|
||||||
if (l->texture[i].data.mask.color->gc == None)
|
if (l->texture[i].data.mask.color->gc == None)
|
||||||
color_allocate_gc(l->texture[i].data.mask.color);
|
color_allocate_gc(l->texture[i].data.mask.color);
|
||||||
mask_draw(l->pixmap, &l->texture[i].data.mask, &tarea);
|
RrPixmapMaskDraw(l->pixmap, &l->texture[i].data.mask, &tarea);
|
||||||
break;
|
break;
|
||||||
case RGBA:
|
case RR_TEXTURE_RGBA:
|
||||||
image_draw(l->surface.pixel_data,
|
image_draw(l->surface.pixel_data,
|
||||||
&l->texture[i].data.rgba, &tarea);
|
&l->texture[i].data.rgba, &tarea);
|
||||||
break;
|
break;
|
||||||
|
@ -262,47 +121,34 @@ void paint(Window win, Appearance *l, int w, int h)
|
||||||
|
|
||||||
if (!transferred) {
|
if (!transferred) {
|
||||||
transferred = 1;
|
transferred = 1;
|
||||||
if (l->surface.grad != Background_Solid)
|
if (l->surface.grad != RR_SURFACE_SOLID)
|
||||||
pixel32_to_pixmap(l->surface.pixel_data, l->pixmap, 0, 0, w, h);
|
pixel32_to_pixmap(l, 0, 0, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
XSetWindowBackgroundPixmap(ob_display, win, l->pixmap);
|
XSetWindowBackgroundPixmap(RrDisplay(l->inst), win, l->pixmap);
|
||||||
XClearWindow(ob_display, win);
|
XClearWindow(RrDisplay(l->inst), win);
|
||||||
if (oldp) XFreePixmap(ob_display, oldp);
|
if (oldp) XFreePixmap(RrDisplay(l->inst), oldp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void render_shutdown(void)
|
RrAppearance *RrAppearanceNew(const RrInstance *inst, gint numtex)
|
||||||
{
|
{
|
||||||
}
|
RrAppearance *out;
|
||||||
|
|
||||||
Appearance *appearance_new(int numtex)
|
out = g_new0(RrAppearance, 1);
|
||||||
{
|
out->inst = inst;
|
||||||
Surface *p;
|
|
||||||
Appearance *out;
|
|
||||||
|
|
||||||
out = g_new(Appearance, 1);
|
|
||||||
out->textures = numtex;
|
out->textures = numtex;
|
||||||
out->xftdraw = NULL;
|
if (numtex) out->texture = g_new0(RrTexture, numtex);
|
||||||
if (numtex) out->texture = g_new0(Texture, numtex);
|
|
||||||
else out->texture = NULL;
|
|
||||||
out->pixmap = None;
|
|
||||||
out->w = out->h = 0;
|
|
||||||
|
|
||||||
p = &out->surface;
|
|
||||||
p->primary = NULL;
|
|
||||||
p->secondary = NULL;
|
|
||||||
p->border_color = NULL;
|
|
||||||
p->bevel_dark = NULL;
|
|
||||||
p->bevel_light = NULL;
|
|
||||||
p->pixel_data = NULL;
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
Appearance *appearance_copy(Appearance *orig)
|
RrAppearance *RrAppearanceCopy(RrAppearance *orig)
|
||||||
{
|
{
|
||||||
Surface *spo, *spc;
|
RrSurface *spo, *spc;
|
||||||
Appearance *copy = g_new(Appearance, 1);
|
RrAppearance *copy = g_new(RrAppearance, 1);
|
||||||
|
|
||||||
|
copy->inst = orig->inst;
|
||||||
|
|
||||||
spo = &(orig->surface);
|
spo = &(orig->surface);
|
||||||
spc = &(copy->surface);
|
spc = &(copy->surface);
|
||||||
|
@ -310,31 +156,36 @@ Appearance *appearance_copy(Appearance *orig)
|
||||||
spc->relief = spo->relief;
|
spc->relief = spo->relief;
|
||||||
spc->bevel = spo->bevel;
|
spc->bevel = spo->bevel;
|
||||||
if (spo->primary != NULL)
|
if (spo->primary != NULL)
|
||||||
spc->primary = color_new(spo->primary->r,
|
spc->primary = RrColorNew(copy->inst,
|
||||||
|
spo->primary->r,
|
||||||
spo->primary->g,
|
spo->primary->g,
|
||||||
spo->primary->b);
|
spo->primary->b);
|
||||||
else spc->primary = NULL;
|
else spc->primary = NULL;
|
||||||
|
|
||||||
if (spo->secondary != NULL)
|
if (spo->secondary != NULL)
|
||||||
spc->secondary = color_new(spo->secondary->r,
|
spc->secondary = RrColorNew(copy->inst,
|
||||||
|
spo->secondary->r,
|
||||||
spo->secondary->g,
|
spo->secondary->g,
|
||||||
spo->secondary->b);
|
spo->secondary->b);
|
||||||
else spc->secondary = NULL;
|
else spc->secondary = NULL;
|
||||||
|
|
||||||
if (spo->border_color != NULL)
|
if (spo->border_color != NULL)
|
||||||
spc->border_color = color_new(spo->border_color->r,
|
spc->border_color = RrColorNew(copy->inst,
|
||||||
|
spo->border_color->r,
|
||||||
spo->border_color->g,
|
spo->border_color->g,
|
||||||
spo->border_color->b);
|
spo->border_color->b);
|
||||||
else spc->border_color = NULL;
|
else spc->border_color = NULL;
|
||||||
|
|
||||||
if (spo->bevel_dark != NULL)
|
if (spo->bevel_dark != NULL)
|
||||||
spc->bevel_dark = color_new(spo->bevel_dark->r,
|
spc->bevel_dark = RrColorNew(copy->inst,
|
||||||
|
spo->bevel_dark->r,
|
||||||
spo->bevel_dark->g,
|
spo->bevel_dark->g,
|
||||||
spo->bevel_dark->b);
|
spo->bevel_dark->b);
|
||||||
else spc->bevel_dark = NULL;
|
else spc->bevel_dark = NULL;
|
||||||
|
|
||||||
if (spo->bevel_light != NULL)
|
if (spo->bevel_light != NULL)
|
||||||
spc->bevel_light = color_new(spo->bevel_light->r,
|
spc->bevel_light = RrColorNew(copy->inst,
|
||||||
|
spo->bevel_light->r,
|
||||||
spo->bevel_light->g,
|
spo->bevel_light->g,
|
||||||
spo->bevel_light->b);
|
spo->bevel_light->b);
|
||||||
else spc->bevel_light = NULL;
|
else spc->bevel_light = NULL;
|
||||||
|
@ -344,27 +195,28 @@ Appearance *appearance_copy(Appearance *orig)
|
||||||
spc->pixel_data = NULL;
|
spc->pixel_data = NULL;
|
||||||
|
|
||||||
copy->textures = orig->textures;
|
copy->textures = orig->textures;
|
||||||
copy->texture = g_memdup(orig->texture, orig->textures * sizeof(Texture));
|
copy->texture = g_memdup(orig->texture,
|
||||||
|
orig->textures * sizeof(RrTexture));
|
||||||
copy->pixmap = None;
|
copy->pixmap = None;
|
||||||
copy->xftdraw = NULL;
|
copy->xftdraw = NULL;
|
||||||
copy->w = copy->h = 0;
|
copy->w = copy->h = 0;
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void appearance_free(Appearance *a)
|
void RrAppearanceFree(RrAppearance *a)
|
||||||
{
|
{
|
||||||
if (a) {
|
if (a) {
|
||||||
Surface *p;
|
RrSurface *p;
|
||||||
if (a->pixmap != None) XFreePixmap(ob_display, a->pixmap);
|
if (a->pixmap != None) XFreePixmap(RrDisplay(a->inst), a->pixmap);
|
||||||
if (a->xftdraw != NULL) XftDrawDestroy(a->xftdraw);
|
if (a->xftdraw != NULL) XftDrawDestroy(a->xftdraw);
|
||||||
if (a->textures)
|
if (a->textures)
|
||||||
g_free(a->texture);
|
g_free(a->texture);
|
||||||
p = &a->surface;
|
p = &a->surface;
|
||||||
color_free(p->primary);
|
RrColorFree(p->primary);
|
||||||
color_free(p->secondary);
|
RrColorFree(p->secondary);
|
||||||
color_free(p->border_color);
|
RrColorFree(p->border_color);
|
||||||
color_free(p->bevel_dark);
|
RrColorFree(p->bevel_dark);
|
||||||
color_free(p->bevel_light);
|
RrColorFree(p->bevel_light);
|
||||||
g_free(p->pixel_data);
|
g_free(p->pixel_data);
|
||||||
|
|
||||||
g_free(a);
|
g_free(a);
|
||||||
|
@ -372,40 +224,48 @@ void appearance_free(Appearance *a)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void pixel32_to_pixmap(pixel32 *in, Pixmap out, int x, int y, int w, int h)
|
static void pixel32_to_pixmap(RrAppearance *l, gint x, gint y, gint w, gint h)
|
||||||
{
|
{
|
||||||
pixel32 *scratch;
|
pixel32 *in, *scratch;
|
||||||
|
Pixmap out;
|
||||||
XImage *im = NULL;
|
XImage *im = NULL;
|
||||||
im = XCreateImage(ob_display, render_visual, render_depth,
|
im = XCreateImage(RrDisplay(l->inst), RrVisual(l->inst), RrDepth(l->inst),
|
||||||
ZPixmap, 0, NULL, w, h, 32, 0);
|
ZPixmap, 0, NULL, w, h, 32, 0);
|
||||||
g_assert(im != NULL);
|
g_assert(im != NULL);
|
||||||
|
|
||||||
|
in = l->surface.pixel_data;
|
||||||
|
out = l->pixmap;
|
||||||
|
|
||||||
im->byte_order = render_endian;
|
im->byte_order = render_endian;
|
||||||
/* this malloc is a complete waste of time on normal 32bpp
|
/* this malloc is a complete waste of time on normal 32bpp
|
||||||
as reduce_depth just sets im->data = data and returns
|
as reduce_depth just sets im->data = data and returns
|
||||||
*/
|
*/
|
||||||
scratch = g_new(pixel32, im->width * im->height);
|
scratch = g_new(pixel32, im->width * im->height);
|
||||||
im->data = (char*) scratch;
|
im->data = (char*) scratch;
|
||||||
reduce_depth(in, im);
|
reduce_depth(l->inst, in, im);
|
||||||
XPutImage(ob_display, out, DefaultGC(ob_display, ob_screen),
|
XPutImage(RrDisplay(l->inst), out,
|
||||||
|
DefaultGC(RrDisplay(l->inst), RrScreen(l->inst)),
|
||||||
im, 0, 0, x, y, w, h);
|
im, 0, 0, x, y, w, h);
|
||||||
im->data = NULL;
|
im->data = NULL;
|
||||||
XDestroyImage(im);
|
XDestroyImage(im);
|
||||||
g_free(scratch);
|
g_free(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void appearance_minsize(Appearance *l, int *w, int *h)
|
void RrMinsize(RrAppearance *l, gint *w, gint *h)
|
||||||
{
|
{
|
||||||
int i;
|
gint i;
|
||||||
int m;
|
gint m;
|
||||||
*w = *h = 0;
|
*w = *h = 0;
|
||||||
|
|
||||||
for (i = 0; i < l->textures; ++i) {
|
for (i = 0; i < l->textures; ++i) {
|
||||||
switch (l->texture[i].type) {
|
switch (l->texture[i].type) {
|
||||||
case Bitmask:
|
case RR_TEXTURE_NONE:
|
||||||
*w = MAX(*w, l->texture[i].data.mask.mask->w);
|
|
||||||
*h = MAX(*h, l->texture[i].data.mask.mask->h);
|
|
||||||
break;
|
break;
|
||||||
case Text:
|
case RR_TEXTURE_MASK:
|
||||||
|
*w = MAX(*w, l->texture[i].data.mask.mask->width);
|
||||||
|
*h = MAX(*h, l->texture[i].data.mask.mask->height);
|
||||||
|
break;
|
||||||
|
case RR_TEXTURE_TEXT:
|
||||||
m = font_measure_string(l->texture[i].data.text.font,
|
m = font_measure_string(l->texture[i].data.text.font,
|
||||||
l->texture[i].data.text.string,
|
l->texture[i].data.text.string,
|
||||||
l->texture[i].data.text.shadow,
|
l->texture[i].data.text.shadow,
|
||||||
|
@ -416,22 +276,20 @@ void appearance_minsize(Appearance *l, int *w, int *h)
|
||||||
l->texture[i].data.text.offset);
|
l->texture[i].data.text.offset);
|
||||||
*h += MAX(*h, m);
|
*h += MAX(*h, m);
|
||||||
break;
|
break;
|
||||||
case RGBA:
|
case RR_TEXTURE_RGBA:
|
||||||
*w += MAX(*w, l->texture[i].data.rgba.width);
|
*w += MAX(*w, l->texture[i].data.rgba.width);
|
||||||
*h += MAX(*h, l->texture[i].data.rgba.height);
|
*h += MAX(*h, l->texture[i].data.rgba.height);
|
||||||
break;
|
break;
|
||||||
case NoTexture:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l->surface.relief != Flat) {
|
if (l->surface.relief != RR_RELIEF_FLAT) {
|
||||||
switch (l->surface.bevel) {
|
switch (l->surface.bevel) {
|
||||||
case Bevel1:
|
case RR_BEVEL_1:
|
||||||
*w += 2;
|
*w += 2;
|
||||||
*h += 2;
|
*h += 2;
|
||||||
break;
|
break;
|
||||||
case Bevel2:
|
case RR_BEVEL_2:
|
||||||
*w += 4;
|
*w += 4;
|
||||||
*h += 4;
|
*h += 4;
|
||||||
break;
|
break;
|
||||||
|
@ -445,35 +303,40 @@ void appearance_minsize(Appearance *l, int *w, int *h)
|
||||||
if (*h < 1) *h = 1;
|
if (*h < 1) *h = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean render_pixmap_to_rgba(Pixmap pmap, Pixmap mask,
|
gboolean RrPixmapToRGBA(const RrInstance *inst,
|
||||||
int *w, int *h, pixel32 **data)
|
Pixmap pmap, Pixmap mask,
|
||||||
|
gint *w, gint *h, pixel32 **data)
|
||||||
{
|
{
|
||||||
Window xr;
|
Window xr;
|
||||||
int xx, xy;
|
gint xx, xy;
|
||||||
guint pw, ph, mw, mh, xb, xd, i, x, y, di;
|
guint pw, ph, mw, mh, xb, xd, i, x, y, di;
|
||||||
XImage *xi, *xm = NULL;
|
XImage *xi, *xm = NULL;
|
||||||
|
|
||||||
if (!XGetGeometry(ob_display, pmap, &xr, &xx, &xy, &pw, &ph, &xb, &xd))
|
if (!XGetGeometry(RrDisplay(inst),
|
||||||
|
pmap, &xr, &xx, &xy, &pw, &ph, &xb, &xd))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (mask) {
|
if (mask) {
|
||||||
if (!XGetGeometry(ob_display, mask, &xr, &xx, &xy, &mw, &mh, &xb, &xd))
|
if (!XGetGeometry(RrDisplay(inst), mask,
|
||||||
|
&xr, &xx, &xy, &mw, &mh, &xb, &xd))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (pw != mw || ph != mh || xd != 1)
|
if (pw != mw || ph != mh || xd != 1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
xi = XGetImage(ob_display, pmap, 0, 0, pw, ph, 0xffffffff, ZPixmap);
|
xi = XGetImage(RrDisplay(inst), pmap,
|
||||||
|
0, 0, pw, ph, 0xffffffff, ZPixmap);
|
||||||
if (!xi)
|
if (!xi)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (mask) {
|
if (mask) {
|
||||||
xm = XGetImage(ob_display, mask, 0, 0, mw, mh, 0xffffffff, ZPixmap);
|
xm = XGetImage(RrDisplay(inst), mask,
|
||||||
|
0, 0, mw, mh, 0xffffffff, ZPixmap);
|
||||||
if (!xm)
|
if (!xm)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
*data = g_new(pixel32, pw * ph);
|
*data = g_new(pixel32, pw * ph);
|
||||||
increase_depth(*data, xi);
|
increase_depth(inst, *data, xi);
|
||||||
|
|
||||||
if (mask) {
|
if (mask) {
|
||||||
/* apply transparency from the mask */
|
/* apply transparency from the mask */
|
||||||
|
|
222
render/render.h
222
render/render.h
|
@ -1,49 +1,67 @@
|
||||||
#ifndef __render_h
|
#ifndef __render_h
|
||||||
#define __render_h
|
#define __render_h
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#define _XFT_NO_COMPAT_ /* no Xft 1 API */
|
#define _XFT_NO_COMPAT_ /* no Xft 1 API */
|
||||||
#include <X11/Xft/Xft.h>
|
#include <X11/Xft/Xft.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include "color.h"
|
|
||||||
#include "kernel/geom.h"
|
typedef union _RrTextureData RrTextureData;
|
||||||
|
typedef struct _RrAppearance RrAppearance;
|
||||||
|
typedef struct _RrSurface RrSurface;
|
||||||
|
typedef struct _RrFont RrFont;
|
||||||
|
typedef struct _RrTexture RrTexture;
|
||||||
|
typedef struct _RrTextureMask RrTextureMask;
|
||||||
|
typedef struct _RrTextureRGBA RrTextureRGBA;
|
||||||
|
typedef struct _RrTextureText RrTextureText;
|
||||||
|
typedef struct _RrPixmapMask RrPixmapMask;
|
||||||
|
typedef struct _RrInstance RrInstance;
|
||||||
|
typedef struct _RrColor color_rgb; /* XXX ugly */
|
||||||
|
|
||||||
|
typedef guint32 pixel32; /* XXX prefix */
|
||||||
|
typedef guint16 pixel16;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
Flat,
|
RR_RELIEF_FLAT,
|
||||||
Raised,
|
RR_RELIEF_RAISED,
|
||||||
Sunken
|
RR_RELIEF_SUNKEN
|
||||||
} ReliefType;
|
} RrReliefType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
Bevel1,
|
RR_BEVEL_1,
|
||||||
Bevel2
|
RR_BEVEL_2
|
||||||
} BevelType;
|
} RrBevelType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
Background_ParentRelative,
|
RR_SURFACE_NONE,
|
||||||
Background_Solid,
|
RR_SURFACE_PARENTREL,
|
||||||
Background_Horizontal,
|
RR_SURFACE_SOLID,
|
||||||
Background_Vertical,
|
RR_SURFACE_HORIZONTAL,
|
||||||
Background_Diagonal,
|
RR_SURFACE_VERTICAL,
|
||||||
Background_CrossDiagonal,
|
RR_SURFACE_DIAGONAL,
|
||||||
Background_PipeCross,
|
RR_SURFACE_CROSS_DIAGONAL,
|
||||||
Background_Rectangle,
|
RR_SURFACE_PIPECROSS,
|
||||||
Background_Pyramid
|
RR_SURFACE_RECTANGLE,
|
||||||
} SurfaceColorType;
|
RR_SURFACE_PYRAMID
|
||||||
|
} RrSurfaceColorType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
Bitmask,
|
RR_TEXTURE_NONE,
|
||||||
Text,
|
RR_TEXTURE_MASK,
|
||||||
RGBA,
|
RR_TEXTURE_TEXT,
|
||||||
NoTexture
|
RR_TEXTURE_RGBA
|
||||||
} TextureType;
|
} RrTextureType;
|
||||||
|
|
||||||
struct Appearance;
|
typedef enum {
|
||||||
|
RR_JUSTIFY_LEFT,
|
||||||
|
RR_JUSTIFY_CENTER,
|
||||||
|
RR_JUSTIFY_RIGHT
|
||||||
|
} RrJustify;
|
||||||
|
|
||||||
typedef struct Surface {
|
struct _RrSurface {
|
||||||
SurfaceColorType grad;
|
RrSurfaceColorType grad;
|
||||||
ReliefType relief;
|
RrReliefType relief;
|
||||||
BevelType bevel;
|
RrBevelType bevel;
|
||||||
color_rgb *primary;
|
color_rgb *primary;
|
||||||
color_rgb *secondary;
|
color_rgb *secondary;
|
||||||
color_rgb *border_color;
|
color_rgb *border_color;
|
||||||
|
@ -51,95 +69,103 @@ typedef struct Surface {
|
||||||
color_rgb *bevel_light;
|
color_rgb *bevel_light;
|
||||||
gboolean interlaced;
|
gboolean interlaced;
|
||||||
gboolean border;
|
gboolean border;
|
||||||
struct Appearance *parent;
|
RrAppearance *parent;
|
||||||
int parentx;
|
gint parentx;
|
||||||
int parenty;
|
gint parenty;
|
||||||
pixel32 *pixel_data;
|
pixel32 *pixel_data;
|
||||||
} Surface;
|
};
|
||||||
|
|
||||||
typedef struct {
|
struct _RrTextureText {
|
||||||
XftFont *xftfont;
|
RrFont *font;
|
||||||
int elipses_length;
|
RrJustify justify;
|
||||||
} ObFont;
|
gint shadow;
|
||||||
|
gchar tint;
|
||||||
typedef enum {
|
guchar offset;
|
||||||
Justify_Center,
|
|
||||||
Justify_Left,
|
|
||||||
Justify_Right
|
|
||||||
} Justify;
|
|
||||||
|
|
||||||
typedef struct TextureText {
|
|
||||||
ObFont *font;
|
|
||||||
Justify justify;
|
|
||||||
int shadow;
|
|
||||||
char tint;
|
|
||||||
unsigned char offset;
|
|
||||||
color_rgb *color;
|
color_rgb *color;
|
||||||
char *string;
|
gchar *string;
|
||||||
} TextureText;
|
};
|
||||||
|
|
||||||
typedef struct {
|
struct _RrPixmapMask {
|
||||||
|
const RrInstance *inst;
|
||||||
Pixmap mask;
|
Pixmap mask;
|
||||||
guint w, h;
|
gint width;
|
||||||
char *data;
|
gint height;
|
||||||
} pixmap_mask;
|
gchar *data;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct TextureMask {
|
struct _RrTextureMask {
|
||||||
color_rgb *color;
|
color_rgb *color;
|
||||||
pixmap_mask *mask;
|
RrPixmapMask *mask;
|
||||||
} TextureMask;
|
};
|
||||||
|
|
||||||
typedef struct TextureRGBA {
|
struct _RrTextureRGBA {
|
||||||
guint width;
|
gint width;
|
||||||
guint height;
|
gint height;
|
||||||
pixel32 *data;
|
pixel32 *data;
|
||||||
/* cached scaled so we don't have to scale often */
|
/* cached scaled so we don't have to scale often */
|
||||||
guint cwidth;
|
gint cwidth;
|
||||||
guint cheight;
|
gint cheight;
|
||||||
pixel32 *cache;
|
pixel32 *cache;
|
||||||
} TextureRGBA;
|
};
|
||||||
|
|
||||||
typedef union {
|
union _RrTextureData {
|
||||||
TextureRGBA rgba;
|
RrTextureRGBA rgba;
|
||||||
TextureText text;
|
RrTextureText text;
|
||||||
TextureMask mask;
|
RrTextureMask mask;
|
||||||
} TextureData;
|
};
|
||||||
|
|
||||||
typedef struct Texture {
|
struct _RrTexture {
|
||||||
TextureType type;
|
RrTextureType type;
|
||||||
TextureData data;
|
RrTextureData data;
|
||||||
} Texture;
|
};
|
||||||
|
|
||||||
typedef struct Appearance {
|
struct _RrAppearance {
|
||||||
Surface surface;
|
const RrInstance *inst;
|
||||||
int textures;
|
|
||||||
Texture *texture;
|
RrSurface surface;
|
||||||
|
gint textures;
|
||||||
|
RrTexture *texture;
|
||||||
Pixmap pixmap;
|
Pixmap pixmap;
|
||||||
XftDraw *xftdraw;
|
XftDraw *xftdraw;
|
||||||
|
|
||||||
/* cached for internal use */
|
/* cached for internal use */
|
||||||
int w, h;
|
gint w, h;
|
||||||
} Appearance;
|
};
|
||||||
|
|
||||||
extern Visual *render_visual;
|
RrInstance* RrInstanceNew (Display *display, gint screen);
|
||||||
extern XVisualInfo render_visual_info;
|
void RrInstanceFree (RrInstance *inst);
|
||||||
extern int render_depth;
|
|
||||||
extern Colormap render_colormap;
|
|
||||||
|
|
||||||
void render_startup(void);
|
Display* RrDisplay (const RrInstance *inst);
|
||||||
void init_appearance(Appearance *l);
|
gint RrScreen (const RrInstance *inst);
|
||||||
void paint(Window win, Appearance *l, int w, int h);
|
Window RrRootWindow (const RrInstance *inst);
|
||||||
void render_shutdown(void);
|
Visual* RrVisual (const RrInstance *inst);
|
||||||
Appearance *appearance_new(int numtex);
|
gint RrDepth (const RrInstance *inst);
|
||||||
Appearance *appearance_copy(Appearance *a);
|
Colormap RrColormap (const RrInstance *inst);
|
||||||
void appearance_free(Appearance *a);
|
gint RrRedOffset (const RrInstance *inst);
|
||||||
void truecolor_startup(void);
|
gint RrGreenOffset (const RrInstance *inst);
|
||||||
void pseudocolor_startup(void);
|
gint RrBlueOffset (const RrInstance *inst);
|
||||||
void pixel32_to_pixmap(pixel32 *in, Pixmap out, int x, int y, int w, int h);
|
gint RrRedShift (const RrInstance *inst);
|
||||||
|
gint RrGreenShift (const RrInstance *inst);
|
||||||
|
gint RrBlueShift (const RrInstance *inst);
|
||||||
|
gint RrRedMask (const RrInstance *inst);
|
||||||
|
gint RrGreenMask (const RrInstance *inst);
|
||||||
|
gint RrBlueMask (const RrInstance *inst);
|
||||||
|
guint RrPseudoBPC (const RrInstance *inst);
|
||||||
|
XColor* RrPseudoColors (const RrInstance *inst);
|
||||||
|
|
||||||
void appearance_minsize(Appearance *l, int *w, int *h);
|
color_rgb *RrColorNew (const RrInstance *inst, gint r, gint g, gint b);
|
||||||
|
color_rgb *RrColorParse (const RrInstance *inst, gchar *colorname);
|
||||||
|
void RrColorFree (color_rgb *in);
|
||||||
|
|
||||||
gboolean render_pixmap_to_rgba(Pixmap pmap, Pixmap mask,
|
RrAppearance *RrAppearanceNew (const RrInstance *inst, gint numtex);
|
||||||
int *w, int *h, pixel32 **data);
|
RrAppearance *RrAppearanceCopy (RrAppearance *a);
|
||||||
|
void RrAppearanceFree (RrAppearance *a);
|
||||||
|
|
||||||
|
void RrPaint (RrAppearance *l, Window win, gint w, gint h);
|
||||||
|
void RrMinsize (RrAppearance *l, gint *w, gint *h);
|
||||||
|
|
||||||
|
gboolean RrPixmapToRGBA(const RrInstance *inst,
|
||||||
|
Pixmap pmap, Pixmap mask,
|
||||||
|
gint *w, gint *h, pixel32 **data);
|
||||||
|
|
||||||
#endif /*__render_h*/
|
#endif /*__render_h*/
|
||||||
|
|
|
@ -21,7 +21,8 @@ Window ob_root;
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
Window win;
|
Window win;
|
||||||
Appearance *look;
|
RrInstance *inst;
|
||||||
|
RrAppearance *look;
|
||||||
|
|
||||||
Window root;
|
Window root;
|
||||||
XEvent report;
|
XEvent report;
|
||||||
|
@ -42,26 +43,26 @@ int main()
|
||||||
XMapWindow(ob_display, win);
|
XMapWindow(ob_display, win);
|
||||||
XSelectInput(ob_display, win, ExposureMask | StructureNotifyMask);
|
XSelectInput(ob_display, win, ExposureMask | StructureNotifyMask);
|
||||||
root = RootWindow (ob_display, DefaultScreen (ob_display));
|
root = RootWindow (ob_display, DefaultScreen (ob_display));
|
||||||
render_startup();
|
inst = RrInstanceNew(ob_display, ob_screen);
|
||||||
|
|
||||||
look = appearance_new(0);
|
look = RrAppearanceNew(inst, 0);
|
||||||
look->surface.grad = Background_Pyramid;
|
look->surface.grad = RR_SURFACE_PYRAMID;
|
||||||
look->surface.secondary = color_parse("Yellow");
|
look->surface.secondary = RrColorParse(inst, "Yellow");
|
||||||
look->surface.primary = color_parse("Blue");
|
look->surface.primary = RrColorParse(inst, "Blue");
|
||||||
look->surface.interlaced = FALSE;
|
look->surface.interlaced = FALSE;
|
||||||
if (ob_display == NULL) {
|
if (ob_display == NULL) {
|
||||||
fprintf(stderr, "couldn't connect to X server :0\n");
|
fprintf(stderr, "couldn't connect to X server :0\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
paint(win, look, w, h);
|
RrPaint(look, win, w, h);
|
||||||
while (1) {
|
while (1) {
|
||||||
XNextEvent(ob_display, &report);
|
XNextEvent(ob_display, &report);
|
||||||
switch (report.type) {
|
switch (report.type) {
|
||||||
case Expose:
|
case Expose:
|
||||||
break;
|
break;
|
||||||
case ConfigureNotify:
|
case ConfigureNotify:
|
||||||
paint(win, look,
|
RrPaint(look, win,
|
||||||
report.xconfigure.width,
|
report.xconfigure.width,
|
||||||
report.xconfigure.height);
|
report.xconfigure.height);
|
||||||
break;
|
break;
|
||||||
|
@ -69,5 +70,8 @@ int main()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RrAppearanceFree (look);
|
||||||
|
RrInstanceFree (inst);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
642
render/theme.c
642
render/theme.c
|
@ -7,10 +7,10 @@
|
||||||
#include <X11/Xresource.h>
|
#include <X11/Xresource.h>
|
||||||
|
|
||||||
/* style settings - geometry */
|
/* style settings - geometry */
|
||||||
int theme_bevel;
|
gint theme_bevel;
|
||||||
int theme_handle_height;
|
gint theme_handle_height;
|
||||||
int theme_bwidth;
|
gint theme_bwidth;
|
||||||
int theme_cbwidth;
|
gint theme_cbwidth;
|
||||||
/* style settings - colors */
|
/* style settings - colors */
|
||||||
color_rgb *theme_b_color;
|
color_rgb *theme_b_color;
|
||||||
color_rgb *theme_cb_focused_color;
|
color_rgb *theme_cb_focused_color;
|
||||||
|
@ -24,83 +24,87 @@ color_rgb *theme_menu_color;
|
||||||
color_rgb *theme_menu_disabled_color;
|
color_rgb *theme_menu_disabled_color;
|
||||||
color_rgb *theme_menu_hilite_color;
|
color_rgb *theme_menu_hilite_color;
|
||||||
/* style settings - fonts */
|
/* style settings - fonts */
|
||||||
int theme_winfont_height;
|
gint theme_winfont_height;
|
||||||
ObFont *theme_winfont;
|
RrFont *theme_winfont;
|
||||||
gboolean theme_winfont_shadow;
|
gboolean theme_winfont_shadow;
|
||||||
int theme_winfont_shadow_offset;
|
gint theme_winfont_shadow_offset;
|
||||||
int theme_winfont_shadow_tint;
|
gint theme_winfont_shadow_tint;
|
||||||
int theme_mtitlefont_height;
|
gint theme_mtitlefont_height;
|
||||||
ObFont *theme_mtitlefont;
|
RrFont *theme_mtitlefont;
|
||||||
gboolean theme_mtitlefont_shadow;
|
gboolean theme_mtitlefont_shadow;
|
||||||
int theme_mtitlefont_shadow_offset;
|
gint theme_mtitlefont_shadow_offset;
|
||||||
int theme_mtitlefont_shadow_tint;
|
gint theme_mtitlefont_shadow_tint;
|
||||||
int theme_mfont_height;
|
gint theme_mfont_height;
|
||||||
ObFont *theme_mfont;
|
RrFont *theme_mfont;
|
||||||
gboolean theme_mfont_shadow;
|
gboolean theme_mfont_shadow;
|
||||||
int theme_mfont_shadow_offset;
|
gint theme_mfont_shadow_offset;
|
||||||
int theme_mfont_shadow_tint;
|
gint theme_mfont_shadow_tint;
|
||||||
/* style settings - title layout */
|
/* style settings - title layout */
|
||||||
char *theme_title_layout;
|
gchar *theme_title_layout;
|
||||||
/* style settings - masks */
|
/* style settings - masks */
|
||||||
pixmap_mask *theme_max_set_mask;
|
RrPixmapMask *theme_max_set_mask;
|
||||||
pixmap_mask *theme_max_unset_mask;
|
RrPixmapMask *theme_max_unset_mask;
|
||||||
pixmap_mask *theme_iconify_mask;
|
RrPixmapMask *theme_iconify_mask;
|
||||||
pixmap_mask *theme_desk_set_mask;
|
RrPixmapMask *theme_desk_set_mask;
|
||||||
pixmap_mask *theme_desk_unset_mask;
|
RrPixmapMask *theme_desk_unset_mask;
|
||||||
pixmap_mask *theme_shade_set_mask;
|
RrPixmapMask *theme_shade_set_mask;
|
||||||
pixmap_mask *theme_shade_unset_mask;
|
RrPixmapMask *theme_shade_unset_mask;
|
||||||
pixmap_mask *theme_close_mask;
|
RrPixmapMask *theme_close_mask;
|
||||||
|
|
||||||
/* global appearances */
|
/* global appearances */
|
||||||
Appearance *theme_a_focused_unpressed_max;
|
RrAppearance *theme_a_focused_unpressed_max;
|
||||||
Appearance *theme_a_focused_pressed_max;
|
RrAppearance *theme_a_focused_pressed_max;
|
||||||
Appearance *theme_a_focused_pressed_set_max;
|
RrAppearance *theme_a_focused_pressed_set_max;
|
||||||
Appearance *theme_a_unfocused_unpressed_max;
|
RrAppearance *theme_a_unfocused_unpressed_max;
|
||||||
Appearance *theme_a_unfocused_pressed_max;
|
RrAppearance *theme_a_unfocused_pressed_max;
|
||||||
Appearance *theme_a_unfocused_pressed_set_max;
|
RrAppearance *theme_a_unfocused_pressed_set_max;
|
||||||
Appearance *theme_a_focused_unpressed_close;
|
RrAppearance *theme_a_focused_unpressed_close;
|
||||||
Appearance *theme_a_focused_pressed_close;
|
RrAppearance *theme_a_focused_pressed_close;
|
||||||
Appearance *theme_a_unfocused_unpressed_close;
|
RrAppearance *theme_a_unfocused_unpressed_close;
|
||||||
Appearance *theme_a_unfocused_pressed_close;
|
RrAppearance *theme_a_unfocused_pressed_close;
|
||||||
Appearance *theme_a_focused_unpressed_desk;
|
RrAppearance *theme_a_focused_unpressed_desk;
|
||||||
Appearance *theme_a_focused_pressed_desk;
|
RrAppearance *theme_a_focused_pressed_desk;
|
||||||
Appearance *theme_a_focused_pressed_set_desk;
|
RrAppearance *theme_a_focused_pressed_set_desk;
|
||||||
Appearance *theme_a_unfocused_unpressed_desk;
|
RrAppearance *theme_a_unfocused_unpressed_desk;
|
||||||
Appearance *theme_a_unfocused_pressed_desk;
|
RrAppearance *theme_a_unfocused_pressed_desk;
|
||||||
Appearance *theme_a_unfocused_pressed_set_desk;
|
RrAppearance *theme_a_unfocused_pressed_set_desk;
|
||||||
Appearance *theme_a_focused_unpressed_shade;
|
RrAppearance *theme_a_focused_unpressed_shade;
|
||||||
Appearance *theme_a_focused_pressed_shade;
|
RrAppearance *theme_a_focused_pressed_shade;
|
||||||
Appearance *theme_a_focused_pressed_set_shade;
|
RrAppearance *theme_a_focused_pressed_set_shade;
|
||||||
Appearance *theme_a_unfocused_unpressed_shade;
|
RrAppearance *theme_a_unfocused_unpressed_shade;
|
||||||
Appearance *theme_a_unfocused_pressed_shade;
|
RrAppearance *theme_a_unfocused_pressed_shade;
|
||||||
Appearance *theme_a_unfocused_pressed_set_shade;
|
RrAppearance *theme_a_unfocused_pressed_set_shade;
|
||||||
Appearance *theme_a_focused_unpressed_iconify;
|
RrAppearance *theme_a_focused_unpressed_iconify;
|
||||||
Appearance *theme_a_focused_pressed_iconify;
|
RrAppearance *theme_a_focused_pressed_iconify;
|
||||||
Appearance *theme_a_unfocused_unpressed_iconify;
|
RrAppearance *theme_a_unfocused_unpressed_iconify;
|
||||||
Appearance *theme_a_unfocused_pressed_iconify;
|
RrAppearance *theme_a_unfocused_pressed_iconify;
|
||||||
Appearance *theme_a_focused_grip;
|
RrAppearance *theme_a_focused_grip;
|
||||||
Appearance *theme_a_unfocused_grip;
|
RrAppearance *theme_a_unfocused_grip;
|
||||||
Appearance *theme_a_focused_title;
|
RrAppearance *theme_a_focused_title;
|
||||||
Appearance *theme_a_unfocused_title;
|
RrAppearance *theme_a_unfocused_title;
|
||||||
Appearance *theme_a_focused_label;
|
RrAppearance *theme_a_focused_label;
|
||||||
Appearance *theme_a_unfocused_label;
|
RrAppearance *theme_a_unfocused_label;
|
||||||
Appearance *theme_a_icon; /* always parentrelative, so no focused/unfocused */
|
RrAppearance *theme_a_icon; /* always parentrelative, so no focused/unfocused */
|
||||||
Appearance *theme_a_focused_handle;
|
RrAppearance *theme_a_focused_handle;
|
||||||
Appearance *theme_a_unfocused_handle;
|
RrAppearance *theme_a_unfocused_handle;
|
||||||
Appearance *theme_a_menu_title;
|
RrAppearance *theme_a_menu_title;
|
||||||
Appearance *theme_a_menu;
|
RrAppearance *theme_a_menu;
|
||||||
Appearance *theme_a_menu_item;
|
RrAppearance *theme_a_menu_item;
|
||||||
Appearance *theme_a_menu_disabled;
|
RrAppearance *theme_a_menu_disabled;
|
||||||
Appearance *theme_a_menu_hilite;
|
RrAppearance *theme_a_menu_hilite;
|
||||||
|
|
||||||
Appearance *theme_app_hilite_bg;
|
RrAppearance *theme_app_hilite_bg;
|
||||||
Appearance *theme_app_unhilite_bg;
|
RrAppearance *theme_app_unhilite_bg;
|
||||||
Appearance *theme_app_hilite_label;
|
RrAppearance *theme_app_hilite_label;
|
||||||
Appearance *theme_app_unhilite_label;
|
RrAppearance *theme_app_unhilite_label;
|
||||||
Appearance *theme_app_icon;
|
RrAppearance *theme_app_icon;
|
||||||
|
|
||||||
void theme_startup()
|
static const RrInstance *theme_inst = NULL;
|
||||||
|
|
||||||
|
void theme_startup(const RrInstance *inst)
|
||||||
{
|
{
|
||||||
|
theme_inst = inst;
|
||||||
|
|
||||||
theme_b_color = theme_cb_unfocused_color = theme_cb_focused_color =
|
theme_b_color = theme_cb_unfocused_color = theme_cb_focused_color =
|
||||||
theme_title_unfocused_color = theme_title_focused_color =
|
theme_title_unfocused_color = theme_title_focused_color =
|
||||||
theme_titlebut_unfocused_color = theme_titlebut_focused_color =
|
theme_titlebut_unfocused_color = theme_titlebut_focused_color =
|
||||||
|
@ -113,12 +117,12 @@ void theme_startup()
|
||||||
theme_shade_set_mask = theme_shade_unset_mask = NULL;
|
theme_shade_set_mask = theme_shade_unset_mask = NULL;
|
||||||
theme_iconify_mask = theme_close_mask = NULL;
|
theme_iconify_mask = theme_close_mask = NULL;
|
||||||
|
|
||||||
theme_a_focused_unpressed_max = appearance_new(1);
|
theme_a_focused_unpressed_max = RrAppearanceNew(inst, 1);
|
||||||
theme_a_focused_pressed_max = appearance_new(1);
|
theme_a_focused_pressed_max = RrAppearanceNew(inst, 1);
|
||||||
theme_a_focused_pressed_set_max = appearance_new(1);
|
theme_a_focused_pressed_set_max = RrAppearanceNew(inst, 1);
|
||||||
theme_a_unfocused_unpressed_max = appearance_new(1);
|
theme_a_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
|
||||||
theme_a_unfocused_pressed_max = appearance_new(1);
|
theme_a_unfocused_pressed_max = RrAppearanceNew(inst, 1);
|
||||||
theme_a_unfocused_pressed_set_max = appearance_new(1);
|
theme_a_unfocused_pressed_set_max = RrAppearanceNew(inst, 1);
|
||||||
theme_a_focused_unpressed_close = NULL;
|
theme_a_focused_unpressed_close = NULL;
|
||||||
theme_a_focused_pressed_close = NULL;
|
theme_a_focused_pressed_close = NULL;
|
||||||
theme_a_unfocused_unpressed_close = NULL;
|
theme_a_unfocused_unpressed_close = NULL;
|
||||||
|
@ -139,51 +143,51 @@ void theme_startup()
|
||||||
theme_a_focused_pressed_iconify = NULL;
|
theme_a_focused_pressed_iconify = NULL;
|
||||||
theme_a_unfocused_unpressed_iconify = NULL;
|
theme_a_unfocused_unpressed_iconify = NULL;
|
||||||
theme_a_unfocused_pressed_iconify = NULL;
|
theme_a_unfocused_pressed_iconify = NULL;
|
||||||
theme_a_focused_grip = appearance_new(0);
|
theme_a_focused_grip = RrAppearanceNew(inst, 0);
|
||||||
theme_a_unfocused_grip = appearance_new(0);
|
theme_a_unfocused_grip = RrAppearanceNew(inst, 0);
|
||||||
theme_a_focused_title = appearance_new(0);
|
theme_a_focused_title = RrAppearanceNew(inst, 0);
|
||||||
theme_a_unfocused_title = appearance_new(0);
|
theme_a_unfocused_title = RrAppearanceNew(inst, 0);
|
||||||
theme_a_focused_label = appearance_new(1);
|
theme_a_focused_label = RrAppearanceNew(inst, 1);
|
||||||
theme_a_unfocused_label = appearance_new(1);
|
theme_a_unfocused_label = RrAppearanceNew(inst, 1);
|
||||||
theme_a_icon = appearance_new(1);
|
theme_a_icon = RrAppearanceNew(inst, 1);
|
||||||
theme_a_focused_handle = appearance_new(0);
|
theme_a_focused_handle = RrAppearanceNew(inst, 0);
|
||||||
theme_a_unfocused_handle = appearance_new(0);
|
theme_a_unfocused_handle = RrAppearanceNew(inst, 0);
|
||||||
theme_a_menu = appearance_new(0);
|
theme_a_menu = RrAppearanceNew(inst, 0);
|
||||||
theme_a_menu_title = appearance_new(1);
|
theme_a_menu_title = RrAppearanceNew(inst, 1);
|
||||||
theme_a_menu_item = appearance_new(1);
|
theme_a_menu_item = RrAppearanceNew(inst, 1);
|
||||||
theme_a_menu_disabled = appearance_new(1);
|
theme_a_menu_disabled = RrAppearanceNew(inst, 1);
|
||||||
theme_a_menu_hilite = appearance_new(1);
|
theme_a_menu_hilite = RrAppearanceNew(inst, 1);
|
||||||
|
|
||||||
theme_app_hilite_bg = appearance_new(0);
|
theme_app_hilite_bg = RrAppearanceNew(inst, 0);
|
||||||
theme_app_unhilite_bg = appearance_new(0);
|
theme_app_unhilite_bg = RrAppearanceNew(inst, 0);
|
||||||
theme_app_hilite_label = appearance_new(1);
|
theme_app_hilite_label = RrAppearanceNew(inst, 1);
|
||||||
theme_app_unhilite_label = appearance_new(1);
|
theme_app_unhilite_label = RrAppearanceNew(inst, 1);
|
||||||
theme_app_icon = appearance_new(1);
|
theme_app_icon = RrAppearanceNew(inst, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void theme_shutdown()
|
void theme_shutdown()
|
||||||
{
|
{
|
||||||
color_free(theme_b_color);
|
RrColorFree(theme_b_color);
|
||||||
color_free(theme_cb_unfocused_color);
|
RrColorFree(theme_cb_unfocused_color);
|
||||||
color_free(theme_cb_focused_color);
|
RrColorFree(theme_cb_focused_color);
|
||||||
color_free(theme_title_unfocused_color);
|
RrColorFree(theme_title_unfocused_color);
|
||||||
color_free(theme_title_focused_color);
|
RrColorFree(theme_title_focused_color);
|
||||||
color_free(theme_titlebut_unfocused_color);
|
RrColorFree(theme_titlebut_unfocused_color);
|
||||||
color_free(theme_titlebut_focused_color);
|
RrColorFree(theme_titlebut_focused_color);
|
||||||
color_free(theme_menu_color);
|
RrColorFree(theme_menu_color);
|
||||||
color_free(theme_menu_title_color);
|
RrColorFree(theme_menu_title_color);
|
||||||
color_free(theme_menu_disabled_color);
|
RrColorFree(theme_menu_disabled_color);
|
||||||
color_free(theme_menu_hilite_color);
|
RrColorFree(theme_menu_hilite_color);
|
||||||
|
|
||||||
pixmap_mask_free(theme_max_set_mask);
|
RrPixmapMaskFree(theme_max_set_mask);
|
||||||
pixmap_mask_free(theme_max_unset_mask);
|
RrPixmapMaskFree(theme_max_unset_mask);
|
||||||
pixmap_mask_free(theme_desk_set_mask);
|
RrPixmapMaskFree(theme_desk_set_mask);
|
||||||
pixmap_mask_free(theme_desk_unset_mask);
|
RrPixmapMaskFree(theme_desk_unset_mask);
|
||||||
pixmap_mask_free(theme_shade_set_mask);
|
RrPixmapMaskFree(theme_shade_set_mask);
|
||||||
pixmap_mask_free(theme_shade_unset_mask);
|
RrPixmapMaskFree(theme_shade_unset_mask);
|
||||||
pixmap_mask_free(theme_iconify_mask);
|
RrPixmapMaskFree(theme_iconify_mask);
|
||||||
pixmap_mask_free(theme_close_mask);
|
RrPixmapMaskFree(theme_close_mask);
|
||||||
|
|
||||||
font_close(theme_winfont);
|
font_close(theme_winfont);
|
||||||
font_close(theme_mtitlefont);
|
font_close(theme_mtitlefont);
|
||||||
|
@ -191,47 +195,47 @@ void theme_shutdown()
|
||||||
|
|
||||||
g_free(theme_title_layout);
|
g_free(theme_title_layout);
|
||||||
|
|
||||||
appearance_free(theme_a_focused_unpressed_max);
|
RrAppearanceFree(theme_a_focused_unpressed_max);
|
||||||
appearance_free(theme_a_focused_pressed_max);
|
RrAppearanceFree(theme_a_focused_pressed_max);
|
||||||
appearance_free(theme_a_focused_pressed_set_max);
|
RrAppearanceFree(theme_a_focused_pressed_set_max);
|
||||||
appearance_free(theme_a_unfocused_unpressed_max);
|
RrAppearanceFree(theme_a_unfocused_unpressed_max);
|
||||||
appearance_free(theme_a_unfocused_pressed_max);
|
RrAppearanceFree(theme_a_unfocused_pressed_max);
|
||||||
appearance_free(theme_a_unfocused_pressed_set_max);
|
RrAppearanceFree(theme_a_unfocused_pressed_set_max);
|
||||||
appearance_free(theme_a_focused_unpressed_close);
|
RrAppearanceFree(theme_a_focused_unpressed_close);
|
||||||
appearance_free(theme_a_focused_pressed_close);
|
RrAppearanceFree(theme_a_focused_pressed_close);
|
||||||
appearance_free(theme_a_unfocused_unpressed_close);
|
RrAppearanceFree(theme_a_unfocused_unpressed_close);
|
||||||
appearance_free(theme_a_unfocused_pressed_close);
|
RrAppearanceFree(theme_a_unfocused_pressed_close);
|
||||||
appearance_free(theme_a_focused_unpressed_desk);
|
RrAppearanceFree(theme_a_focused_unpressed_desk);
|
||||||
appearance_free(theme_a_focused_pressed_desk);
|
RrAppearanceFree(theme_a_focused_pressed_desk);
|
||||||
appearance_free(theme_a_unfocused_unpressed_desk);
|
RrAppearanceFree(theme_a_unfocused_unpressed_desk);
|
||||||
appearance_free(theme_a_unfocused_pressed_desk);
|
RrAppearanceFree(theme_a_unfocused_pressed_desk);
|
||||||
appearance_free(theme_a_focused_unpressed_shade);
|
RrAppearanceFree(theme_a_focused_unpressed_shade);
|
||||||
appearance_free(theme_a_focused_pressed_shade);
|
RrAppearanceFree(theme_a_focused_pressed_shade);
|
||||||
appearance_free(theme_a_unfocused_unpressed_shade);
|
RrAppearanceFree(theme_a_unfocused_unpressed_shade);
|
||||||
appearance_free(theme_a_unfocused_pressed_shade);
|
RrAppearanceFree(theme_a_unfocused_pressed_shade);
|
||||||
appearance_free(theme_a_focused_unpressed_iconify);
|
RrAppearanceFree(theme_a_focused_unpressed_iconify);
|
||||||
appearance_free(theme_a_focused_pressed_iconify);
|
RrAppearanceFree(theme_a_focused_pressed_iconify);
|
||||||
appearance_free(theme_a_unfocused_unpressed_iconify);
|
RrAppearanceFree(theme_a_unfocused_unpressed_iconify);
|
||||||
appearance_free(theme_a_unfocused_pressed_iconify);
|
RrAppearanceFree(theme_a_unfocused_pressed_iconify);
|
||||||
appearance_free(theme_a_focused_grip);
|
RrAppearanceFree(theme_a_focused_grip);
|
||||||
appearance_free(theme_a_unfocused_grip);
|
RrAppearanceFree(theme_a_unfocused_grip);
|
||||||
appearance_free(theme_a_focused_title);
|
RrAppearanceFree(theme_a_focused_title);
|
||||||
appearance_free(theme_a_unfocused_title);
|
RrAppearanceFree(theme_a_unfocused_title);
|
||||||
appearance_free(theme_a_focused_label);
|
RrAppearanceFree(theme_a_focused_label);
|
||||||
appearance_free(theme_a_unfocused_label);
|
RrAppearanceFree(theme_a_unfocused_label);
|
||||||
appearance_free(theme_a_icon);
|
RrAppearanceFree(theme_a_icon);
|
||||||
appearance_free(theme_a_focused_handle);
|
RrAppearanceFree(theme_a_focused_handle);
|
||||||
appearance_free(theme_a_unfocused_handle);
|
RrAppearanceFree(theme_a_unfocused_handle);
|
||||||
appearance_free(theme_a_menu);
|
RrAppearanceFree(theme_a_menu);
|
||||||
appearance_free(theme_a_menu_title);
|
RrAppearanceFree(theme_a_menu_title);
|
||||||
appearance_free(theme_a_menu_item);
|
RrAppearanceFree(theme_a_menu_item);
|
||||||
appearance_free(theme_a_menu_disabled);
|
RrAppearanceFree(theme_a_menu_disabled);
|
||||||
appearance_free(theme_a_menu_hilite);
|
RrAppearanceFree(theme_a_menu_hilite);
|
||||||
appearance_free(theme_app_hilite_bg);
|
RrAppearanceFree(theme_app_hilite_bg);
|
||||||
appearance_free(theme_app_unhilite_bg);
|
RrAppearanceFree(theme_app_unhilite_bg);
|
||||||
appearance_free(theme_app_hilite_label);
|
RrAppearanceFree(theme_app_hilite_label);
|
||||||
appearance_free(theme_app_unhilite_label);
|
RrAppearanceFree(theme_app_unhilite_label);
|
||||||
appearance_free(theme_app_icon);
|
RrAppearanceFree(theme_app_icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
static XrmDatabase loaddb(char *theme)
|
static XrmDatabase loaddb(char *theme)
|
||||||
|
@ -303,7 +307,8 @@ static gboolean read_string(XrmDatabase db, char *rname, char **value)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean read_color(XrmDatabase db, char *rname, color_rgb **value)
|
static gboolean read_color(XrmDatabase db, const RrInstance *inst,
|
||||||
|
gchar *rname, color_rgb **value)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
char *rclass = create_class_name(rname);
|
char *rclass = create_class_name(rname);
|
||||||
|
@ -312,7 +317,7 @@ static gboolean read_color(XrmDatabase db, char *rname, color_rgb **value)
|
||||||
|
|
||||||
if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
|
if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
|
||||||
retvalue.addr != NULL) {
|
retvalue.addr != NULL) {
|
||||||
color_rgb *c = color_parse(retvalue.addr);
|
color_rgb *c = RrColorParse(inst, retvalue.addr);
|
||||||
if (c != NULL) {
|
if (c != NULL) {
|
||||||
*value = c;
|
*value = c;
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
@ -323,8 +328,9 @@ static gboolean read_color(XrmDatabase db, char *rname, color_rgb **value)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean read_mask(XrmDatabase db, char *rname, char *theme,
|
static gboolean read_mask(XrmDatabase db, const RrInstance *inst,
|
||||||
pixmap_mask **value)
|
gchar *rname, gchar *theme,
|
||||||
|
RrPixmapMask **value)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
char *rclass = create_class_name(rname);
|
char *rclass = create_class_name(rname);
|
||||||
|
@ -369,7 +375,7 @@ static gboolean read_mask(XrmDatabase db, char *rname, char *theme,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
*value = pixmap_mask_new(w, h, (char*)b);
|
*value = RrPixmapMaskNew(inst, w, h, (char*)b);
|
||||||
XFree(b);
|
XFree(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,8 +387,8 @@ static gboolean read_mask(XrmDatabase db, char *rname, char *theme,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_appearance(char *tex, SurfaceColorType *grad,
|
static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
|
||||||
ReliefType *relief, BevelType *bevel,
|
RrReliefType *relief, RrBevelType *bevel,
|
||||||
gboolean *interlaced, gboolean *border)
|
gboolean *interlaced, gboolean *border)
|
||||||
{
|
{
|
||||||
char *t;
|
char *t;
|
||||||
|
@ -392,45 +398,45 @@ static void parse_appearance(char *tex, SurfaceColorType *grad,
|
||||||
*t = g_ascii_tolower(*t);
|
*t = g_ascii_tolower(*t);
|
||||||
|
|
||||||
if (strstr(tex, "parentrelative") != NULL) {
|
if (strstr(tex, "parentrelative") != NULL) {
|
||||||
*grad = Background_ParentRelative;
|
*grad = RR_SURFACE_PARENTREL;
|
||||||
} else {
|
} else {
|
||||||
if (strstr(tex, "gradient") != NULL) {
|
if (strstr(tex, "gradient") != NULL) {
|
||||||
if (strstr(tex, "crossdiagonal") != NULL)
|
if (strstr(tex, "crossdiagonal") != NULL)
|
||||||
*grad = Background_CrossDiagonal;
|
*grad = RR_SURFACE_CROSS_DIAGONAL;
|
||||||
else if (strstr(tex, "rectangle") != NULL)
|
else if (strstr(tex, "rectangle") != NULL)
|
||||||
*grad = Background_Rectangle;
|
*grad = RR_SURFACE_RECTANGLE;
|
||||||
else if (strstr(tex, "pyramid") != NULL)
|
else if (strstr(tex, "pyramid") != NULL)
|
||||||
*grad = Background_Pyramid;
|
*grad = RR_SURFACE_PYRAMID;
|
||||||
else if (strstr(tex, "pipecross") != NULL)
|
else if (strstr(tex, "pipecross") != NULL)
|
||||||
*grad = Background_PipeCross;
|
*grad = RR_SURFACE_PIPECROSS;
|
||||||
else if (strstr(tex, "elliptic") != NULL)
|
else if (strstr(tex, "elliptic") != NULL)
|
||||||
*grad = Background_Rectangle;
|
*grad = RR_SURFACE_PIPECROSS;
|
||||||
else if (strstr(tex, "horizontal") != NULL)
|
else if (strstr(tex, "horizontal") != NULL)
|
||||||
*grad = Background_Horizontal;
|
*grad = RR_SURFACE_HORIZONTAL;
|
||||||
else if (strstr(tex, "vertical") != NULL)
|
else if (strstr(tex, "vertical") != NULL)
|
||||||
*grad = Background_Vertical;
|
*grad = RR_SURFACE_VERTICAL;
|
||||||
else
|
else
|
||||||
*grad = Background_Diagonal;
|
*grad = RR_SURFACE_DIAGONAL;
|
||||||
} else {
|
} else {
|
||||||
*grad = Background_Solid;
|
*grad = RR_SURFACE_SOLID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strstr(tex, "sunken") != NULL)
|
if (strstr(tex, "sunken") != NULL)
|
||||||
*relief = Sunken;
|
*relief = RR_RELIEF_SUNKEN;
|
||||||
else if (strstr(tex, "flat") != NULL)
|
else if (strstr(tex, "flat") != NULL)
|
||||||
*relief = Flat;
|
*relief = RR_RELIEF_FLAT;
|
||||||
else
|
else
|
||||||
*relief = Raised;
|
*relief = RR_RELIEF_RAISED;
|
||||||
|
|
||||||
*border = FALSE;
|
*border = FALSE;
|
||||||
if (*relief == Flat) {
|
if (*relief == RR_RELIEF_FLAT) {
|
||||||
if (strstr(tex, "border") != NULL)
|
if (strstr(tex, "border") != NULL)
|
||||||
*border = TRUE;
|
*border = TRUE;
|
||||||
} else {
|
} else {
|
||||||
if (strstr(tex, "bevel2") != NULL)
|
if (strstr(tex, "bevel2") != NULL)
|
||||||
*bevel = Bevel2;
|
*bevel = RR_BEVEL_2;
|
||||||
else
|
else
|
||||||
*bevel = Bevel1;
|
*bevel = RR_BEVEL_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strstr(tex, "interlaced") != NULL)
|
if (strstr(tex, "interlaced") != NULL)
|
||||||
|
@ -441,7 +447,8 @@ static void parse_appearance(char *tex, SurfaceColorType *grad,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean read_appearance(XrmDatabase db, char *rname, Appearance *value)
|
static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
|
||||||
|
gchar *rname, RrAppearance *value)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
char *rclass = create_class_name(rname), *cname, *ctoname, *bcname;
|
char *rclass = create_class_name(rname), *cname, *ctoname, *bcname;
|
||||||
|
@ -460,14 +467,14 @@ static gboolean read_appearance(XrmDatabase db, char *rname, Appearance *value)
|
||||||
&value->surface.bevel,
|
&value->surface.bevel,
|
||||||
&value->surface.interlaced,
|
&value->surface.interlaced,
|
||||||
&value->surface.border);
|
&value->surface.border);
|
||||||
if (!read_color(db, cname, &value->surface.primary))
|
if (!read_color(db, inst, cname, &value->surface.primary))
|
||||||
value->surface.primary = color_new(0, 0, 0);
|
value->surface.primary = RrColorNew(inst, 0, 0, 0);
|
||||||
if (!read_color(db, ctoname, &value->surface.secondary))
|
if (!read_color(db, inst, ctoname, &value->surface.secondary))
|
||||||
value->surface.secondary = color_new(0, 0, 0);
|
value->surface.secondary = RrColorNew(inst, 0, 0, 0);
|
||||||
if (value->surface.border)
|
if (value->surface.border)
|
||||||
if (!read_color(db, bcname,
|
if (!read_color(db, inst, bcname,
|
||||||
&value->surface.border_color))
|
&value->surface.border_color))
|
||||||
value->surface.border_color = color_new(0, 0, 0);
|
value->surface.border_color = RrColorNew(inst, 0, 0, 0);
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,24 +485,25 @@ static gboolean read_appearance(XrmDatabase db, char *rname, Appearance *value)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_default_appearance(Appearance *a)
|
static void set_default_appearance(RrAppearance *a)
|
||||||
{
|
{
|
||||||
a->surface.grad = Background_Solid;
|
a->surface.grad = RR_SURFACE_SOLID;
|
||||||
a->surface.relief = Flat;
|
a->surface.relief = RR_RELIEF_FLAT;
|
||||||
a->surface.bevel = Bevel1;
|
a->surface.bevel = RR_BEVEL_1;
|
||||||
a->surface.interlaced = FALSE;
|
a->surface.interlaced = FALSE;
|
||||||
a->surface.border = FALSE;
|
a->surface.border = FALSE;
|
||||||
a->surface.primary = color_new(0, 0, 0);
|
a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
|
||||||
a->surface.secondary = color_new(0, 0, 0);
|
a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *theme_load(char *theme)
|
gchar *theme_load(gchar *theme)
|
||||||
{
|
{
|
||||||
XrmDatabase db = NULL;
|
XrmDatabase db = NULL;
|
||||||
char *loaded = NULL;
|
gchar *loaded = NULL;
|
||||||
Justify winjust, mtitlejust, mjust;
|
RrJustify winjust, mtitlejust, mjust;
|
||||||
char *str;
|
gchar *str;
|
||||||
char *font_str;
|
gchar *font_str;
|
||||||
|
const RrInstance *inst = theme_inst;
|
||||||
|
|
||||||
if (theme) {
|
if (theme) {
|
||||||
db = loaddb(theme);
|
db = loaddb(theme);
|
||||||
|
@ -536,12 +544,12 @@ char *theme_load(char *theme)
|
||||||
theme_winfont_height = font_height(theme_winfont, theme_winfont_shadow,
|
theme_winfont_height = font_height(theme_winfont, theme_winfont_shadow,
|
||||||
theme_winfont_shadow_offset);
|
theme_winfont_shadow_offset);
|
||||||
|
|
||||||
winjust = Justify_Left;
|
winjust = RR_JUSTIFY_LEFT;
|
||||||
if (read_string(db, "window.justify", &str)) {
|
if (read_string(db, "window.justify", &str)) {
|
||||||
if (!g_ascii_strcasecmp(str, "right"))
|
if (!g_ascii_strcasecmp(str, "right"))
|
||||||
winjust = Justify_Right;
|
winjust = RR_JUSTIFY_RIGHT;
|
||||||
else if (!g_ascii_strcasecmp(str, "center"))
|
else if (!g_ascii_strcasecmp(str, "center"))
|
||||||
winjust = Justify_Center;
|
winjust = RR_JUSTIFY_CENTER;
|
||||||
g_free(str);
|
g_free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,12 +576,12 @@ char *theme_load(char *theme)
|
||||||
theme_mtitlefont_shadow,
|
theme_mtitlefont_shadow,
|
||||||
theme_mtitlefont_shadow_offset);
|
theme_mtitlefont_shadow_offset);
|
||||||
|
|
||||||
mtitlejust = Justify_Left;
|
mtitlejust = RR_JUSTIFY_LEFT;
|
||||||
if (read_string(db, "menu.title.justify", &str)) {
|
if (read_string(db, "menu.title.justify", &str)) {
|
||||||
if (!g_ascii_strcasecmp(str, "right"))
|
if (!g_ascii_strcasecmp(str, "right"))
|
||||||
mtitlejust = Justify_Right;
|
mtitlejust = RR_JUSTIFY_RIGHT;
|
||||||
else if (!g_ascii_strcasecmp(str, "center"))
|
else if (!g_ascii_strcasecmp(str, "center"))
|
||||||
mtitlejust = Justify_Center;
|
mtitlejust = RR_JUSTIFY_CENTER;
|
||||||
g_free(str);
|
g_free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,12 +607,12 @@ char *theme_load(char *theme)
|
||||||
theme_mfont_height = font_height(theme_mfont, theme_mfont_shadow,
|
theme_mfont_height = font_height(theme_mfont, theme_mfont_shadow,
|
||||||
theme_mfont_shadow_offset);
|
theme_mfont_shadow_offset);
|
||||||
|
|
||||||
mjust = Justify_Left;
|
mjust = RR_JUSTIFY_LEFT;
|
||||||
if (read_string(db, "menu.frame.justify", &str)) {
|
if (read_string(db, "menu.frame.justify", &str)) {
|
||||||
if (!g_ascii_strcasecmp(str, "right"))
|
if (!g_ascii_strcasecmp(str, "right"))
|
||||||
mjust = Justify_Right;
|
mjust = RR_JUSTIFY_RIGHT;
|
||||||
else if (!g_ascii_strcasecmp(str, "center"))
|
else if (!g_ascii_strcasecmp(str, "center"))
|
||||||
mjust = Justify_Center;
|
mjust = RR_JUSTIFY_CENTER;
|
||||||
g_free(str);
|
g_free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,201 +630,237 @@ char *theme_load(char *theme)
|
||||||
theme_cbwidth < 0 || theme_cbwidth > 100) theme_cbwidth = theme_bevel;
|
theme_cbwidth < 0 || theme_cbwidth > 100) theme_cbwidth = theme_bevel;
|
||||||
|
|
||||||
/* load colors */
|
/* load colors */
|
||||||
if (!read_color(db, "borderColor", &theme_b_color))
|
if (!read_color(db, inst,
|
||||||
theme_b_color = color_new(0, 0, 0);
|
"borderColor", &theme_b_color))
|
||||||
if (!read_color(db, "window.frame.focusColor", &theme_cb_focused_color))
|
theme_b_color = RrColorNew(inst, 0, 0, 0);
|
||||||
theme_cb_focused_color = color_new(0xff, 0xff, 0xff);
|
if (!read_color(db, inst,
|
||||||
if (!read_color(db, "window.frame.unfocusColor",&theme_cb_unfocused_color))
|
"window.frame.focusColor", &theme_cb_focused_color))
|
||||||
theme_cb_unfocused_color = color_new(0xff, 0xff, 0xff);
|
theme_cb_focused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
|
||||||
if (!read_color(db, "window.label.focus.textColor",
|
if (!read_color(db, inst,
|
||||||
|
"window.frame.unfocusColor",&theme_cb_unfocused_color))
|
||||||
|
theme_cb_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
|
||||||
|
if (!read_color(db, inst,
|
||||||
|
"window.label.focus.textColor",
|
||||||
&theme_title_focused_color))
|
&theme_title_focused_color))
|
||||||
theme_title_focused_color = color_new(0x0, 0x0, 0x0);
|
theme_title_focused_color = RrColorNew(inst, 0x0, 0x0, 0x0);
|
||||||
if (!read_color(db, "window.label.unfocus.textColor",
|
if (!read_color(db, inst,
|
||||||
|
"window.label.unfocus.textColor",
|
||||||
&theme_title_unfocused_color))
|
&theme_title_unfocused_color))
|
||||||
theme_title_unfocused_color = color_new(0xff, 0xff, 0xff);
|
theme_title_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
|
||||||
if (!read_color(db, "window.button.focus.picColor",
|
if (!read_color(db, inst,
|
||||||
|
"window.button.focus.picColor",
|
||||||
&theme_titlebut_focused_color))
|
&theme_titlebut_focused_color))
|
||||||
theme_titlebut_focused_color = color_new(0, 0, 0);
|
theme_titlebut_focused_color = RrColorNew(inst, 0, 0, 0);
|
||||||
if (!read_color(db, "window.button.unfocus.picColor",
|
if (!read_color(db, inst,
|
||||||
|
"window.button.unfocus.picColor",
|
||||||
&theme_titlebut_unfocused_color))
|
&theme_titlebut_unfocused_color))
|
||||||
theme_titlebut_unfocused_color = color_new(0xff, 0xff, 0xff);
|
theme_titlebut_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
|
||||||
if (!read_color(db, "menu.title.textColor", &theme_menu_title_color))
|
if (!read_color(db, inst,
|
||||||
theme_menu_title_color = color_new(0, 0, 0);
|
"menu.title.textColor", &theme_menu_title_color))
|
||||||
if (!read_color(db, "menu.frame.textColor", &theme_menu_color))
|
theme_menu_title_color = RrColorNew(inst, 0, 0, 0);
|
||||||
theme_menu_color = color_new(0xff, 0xff, 0xff);
|
if (!read_color(db, inst,
|
||||||
if (!read_color(db, "menu.frame.disableColor", &theme_menu_disabled_color))
|
"menu.frame.textColor", &theme_menu_color))
|
||||||
theme_menu_disabled_color = color_new(0, 0, 0);
|
theme_menu_color = RrColorNew(inst, 0xff, 0xff, 0xff);
|
||||||
if (!read_color(db, "menu.hilite.textColor", &theme_menu_hilite_color))
|
if (!read_color(db, inst,
|
||||||
theme_menu_hilite_color = color_new(0, 0, 0);
|
"menu.frame.disableColor", &theme_menu_disabled_color))
|
||||||
|
theme_menu_disabled_color = RrColorNew(inst, 0, 0, 0);
|
||||||
|
if (!read_color(db, inst,
|
||||||
|
"menu.hilite.textColor", &theme_menu_hilite_color))
|
||||||
|
theme_menu_hilite_color = RrColorNew(inst, 0, 0, 0);
|
||||||
|
|
||||||
if (read_mask(db, "window.button.max.mask", theme, &theme_max_unset_mask)){
|
if (read_mask(db, inst,
|
||||||
if (!read_mask(db, "window.button.max.toggled.mask", theme,
|
"window.button.max.mask", theme, &theme_max_unset_mask)){
|
||||||
|
if (!read_mask(db, inst,
|
||||||
|
"window.button.max.toggled.mask", theme,
|
||||||
&theme_max_set_mask)) {
|
&theme_max_set_mask)) {
|
||||||
theme_max_set_mask = pixmap_mask_copy(theme_max_unset_mask);
|
theme_max_set_mask = RrPixmapMaskCopy(theme_max_unset_mask);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
{
|
{
|
||||||
char data[] = { 0x7f, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f };
|
char data[] = { 0x7f, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f };
|
||||||
theme_max_unset_mask = pixmap_mask_new(7, 7, data);
|
theme_max_unset_mask = RrPixmapMaskNew(inst, 7, 7, data);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
char data[] = { 0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
|
char data[] = { 0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
|
||||||
theme_max_set_mask = pixmap_mask_new(7, 7, data);
|
theme_max_set_mask = RrPixmapMaskNew(inst, 7, 7, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!read_mask(db, "window.button.icon.mask", theme,
|
if (!read_mask(db, inst,
|
||||||
|
"window.button.icon.mask", theme,
|
||||||
&theme_iconify_mask)) {
|
&theme_iconify_mask)) {
|
||||||
char data[] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x7f };
|
char data[] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x7f };
|
||||||
theme_iconify_mask = pixmap_mask_new(7, 7, data);
|
theme_iconify_mask = RrPixmapMaskNew(inst, 7, 7, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read_mask(db, "window.button.stick.mask", theme,
|
if (read_mask(db, inst,
|
||||||
|
"window.button.stick.mask", theme,
|
||||||
&theme_desk_unset_mask)) {
|
&theme_desk_unset_mask)) {
|
||||||
if (!read_mask(db, "window.button.stick.toggled.mask", theme,
|
if (!read_mask(db, inst, "window.button.stick.toggled.mask", theme,
|
||||||
&theme_desk_set_mask)) {
|
&theme_desk_set_mask)) {
|
||||||
theme_desk_set_mask =
|
theme_desk_set_mask =
|
||||||
pixmap_mask_copy(theme_desk_unset_mask);
|
RrPixmapMaskCopy(theme_desk_unset_mask);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
{
|
{
|
||||||
char data[] = { 0x63, 0x63, 0x00, 0x00, 0x00, 0x63, 0x63 };
|
char data[] = { 0x63, 0x63, 0x00, 0x00, 0x00, 0x63, 0x63 };
|
||||||
theme_desk_unset_mask = pixmap_mask_new(7, 7, data);
|
theme_desk_unset_mask = RrPixmapMaskNew(inst, 7, 7, data);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
char data[] = { 0x00, 0x36, 0x36, 0x08, 0x36, 0x36, 0x00 };
|
char data[] = { 0x00, 0x36, 0x36, 0x08, 0x36, 0x36, 0x00 };
|
||||||
theme_desk_set_mask = pixmap_mask_new(7, 7, data);
|
theme_desk_set_mask = RrPixmapMaskNew(inst, 7, 7, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read_mask(db, "window.button.shade.mask", theme,
|
if (read_mask(db, inst, "window.button.shade.mask", theme,
|
||||||
&theme_shade_unset_mask)) {
|
&theme_shade_unset_mask)) {
|
||||||
if (!read_mask(db, "window.button.shade.toggled.mask", theme,
|
if (!read_mask(db, inst, "window.button.shade.toggled.mask", theme,
|
||||||
&theme_shade_set_mask)) {
|
&theme_shade_set_mask)) {
|
||||||
theme_shade_set_mask =
|
theme_shade_set_mask =
|
||||||
pixmap_mask_copy(theme_shade_unset_mask);
|
RrPixmapMaskCopy(theme_shade_unset_mask);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
{
|
{
|
||||||
char data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00 };
|
char data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00 };
|
||||||
theme_shade_unset_mask = pixmap_mask_new(7, 7, data);
|
theme_shade_unset_mask = RrPixmapMaskNew(inst, 7, 7, data);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
char data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x7f };
|
char data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x7f };
|
||||||
theme_shade_set_mask = pixmap_mask_new(7, 7, data);
|
theme_shade_set_mask = RrPixmapMaskNew(inst, 7, 7, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!read_mask(db, "window.button.close.mask", theme,
|
if (!read_mask(db, inst, "window.button.close.mask", theme,
|
||||||
&theme_close_mask)) {
|
&theme_close_mask)) {
|
||||||
char data[] = { 0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63 };
|
char data[] = { 0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63 };
|
||||||
theme_close_mask = pixmap_mask_new(7, 7, data);
|
theme_close_mask = RrPixmapMaskNew(inst, 7, 7, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read the decoration textures */
|
/* read the decoration textures */
|
||||||
if (!read_appearance(db, "window.title.focus", theme_a_focused_title))
|
if (!read_appearance(db, inst,
|
||||||
|
"window.title.focus", theme_a_focused_title))
|
||||||
set_default_appearance(theme_a_focused_title);
|
set_default_appearance(theme_a_focused_title);
|
||||||
if (!read_appearance(db, "window.title.unfocus", theme_a_unfocused_title))
|
if (!read_appearance(db, inst,
|
||||||
|
"window.title.unfocus", theme_a_unfocused_title))
|
||||||
set_default_appearance(theme_a_unfocused_title);
|
set_default_appearance(theme_a_unfocused_title);
|
||||||
if (!read_appearance(db, "window.label.focus", theme_a_focused_label))
|
if (!read_appearance(db, inst,
|
||||||
|
"window.label.focus", theme_a_focused_label))
|
||||||
set_default_appearance(theme_a_focused_label);
|
set_default_appearance(theme_a_focused_label);
|
||||||
if (!read_appearance(db, "window.label.unfocus", theme_a_unfocused_label))
|
if (!read_appearance(db, inst,
|
||||||
|
"window.label.unfocus", theme_a_unfocused_label))
|
||||||
set_default_appearance(theme_a_unfocused_label);
|
set_default_appearance(theme_a_unfocused_label);
|
||||||
if (!read_appearance(db, "window.handle.focus", theme_a_focused_handle))
|
if (!read_appearance(db, inst,
|
||||||
|
"window.handle.focus", theme_a_focused_handle))
|
||||||
set_default_appearance(theme_a_focused_handle);
|
set_default_appearance(theme_a_focused_handle);
|
||||||
if (!read_appearance(db, "window.handle.unfocus",theme_a_unfocused_handle))
|
if (!read_appearance(db, inst,
|
||||||
|
"window.handle.unfocus",theme_a_unfocused_handle))
|
||||||
set_default_appearance(theme_a_unfocused_handle);
|
set_default_appearance(theme_a_unfocused_handle);
|
||||||
if (!read_appearance(db, "window.grip.focus", theme_a_focused_grip))
|
if (!read_appearance(db, inst,
|
||||||
|
"window.grip.focus", theme_a_focused_grip))
|
||||||
set_default_appearance(theme_a_focused_grip);
|
set_default_appearance(theme_a_focused_grip);
|
||||||
if (!read_appearance(db, "window.grip.unfocus", theme_a_unfocused_grip))
|
if (!read_appearance(db, inst,
|
||||||
|
"window.grip.unfocus", theme_a_unfocused_grip))
|
||||||
set_default_appearance(theme_a_unfocused_grip);
|
set_default_appearance(theme_a_unfocused_grip);
|
||||||
if (!read_appearance(db, "menu.frame", theme_a_menu))
|
if (!read_appearance(db, inst,
|
||||||
|
"menu.frame", theme_a_menu))
|
||||||
set_default_appearance(theme_a_menu);
|
set_default_appearance(theme_a_menu);
|
||||||
if (!read_appearance(db, "menu.title", theme_a_menu_title))
|
if (!read_appearance(db, inst,
|
||||||
|
"menu.title", theme_a_menu_title))
|
||||||
set_default_appearance(theme_a_menu_title);
|
set_default_appearance(theme_a_menu_title);
|
||||||
if (!read_appearance(db, "menu.hilite", theme_a_menu_hilite))
|
if (!read_appearance(db, inst,
|
||||||
|
"menu.hilite", theme_a_menu_hilite))
|
||||||
set_default_appearance(theme_a_menu_hilite);
|
set_default_appearance(theme_a_menu_hilite);
|
||||||
|
|
||||||
/* read the appearances for rendering non-decorations */
|
/* read the appearances for rendering non-decorations */
|
||||||
if (!read_appearance(db, "window.title.focus", theme_app_hilite_bg))
|
if (!read_appearance(db, inst,
|
||||||
|
"window.title.focus", theme_app_hilite_bg))
|
||||||
set_default_appearance(theme_app_hilite_bg);
|
set_default_appearance(theme_app_hilite_bg);
|
||||||
if (!read_appearance(db, "window.label.focus", theme_app_hilite_label))
|
if (!read_appearance(db, inst,
|
||||||
|
"window.label.focus", theme_app_hilite_label))
|
||||||
set_default_appearance(theme_app_hilite_label);
|
set_default_appearance(theme_app_hilite_label);
|
||||||
if (!read_appearance(db, "window.title.unfocus", theme_app_unhilite_bg))
|
if (!read_appearance(db, inst,
|
||||||
|
"window.title.unfocus", theme_app_unhilite_bg))
|
||||||
set_default_appearance(theme_app_unhilite_bg);
|
set_default_appearance(theme_app_unhilite_bg);
|
||||||
if (!read_appearance(db, "window.label.unfocus", theme_app_unhilite_label))
|
if (!read_appearance(db, inst,
|
||||||
|
"window.label.unfocus", theme_app_unhilite_label))
|
||||||
set_default_appearance(theme_app_unhilite_label);
|
set_default_appearance(theme_app_unhilite_label);
|
||||||
|
|
||||||
/* read buttons textures */
|
/* read buttons textures */
|
||||||
if (!read_appearance(db, "window.button.pressed.focus",
|
if (!read_appearance(db, inst,
|
||||||
|
"window.button.pressed.focus",
|
||||||
theme_a_focused_pressed_max))
|
theme_a_focused_pressed_max))
|
||||||
if (!read_appearance(db, "window.button.pressed",
|
if (!read_appearance(db, inst,
|
||||||
|
"window.button.pressed",
|
||||||
theme_a_focused_pressed_max))
|
theme_a_focused_pressed_max))
|
||||||
set_default_appearance(theme_a_focused_pressed_max);
|
set_default_appearance(theme_a_focused_pressed_max);
|
||||||
if (!read_appearance(db, "window.button.pressed.unfocus",
|
if (!read_appearance(db, inst,
|
||||||
|
"window.button.pressed.unfocus",
|
||||||
theme_a_unfocused_pressed_max))
|
theme_a_unfocused_pressed_max))
|
||||||
if (!read_appearance(db, "window.button.pressed",
|
if (!read_appearance(db, inst,
|
||||||
|
"window.button.pressed",
|
||||||
theme_a_unfocused_pressed_max))
|
theme_a_unfocused_pressed_max))
|
||||||
set_default_appearance(theme_a_unfocused_pressed_max);
|
set_default_appearance(theme_a_unfocused_pressed_max);
|
||||||
if (!read_appearance(db, "window.button.focus",
|
if (!read_appearance(db, inst,
|
||||||
|
"window.button.focus",
|
||||||
theme_a_focused_unpressed_max))
|
theme_a_focused_unpressed_max))
|
||||||
set_default_appearance(theme_a_focused_unpressed_max);
|
set_default_appearance(theme_a_focused_unpressed_max);
|
||||||
if (!read_appearance(db, "window.button.unfocus",
|
if (!read_appearance(db, inst,
|
||||||
|
"window.button.unfocus",
|
||||||
theme_a_unfocused_unpressed_max))
|
theme_a_unfocused_unpressed_max))
|
||||||
set_default_appearance(theme_a_unfocused_unpressed_max);
|
set_default_appearance(theme_a_unfocused_unpressed_max);
|
||||||
|
|
||||||
theme_a_unfocused_unpressed_close =
|
theme_a_unfocused_unpressed_close =
|
||||||
appearance_copy(theme_a_unfocused_unpressed_max);
|
RrAppearanceCopy(theme_a_unfocused_unpressed_max);
|
||||||
theme_a_unfocused_pressed_close =
|
theme_a_unfocused_pressed_close =
|
||||||
appearance_copy(theme_a_unfocused_pressed_max);
|
RrAppearanceCopy(theme_a_unfocused_pressed_max);
|
||||||
theme_a_focused_unpressed_close =
|
theme_a_focused_unpressed_close =
|
||||||
appearance_copy(theme_a_focused_unpressed_max);
|
RrAppearanceCopy(theme_a_focused_unpressed_max);
|
||||||
theme_a_focused_pressed_close =
|
theme_a_focused_pressed_close =
|
||||||
appearance_copy(theme_a_focused_pressed_max);
|
RrAppearanceCopy(theme_a_focused_pressed_max);
|
||||||
theme_a_unfocused_unpressed_desk =
|
theme_a_unfocused_unpressed_desk =
|
||||||
appearance_copy(theme_a_unfocused_unpressed_max);
|
RrAppearanceCopy(theme_a_unfocused_unpressed_max);
|
||||||
theme_a_unfocused_pressed_desk =
|
theme_a_unfocused_pressed_desk =
|
||||||
appearance_copy(theme_a_unfocused_pressed_max);
|
RrAppearanceCopy(theme_a_unfocused_pressed_max);
|
||||||
theme_a_unfocused_pressed_set_desk =
|
theme_a_unfocused_pressed_set_desk =
|
||||||
appearance_copy(theme_a_unfocused_pressed_max);
|
RrAppearanceCopy(theme_a_unfocused_pressed_max);
|
||||||
theme_a_focused_unpressed_desk =
|
theme_a_focused_unpressed_desk =
|
||||||
appearance_copy(theme_a_focused_unpressed_max);
|
RrAppearanceCopy(theme_a_focused_unpressed_max);
|
||||||
theme_a_focused_pressed_desk =
|
theme_a_focused_pressed_desk =
|
||||||
appearance_copy(theme_a_focused_pressed_max);
|
RrAppearanceCopy(theme_a_focused_pressed_max);
|
||||||
theme_a_focused_pressed_set_desk =
|
theme_a_focused_pressed_set_desk =
|
||||||
appearance_copy(theme_a_focused_pressed_max);
|
RrAppearanceCopy(theme_a_focused_pressed_max);
|
||||||
theme_a_unfocused_unpressed_shade =
|
theme_a_unfocused_unpressed_shade =
|
||||||
appearance_copy(theme_a_unfocused_unpressed_max);
|
RrAppearanceCopy(theme_a_unfocused_unpressed_max);
|
||||||
theme_a_unfocused_pressed_shade =
|
theme_a_unfocused_pressed_shade =
|
||||||
appearance_copy(theme_a_unfocused_pressed_max);
|
RrAppearanceCopy(theme_a_unfocused_pressed_max);
|
||||||
theme_a_unfocused_pressed_set_shade =
|
theme_a_unfocused_pressed_set_shade =
|
||||||
appearance_copy(theme_a_unfocused_pressed_max);
|
RrAppearanceCopy(theme_a_unfocused_pressed_max);
|
||||||
theme_a_focused_unpressed_shade =
|
theme_a_focused_unpressed_shade =
|
||||||
appearance_copy(theme_a_focused_unpressed_max);
|
RrAppearanceCopy(theme_a_focused_unpressed_max);
|
||||||
theme_a_focused_pressed_shade =
|
theme_a_focused_pressed_shade =
|
||||||
appearance_copy(theme_a_focused_pressed_max);
|
RrAppearanceCopy(theme_a_focused_pressed_max);
|
||||||
theme_a_focused_pressed_set_shade =
|
theme_a_focused_pressed_set_shade =
|
||||||
appearance_copy(theme_a_focused_pressed_max);
|
RrAppearanceCopy(theme_a_focused_pressed_max);
|
||||||
theme_a_unfocused_unpressed_iconify =
|
theme_a_unfocused_unpressed_iconify =
|
||||||
appearance_copy(theme_a_unfocused_unpressed_max);
|
RrAppearanceCopy(theme_a_unfocused_unpressed_max);
|
||||||
theme_a_unfocused_pressed_iconify =
|
theme_a_unfocused_pressed_iconify =
|
||||||
appearance_copy(theme_a_unfocused_pressed_max);
|
RrAppearanceCopy(theme_a_unfocused_pressed_max);
|
||||||
theme_a_focused_unpressed_iconify =
|
theme_a_focused_unpressed_iconify =
|
||||||
appearance_copy(theme_a_focused_unpressed_max);
|
RrAppearanceCopy(theme_a_focused_unpressed_max);
|
||||||
theme_a_focused_pressed_iconify =
|
theme_a_focused_pressed_iconify =
|
||||||
appearance_copy(theme_a_focused_pressed_max);
|
RrAppearanceCopy(theme_a_focused_pressed_max);
|
||||||
theme_a_unfocused_pressed_set_max =
|
theme_a_unfocused_pressed_set_max =
|
||||||
appearance_copy(theme_a_unfocused_pressed_max);
|
RrAppearanceCopy(theme_a_unfocused_pressed_max);
|
||||||
theme_a_focused_pressed_set_max =
|
theme_a_focused_pressed_set_max =
|
||||||
appearance_copy(theme_a_focused_pressed_max);
|
RrAppearanceCopy(theme_a_focused_pressed_max);
|
||||||
|
|
||||||
theme_a_icon->surface.grad = Background_ParentRelative;
|
theme_a_icon->surface.grad = RR_SURFACE_PARENTREL;
|
||||||
|
|
||||||
/* set up the textures */
|
/* set up the textures */
|
||||||
theme_a_focused_label->texture[0].type =
|
theme_a_focused_label->texture[0].type =
|
||||||
theme_app_hilite_label->texture[0].type = Text;
|
theme_app_hilite_label->texture[0].type = RR_TEXTURE_TEXT;
|
||||||
theme_a_focused_label->texture[0].data.text.justify = winjust;
|
theme_a_focused_label->texture[0].data.text.justify = winjust;
|
||||||
theme_app_hilite_label->texture[0].data.text.justify = Justify_Left;
|
theme_app_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
|
||||||
theme_a_focused_label->texture[0].data.text.font =
|
theme_a_focused_label->texture[0].data.text.font =
|
||||||
theme_app_hilite_label->texture[0].data.text.font = theme_winfont;
|
theme_app_hilite_label->texture[0].data.text.font = theme_winfont;
|
||||||
theme_a_focused_label->texture[0].data.text.shadow =
|
theme_a_focused_label->texture[0].data.text.shadow =
|
||||||
|
@ -833,9 +877,9 @@ char *theme_load(char *theme)
|
||||||
theme_title_focused_color;
|
theme_title_focused_color;
|
||||||
|
|
||||||
theme_a_unfocused_label->texture[0].type =
|
theme_a_unfocused_label->texture[0].type =
|
||||||
theme_app_unhilite_label->texture[0].type = Text;
|
theme_app_unhilite_label->texture[0].type = RR_TEXTURE_TEXT;
|
||||||
theme_a_unfocused_label->texture[0].data.text.justify = winjust;
|
theme_a_unfocused_label->texture[0].data.text.justify = winjust;
|
||||||
theme_app_unhilite_label->texture[0].data.text.justify = Justify_Left;
|
theme_app_unhilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
|
||||||
theme_a_unfocused_label->texture[0].data.text.font =
|
theme_a_unfocused_label->texture[0].data.text.font =
|
||||||
theme_app_unhilite_label->texture[0].data.text.font = theme_winfont;
|
theme_app_unhilite_label->texture[0].data.text.font = theme_winfont;
|
||||||
theme_a_unfocused_label->texture[0].data.text.shadow =
|
theme_a_unfocused_label->texture[0].data.text.shadow =
|
||||||
|
@ -851,7 +895,7 @@ char *theme_load(char *theme)
|
||||||
theme_app_unhilite_label->texture[0].data.text.color =
|
theme_app_unhilite_label->texture[0].data.text.color =
|
||||||
theme_title_unfocused_color;
|
theme_title_unfocused_color;
|
||||||
|
|
||||||
theme_a_menu_title->texture[0].type = Text;
|
theme_a_menu_title->texture[0].type = RR_TEXTURE_TEXT;
|
||||||
theme_a_menu_title->texture[0].data.text.justify = mtitlejust;
|
theme_a_menu_title->texture[0].data.text.justify = mtitlejust;
|
||||||
theme_a_menu_title->texture[0].data.text.font = theme_mtitlefont;
|
theme_a_menu_title->texture[0].data.text.font = theme_mtitlefont;
|
||||||
theme_a_menu_title->texture[0].data.text.shadow = theme_mtitlefont_shadow;
|
theme_a_menu_title->texture[0].data.text.shadow = theme_mtitlefont_shadow;
|
||||||
|
@ -863,11 +907,11 @@ char *theme_load(char *theme)
|
||||||
|
|
||||||
theme_a_menu_item->surface.grad =
|
theme_a_menu_item->surface.grad =
|
||||||
theme_a_menu_disabled->surface.grad =
|
theme_a_menu_disabled->surface.grad =
|
||||||
theme_app_icon->surface.grad = Background_ParentRelative;
|
theme_app_icon->surface.grad = RR_SURFACE_PARENTREL;
|
||||||
|
|
||||||
theme_a_menu_item->texture[0].type =
|
theme_a_menu_item->texture[0].type =
|
||||||
theme_a_menu_disabled->texture[0].type =
|
theme_a_menu_disabled->texture[0].type =
|
||||||
theme_a_menu_hilite->texture[0].type = Text;
|
theme_a_menu_hilite->texture[0].type = RR_TEXTURE_TEXT;
|
||||||
theme_a_menu_item->texture[0].data.text.justify =
|
theme_a_menu_item->texture[0].data.text.justify =
|
||||||
theme_a_menu_disabled->texture[0].data.text.justify =
|
theme_a_menu_disabled->texture[0].data.text.justify =
|
||||||
theme_a_menu_hilite->texture[0].data.text.justify = mjust;
|
theme_a_menu_hilite->texture[0].data.text.justify = mjust;
|
||||||
|
@ -915,7 +959,7 @@ char *theme_load(char *theme)
|
||||||
theme_a_focused_unpressed_iconify->texture[0].type =
|
theme_a_focused_unpressed_iconify->texture[0].type =
|
||||||
theme_a_focused_pressed_iconify->texture[0].type =
|
theme_a_focused_pressed_iconify->texture[0].type =
|
||||||
theme_a_unfocused_unpressed_iconify->texture[0].type =
|
theme_a_unfocused_unpressed_iconify->texture[0].type =
|
||||||
theme_a_unfocused_pressed_iconify->texture[0].type = Bitmask;
|
theme_a_unfocused_pressed_iconify->texture[0].type = RR_TEXTURE_MASK;
|
||||||
theme_a_focused_unpressed_max->texture[0].data.mask.mask =
|
theme_a_focused_unpressed_max->texture[0].data.mask.mask =
|
||||||
theme_a_unfocused_unpressed_max->texture[0].data.mask.mask =
|
theme_a_unfocused_unpressed_max->texture[0].data.mask.mask =
|
||||||
theme_a_focused_pressed_max->texture[0].data.mask.mask =
|
theme_a_focused_pressed_max->texture[0].data.mask.mask =
|
||||||
|
|
124
render/theme.h
124
render/theme.h
|
@ -6,10 +6,10 @@
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "mask.h"
|
#include "mask.h"
|
||||||
|
|
||||||
extern int theme_bevel;
|
extern gint theme_bevel;
|
||||||
extern int theme_handle_height;
|
extern gint theme_handle_height;
|
||||||
extern int theme_bwidth;
|
extern gint theme_bwidth;
|
||||||
extern int theme_cbwidth;
|
extern gint theme_cbwidth;
|
||||||
|
|
||||||
#define theme_label_height (theme_winfont_height)
|
#define theme_label_height (theme_winfont_height)
|
||||||
#define theme_title_height (theme_label_height + theme_bevel * 2)
|
#define theme_title_height (theme_label_height + theme_bevel * 2)
|
||||||
|
@ -24,69 +24,69 @@ extern color_rgb *theme_title_unfocused_color;
|
||||||
extern color_rgb *theme_titlebut_focused_color;
|
extern color_rgb *theme_titlebut_focused_color;
|
||||||
extern color_rgb *theme_titlebut_unfocused_color;
|
extern color_rgb *theme_titlebut_unfocused_color;
|
||||||
|
|
||||||
extern int theme_winfont_height;
|
extern gint theme_winfont_height;
|
||||||
extern ObFont *theme_winfont;
|
extern RrFont *theme_winfont;
|
||||||
extern char *theme_title_layout;
|
extern gchar *theme_title_layout;
|
||||||
|
|
||||||
extern pixmap_mask *theme_max_set_mask;
|
extern RrPixmapMask *theme_max_set_mask;
|
||||||
extern pixmap_mask *theme_max_unset_mask;
|
extern RrPixmapMask *theme_max_unset_mask;
|
||||||
extern pixmap_mask *theme_iconify_mask;
|
extern RrPixmapMask *theme_iconify_mask;
|
||||||
extern pixmap_mask *theme_desk_set_mask;
|
extern RrPixmapMask *theme_desk_set_mask;
|
||||||
extern pixmap_mask *theme_desk_unset_mask;
|
extern RrPixmapMask *theme_desk_unset_mask;
|
||||||
extern pixmap_mask *theme_shade_set_mask;
|
extern RrPixmapMask *theme_shade_set_mask;
|
||||||
extern pixmap_mask *theme_shade_unset_mask;
|
extern RrPixmapMask *theme_shade_unset_mask;
|
||||||
extern pixmap_mask *theme_close_mask;
|
extern RrPixmapMask *theme_close_mask;
|
||||||
|
|
||||||
extern Appearance *theme_a_focused_unpressed_max;
|
extern RrAppearance *theme_a_focused_unpressed_max;
|
||||||
extern Appearance *theme_a_focused_pressed_max;
|
extern RrAppearance *theme_a_focused_pressed_max;
|
||||||
extern Appearance *theme_a_focused_pressed_set_max;
|
extern RrAppearance *theme_a_focused_pressed_set_max;
|
||||||
extern Appearance *theme_a_unfocused_unpressed_max;
|
extern RrAppearance *theme_a_unfocused_unpressed_max;
|
||||||
extern Appearance *theme_a_unfocused_pressed_max;
|
extern RrAppearance *theme_a_unfocused_pressed_max;
|
||||||
extern Appearance *theme_a_unfocused_pressed_set_max;
|
extern RrAppearance *theme_a_unfocused_pressed_set_max;
|
||||||
extern Appearance *theme_a_focused_unpressed_close;
|
extern RrAppearance *theme_a_focused_unpressed_close;
|
||||||
extern Appearance *theme_a_focused_pressed_close;
|
extern RrAppearance *theme_a_focused_pressed_close;
|
||||||
extern Appearance *theme_a_unfocused_unpressed_close;
|
extern RrAppearance *theme_a_unfocused_unpressed_close;
|
||||||
extern Appearance *theme_a_unfocused_pressed_close;
|
extern RrAppearance *theme_a_unfocused_pressed_close;
|
||||||
extern Appearance *theme_a_focused_unpressed_desk;
|
extern RrAppearance *theme_a_focused_unpressed_desk;
|
||||||
extern Appearance *theme_a_focused_pressed_desk;
|
extern RrAppearance *theme_a_focused_pressed_desk;
|
||||||
extern Appearance *theme_a_focused_pressed_set_desk;
|
extern RrAppearance *theme_a_focused_pressed_set_desk;
|
||||||
extern Appearance *theme_a_unfocused_unpressed_desk;
|
extern RrAppearance *theme_a_unfocused_unpressed_desk;
|
||||||
extern Appearance *theme_a_unfocused_pressed_desk;
|
extern RrAppearance *theme_a_unfocused_pressed_desk;
|
||||||
extern Appearance *theme_a_unfocused_pressed_set_desk;
|
extern RrAppearance *theme_a_unfocused_pressed_set_desk;
|
||||||
extern Appearance *theme_a_focused_unpressed_shade;
|
extern RrAppearance *theme_a_focused_unpressed_shade;
|
||||||
extern Appearance *theme_a_focused_pressed_shade;
|
extern RrAppearance *theme_a_focused_pressed_shade;
|
||||||
extern Appearance *theme_a_focused_pressed_set_shade;
|
extern RrAppearance *theme_a_focused_pressed_set_shade;
|
||||||
extern Appearance *theme_a_unfocused_unpressed_shade;
|
extern RrAppearance *theme_a_unfocused_unpressed_shade;
|
||||||
extern Appearance *theme_a_unfocused_pressed_shade;
|
extern RrAppearance *theme_a_unfocused_pressed_shade;
|
||||||
extern Appearance *theme_a_unfocused_pressed_set_shade;
|
extern RrAppearance *theme_a_unfocused_pressed_set_shade;
|
||||||
extern Appearance *theme_a_focused_unpressed_iconify;
|
extern RrAppearance *theme_a_focused_unpressed_iconify;
|
||||||
extern Appearance *theme_a_focused_pressed_iconify;
|
extern RrAppearance *theme_a_focused_pressed_iconify;
|
||||||
extern Appearance *theme_a_unfocused_unpressed_iconify;
|
extern RrAppearance *theme_a_unfocused_unpressed_iconify;
|
||||||
extern Appearance *theme_a_unfocused_pressed_iconify;
|
extern RrAppearance *theme_a_unfocused_pressed_iconify;
|
||||||
extern Appearance *theme_a_focused_grip;
|
extern RrAppearance *theme_a_focused_grip;
|
||||||
extern Appearance *theme_a_unfocused_grip;
|
extern RrAppearance *theme_a_unfocused_grip;
|
||||||
extern Appearance *theme_a_focused_title;
|
extern RrAppearance *theme_a_focused_title;
|
||||||
extern Appearance *theme_a_unfocused_title;
|
extern RrAppearance *theme_a_unfocused_title;
|
||||||
extern Appearance *theme_a_focused_label;
|
extern RrAppearance *theme_a_focused_label;
|
||||||
extern Appearance *theme_a_unfocused_label;
|
extern RrAppearance *theme_a_unfocused_label;
|
||||||
extern Appearance *theme_a_icon;
|
extern RrAppearance *theme_a_icon;
|
||||||
extern Appearance *theme_a_focused_handle;
|
extern RrAppearance *theme_a_focused_handle;
|
||||||
extern Appearance *theme_a_unfocused_handle;
|
extern RrAppearance *theme_a_unfocused_handle;
|
||||||
extern Appearance *theme_a_menu_title;
|
extern RrAppearance *theme_a_menu_title;
|
||||||
extern Appearance *theme_a_menu;
|
extern RrAppearance *theme_a_menu;
|
||||||
extern Appearance *theme_a_menu_item;
|
extern RrAppearance *theme_a_menu_item;
|
||||||
extern Appearance *theme_a_menu_disabled;
|
extern RrAppearance *theme_a_menu_disabled;
|
||||||
extern Appearance *theme_a_menu_hilite;
|
extern RrAppearance *theme_a_menu_hilite;
|
||||||
|
|
||||||
extern Appearance *theme_app_hilite_bg;
|
extern RrAppearance *theme_app_hilite_bg;
|
||||||
extern Appearance *theme_app_unhilite_bg;
|
extern RrAppearance *theme_app_unhilite_bg;
|
||||||
extern Appearance *theme_app_hilite_label;
|
extern RrAppearance *theme_app_hilite_label;
|
||||||
extern Appearance *theme_app_unhilite_label;
|
extern RrAppearance *theme_app_unhilite_label;
|
||||||
extern Appearance *theme_app_icon;
|
extern RrAppearance *theme_app_icon;
|
||||||
|
|
||||||
void theme_startup();
|
void theme_startup(const RrInstance *inst);
|
||||||
void theme_shutdown();
|
void theme_shutdown();
|
||||||
|
|
||||||
char *theme_load(char *theme);
|
gchar *theme_load(gchar *theme);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue