7 #include "parser/parse.h"
10 #include <X11/Xresource.h>
15 static XrmDatabase
loaddb(RrTheme
*theme
, char *name
);
16 static gboolean
read_int(XrmDatabase db
, char *rname
, int *value
);
17 static gboolean
read_string(XrmDatabase db
, char *rname
, char **value
);
18 static gboolean
read_color(XrmDatabase db
, const RrInstance
*inst
,
19 gchar
*rname
, RrColor
**value
);
20 static gboolean
read_mask(const RrInstance
*inst
,
21 gchar
*maskname
, RrTheme
*theme
,
22 RrPixmapMask
**value
);
23 static gboolean
read_appearance(XrmDatabase db
, const RrInstance
*inst
,
24 gchar
*rname
, RrAppearance
*value
,
25 gboolean allow_trans
);
26 static RrPixel32
* read_c_image(gint width
, gint height
, const guint8
*data
);
27 static void set_default_appearance(RrAppearance
*a
);
29 RrTheme
* RrThemeNew(const RrInstance
*inst
, gchar
*name
)
31 XrmDatabase db
= NULL
;
32 RrJustify winjust
, mtitlejust
;
37 theme
= g_new0(RrTheme
, 1);
41 theme
->show_handle
= TRUE
;
43 theme
->a_disabled_focused_max
= RrAppearanceNew(inst
, 1);
44 theme
->a_disabled_unfocused_max
= RrAppearanceNew(inst
, 1);
45 theme
->a_hover_focused_max
= RrAppearanceNew(inst
, 1);
46 theme
->a_hover_unfocused_max
= RrAppearanceNew(inst
, 1);
47 theme
->a_toggled_focused_max
= RrAppearanceNew(inst
, 1);
48 theme
->a_toggled_unfocused_max
= RrAppearanceNew(inst
, 1);
49 theme
->a_focused_unpressed_max
= RrAppearanceNew(inst
, 1);
50 theme
->a_focused_pressed_max
= RrAppearanceNew(inst
, 1);
51 theme
->a_unfocused_unpressed_max
= RrAppearanceNew(inst
, 1);
52 theme
->a_unfocused_pressed_max
= RrAppearanceNew(inst
, 1);
53 theme
->a_focused_grip
= RrAppearanceNew(inst
, 0);
54 theme
->a_unfocused_grip
= RrAppearanceNew(inst
, 0);
55 theme
->a_focused_title
= RrAppearanceNew(inst
, 0);
56 theme
->a_unfocused_title
= RrAppearanceNew(inst
, 0);
57 theme
->a_focused_label
= RrAppearanceNew(inst
, 1);
58 theme
->a_unfocused_label
= RrAppearanceNew(inst
, 1);
59 theme
->a_icon
= RrAppearanceNew(inst
, 1);
60 theme
->a_focused_handle
= RrAppearanceNew(inst
, 0);
61 theme
->a_unfocused_handle
= RrAppearanceNew(inst
, 0);
62 theme
->a_menu
= RrAppearanceNew(inst
, 0);
63 theme
->a_menu_title
= RrAppearanceNew(inst
, 1);
64 theme
->a_menu_normal
= RrAppearanceNew(inst
, 0);
65 theme
->a_menu_disabled
= RrAppearanceNew(inst
, 0);
66 theme
->a_menu_selected
= RrAppearanceNew(inst
, 0);
67 theme
->a_menu_text_normal
= RrAppearanceNew(inst
, 1);
68 theme
->a_menu_text_disabled
= RrAppearanceNew(inst
, 1);
69 theme
->a_menu_text_selected
= RrAppearanceNew(inst
, 1);
70 theme
->a_menu_bullet_normal
= RrAppearanceNew(inst
, 1);
71 theme
->a_menu_bullet_selected
= RrAppearanceNew(inst
, 1);
72 theme
->a_clear
= RrAppearanceNew(inst
, 0);
73 theme
->a_clear_tex
= RrAppearanceNew(inst
, 1);
75 theme
->app_hilite_bg
= RrAppearanceNew(inst
, 0);
76 theme
->app_unhilite_bg
= RrAppearanceNew(inst
, 0);
77 theme
->app_hilite_fg
= RrAppearanceNew(inst
, 0);
78 theme
->app_unhilite_fg
= RrAppearanceNew(inst
, 0);
79 theme
->app_hilite_label
= RrAppearanceNew(inst
, 1);
80 theme
->app_unhilite_label
= RrAppearanceNew(inst
, 1);
83 db
= loaddb(theme
, name
);
85 g_warning("Failed to load the theme '%s'\n"
86 "Falling back to the default: '%s'",
89 theme
->name
= g_path_get_basename(name
);
92 db
= loaddb(theme
, DEFAULT_THEME
);
94 g_warning("Failed to load the theme '%s'.", DEFAULT_THEME
);
97 theme
->name
= g_path_get_basename(DEFAULT_THEME
);
100 /* load the font stuff */
101 if (!read_string(db
, "window.active.label.text.font", &font_str
))
102 font_str
= "arial,sans:bold:pixelsize=10:shadow=y:shadowtint=50";
104 if (!(theme
->winfont_focused
= RrFontOpen(inst
, font_str
))) {
108 theme
->winfont_height
= RrFontHeight(theme
->winfont_focused
);
110 if (!read_string(db
, "window.inactive.label.text.font", &font_str
))
111 /* font_str will already be set to the last one */;
113 if (!(theme
->winfont_unfocused
= RrFontOpen(inst
, font_str
))) {
117 theme
->winfont_height
= MAX(theme
->winfont_height
,
118 RrFontHeight(theme
->winfont_unfocused
));
120 winjust
= RR_JUSTIFY_LEFT
;
121 if (read_string(db
, "window.label.text.justify", &str
)) {
122 if (!g_ascii_strcasecmp(str
, "right"))
123 winjust
= RR_JUSTIFY_RIGHT
;
124 else if (!g_ascii_strcasecmp(str
, "center"))
125 winjust
= RR_JUSTIFY_CENTER
;
128 if (!read_string(db
, "menu.title.text.font", &font_str
))
129 font_str
= "arial,sans:bold:pixelsize=12:shadow=y";
131 if (!(theme
->mtitlefont
= RrFontOpen(inst
, font_str
))) {
135 theme
->mtitlefont_height
= RrFontHeight(theme
->mtitlefont
);
137 mtitlejust
= RR_JUSTIFY_LEFT
;
138 if (read_string(db
, "menu.title.text.justify", &str
)) {
139 if (!g_ascii_strcasecmp(str
, "right"))
140 mtitlejust
= RR_JUSTIFY_RIGHT
;
141 else if (!g_ascii_strcasecmp(str
, "center"))
142 mtitlejust
= RR_JUSTIFY_CENTER
;
145 if (!read_string(db
, "menu.items.font", &font_str
))
146 font_str
= "arial,sans:bold:pixelsize=11:shadow=y";
148 if (!(theme
->mfont
= RrFontOpen(inst
, font_str
))) {
152 theme
->mfont_height
= RrFontHeight(theme
->mfont
);
154 /* load direct dimensions */
155 if (!read_int(db
, "menu.overlap", &theme
->menu_overlap
) ||
156 theme
->menu_overlap
< 0 || theme
->menu_overlap
> 20)
157 theme
->menu_overlap
= 0;
158 if (!read_int(db
, "window.handle.width", &theme
->handle_height
))
159 theme
->handle_height
= 6;
160 if (!theme
->handle_height
)
161 theme
->show_handle
= FALSE
;
162 if (theme
->handle_height
<= 0 || theme
->handle_height
> 100)
163 theme
->handle_height
= 6;
164 if (!read_int(db
, "padding.width", &theme
->padding
) ||
165 theme
->padding
< 0 || theme
->padding
> 100)
167 if (!read_int(db
, "border.width", &theme
->bwidth
) ||
168 theme
->bwidth
< 0 || theme
->bwidth
> 100)
170 if (!read_int(db
, "window.client.padding.width", &theme
->cbwidth
) ||
171 theme
->cbwidth
< 0 || theme
->cbwidth
> 100)
172 theme
->cbwidth
= theme
->padding
;
175 if (!read_color(db
, inst
,
176 "border.color", &theme
->b_color
))
177 theme
->b_color
= RrColorNew(inst
, 0, 0, 0);
178 if (!read_color(db
, inst
,
179 "window.active.client.color",
180 &theme
->cb_focused_color
))
181 theme
->cb_focused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
182 if (!read_color(db
, inst
,
183 "window.inactive.client.color",
184 &theme
->cb_unfocused_color
))
185 theme
->cb_unfocused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
186 if (!read_color(db
, inst
,
187 "window.active.label.text.color",
188 &theme
->title_focused_color
))
189 theme
->title_focused_color
= RrColorNew(inst
, 0x0, 0x0, 0x0);
190 if (!read_color(db
, inst
,
191 "window.inactive.label.text.color",
192 &theme
->title_unfocused_color
))
193 theme
->title_unfocused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
194 if (!read_color(db
, inst
,
195 "window.active.button.unpressed.image.color",
196 &theme
->titlebut_focused_unpressed_color
))
197 theme
->titlebut_focused_unpressed_color
= RrColorNew(inst
, 0, 0, 0);
198 if (!read_color(db
, inst
,
199 "window.inactive.button.unpressed.image.color",
200 &theme
->titlebut_unfocused_unpressed_color
))
201 theme
->titlebut_unfocused_unpressed_color
=
202 RrColorNew(inst
, 0xff, 0xff, 0xff);
203 if (!read_color(db
, inst
,
204 "window.active.button.pressed.image.color",
205 &theme
->titlebut_focused_pressed_color
))
206 theme
->titlebut_focused_pressed_color
=
208 theme
->titlebut_focused_unpressed_color
->r
,
209 theme
->titlebut_focused_unpressed_color
->g
,
210 theme
->titlebut_focused_unpressed_color
->b
);
211 if (!read_color(db
, inst
,
212 "window.inactive.button.pressed.image.color",
213 &theme
->titlebut_unfocused_pressed_color
))
214 theme
->titlebut_unfocused_pressed_color
=
216 theme
->titlebut_unfocused_unpressed_color
->r
,
217 theme
->titlebut_unfocused_unpressed_color
->g
,
218 theme
->titlebut_unfocused_unpressed_color
->b
);
219 if (!read_color(db
, inst
,
220 "window.active.button.disabled.image.color",
221 &theme
->titlebut_disabled_focused_color
))
222 theme
->titlebut_disabled_focused_color
=
223 RrColorNew(inst
, 0xff, 0xff, 0xff);
224 if (!read_color(db
, inst
,
225 "window.inactive.button.disabled.image.color",
226 &theme
->titlebut_disabled_unfocused_color
))
227 theme
->titlebut_disabled_unfocused_color
= RrColorNew(inst
, 0, 0, 0);
228 if (!read_color(db
, inst
,
229 "window.active.button.hover.image.color",
230 &theme
->titlebut_hover_focused_color
))
231 theme
->titlebut_hover_focused_color
=
233 theme
->titlebut_focused_unpressed_color
->r
,
234 theme
->titlebut_focused_unpressed_color
->g
,
235 theme
->titlebut_focused_unpressed_color
->b
);
236 if (!read_color(db
, inst
,
237 "window.inactive.button.hover.image.color",
238 &theme
->titlebut_hover_unfocused_color
))
239 theme
->titlebut_hover_unfocused_color
=
241 theme
->titlebut_unfocused_unpressed_color
->r
,
242 theme
->titlebut_unfocused_unpressed_color
->g
,
243 theme
->titlebut_unfocused_unpressed_color
->b
);
244 if (!read_color(db
, inst
,
245 "window.active.button.toggled.image.color",
246 &theme
->titlebut_toggled_focused_color
))
247 theme
->titlebut_toggled_focused_color
=
249 theme
->titlebut_focused_pressed_color
->r
,
250 theme
->titlebut_focused_pressed_color
->g
,
251 theme
->titlebut_focused_pressed_color
->b
);
252 if (!read_color(db
, inst
,
253 "window.inactive.button.toggled.image.color",
254 &theme
->titlebut_toggled_unfocused_color
))
255 theme
->titlebut_toggled_unfocused_color
=
257 theme
->titlebut_unfocused_pressed_color
->r
,
258 theme
->titlebut_unfocused_pressed_color
->g
,
259 theme
->titlebut_unfocused_pressed_color
->b
);
260 if (!read_color(db
, inst
,
261 "menu.title.text.color", &theme
->menu_title_color
))
262 theme
->menu_title_color
= RrColorNew(inst
, 0, 0, 0);
263 if (!read_color(db
, inst
,
264 "menu.items.text.color", &theme
->menu_color
))
265 theme
->menu_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
266 if (!read_color(db
, inst
,
267 "menu.items.disabled.text.color",
268 &theme
->menu_disabled_color
))
269 theme
->menu_disabled_color
= RrColorNew(inst
, 0, 0, 0);
270 if (!read_color(db
, inst
,
271 "menu.items.active.text.color",
272 &theme
->menu_selected_color
))
273 theme
->menu_selected_color
= RrColorNew(inst
, 0, 0, 0);
275 if (read_mask(inst
, "max.xbm", theme
, &theme
->max_mask
)) {
276 if (!read_mask(inst
, "max_pressed.xbm", theme
,
277 &theme
->max_pressed_mask
)) {
278 theme
->max_pressed_mask
= RrPixmapMaskCopy(theme
->max_mask
);
280 if (!read_mask(inst
, "max_toggled.xbm", theme
,
281 &theme
->max_toggled_mask
)) {
282 theme
->max_toggled_mask
=
283 RrPixmapMaskCopy(theme
->max_pressed_mask
);
285 if (!read_mask(inst
, "max_disabled.xbm", theme
,
286 &theme
->max_disabled_mask
)) {
287 theme
->max_disabled_mask
= RrPixmapMaskCopy(theme
->max_mask
);
289 if (!read_mask(inst
, "max_hover.xbm", theme
, &theme
->max_hover_mask
)) {
290 theme
->max_hover_mask
= RrPixmapMaskCopy(theme
->max_mask
);
294 guchar data
[] = { 0x7f, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f };
295 theme
->max_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
298 guchar data
[] = { 0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
299 theme
->max_toggled_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
301 theme
->max_pressed_mask
= RrPixmapMaskCopy(theme
->max_mask
);
302 theme
->max_disabled_mask
= RrPixmapMaskCopy(theme
->max_mask
);
303 theme
->max_hover_mask
= RrPixmapMaskCopy(theme
->max_mask
);
306 if (read_mask(inst
, "iconify.xbm", theme
, &theme
->iconify_mask
)) {
307 if (!read_mask(inst
, "iconify_pressed.xbm", theme
,
308 &theme
->iconify_pressed_mask
)) {
309 theme
->iconify_pressed_mask
=
310 RrPixmapMaskCopy(theme
->iconify_mask
);
312 if (!read_mask(inst
, "iconify_disabled.xbm", theme
,
313 &theme
->iconify_disabled_mask
)) {
314 theme
->iconify_disabled_mask
=
315 RrPixmapMaskCopy(theme
->iconify_mask
);
317 if (!read_mask(inst
, "iconify_hover.xbm", theme
,
318 &theme
->iconify_hover_mask
)) {
319 theme
->iconify_hover_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
323 guchar data
[] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x7f };
324 theme
->iconify_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
326 theme
->iconify_pressed_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
327 theme
->iconify_disabled_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
328 theme
->iconify_hover_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
331 theme
->def_win_icon
= read_c_image(OB_DEFAULT_ICON_WIDTH
,
332 OB_DEFAULT_ICON_HEIGHT
,
333 OB_DEFAULT_ICON_pixel_data
);
335 if (read_mask(inst
, "desk.xbm", theme
, &theme
->desk_mask
)) {
336 if (!read_mask(inst
, "desk_pressed.xbm", theme
,
337 &theme
->desk_pressed_mask
)) {
338 theme
->desk_pressed_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
340 if (!read_mask(inst
, "desk_toggled.xbm", theme
,
341 &theme
->desk_toggled_mask
)) {
342 theme
->desk_toggled_mask
=
343 RrPixmapMaskCopy(theme
->desk_pressed_mask
);
345 if (!read_mask(inst
, "desk_disabled.xbm", theme
,
346 &theme
->desk_disabled_mask
)) {
347 theme
->desk_disabled_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
349 if (!read_mask(inst
, "desk_hover.xbm", theme
,
350 &theme
->desk_hover_mask
)) {
351 theme
->desk_hover_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
355 guchar data
[] = { 0x63, 0x63, 0x00, 0x00, 0x00, 0x63, 0x63 };
356 theme
->desk_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
359 guchar data
[] = { 0x00, 0x36, 0x36, 0x08, 0x36, 0x36, 0x00 };
360 theme
->desk_toggled_mask
= RrPixmapMaskNew(inst
, 7, 7,
363 theme
->desk_pressed_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
364 theme
->desk_disabled_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
365 theme
->desk_hover_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
368 if (read_mask(inst
, "shade.xbm", theme
, &theme
->shade_mask
)) {
369 if (!read_mask(inst
, "shade_pressed.xbm", theme
,
370 &theme
->shade_pressed_mask
)) {
371 theme
->shade_pressed_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
373 if (!read_mask(inst
, "shade_toggled.xbm", theme
,
374 &theme
->shade_toggled_mask
)) {
375 theme
->shade_toggled_mask
=
376 RrPixmapMaskCopy(theme
->shade_pressed_mask
);
378 if (!read_mask(inst
, "shade_disabled.xbm", theme
,
379 &theme
->shade_disabled_mask
)) {
380 theme
->shade_disabled_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
382 if (!read_mask(inst
, "shade_hover.xbm", theme
,
383 &theme
->shade_hover_mask
)) {
384 theme
->shade_hover_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
388 guchar data
[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00 };
389 theme
->shade_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
392 guchar data
[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x7f };
393 theme
->shade_toggled_mask
= RrPixmapMaskNew(inst
, 7, 7,
396 theme
->shade_pressed_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
397 theme
->shade_disabled_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
398 theme
->shade_hover_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
401 if (read_mask(inst
, "close.xbm", theme
, &theme
->close_mask
)) {
402 if (!read_mask(inst
, "close_pressed.xbm", theme
,
403 &theme
->close_pressed_mask
)) {
404 theme
->close_pressed_mask
= RrPixmapMaskCopy(theme
->close_mask
);
406 if (!read_mask(inst
, "close_disabled.xbm", theme
,
407 &theme
->close_disabled_mask
)) {
408 theme
->close_disabled_mask
= RrPixmapMaskCopy(theme
->close_mask
);
410 if (!read_mask(inst
, "close_hover.xbm", theme
,
411 &theme
->close_hover_mask
)) {
412 theme
->close_hover_mask
= RrPixmapMaskCopy(theme
->close_mask
);
416 guchar data
[] = { 0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63 };
417 theme
->close_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
419 theme
->close_pressed_mask
= RrPixmapMaskCopy(theme
->close_mask
);
420 theme
->close_disabled_mask
= RrPixmapMaskCopy(theme
->close_mask
);
421 theme
->close_hover_mask
= RrPixmapMaskCopy(theme
->close_mask
);
424 if (!read_mask(inst
, "bullet.xbm", theme
, &theme
->menu_bullet_mask
)) {
425 guchar data
[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
426 theme
->menu_bullet_mask
= RrPixmapMaskNew(inst
, 4, 7, (char*)data
);
429 /* read the decoration textures */
430 if (!read_appearance(db
, inst
,
431 "window.active.title.bg", theme
->a_focused_title
,
433 set_default_appearance(theme
->a_focused_title
);
434 if (!read_appearance(db
, inst
,
435 "window.inactive.title.bg", theme
->a_unfocused_title
,
437 set_default_appearance(theme
->a_unfocused_title
);
438 if (!read_appearance(db
, inst
,
439 "window.active.label.bg", theme
->a_focused_label
,
441 set_default_appearance(theme
->a_focused_label
);
442 if (!read_appearance(db
, inst
,
443 "window.inactive.label.bg", theme
->a_unfocused_label
,
445 set_default_appearance(theme
->a_unfocused_label
);
446 if (!read_appearance(db
, inst
,
447 "window.active.handle.bg", theme
->a_focused_handle
,
449 set_default_appearance(theme
->a_focused_handle
);
450 if (!read_appearance(db
, inst
,
451 "window.inactive.handle.bg",theme
->a_unfocused_handle
,
453 set_default_appearance(theme
->a_unfocused_handle
);
454 if (!read_appearance(db
, inst
,
455 "window.active.grip.bg", theme
->a_focused_grip
,
457 set_default_appearance(theme
->a_focused_grip
);
458 if (!read_appearance(db
, inst
,
459 "window.inactive.grip.bg", theme
->a_unfocused_grip
,
461 set_default_appearance(theme
->a_unfocused_grip
);
462 if (!read_appearance(db
, inst
,
463 "menu.items.bg", theme
->a_menu
,
465 set_default_appearance(theme
->a_menu
);
466 if (!read_appearance(db
, inst
,
467 "menu.title.bg", theme
->a_menu_title
,
469 set_default_appearance(theme
->a_menu_title
);
470 if (!read_appearance(db
, inst
,
471 "menu.items.active.bg", theme
->a_menu_selected
,
473 set_default_appearance(theme
->a_menu_selected
);
475 /* read the appearances for rendering non-decorations */
476 if (!read_appearance(db
, inst
,
477 "window.active.title.bg", theme
->app_hilite_bg
,
479 set_default_appearance(theme
->app_hilite_bg
);
480 if (!read_appearance(db
, inst
,
481 "window.active.label.bg", theme
->app_hilite_label
,
483 set_default_appearance(theme
->app_hilite_label
);
484 if (!read_appearance(db
, inst
,
485 "window.active.label.bg", theme
->app_hilite_fg
,
487 set_default_appearance(theme
->app_hilite_fg
);
488 else if (theme
->app_hilite_label
->surface
.grad
== RR_SURFACE_PARENTREL
) {
489 if (!read_appearance(db
, inst
,
490 "window.active.title.bg",
491 theme
->app_hilite_fg
,
493 set_default_appearance(theme
->app_hilite_fg
);
495 if (!read_appearance(db
, inst
,
496 "window.inactive.title.bg", theme
->app_unhilite_bg
,
498 set_default_appearance(theme
->app_unhilite_bg
);
499 if (!read_appearance(db
, inst
,
500 "window.inactive.label.bg", theme
->app_unhilite_label
,
502 set_default_appearance(theme
->app_unhilite_label
);
503 if (!read_appearance(db
, inst
,
504 "window.inactive.label.bg", theme
->app_unhilite_fg
,
506 set_default_appearance(theme
->app_unhilite_fg
);
507 else if (theme
->app_unhilite_label
->surface
.grad
== RR_SURFACE_PARENTREL
) {
508 if (!read_appearance(db
, inst
,
509 "window.inactive.title.bg",
510 theme
->app_unhilite_fg
,
512 set_default_appearance(theme
->app_unhilite_fg
);
516 /* read buttons textures */
517 if (!read_appearance(db
, inst
,
518 "window.active.button.disabled.bg",
519 theme
->a_disabled_focused_max
,
521 set_default_appearance(theme
->a_disabled_focused_max
);
522 if (!read_appearance(db
, inst
,
523 "window.inactive.button.disabled.bg",
524 theme
->a_disabled_unfocused_max
,
526 set_default_appearance(theme
->a_disabled_unfocused_max
);
527 if (!read_appearance(db
, inst
,
528 "window.active.button.pressed.bg",
529 theme
->a_focused_pressed_max
,
531 set_default_appearance(theme
->a_focused_pressed_max
);
532 if (!read_appearance(db
, inst
,
533 "window.inactive.button.pressed.bg",
534 theme
->a_unfocused_pressed_max
,
536 set_default_appearance(theme
->a_unfocused_pressed_max
);
537 if (!read_appearance(db
, inst
,
538 "window.active.button.toggled.bg",
539 theme
->a_toggled_focused_max
,
542 RrAppearanceFree(theme
->a_toggled_focused_max
);
543 theme
->a_toggled_focused_max
=
544 RrAppearanceCopy(theme
->a_focused_pressed_max
);
546 if (!read_appearance(db
, inst
,
547 "window.inactive.button.toggled.bg",
548 theme
->a_toggled_unfocused_max
,
551 RrAppearanceFree(theme
->a_toggled_unfocused_max
);
552 theme
->a_toggled_unfocused_max
=
553 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
555 if (!read_appearance(db
, inst
,
556 "window.active.button.unpressed.bg",
557 theme
->a_focused_unpressed_max
,
559 set_default_appearance(theme
->a_focused_unpressed_max
);
560 if (!read_appearance(db
, inst
,
561 "window.inactive.button.unpressed.bg",
562 theme
->a_unfocused_unpressed_max
,
564 set_default_appearance(theme
->a_unfocused_unpressed_max
);
565 if (!read_appearance(db
, inst
,
566 "window.active.button.hover.bg",
567 theme
->a_hover_focused_max
,
570 RrAppearanceFree(theme
->a_hover_focused_max
);
571 theme
->a_hover_focused_max
=
572 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
574 if (!read_appearance(db
, inst
,
575 "window.inactive.button.hover.bg",
576 theme
->a_hover_unfocused_max
,
579 RrAppearanceFree(theme
->a_hover_unfocused_max
);
580 theme
->a_hover_unfocused_max
=
581 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
584 theme
->a_disabled_focused_close
=
585 RrAppearanceCopy(theme
->a_disabled_focused_max
);
586 theme
->a_disabled_unfocused_close
=
587 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
588 theme
->a_hover_focused_close
=
589 RrAppearanceCopy(theme
->a_hover_focused_max
);
590 theme
->a_hover_unfocused_close
=
591 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
592 theme
->a_unfocused_unpressed_close
=
593 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
594 theme
->a_unfocused_pressed_close
=
595 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
596 theme
->a_focused_unpressed_close
=
597 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
598 theme
->a_focused_pressed_close
=
599 RrAppearanceCopy(theme
->a_focused_pressed_max
);
600 theme
->a_disabled_focused_desk
=
601 RrAppearanceCopy(theme
->a_disabled_focused_max
);
602 theme
->a_disabled_unfocused_desk
=
603 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
604 theme
->a_hover_focused_desk
=
605 RrAppearanceCopy(theme
->a_hover_focused_max
);
606 theme
->a_hover_unfocused_desk
=
607 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
608 theme
->a_toggled_focused_desk
=
609 RrAppearanceCopy(theme
->a_toggled_focused_max
);
610 theme
->a_toggled_unfocused_desk
=
611 RrAppearanceCopy(theme
->a_toggled_unfocused_max
);
612 theme
->a_unfocused_unpressed_desk
=
613 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
614 theme
->a_unfocused_pressed_desk
=
615 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
616 theme
->a_focused_unpressed_desk
=
617 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
618 theme
->a_focused_pressed_desk
=
619 RrAppearanceCopy(theme
->a_focused_pressed_max
);
620 theme
->a_disabled_focused_shade
=
621 RrAppearanceCopy(theme
->a_disabled_focused_max
);
622 theme
->a_disabled_unfocused_shade
=
623 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
624 theme
->a_hover_focused_shade
=
625 RrAppearanceCopy(theme
->a_hover_focused_max
);
626 theme
->a_hover_unfocused_shade
=
627 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
628 theme
->a_toggled_focused_shade
=
629 RrAppearanceCopy(theme
->a_toggled_focused_max
);
630 theme
->a_toggled_unfocused_shade
=
631 RrAppearanceCopy(theme
->a_toggled_unfocused_max
);
632 theme
->a_unfocused_unpressed_shade
=
633 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
634 theme
->a_unfocused_pressed_shade
=
635 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
636 theme
->a_focused_unpressed_shade
=
637 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
638 theme
->a_focused_pressed_shade
=
639 RrAppearanceCopy(theme
->a_focused_pressed_max
);
640 theme
->a_disabled_focused_iconify
=
641 RrAppearanceCopy(theme
->a_disabled_focused_max
);
642 theme
->a_disabled_unfocused_iconify
=
643 RrAppearanceCopy(theme
->a_disabled_focused_max
);
644 theme
->a_hover_focused_iconify
=
645 RrAppearanceCopy(theme
->a_hover_focused_max
);
646 theme
->a_hover_unfocused_iconify
=
647 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
648 theme
->a_unfocused_unpressed_iconify
=
649 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
650 theme
->a_unfocused_pressed_iconify
=
651 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
652 theme
->a_focused_unpressed_iconify
=
653 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
654 theme
->a_focused_pressed_iconify
=
655 RrAppearanceCopy(theme
->a_focused_pressed_max
);
657 theme
->a_icon
->surface
.grad
=
658 theme
->a_clear
->surface
.grad
=
659 theme
->a_clear_tex
->surface
.grad
=
660 theme
->a_menu_normal
->surface
.grad
=
661 theme
->a_menu_disabled
->surface
.grad
=
662 theme
->a_menu_text_normal
->surface
.grad
=
663 theme
->a_menu_text_disabled
->surface
.grad
=
664 theme
->a_menu_text_selected
->surface
.grad
=
665 theme
->a_menu_bullet_normal
->surface
.grad
=
666 theme
->a_menu_bullet_selected
->surface
.grad
= RR_SURFACE_PARENTREL
;
668 /* set up the textures */
669 theme
->a_focused_label
->texture
[0].type
=
670 theme
->app_hilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
671 theme
->a_focused_label
->texture
[0].data
.text
.justify
= winjust
;
672 theme
->app_hilite_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
673 theme
->a_focused_label
->texture
[0].data
.text
.font
=
674 theme
->app_hilite_label
->texture
[0].data
.text
.font
=
675 theme
->winfont_focused
;
676 theme
->a_focused_label
->texture
[0].data
.text
.color
=
677 theme
->app_hilite_label
->texture
[0].data
.text
.color
=
678 theme
->title_focused_color
;
680 theme
->a_unfocused_label
->texture
[0].type
=
681 theme
->app_unhilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
682 theme
->a_unfocused_label
->texture
[0].data
.text
.justify
= winjust
;
683 theme
->app_unhilite_label
->texture
[0].data
.text
.justify
=
685 theme
->a_unfocused_label
->texture
[0].data
.text
.font
=
686 theme
->app_unhilite_label
->texture
[0].data
.text
.font
=
687 theme
->winfont_unfocused
;
688 theme
->a_unfocused_label
->texture
[0].data
.text
.color
=
689 theme
->app_unhilite_label
->texture
[0].data
.text
.color
=
690 theme
->title_unfocused_color
;
692 theme
->a_menu_title
->texture
[0].type
= RR_TEXTURE_TEXT
;
693 theme
->a_menu_title
->texture
[0].data
.text
.justify
= mtitlejust
;
694 theme
->a_menu_title
->texture
[0].data
.text
.font
= theme
->mtitlefont
;
695 theme
->a_menu_title
->texture
[0].data
.text
.color
= theme
->menu_title_color
;
697 theme
->a_menu_text_normal
->texture
[0].type
=
698 theme
->a_menu_text_disabled
->texture
[0].type
=
699 theme
->a_menu_text_selected
->texture
[0].type
= RR_TEXTURE_TEXT
;
700 theme
->a_menu_text_normal
->texture
[0].data
.text
.justify
=
701 theme
->a_menu_text_disabled
->texture
[0].data
.text
.justify
=
702 theme
->a_menu_text_selected
->texture
[0].data
.text
.justify
=
704 theme
->a_menu_text_normal
->texture
[0].data
.text
.font
=
705 theme
->a_menu_text_disabled
->texture
[0].data
.text
.font
=
706 theme
->a_menu_text_selected
->texture
[0].data
.text
.font
= theme
->mfont
;
707 theme
->a_menu_text_normal
->texture
[0].data
.text
.color
= theme
->menu_color
;
708 theme
->a_menu_text_disabled
->texture
[0].data
.text
.color
=
709 theme
->menu_disabled_color
;
710 theme
->a_menu_text_selected
->texture
[0].data
.text
.color
=
711 theme
->menu_selected_color
;
713 theme
->a_disabled_focused_max
->texture
[0].type
=
714 theme
->a_disabled_unfocused_max
->texture
[0].type
=
715 theme
->a_hover_focused_max
->texture
[0].type
=
716 theme
->a_hover_unfocused_max
->texture
[0].type
=
717 theme
->a_toggled_focused_max
->texture
[0].type
=
718 theme
->a_toggled_unfocused_max
->texture
[0].type
=
719 theme
->a_focused_unpressed_max
->texture
[0].type
=
720 theme
->a_focused_pressed_max
->texture
[0].type
=
721 theme
->a_unfocused_unpressed_max
->texture
[0].type
=
722 theme
->a_unfocused_pressed_max
->texture
[0].type
=
723 theme
->a_disabled_focused_close
->texture
[0].type
=
724 theme
->a_disabled_unfocused_close
->texture
[0].type
=
725 theme
->a_hover_focused_close
->texture
[0].type
=
726 theme
->a_hover_unfocused_close
->texture
[0].type
=
727 theme
->a_focused_unpressed_close
->texture
[0].type
=
728 theme
->a_focused_pressed_close
->texture
[0].type
=
729 theme
->a_unfocused_unpressed_close
->texture
[0].type
=
730 theme
->a_unfocused_pressed_close
->texture
[0].type
=
731 theme
->a_disabled_focused_desk
->texture
[0].type
=
732 theme
->a_disabled_unfocused_desk
->texture
[0].type
=
733 theme
->a_hover_focused_desk
->texture
[0].type
=
734 theme
->a_hover_unfocused_desk
->texture
[0].type
=
735 theme
->a_toggled_focused_desk
->texture
[0].type
=
736 theme
->a_toggled_unfocused_desk
->texture
[0].type
=
737 theme
->a_focused_unpressed_desk
->texture
[0].type
=
738 theme
->a_focused_pressed_desk
->texture
[0].type
=
739 theme
->a_unfocused_unpressed_desk
->texture
[0].type
=
740 theme
->a_unfocused_pressed_desk
->texture
[0].type
=
741 theme
->a_disabled_focused_shade
->texture
[0].type
=
742 theme
->a_disabled_unfocused_shade
->texture
[0].type
=
743 theme
->a_hover_focused_shade
->texture
[0].type
=
744 theme
->a_hover_unfocused_shade
->texture
[0].type
=
745 theme
->a_toggled_focused_shade
->texture
[0].type
=
746 theme
->a_toggled_unfocused_shade
->texture
[0].type
=
747 theme
->a_focused_unpressed_shade
->texture
[0].type
=
748 theme
->a_focused_pressed_shade
->texture
[0].type
=
749 theme
->a_unfocused_unpressed_shade
->texture
[0].type
=
750 theme
->a_unfocused_pressed_shade
->texture
[0].type
=
751 theme
->a_disabled_focused_iconify
->texture
[0].type
=
752 theme
->a_disabled_unfocused_iconify
->texture
[0].type
=
753 theme
->a_hover_focused_iconify
->texture
[0].type
=
754 theme
->a_hover_unfocused_iconify
->texture
[0].type
=
755 theme
->a_focused_unpressed_iconify
->texture
[0].type
=
756 theme
->a_focused_pressed_iconify
->texture
[0].type
=
757 theme
->a_unfocused_unpressed_iconify
->texture
[0].type
=
758 theme
->a_unfocused_pressed_iconify
->texture
[0].type
=
759 theme
->a_menu_bullet_normal
->texture
[0].type
=
760 theme
->a_menu_bullet_selected
->texture
[0].type
= RR_TEXTURE_MASK
;
762 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.mask
=
763 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.mask
=
764 theme
->max_disabled_mask
;
765 theme
->a_hover_focused_max
->texture
[0].data
.mask
.mask
=
766 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.mask
=
767 theme
->max_hover_mask
;
768 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.mask
=
769 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.mask
=
770 theme
->max_pressed_mask
;
771 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.mask
=
772 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.mask
=
774 theme
->a_toggled_focused_max
->texture
[0].data
.mask
.mask
=
775 theme
->a_toggled_unfocused_max
->texture
[0].data
.mask
.mask
=
776 theme
->max_toggled_mask
;
777 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.mask
=
778 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.mask
=
779 theme
->close_disabled_mask
;
780 theme
->a_hover_focused_close
->texture
[0].data
.mask
.mask
=
781 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.mask
=
782 theme
->close_hover_mask
;
783 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.mask
=
784 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.mask
=
785 theme
->close_pressed_mask
;
786 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.mask
=
787 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.mask
=
789 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.mask
=
790 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.mask
=
791 theme
->desk_disabled_mask
;
792 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.mask
=
793 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.mask
=
794 theme
->desk_hover_mask
;
795 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.mask
=
796 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.mask
=
797 theme
->desk_pressed_mask
;
798 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.mask
=
799 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.mask
=
801 theme
->a_toggled_focused_desk
->texture
[0].data
.mask
.mask
=
802 theme
->a_toggled_unfocused_desk
->texture
[0].data
.mask
.mask
=
803 theme
->desk_toggled_mask
;
804 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.mask
=
805 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.mask
=
806 theme
->shade_disabled_mask
;
807 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.mask
=
808 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.mask
=
809 theme
->shade_hover_mask
;
810 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.mask
=
811 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.mask
=
812 theme
->shade_pressed_mask
;
813 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.mask
=
814 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.mask
=
816 theme
->a_toggled_focused_shade
->texture
[0].data
.mask
.mask
=
817 theme
->a_toggled_unfocused_shade
->texture
[0].data
.mask
.mask
=
818 theme
->shade_toggled_mask
;
819 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.mask
=
820 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.mask
=
821 theme
->iconify_disabled_mask
;
822 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.mask
=
823 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.mask
=
824 theme
->iconify_hover_mask
;
825 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.mask
=
826 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.mask
=
827 theme
->iconify_pressed_mask
;
828 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
829 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
831 theme
->a_menu_bullet_normal
->texture
[0].data
.mask
.mask
=
832 theme
->a_menu_bullet_selected
->texture
[0].data
.mask
.mask
=
833 theme
->menu_bullet_mask
;
834 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.color
=
835 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.color
=
836 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.color
=
837 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.color
=
838 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.color
=
839 theme
->titlebut_disabled_focused_color
;
840 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.color
=
841 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.color
=
842 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.color
=
843 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.color
=
844 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.color
=
845 theme
->titlebut_disabled_unfocused_color
;
846 theme
->a_hover_focused_max
->texture
[0].data
.mask
.color
=
847 theme
->a_hover_focused_close
->texture
[0].data
.mask
.color
=
848 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.color
=
849 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.color
=
850 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.color
=
851 theme
->titlebut_hover_focused_color
;
852 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.color
=
853 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.color
=
854 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.color
=
855 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.color
=
856 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.color
=
857 theme
->titlebut_hover_unfocused_color
;
858 theme
->a_toggled_focused_max
->texture
[0].data
.mask
.color
=
859 theme
->a_toggled_focused_desk
->texture
[0].data
.mask
.color
=
860 theme
->a_toggled_focused_shade
->texture
[0].data
.mask
.color
=
861 theme
->titlebut_toggled_focused_color
;
862 theme
->a_toggled_unfocused_max
->texture
[0].data
.mask
.color
=
863 theme
->a_toggled_unfocused_desk
->texture
[0].data
.mask
.color
=
864 theme
->a_toggled_unfocused_shade
->texture
[0].data
.mask
.color
=
865 theme
->titlebut_toggled_unfocused_color
;
866 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.color
=
867 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.color
=
868 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.color
=
869 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.color
=
870 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.color
=
871 theme
->titlebut_focused_unpressed_color
;
872 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.color
=
873 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.color
=
874 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.color
=
875 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.color
=
876 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.color
=
877 theme
->titlebut_focused_pressed_color
;
878 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.color
=
879 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.color
=
880 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.color
=
881 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.color
=
882 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.color
=
883 theme
->titlebut_unfocused_unpressed_color
;
884 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.color
=
885 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.color
=
886 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.color
=
887 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.color
=
888 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.color
=
889 theme
->titlebut_unfocused_pressed_color
;
890 theme
->a_menu_bullet_normal
->texture
[0].data
.mask
.color
=
892 theme
->a_menu_bullet_selected
->texture
[0].data
.mask
.color
=
893 theme
->menu_selected_color
;
895 XrmDestroyDatabase(db
);
901 RrMargins(theme
->a_focused_label
, &fl
, &ft
, &fr
, &fb
);
902 RrMargins(theme
->a_unfocused_label
, &ul
, &ut
, &ur
, &ub
);
903 theme
->label_height
= theme
->winfont_height
904 + MAX(ft
+ fb
, ut
+ ub
);
906 /* this would be nice I think, since padding.width can now be 0,
907 but it breaks frame.c horribly and I don't feel like fixing that
908 right now, so if anyone complains, here is how to keep text from
909 going over the title's bevel/border with a padding.width of 0 and a
910 bevelless/borderless label
911 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
912 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
913 theme->title_height = theme->label_height +
914 MAX(MAX(theme->padding * 2, ft + fb),
915 MAX(theme->padding * 2, ut + ub));
917 theme
->title_height
= theme
->label_height
+ theme
->padding
* 2;
919 theme
->button_size
= theme
->label_height
- 2;
920 theme
->grip_width
= theme
->title_height
* 1.5;
925 void RrThemeFree(RrTheme
*theme
)
931 RrColorFree(theme
->b_color
);
932 RrColorFree(theme
->cb_unfocused_color
);
933 RrColorFree(theme
->cb_focused_color
);
934 RrColorFree(theme
->title_unfocused_color
);
935 RrColorFree(theme
->title_focused_color
);
936 RrColorFree(theme
->titlebut_disabled_focused_color
);
937 RrColorFree(theme
->titlebut_disabled_unfocused_color
);
938 RrColorFree(theme
->titlebut_hover_focused_color
);
939 RrColorFree(theme
->titlebut_hover_unfocused_color
);
940 RrColorFree(theme
->titlebut_toggled_focused_color
);
941 RrColorFree(theme
->titlebut_toggled_unfocused_color
);
942 RrColorFree(theme
->titlebut_unfocused_pressed_color
);
943 RrColorFree(theme
->titlebut_focused_pressed_color
);
944 RrColorFree(theme
->titlebut_unfocused_unpressed_color
);
945 RrColorFree(theme
->titlebut_focused_unpressed_color
);
946 RrColorFree(theme
->menu_color
);
947 RrColorFree(theme
->menu_title_color
);
948 RrColorFree(theme
->menu_disabled_color
);
949 RrColorFree(theme
->menu_selected_color
);
951 g_free(theme
->def_win_icon
);
953 RrPixmapMaskFree(theme
->max_mask
);
954 RrPixmapMaskFree(theme
->max_toggled_mask
);
955 RrPixmapMaskFree(theme
->max_disabled_mask
);
956 RrPixmapMaskFree(theme
->max_hover_mask
);
957 RrPixmapMaskFree(theme
->max_pressed_mask
);
958 RrPixmapMaskFree(theme
->desk_mask
);
959 RrPixmapMaskFree(theme
->desk_toggled_mask
);
960 RrPixmapMaskFree(theme
->desk_disabled_mask
);
961 RrPixmapMaskFree(theme
->desk_hover_mask
);
962 RrPixmapMaskFree(theme
->desk_pressed_mask
);
963 RrPixmapMaskFree(theme
->shade_mask
);
964 RrPixmapMaskFree(theme
->shade_toggled_mask
);
965 RrPixmapMaskFree(theme
->shade_disabled_mask
);
966 RrPixmapMaskFree(theme
->shade_hover_mask
);
967 RrPixmapMaskFree(theme
->shade_pressed_mask
);
968 RrPixmapMaskFree(theme
->iconify_mask
);
969 RrPixmapMaskFree(theme
->iconify_disabled_mask
);
970 RrPixmapMaskFree(theme
->iconify_hover_mask
);
971 RrPixmapMaskFree(theme
->iconify_pressed_mask
);
972 RrPixmapMaskFree(theme
->close_mask
);
973 RrPixmapMaskFree(theme
->close_disabled_mask
);
974 RrPixmapMaskFree(theme
->close_hover_mask
);
975 RrPixmapMaskFree(theme
->close_pressed_mask
);
976 RrPixmapMaskFree(theme
->menu_bullet_mask
);
978 RrFontClose(theme
->winfont_focused
);
979 RrFontClose(theme
->winfont_unfocused
);
980 RrFontClose(theme
->mtitlefont
);
981 RrFontClose(theme
->mfont
);
983 RrAppearanceFree(theme
->a_disabled_focused_max
);
984 RrAppearanceFree(theme
->a_disabled_unfocused_max
);
985 RrAppearanceFree(theme
->a_hover_focused_max
);
986 RrAppearanceFree(theme
->a_hover_unfocused_max
);
987 RrAppearanceFree(theme
->a_toggled_focused_max
);
988 RrAppearanceFree(theme
->a_toggled_unfocused_max
);
989 RrAppearanceFree(theme
->a_focused_unpressed_max
);
990 RrAppearanceFree(theme
->a_focused_pressed_max
);
991 RrAppearanceFree(theme
->a_unfocused_unpressed_max
);
992 RrAppearanceFree(theme
->a_unfocused_pressed_max
);
993 RrAppearanceFree(theme
->a_disabled_focused_close
);
994 RrAppearanceFree(theme
->a_disabled_unfocused_close
);
995 RrAppearanceFree(theme
->a_hover_focused_close
);
996 RrAppearanceFree(theme
->a_hover_unfocused_close
);
997 RrAppearanceFree(theme
->a_focused_unpressed_close
);
998 RrAppearanceFree(theme
->a_focused_pressed_close
);
999 RrAppearanceFree(theme
->a_unfocused_unpressed_close
);
1000 RrAppearanceFree(theme
->a_unfocused_pressed_close
);
1001 RrAppearanceFree(theme
->a_disabled_focused_desk
);
1002 RrAppearanceFree(theme
->a_disabled_unfocused_desk
);
1003 RrAppearanceFree(theme
->a_hover_focused_desk
);
1004 RrAppearanceFree(theme
->a_hover_unfocused_desk
);
1005 RrAppearanceFree(theme
->a_toggled_focused_desk
);
1006 RrAppearanceFree(theme
->a_toggled_unfocused_desk
);
1007 RrAppearanceFree(theme
->a_focused_unpressed_desk
);
1008 RrAppearanceFree(theme
->a_focused_pressed_desk
);
1009 RrAppearanceFree(theme
->a_unfocused_unpressed_desk
);
1010 RrAppearanceFree(theme
->a_unfocused_pressed_desk
);
1011 RrAppearanceFree(theme
->a_disabled_focused_shade
);
1012 RrAppearanceFree(theme
->a_disabled_unfocused_shade
);
1013 RrAppearanceFree(theme
->a_hover_focused_shade
);
1014 RrAppearanceFree(theme
->a_hover_unfocused_shade
);
1015 RrAppearanceFree(theme
->a_toggled_focused_shade
);
1016 RrAppearanceFree(theme
->a_toggled_unfocused_shade
);
1017 RrAppearanceFree(theme
->a_focused_unpressed_shade
);
1018 RrAppearanceFree(theme
->a_focused_pressed_shade
);
1019 RrAppearanceFree(theme
->a_unfocused_unpressed_shade
);
1020 RrAppearanceFree(theme
->a_unfocused_pressed_shade
);
1021 RrAppearanceFree(theme
->a_disabled_focused_iconify
);
1022 RrAppearanceFree(theme
->a_disabled_unfocused_iconify
);
1023 RrAppearanceFree(theme
->a_hover_focused_iconify
);
1024 RrAppearanceFree(theme
->a_hover_unfocused_iconify
);
1025 RrAppearanceFree(theme
->a_focused_unpressed_iconify
);
1026 RrAppearanceFree(theme
->a_focused_pressed_iconify
);
1027 RrAppearanceFree(theme
->a_unfocused_unpressed_iconify
);
1028 RrAppearanceFree(theme
->a_unfocused_pressed_iconify
);
1029 RrAppearanceFree(theme
->a_focused_grip
);
1030 RrAppearanceFree(theme
->a_unfocused_grip
);
1031 RrAppearanceFree(theme
->a_focused_title
);
1032 RrAppearanceFree(theme
->a_unfocused_title
);
1033 RrAppearanceFree(theme
->a_focused_label
);
1034 RrAppearanceFree(theme
->a_unfocused_label
);
1035 RrAppearanceFree(theme
->a_icon
);
1036 RrAppearanceFree(theme
->a_focused_handle
);
1037 RrAppearanceFree(theme
->a_unfocused_handle
);
1038 RrAppearanceFree(theme
->a_menu
);
1039 RrAppearanceFree(theme
->a_menu_title
);
1040 RrAppearanceFree(theme
->a_menu_normal
);
1041 RrAppearanceFree(theme
->a_menu_disabled
);
1042 RrAppearanceFree(theme
->a_menu_selected
);
1043 RrAppearanceFree(theme
->a_menu_text_normal
);
1044 RrAppearanceFree(theme
->a_menu_text_disabled
);
1045 RrAppearanceFree(theme
->a_menu_text_selected
);
1046 RrAppearanceFree(theme
->a_menu_bullet_normal
);
1047 RrAppearanceFree(theme
->a_menu_bullet_selected
);
1048 RrAppearanceFree(theme
->a_clear
);
1049 RrAppearanceFree(theme
->a_clear_tex
);
1050 RrAppearanceFree(theme
->app_hilite_bg
);
1051 RrAppearanceFree(theme
->app_unhilite_bg
);
1052 RrAppearanceFree(theme
->app_hilite_fg
);
1053 RrAppearanceFree(theme
->app_unhilite_fg
);
1054 RrAppearanceFree(theme
->app_hilite_label
);
1055 RrAppearanceFree(theme
->app_unhilite_label
);
1061 static XrmDatabase
loaddb(RrTheme
*theme
, char *name
)
1064 XrmDatabase db
= NULL
;
1067 if (name
[0] == '/') {
1068 s
= g_build_filename(name
, "openbox-3", "themerc", NULL
);
1069 if ((db
= XrmGetFileDatabase(s
)))
1070 theme
->path
= g_path_get_dirname(s
);
1073 for (it
= parse_xdg_data_dir_paths(); !db
&& it
;
1074 it
= g_slist_next(it
))
1076 s
= g_build_filename(it
->data
, "themes", name
,
1077 "openbox-3", "themerc", NULL
);
1078 if ((db
= XrmGetFileDatabase(s
)))
1079 theme
->path
= g_path_get_dirname(s
);
1085 s
= g_build_filename(name
, "themerc", NULL
);
1086 if ((db
= XrmGetFileDatabase(s
)))
1087 theme
->path
= g_path_get_dirname(s
);
1094 static char *create_class_name(char *rname
)
1096 char *rclass
= g_strdup(rname
);
1101 p
= strchr(p
+1, '.');
1102 if (p
== NULL
) break;
1104 if (*p
== '\0') break;
1109 static gboolean
read_int(XrmDatabase db
, char *rname
, int *value
)
1111 gboolean ret
= FALSE
;
1112 char *rclass
= create_class_name(rname
);
1113 char *rettype
, *end
;
1116 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1117 retvalue
.addr
!= NULL
) {
1118 *value
= (int)strtol(retvalue
.addr
, &end
, 10);
1119 if (end
!= retvalue
.addr
)
1127 static gboolean
read_string(XrmDatabase db
, char *rname
, char **value
)
1129 gboolean ret
= FALSE
;
1130 char *rclass
= create_class_name(rname
);
1134 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1135 retvalue
.addr
!= NULL
) {
1136 *value
= retvalue
.addr
;
1144 static gboolean
read_color(XrmDatabase db
, const RrInstance
*inst
,
1145 gchar
*rname
, RrColor
**value
)
1147 gboolean ret
= FALSE
;
1148 char *rclass
= create_class_name(rname
);
1152 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1153 retvalue
.addr
!= NULL
) {
1154 RrColor
*c
= RrColorParse(inst
, retvalue
.addr
);
1165 static gboolean
read_mask(const RrInstance
*inst
,
1166 gchar
*maskname
, RrTheme
*theme
,
1167 RrPixmapMask
**value
)
1169 gboolean ret
= FALSE
;
1171 int hx
, hy
; /* ignored */
1175 s
= g_build_filename(theme
->path
, maskname
, NULL
);
1176 if (XReadBitmapFileData(s
, &w
, &h
, &b
, &hx
, &hy
) == BitmapSuccess
) {
1178 *value
= RrPixmapMaskNew(inst
, w
, h
, (char*)b
);
1186 static void parse_appearance(gchar
*tex
, RrSurfaceColorType
*grad
,
1187 RrReliefType
*relief
, RrBevelType
*bevel
,
1188 gboolean
*interlaced
, gboolean
*border
,
1189 gboolean allow_trans
)
1193 /* convert to all lowercase */
1194 for (t
= tex
; *t
!= '\0'; ++t
)
1195 *t
= g_ascii_tolower(*t
);
1197 if (allow_trans
&& strstr(tex
, "parentrelative") != NULL
) {
1198 *grad
= RR_SURFACE_PARENTREL
;
1200 if (strstr(tex
, "gradient") != NULL
) {
1201 if (strstr(tex
, "crossdiagonal") != NULL
)
1202 *grad
= RR_SURFACE_CROSS_DIAGONAL
;
1203 else if (strstr(tex
, "pyramid") != NULL
)
1204 *grad
= RR_SURFACE_PYRAMID
;
1205 else if (strstr(tex
, "horizontal") != NULL
)
1206 *grad
= RR_SURFACE_HORIZONTAL
;
1207 else if (strstr(tex
, "vertical") != NULL
)
1208 *grad
= RR_SURFACE_VERTICAL
;
1210 *grad
= RR_SURFACE_DIAGONAL
;
1212 *grad
= RR_SURFACE_SOLID
;
1215 if (strstr(tex
, "sunken") != NULL
)
1216 *relief
= RR_RELIEF_SUNKEN
;
1217 else if (strstr(tex
, "flat") != NULL
)
1218 *relief
= RR_RELIEF_FLAT
;
1220 *relief
= RR_RELIEF_RAISED
;
1223 if (*relief
== RR_RELIEF_FLAT
) {
1224 if (strstr(tex
, "border") != NULL
)
1227 if (strstr(tex
, "bevel2") != NULL
)
1228 *bevel
= RR_BEVEL_2
;
1230 *bevel
= RR_BEVEL_1
;
1233 if (strstr(tex
, "interlaced") != NULL
)
1236 *interlaced
= FALSE
;
1241 static gboolean
read_appearance(XrmDatabase db
, const RrInstance
*inst
,
1242 gchar
*rname
, RrAppearance
*value
,
1243 gboolean allow_trans
)
1245 gboolean ret
= FALSE
;
1246 char *rclass
= create_class_name(rname
);
1247 char *cname
, *ctoname
, *bcname
, *icname
;
1251 cname
= g_strconcat(rname
, ".color", NULL
);
1252 ctoname
= g_strconcat(rname
, ".colorTo", NULL
);
1253 bcname
= g_strconcat(rname
, ".border.color", NULL
);
1254 icname
= g_strconcat(rname
, ".interlace.color", NULL
);
1256 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1257 retvalue
.addr
!= NULL
) {
1258 parse_appearance(retvalue
.addr
,
1259 &value
->surface
.grad
,
1260 &value
->surface
.relief
,
1261 &value
->surface
.bevel
,
1262 &value
->surface
.interlaced
,
1263 &value
->surface
.border
,
1265 if (!read_color(db
, inst
, cname
, &value
->surface
.primary
))
1266 value
->surface
.primary
= RrColorNew(inst
, 0, 0, 0);
1267 if (!read_color(db
, inst
, ctoname
, &value
->surface
.secondary
))
1268 value
->surface
.secondary
= RrColorNew(inst
, 0, 0, 0);
1269 if (value
->surface
.border
)
1270 if (!read_color(db
, inst
, bcname
,
1271 &value
->surface
.border_color
))
1272 value
->surface
.border_color
= RrColorNew(inst
, 0, 0, 0);
1273 if (value
->surface
.interlaced
)
1274 if (!read_color(db
, inst
, icname
,
1275 &value
->surface
.interlace_color
))
1276 value
->surface
.interlace_color
= RrColorNew(inst
, 0, 0, 0);
1288 static void set_default_appearance(RrAppearance
*a
)
1290 a
->surface
.grad
= RR_SURFACE_SOLID
;
1291 a
->surface
.relief
= RR_RELIEF_FLAT
;
1292 a
->surface
.bevel
= RR_BEVEL_1
;
1293 a
->surface
.interlaced
= FALSE
;
1294 a
->surface
.border
= FALSE
;
1295 a
->surface
.primary
= RrColorNew(a
->inst
, 0, 0, 0);
1296 a
->surface
.secondary
= RrColorNew(a
->inst
, 0, 0, 0);
1299 /* Reads the output from gimp's C-Source file format into valid RGBA data for
1300 an RrTextureRGBA. */
1301 static RrPixel32
* read_c_image(gint width
, gint height
, const guint8
*data
)
1306 p
= im
= g_memdup(data
, width
* height
* sizeof(RrPixel32
));
1308 for (i
= 0; i
< width
* height
; ++i
) {
1309 guchar a
= ((*p
>> 24) & 0xff);
1310 guchar b
= ((*p
>> 16) & 0xff);
1311 guchar g
= ((*p
>> 8) & 0xff);
1312 guchar r
= ((*p
>> 0) & 0xff);
1314 *p
= ((r
<< RrDefaultRedOffset
) +
1315 (g
<< RrDefaultGreenOffset
) +
1316 (b
<< RrDefaultBlueOffset
) +
1317 (a
<< RrDefaultAlphaOffset
));