rendertest works, yay.
CWOverrideRedirect | CWEventMask,
&attrib);
dock->a_frame = appearance_copy(theme_a_unfocused_title);
- XSetWindowBorder(ob_display, dock->frame, theme_b_color->pixel);
XSetWindowBorderWidth(ob_display, dock->frame, theme_bwidth);
g_hash_table_insert(window_map, &dock->frame, dock);
XMapWindow(ob_display, self->label);
/* set colors/appearance/sizes for stuff that doesn't change */
- XSetWindowBorder(ob_display, self->window, theme_b_color->pixel);
- XSetWindowBorder(ob_display, self->label, theme_b_color->pixel);
- XSetWindowBorder(ob_display, self->rgrip, theme_b_color->pixel);
- XSetWindowBorder(ob_display, self->lgrip, theme_b_color->pixel);
XResizeWindow(ob_display, self->max, theme_button_size, theme_button_size);
XResizeWindow(ob_display, self->iconify,
void framerender_frame(Frame *self)
{
- if (self->focused)
- XSetWindowBorder(ob_display, self->plate,
- theme_cb_focused_color->pixel);
- else
- XSetWindowBorder(ob_display, self->plate,
- theme_cb_unfocused_color->pixel);
-
if (self->client->decorations & Decor_Titlebar) {
Appearance *t, *l, *m, *n, *i, *d, *s, *c;
attrib.event_mask = TITLE_EVENTMASK;
self->title = createWindow(self->frame, CWEventMask, &attrib);
self->items = createWindow(self->frame, 0, &attrib);
-
+/*
XSetWindowBorderWidth(ob_display, self->frame, theme_bwidth);
XSetWindowBackground(ob_display, self->frame, theme_b_color->pixel);
XSetWindowBorderWidth(ob_display, self->title, theme_bwidth);
XSetWindowBorder(ob_display, self->frame, theme_b_color->pixel);
XSetWindowBorder(ob_display, self->title, theme_b_color->pixel);
-
+*/
XMapWindow(ob_display, self->title);
XMapWindow(ob_display, self->items);
self->bg = XCreateWindow(ob_display, ob_root,
0, 0, 1, 1, 0, render_depth, InputOutput,
render_visual, CWOverrideRedirect, &attrib);
-
+/*
XSetWindowBorderWidth(ob_display, self->bg, theme_bwidth);
XSetWindowBorder(ob_display, self->bg, theme_b_color->pixel);
-
+*/
self->text = XCreateWindow(ob_display, self->bg,
0, 0, 1, 1, 0, render_depth, InputOutput,
render_visual, 0, NULL);
if (client == NULL) {
if (install)
- XInstallColormap(ob_display, render_colormap);
+ XInstallColormap(ob_display,
+ DefaultColormap(ob_display, ob_screen));
else
- XUninstallColormap(ob_display, render_colormap);
+ XUninstallColormap(ob_display,
+ DefaultColormap(ob_display, ob_screen));
} else {
if (XGetWindowAttributes(ob_display, client->window, &wa) &&
wa.colormap != None) {
#include "color.h"
#include "../kernel/openbox.h"
-XColor *pseudo_colors;
-int pseudo_bpc;
-
-void color_allocate_gc(color_rgb *in)
-{
- XGCValues gcv;
-
- gcv.foreground = in->pixel;
- gcv.cap_style = CapProjecting;
- in->gc = XCreateGC(ob_display, ob_root, GCForeground | GCCapStyle, &gcv);
-}
-
-color_rgb *color_parse(char *colorname)
+gboolean color_parse(char *colorname, struct RrRGB *ret)
{
XColor xcol;
xcol.green = 0;
xcol.blue = 0;
xcol.pixel = 0;
- if (!XParseColor(ob_display, render_colormap, colorname, &xcol)) {
+ if (!XParseColor(ob_display,
+ DefaultColormap(ob_display, ob_screen),
+ colorname, &xcol)) {
g_warning("unable to parse color '%s'", colorname);
- return NULL;
- }
- return color_new(xcol.red >> 8, xcol.green >> 8, xcol.blue >> 8);
-}
-
-color_rgb *color_new(int r, int g, int b)
-{
-/* this should be replaced with something far cooler */
- color_rgb *out;
- XColor xcol;
- xcol.red = (r << 8) | r;
- xcol.green = (g << 8) | g;
- xcol.blue = (b << 8) | b;
- if (XAllocColor(ob_display, render_colormap, &xcol)) {
- out = g_new(color_rgb, 1);
- out->r = xcol.red >> 8;
- out->g = xcol.green >> 8;
- out->b = xcol.blue >> 8;
- out->gc = None;
- out->pixel = xcol.pixel;
- return out;
- }
- return NULL;
-}
-
-/*XXX same color could be pointed to twice, this might have to be a refcount*/
-
-void color_free(color_rgb *c)
-{
- if (c != NULL) {
- if (c->gc != None)
- XFreeGC(ob_display, c->gc);
- g_free(c);
+ ret->r = 0.0;
+ ret->g = 0.0;
+ ret->b = 0.0;
+ return FALSE;
}
+ ret->r = (xcol.red >> 8)/255.0;
+ ret->g = (xcol.green >> 8)/255.0;
+ ret->b = (xcol.blue >> 8)/255.0;
+ return TRUE;
}
void reduce_depth(pixel32 *data, XImage *im)
p16 += im->bytes_per_line/2;
}
break;
+/*
case 8:
g_assert(render_visual->class != TrueColor);
for (y = 0; y < im->height; y++) {
p8[x] = pickColor(data[x] >> default_red_offset,
data[x] >> default_green_offset,
data[x] >> default_blue_offset)->pixel;
+ }
+ data += im->width;
+ p8 += im->bytes_per_line;
}
- data += im->width;
- p8 += im->bytes_per_line;
- }
-
+*/
break;
default:
g_message("your bit depth is currently unhandled\n");
}
}
-XColor *pickColor(int r, int g, int b)
-{
- r = (r & 0xff) >> (8-pseudo_bpc);
- g = (g & 0xff) >> (8-pseudo_bpc);
- b = (b & 0xff) >> (8-pseudo_bpc);
- return &pseudo_colors[(r << (2*pseudo_bpc)) + (g << (1*pseudo_bpc)) + b];
-}
-
static void swap_byte_order(XImage *im)
{
int x, y, di;
int x,y;
pixel32 *p32 = (pixel32 *) im->data;
pixel16 *p16 = (pixel16 *) im->data;
- unsigned char *p8 = (unsigned char *)im->data;
if (im->byte_order != render_endian)
swap_byte_order(im);
}
break;
case 8:
+#if 0
g_assert(render_visual->class != TrueColor);
for (y = 0; y < im->height; y++) {
for (x = 0; x < im->width; x++) {
data += im->width;
p8 += im->bytes_per_line;
}
-
+#endif
break;
default:
g_message("your bit depth is currently unhandled\n");
#endif /* G_BYTE_ORDER == G_BIG_ENDIAN */
-typedef struct color_rgb {
- int r;
- int g;
- int b;
- unsigned long pixel;
- GC gc;
-} color_rgb;
+struct RrRGB {
+ float r,g,b;
+};
-void color_allocate_gc(color_rgb *in);
-XColor *pickColor(int r, int g, int b);
-color_rgb *color_parse(char *colorname);
-color_rgb *color_new(int r, int g, int b);
-void color_free(color_rgb *in);
+#define rr_color_set(col, x, y, z) (col).r = (x), (col).g = (y), (col).b = (z)
+
+gboolean color_parse(char *colorname, struct RrRGB *ret);
void reduce_depth(pixel32 *data, XImage *im);
void increase_depth(pixel32 *data, XImage *im);
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 */
float sr, sg, sb;
float ar, ag, ab;
- pr = (float)sf->data.planar.primary->r/255.0;
- pg = (float)sf->data.planar.primary->g/255.0;
- pb = (float)sf->data.planar.primary->b/255.0;
- if (sf->data.planar.secondary) {
- sr = (float)sf->data.planar.secondary->r/255.0;
- sg = (float)sf->data.planar.secondary->g/255.0;
- sb = (float)sf->data.planar.secondary->b/255.0;
- }
+ pr = sf->data.planar.primary.r;
+ pg = sf->data.planar.primary.g;
+ pb = sf->data.planar.primary.b;
+ sr = sf->data.planar.secondary.r;
+ sg = sf->data.planar.secondary.g;
+ sb = sf->data.planar.secondary.b;
switch (sf->data.planar.grad) {
case Background_Solid: /* already handled */
glBegin(GL_TRIANGLES);
{
int x, y;
if (m->mask == None) return; /* no mask given */
-
- /* set the clip region */
- x = position->x + (position->width - m->mask->w) / 2;
- y = position->y + (position->height - m->mask->h) / 2;
-
- if (x < 0) x = 0;
- if (y < 0) y = 0;
-
- XSetClipMask(ob_display, m->color->gc, m->mask->mask);
- XSetClipOrigin(ob_display, m->color->gc, x, y);
-
- /* fill in the clipped region */
- XFillRectangle(ob_display, p, m->color->gc, x, y,
- x + m->mask->w, y + m->mask->h);
-
- /* unset the clip region */
- XSetClipMask(ob_display, m->color->gc, None);
- XSetClipOrigin(ob_display, m->color->gc, 0, 0);
}
pixmap_mask *pixmap_mask_copy(pixmap_mask *src)
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
+#include <stdio.h>
int render_depth;
XVisualInfo render_visual_info;
Visual *render_visual;
-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_glx_rating(XVisualInfo *v)
{
- int er;
int rating = 0;
int val;
- printf("evaluating visual %d\n", v->visualid);
glXGetConfig(ob_display, v, GLX_BUFFER_SIZE, &val);
printf("buffer size %d\n", val);
render_depth = DefaultDepth(ob_display, ob_screen);
render_visual = DefaultVisual(ob_display, ob_screen);
- render_colormap = DefaultColormap(ob_display, ob_screen);
vimatch.screen = ob_screen;
vimatch.class = TrueColor;
printf("picked visual %d with rating %d\n", best, rate);
render_depth = vilist[best].depth;
render_visual = vilist[best].visual;
- render_colormap = XCreateColormap(ob_display, ob_root,
- render_visual, AllocNone);
render_visual_info = vilist[best];
render_glx_context = glXCreateContext(ob_display, &render_visual_info,
NULL, True);
Appearance *appearance_new(SurfaceType type, int numtex)
{
- PlanarSurface *p;
Appearance *out;
out = g_new(Appearance, 1);
if (numtex) out->texture = g_new0(Texture, numtex);
else out->texture = NULL;
- switch (type) {
- case Surface_Planar:
- p = &out->surface.data.planar;
- p->primary = NULL;
- p->secondary = NULL;
- p->border_color = NULL;
- p->bevel_dark = NULL;
- p->bevel_light = NULL;
- p->pixel_data = NULL;
- break;
- }
return out;
}
Appearance *appearance_copy(Appearance *orig)
{
- PlanarSurface *spo, *spc;
Appearance *copy = g_new(Appearance, 1);
copy->surface.type = orig->surface.type;
switch (orig->surface.type) {
case Surface_Planar:
- spo = &(orig->surface.data.planar);
- spc = &(copy->surface.data.planar);
- spc->grad = spo->grad;
- spc->relief = spo->relief;
- spc->bevel = spo->bevel;
- if (spo->primary != NULL)
- spc->primary = color_new(spo->primary->r,
- spo->primary->g,
- spo->primary->b);
- else spc->primary = NULL;
-
- if (spo->secondary != NULL)
- spc->secondary = color_new(spo->secondary->r,
- spo->secondary->g,
- spo->secondary->b);
- else spc->secondary = NULL;
-
- if (spo->border_color != NULL)
- spc->border_color = color_new(spo->border_color->r,
- spo->border_color->g,
- spo->border_color->b);
- else spc->border_color = NULL;
-
- if (spo->bevel_dark != NULL)
- spc->bevel_dark = color_new(spo->bevel_dark->r,
- spo->bevel_dark->g,
- spo->bevel_dark->b);
- else spc->bevel_dark = NULL;
-
- if (spo->bevel_light != NULL)
- spc->bevel_light = color_new(spo->bevel_light->r,
- spo->bevel_light->g,
- spo->bevel_light->b);
- else spc->bevel_light = NULL;
-
- spc->interlaced = spo->interlaced;
- spc->border = spo->border;
- spc->pixel_data = NULL;
+ copy->surface.data.planar = orig->surface.data.planar;
break;
}
copy->textures = orig->textures;
PlanarSurface *p;
if (a->textures)
g_free(a->texture);
- if (a->surface.type == Surface_Planar) {
- p = &a->surface.data.planar;
- color_free(p->primary);
- color_free(p->secondary);
- color_free(p->border_color);
- color_free(p->bevel_dark);
- color_free(p->bevel_light);
- g_free(p->pixel_data);
- }
g_free(a);
}
}
SurfaceColorType grad;
ReliefType relief;
BevelType bevel;
- color_rgb *primary;
- color_rgb *secondary;
- color_rgb *border_color;
- color_rgb *bevel_dark;
- color_rgb *bevel_light;
+ struct RrRGB primary;
+ struct RrRGB secondary;
+ struct RrRGB border_color;
+ struct RrRGB bevel_dark;
+ struct RrRGB bevel_light;
gboolean interlaced;
gboolean border;
struct Appearance *parent;
int parentx;
int parenty;
- pixel32 *pixel_data;
} PlanarSurface;
typedef struct NonplanarSurface {
int shadow;
char tint;
unsigned char offset;
- color_rgb *color;
+ struct RrRGB color;
char *string;
} TextureText;
} pixmap_mask;
typedef struct TextureMask {
- color_rgb *color;
+ struct RrRGB color;
pixmap_mask *mask;
} TextureMask;
look = appearance_new(Surface_Planar, 0);
look->surface.data.planar.grad = Background_Pyramid;
- look->surface.data.planar.secondary = color_parse("Yellow");
- look->surface.data.planar.primary = color_parse("Blue");
+ color_parse("Yellow", &look->surface.data.planar.secondary);
+ color_parse("Blue", &look->surface.data.planar.primary);
look->surface.data.planar.interlaced = FALSE;
look->area.x = 0;
look->area.y = 0;
#include <X11/Xlib.h>
#include <X11/Xresource.h>
+#include <ctype.h>
+#include <string.h>
+#include <stdlib.h>
/* style settings - geometry */
int theme_bevel;
int theme_bwidth;
int theme_cbwidth;
/* style settings - colors */
-color_rgb *theme_b_color;
-color_rgb *theme_cb_focused_color;
-color_rgb *theme_cb_unfocused_color;
-color_rgb *theme_title_focused_color;
-color_rgb *theme_title_unfocused_color;
-color_rgb *theme_titlebut_focused_color;
-color_rgb *theme_titlebut_unfocused_color;
-color_rgb *theme_menu_title_color;
-color_rgb *theme_menu_color;
-color_rgb *theme_menu_disabled_color;
-color_rgb *theme_menu_hilite_color;
+struct RrRGB theme_b_color;
+struct RrRGB theme_cb_focused_color;
+struct RrRGB theme_cb_unfocused_color;
+struct RrRGB theme_title_focused_color;
+struct RrRGB theme_title_unfocused_color;
+struct RrRGB theme_titlebut_focused_color;
+struct RrRGB theme_titlebut_unfocused_color;
+struct RrRGB theme_menu_title_color;
+struct RrRGB theme_menu_color;
+struct RrRGB theme_menu_disabled_color;
+struct RrRGB theme_menu_hilite_color;
/* style settings - fonts */
int theme_winfont_height;
ObFont *theme_winfont;
void theme_startup()
{
- theme_b_color = theme_cb_unfocused_color = theme_cb_focused_color =
- theme_title_unfocused_color = theme_title_focused_color =
- theme_titlebut_unfocused_color = theme_titlebut_focused_color =
- theme_menu_color = theme_menu_title_color = theme_menu_disabled_color =
- theme_menu_hilite_color = NULL;
theme_winfont = theme_mtitlefont = theme_mfont = NULL;
theme_title_layout = NULL;
theme_max_set_mask = theme_max_unset_mask = NULL;
void theme_shutdown()
{
- color_free(theme_b_color);
- color_free(theme_cb_unfocused_color);
- color_free(theme_cb_focused_color);
- color_free(theme_title_unfocused_color);
- color_free(theme_title_focused_color);
- color_free(theme_titlebut_unfocused_color);
- color_free(theme_titlebut_focused_color);
- color_free(theme_menu_color);
- color_free(theme_menu_title_color);
- color_free(theme_menu_disabled_color);
- color_free(theme_menu_hilite_color);
-
pixmap_mask_free(theme_max_set_mask);
pixmap_mask_free(theme_max_unset_mask);
pixmap_mask_free(theme_desk_set_mask);
return ret;
}
-static gboolean read_color(XrmDatabase db, char *rname, color_rgb **value)
+static gboolean read_color(XrmDatabase db, char *rname, struct RrRGB *value)
{
gboolean ret = FALSE;
char *rclass = create_class_name(rname);
XrmValue retvalue;
if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
- retvalue.addr != NULL) {
- color_rgb *c = color_parse(retvalue.addr);
- if (c != NULL) {
- *value = c;
- ret = TRUE;
- }
+ retvalue.addr != NULL)
+ ret = color_parse(retvalue.addr, value);
+ else {
+ value->r = 0.0;
+ value->g = 0.0;
+ value->b = 0.0;
}
-
g_free(rclass);
return ret;
}
&value->surface.data.planar.bevel,
&value->surface.data.planar.interlaced,
&value->surface.data.planar.border);
- if (!read_color(db, cname, &value->surface.data.planar.primary))
- value->surface.data.planar.primary = color_new(0, 0, 0);
- if (!read_color(db, ctoname, &value->surface.data.planar.secondary))
- value->surface.data.planar.secondary = color_new(0, 0, 0);
+ read_color(db, cname, &value->surface.data.planar.primary);
+ read_color(db, ctoname, &value->surface.data.planar.secondary);
if (value->surface.data.planar.border)
- if (!read_color(db, bcname,
- &value->surface.data.planar.border_color))
- value->surface.data.planar.border_color = color_new(0, 0, 0);
+ read_color(db, bcname, &value->surface.data.planar.border_color);
ret = TRUE;
}
a->surface.data.planar.bevel = Bevel1;
a->surface.data.planar.interlaced = FALSE;
a->surface.data.planar.border = FALSE;
- a->surface.data.planar.primary = color_new(0, 0, 0);
- a->surface.data.planar.secondary = color_new(0, 0, 0);
+ rr_color_set(a->surface.data.planar.primary, 0.0, 0.0, 0.0);
+ rr_color_set(a->surface.data.planar.secondary, 0.0, 0.0, 0.0);
}
char *theme_load(char *theme)
theme_cbwidth < 0 || theme_cbwidth > 100) theme_cbwidth = theme_bevel;
/* load colors */
- if (!read_color(db, "borderColor", &theme_b_color))
- theme_b_color = color_new(0, 0, 0);
+ read_color(db, "borderColor", &theme_b_color);
if (!read_color(db, "window.frame.focusColor", &theme_cb_focused_color))
- theme_cb_focused_color = color_new(0xff, 0xff, 0xff);
+ rr_color_set(theme_cb_focused_color, 1.0, 1.0, 1.0);
if (!read_color(db, "window.frame.unfocusColor",&theme_cb_unfocused_color))
- theme_cb_unfocused_color = color_new(0xff, 0xff, 0xff);
- if (!read_color(db, "window.label.focus.textColor",
- &theme_title_focused_color))
- theme_title_focused_color = color_new(0x0, 0x0, 0x0);
+ rr_color_set(theme_cb_unfocused_color, 1.0, 1.0, 1.0);
+ read_color(db, "window.label.focus.textColor", &theme_title_focused_color);
if (!read_color(db, "window.label.unfocus.textColor",
&theme_title_unfocused_color))
- theme_title_unfocused_color = color_new(0xff, 0xff, 0xff);
- if (!read_color(db, "window.button.focus.picColor",
- &theme_titlebut_focused_color))
- theme_titlebut_focused_color = color_new(0, 0, 0);
+ rr_color_set(theme_title_unfocused_color, 1.0, 1.0, 1.0);
+ read_color(db, "window.button.focus.picColor",
+ &theme_titlebut_focused_color);
if (!read_color(db, "window.button.unfocus.picColor",
&theme_titlebut_unfocused_color))
- theme_titlebut_unfocused_color = color_new(0xff, 0xff, 0xff);
- if (!read_color(db, "menu.title.textColor", &theme_menu_title_color))
- theme_menu_title_color = color_new(0, 0, 0);
+ rr_color_set(theme_titlebut_unfocused_color, 1.0, 1.0, 1.0);
+ read_color(db, "menu.title.textColor", &theme_menu_title_color);
if (!read_color(db, "menu.frame.textColor", &theme_menu_color))
- theme_menu_color = color_new(0xff, 0xff, 0xff);
- if (!read_color(db, "menu.frame.disableColor", &theme_menu_disabled_color))
- theme_menu_disabled_color = color_new(0, 0, 0);
- if (!read_color(db, "menu.hilite.textColor", &theme_menu_hilite_color))
- theme_menu_hilite_color = color_new(0, 0, 0);
+ rr_color_set(theme_menu_color, 1.0, 1.0, 1.0);
+ read_color(db, "menu.frame.disableColor", &theme_menu_disabled_color);
+ read_color(db, "menu.hilite.textColor", &theme_menu_hilite_color);
if (read_mask(db, "window.button.max.mask", theme, &theme_max_unset_mask)){
if (!read_mask(db, "window.button.max.toggled.mask", theme,
#define theme_button_size (theme_label_height - 2)
#define theme_grip_width (theme_button_size * 2)
-extern color_rgb *theme_b_color;
-extern color_rgb *theme_cb_focused_color;
-extern color_rgb *theme_cb_unfocused_color;
-extern color_rgb *theme_title_focused_color;
-extern color_rgb *theme_title_unfocused_color;
-extern color_rgb *theme_titlebut_focused_color;
-extern color_rgb *theme_titlebut_unfocused_color;
+extern struct RrRGB theme_b_color;
+extern struct RrRGB theme_cb_focused_color;
+extern struct RrRGB theme_cb_unfocused_color;
+extern struct RrRGB theme_title_focused_color;
+extern struct RrRGB theme_title_unfocused_color;
+extern struct RrRGB theme_titlebut_focused_color;
+extern struct RrRGB theme_titlebut_unfocused_color;
extern int theme_winfont_height;
extern ObFont *theme_winfont;