1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 theme.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 See the COPYING file for a copy of the GNU General Public License.
26 #include "parser/parse.h"
29 #include <X11/Xresource.h>
34 static XrmDatabase loaddb(const gchar *name, gchar **path);
35 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value);
36 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value);
37 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
38 const gchar *rname, RrColor **value);
39 static gboolean read_mask(const RrInstance *inst, const gchar *path,
40 RrTheme *theme, const gchar *maskname,
41 RrPixmapMask **value);
42 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
43 const gchar *rname, RrAppearance *value,
44 gboolean allow_trans);
45 static int parse_inline_number(const char *p);
46 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data);
47 static void set_default_appearance(RrAppearance *a);
49 #define READ_INT(x_resstr, x_var, x_min, x_max, x_def) \
50 if (!read_int(db, x_resstr, & x_var) || \
51 x_var < x_min || x_var > x_max) \
54 #define READ_COLOR(x_resstr, x_var, x_def) \
55 if (!read_color(db, inst, x_resstr, & x_var)) \
58 #define READ_COLOR_(x_res1, x_res2, x_var, x_def) \
59 if (!read_color(db, inst, x_res1, & x_var) && \
60 !read_color(db, inst, x_res2, & x_var)) \
63 #define READ_MASK_COPY(x_file, x_var, x_copysrc) \
64 if (!read_mask(inst, path, theme, x_file, & x_var)) \
65 x_var = RrPixmapMaskCopy(x_copysrc);
67 #define READ_APPEARANCE(x_resstr, x_var, x_parrel) \
68 if (!read_appearance(db, inst, x_resstr, x_var, x_parrel)) \
69 set_default_appearance(x_var);
71 #define READ_APPEARANCE_COPY(x_resstr, x_var, x_parrel, x_defval) \
72 if (!read_appearance(db, inst, x_resstr, x_var, x_parrel)) {\
73 RrAppearanceFree(x_var); \
74 x_var = RrAppearanceCopy(x_defval); }
76 #define READ_APPEARANCE_(x_res1, x_res2, x_var, x_parrel, x_defval) \
77 if (!read_appearance(db, inst, x_res1, x_var, x_parrel) && \
78 !read_appearance(db, inst, x_res2, x_var, x_parrel)) {\
79 RrAppearanceFree(x_var); \
80 x_var = RrAppearanceCopy(x_defval); }
82 RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
83 gboolean allow_fallback,
84 RrFont *active_window_font, RrFont *inactive_window_font,
85 RrFont *menu_title_font, RrFont *menu_item_font,
88 XrmDatabase db = NULL;
89 RrJustify winjust, mtitlejust;
94 RrAppearance *a_disabled_focused_tmp;
95 RrAppearance *a_disabled_unfocused_tmp;
96 RrAppearance *a_hover_focused_tmp;
97 RrAppearance *a_hover_unfocused_tmp;
98 RrAppearance *a_focused_unpressed_tmp;
99 RrAppearance *a_focused_pressed_tmp;
100 RrAppearance *a_unfocused_unpressed_tmp;
101 RrAppearance *a_unfocused_pressed_tmp;
102 RrAppearance *a_toggled_hover_focused_tmp;
103 RrAppearance *a_toggled_hover_unfocused_tmp;
104 RrAppearance *a_toggled_focused_unpressed_tmp;
105 RrAppearance *a_toggled_focused_pressed_tmp;
106 RrAppearance *a_toggled_unfocused_unpressed_tmp;
107 RrAppearance *a_toggled_unfocused_pressed_tmp;
110 db = loaddb(name, &path);
112 g_message("Unable to load the theme '%s'", name);
114 g_message("Falling back to the default theme '%s'",
116 /* fallback to the default theme */
121 if (allow_fallback) {
122 db = loaddb(DEFAULT_THEME, &path);
124 g_message("Unable to load the theme '%s'", DEFAULT_THEME);
131 /* initialize temp reading textures */
132 a_disabled_focused_tmp = RrAppearanceNew(inst, 1);
133 a_disabled_unfocused_tmp = RrAppearanceNew(inst, 1);
134 a_hover_focused_tmp = RrAppearanceNew(inst, 1);
135 a_hover_unfocused_tmp = RrAppearanceNew(inst, 1);
136 a_toggled_focused_unpressed_tmp = RrAppearanceNew(inst, 1);
137 a_toggled_unfocused_unpressed_tmp = RrAppearanceNew(inst, 1);
138 a_toggled_hover_focused_tmp = RrAppearanceNew(inst, 1);
139 a_toggled_hover_unfocused_tmp = RrAppearanceNew(inst, 1);
140 a_toggled_focused_pressed_tmp = RrAppearanceNew(inst, 1);
141 a_toggled_unfocused_pressed_tmp = RrAppearanceNew(inst, 1);
142 a_focused_unpressed_tmp = RrAppearanceNew(inst, 1);
143 a_focused_pressed_tmp = RrAppearanceNew(inst, 1);
144 a_unfocused_unpressed_tmp = RrAppearanceNew(inst, 1);
145 a_unfocused_pressed_tmp = RrAppearanceNew(inst, 1);
147 /* initialize theme */
148 theme = g_new0(RrTheme, 1);
151 theme->name = g_strdup(name ? name : DEFAULT_THEME);
154 theme->btn_max = RrButtonNew(inst);
155 theme->btn_close = RrButtonNew(inst);
156 theme->btn_desk = RrButtonNew(inst);
157 theme->btn_shade = RrButtonNew(inst);
158 theme->btn_iconify = RrButtonNew(inst);
160 /* init appearances */
161 theme->a_focused_grip = RrAppearanceNew(inst, 0);
162 theme->a_unfocused_grip = RrAppearanceNew(inst, 0);
163 theme->a_focused_title = RrAppearanceNew(inst, 0);
164 theme->a_unfocused_title = RrAppearanceNew(inst, 0);
165 theme->a_focused_label = RrAppearanceNew(inst, 1);
166 theme->a_unfocused_label = RrAppearanceNew(inst, 1);
167 theme->a_icon = RrAppearanceNew(inst, 1);
168 theme->a_focused_handle = RrAppearanceNew(inst, 0);
169 theme->a_unfocused_handle = RrAppearanceNew(inst, 0);
170 theme->a_menu = RrAppearanceNew(inst, 0);
171 theme->a_menu_title = RrAppearanceNew(inst, 0);
172 theme->a_menu_text_title = RrAppearanceNew(inst, 1);
173 theme->a_menu_normal = RrAppearanceNew(inst, 0);
174 theme->a_menu_selected = RrAppearanceNew(inst, 0);
175 theme->a_menu_disabled = RrAppearanceNew(inst, 0);
176 /* a_menu_disabled_selected is copied from a_menu_selected */
177 theme->a_menu_text_normal = RrAppearanceNew(inst, 1);
178 theme->a_menu_text_selected = RrAppearanceNew(inst, 1);
179 theme->a_menu_text_disabled = RrAppearanceNew(inst, 1);
180 theme->a_menu_text_disabled_selected = RrAppearanceNew(inst, 1);
181 theme->a_menu_bullet_normal = RrAppearanceNew(inst, 1);
182 theme->a_menu_bullet_selected = RrAppearanceNew(inst, 1);
183 theme->a_clear = RrAppearanceNew(inst, 0);
184 theme->a_clear_tex = RrAppearanceNew(inst, 1);
185 theme->osd_hilite_bg = RrAppearanceNew(inst, 0);
186 theme->osd_hilite_label = RrAppearanceNew(inst, 1);
187 theme->osd_hilite_fg = RrAppearanceNew(inst, 0);
188 theme->osd_unhilite_fg = RrAppearanceNew(inst, 0);
190 /* load the font stuff */
191 if (active_window_font) {
192 theme->win_font_focused = active_window_font;
193 RrFontRef(active_window_font);
195 theme->win_font_focused = RrFontOpenDefault(inst);
197 if (inactive_window_font) {
198 theme->win_font_unfocused = inactive_window_font;
199 RrFontRef(inactive_window_font);
201 theme->win_font_unfocused = RrFontOpenDefault(inst);
203 winjust = RR_JUSTIFY_LEFT;
204 if (read_string(db, "window.label.text.justify", &str)) {
205 if (!g_ascii_strcasecmp(str, "right"))
206 winjust = RR_JUSTIFY_RIGHT;
207 else if (!g_ascii_strcasecmp(str, "center"))
208 winjust = RR_JUSTIFY_CENTER;
211 if (menu_title_font) {
212 theme->menu_title_font = menu_title_font;
213 RrFontRef(menu_title_font);
215 theme->menu_title_font = RrFontOpenDefault(inst);
217 mtitlejust = RR_JUSTIFY_LEFT;
218 if (read_string(db, "menu.title.text.justify", &str)) {
219 if (!g_ascii_strcasecmp(str, "right"))
220 mtitlejust = RR_JUSTIFY_RIGHT;
221 else if (!g_ascii_strcasecmp(str, "center"))
222 mtitlejust = RR_JUSTIFY_CENTER;
225 if (menu_item_font) {
226 theme->menu_font = menu_item_font;
227 RrFontRef(menu_item_font);
229 theme->menu_font = RrFontOpenDefault(inst);
232 theme->osd_font = osd_font;
235 theme->osd_font = RrFontOpenDefault(inst);
237 /* load direct dimensions */
238 READ_INT("menu.overlap", theme->menu_overlap, -100, 100, 0);
239 READ_INT("window.handle.width", theme->handle_height, 0, 100, 6);
240 READ_INT("padding.width", theme->paddingx, 0, 100, 3);
241 READ_INT("padding.height", theme->paddingy, 0, 100, theme->paddingx);
242 READ_INT("border.width", theme->fbwidth, 0, 100, 1);
243 READ_INT("menu.border.width", theme->mbwidth, 0, 100, theme->fbwidth);
244 READ_INT("osd.border.width", theme->obwidth, 0, 100, theme->fbwidth);
245 READ_INT("window.client.padding.width", theme->cbwidthx, 0, 100,
247 READ_INT("window.client.padding.height", theme->cbwidthy, 0, 100,
251 READ_COLOR_("window.active.border.color", "border.color",
252 theme->frame_focused_border_color, RrColorNew(inst, 0, 0, 0));
254 /* title separator focused color inherits from focused boder color */
255 READ_COLOR("window.active.title.separator.color",
256 theme->title_separator_focused_color,
257 RrColorCopy(theme->frame_focused_border_color));
259 /* unfocused border color inherits from frame focused border color */
260 READ_COLOR("window.inactive.border.color",
261 theme->frame_unfocused_border_color,
262 RrColorCopy(theme->frame_focused_border_color));
264 /* title separator unfocused color inherits from unfocused boder color */
265 READ_COLOR("window.inactive.title.separator.color",
266 theme->title_separator_unfocused_color,
267 RrColorCopy(theme->frame_unfocused_border_color));
269 /* menu border color inherits from frame focused border color */
270 READ_COLOR("menu.border.color", theme->menu_border_color,
271 RrColorCopy(theme->frame_focused_border_color));
273 /* osd border color inherits from frame focused border color */
274 READ_COLOR("osd.border.color", theme->osd_border_color,
275 RrColorCopy(theme->frame_focused_border_color));
277 READ_COLOR("window.active.client.color", theme->cb_focused_color,
278 RrColorNew(inst, 0xff, 0xff, 0xff));
280 READ_COLOR("window.inactive.client.color", theme->cb_unfocused_color,
281 RrColorNew(inst, 0xff, 0xff, 0xff));
283 READ_COLOR("window.active.label.text.color", theme->title_focused_color,
284 RrColorNew(inst, 0x0, 0x0, 0x0));
286 READ_COLOR("osd.label.text.color", theme->osd_color,
287 RrColorCopy(theme->title_focused_color));
289 READ_COLOR("window.inactive.label.text.color",
290 theme->title_unfocused_color,
291 RrColorNew(inst, 0xff, 0xff, 0xff));
293 READ_COLOR("window.active.button.unpressed.image.color",
294 theme->titlebut_focused_unpressed_color,
295 RrColorNew(inst, 0, 0, 0));
297 READ_COLOR("window.inactive.button.unpressed.image.color",
298 theme->titlebut_unfocused_unpressed_color,
299 RrColorNew(inst, 0xff, 0xff, 0xff));
301 READ_COLOR("window.active.button.pressed.image.color",
302 theme->titlebut_focused_pressed_color,
303 RrColorCopy(theme->titlebut_focused_unpressed_color));
305 READ_COLOR("window.inactive.button.pressed.image.color",
306 theme->titlebut_unfocused_pressed_color,
307 RrColorCopy(theme->titlebut_unfocused_unpressed_color));
309 READ_COLOR("window.active.button.disabled.image.color",
310 theme->titlebut_disabled_focused_color,
311 RrColorNew(inst, 0xff, 0xff, 0xff));
313 READ_COLOR("window.inactive.button.disabled.image.color",
314 theme->titlebut_disabled_unfocused_color,
315 RrColorNew(inst, 0, 0, 0));
317 READ_COLOR("window.active.button.hover.image.color",
318 theme->titlebut_hover_focused_color,
319 RrColorCopy(theme->titlebut_focused_unpressed_color));
321 READ_COLOR("window.inactive.button.hover.image.color",
322 theme->titlebut_hover_unfocused_color,
323 RrColorCopy(theme->titlebut_unfocused_unpressed_color));
325 READ_COLOR_("window.active.button.toggled.unpressed.image.color",
326 "window.active.button.toggled.image.color",
327 theme->titlebut_toggled_focused_unpressed_color,
328 RrColorCopy(theme->titlebut_focused_pressed_color));
330 READ_COLOR_("window.inactive.button.toggled.unpressed.image.color",
331 "window.inactive.button.toggled.image.color",
332 theme->titlebut_toggled_unfocused_unpressed_color,
333 RrColorCopy(theme->titlebut_unfocused_pressed_color));
335 READ_COLOR("window.active.button.toggled.hover.image.color",
336 theme->titlebut_toggled_hover_focused_color,
337 RrColorCopy(theme->titlebut_toggled_focused_unpressed_color));
339 READ_COLOR("window.inactive.button.toggled.hover.image.color",
340 theme->titlebut_toggled_hover_unfocused_color,
341 RrColorCopy(theme->titlebut_toggled_unfocused_unpressed_color));
343 READ_COLOR("window.active.button.toggled.pressed.image.color",
344 theme->titlebut_toggled_focused_pressed_color,
345 RrColorCopy(theme->titlebut_focused_pressed_color));
347 READ_COLOR("window.inactive.button.toggled.pressed.image.color",
348 theme->titlebut_toggled_unfocused_pressed_color,
349 RrColorCopy(theme->titlebut_unfocused_pressed_color));
351 READ_COLOR("menu.title.text.color", theme->menu_title_color,
352 RrColorNew(inst, 0, 0, 0));
354 READ_COLOR("menu.items.text.color", theme->menu_color,
355 RrColorNew(inst, 0xff, 0xff, 0xff));
357 READ_COLOR("menu.items.disabled.text.color", theme->menu_disabled_color,
358 RrColorNew(inst, 0, 0, 0));
360 READ_COLOR("menu.items.active.disabled.text.color",
361 theme->menu_disabled_selected_color,
362 RrColorCopy(theme->menu_disabled_color));
364 READ_COLOR("menu.items.active.text.color", theme->menu_selected_color,
365 RrColorNew(inst, 0, 0, 0));
368 /* load the image masks */
370 /* maximize button masks */
372 if (!read_mask(inst, path, theme, "max.xbm", &theme->btn_max->mask)) {
373 guchar data[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
374 theme->btn_max->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
377 if (!read_mask(inst, path, theme, "max_toggled.xbm",
378 &theme->btn_max->toggled_mask))
381 theme->btn_max->toggled_mask = RrPixmapMaskCopy(theme->btn_max->mask);
383 guchar data[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
384 theme->btn_max->toggled_mask = RrPixmapMaskNew(inst, 6, 6,(gchar*)data);
387 READ_MASK_COPY("max_pressed.xbm", theme->btn_max->pressed_mask,
388 theme->btn_max->mask);
389 READ_MASK_COPY("max_disabled.xbm", theme->btn_max->disabled_mask,
390 theme->btn_max->mask);
391 READ_MASK_COPY("max_hover.xbm", theme->btn_max->hover_mask,
392 theme->btn_max->mask);
393 READ_MASK_COPY("max_toggled_pressed.xbm",
394 theme->btn_max->toggled_pressed_mask,
395 theme->btn_max->toggled_mask);
396 READ_MASK_COPY("max_toggled_hover.xbm",
397 theme->btn_max->toggled_hover_mask,
398 theme->btn_max->toggled_mask);
400 /* iconify button masks */
401 if (!read_mask(inst, path, theme, "iconify.xbm", &theme->btn_iconify->mask)) {
402 guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
403 theme->btn_iconify->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
405 READ_MASK_COPY("iconify_pressed.xbm", theme->btn_iconify->pressed_mask,
406 theme->btn_iconify->mask);
407 READ_MASK_COPY("iconify_disabled.xbm", theme->btn_iconify->disabled_mask,
408 theme->btn_iconify->mask);
409 READ_MASK_COPY("iconify_hover.xbm", theme->btn_iconify->hover_mask,
410 theme->btn_iconify->mask);
412 /* all desktops button masks */
414 if (!read_mask(inst, path, theme, "desk.xbm", &theme->btn_desk->mask)) {
415 guchar data[] = { 0x33, 0x33, 0x00, 0x00, 0x33, 0x33 };
416 theme->btn_desk->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
419 if (!read_mask(inst, path, theme, "desk_toggled.xbm",
420 &theme->btn_desk->toggled_mask)) {
422 theme->btn_desk->toggled_mask = RrPixmapMaskCopy(theme->btn_desk->mask);
424 guchar data[] = { 0x00, 0x1e, 0x1a, 0x16, 0x1e, 0x00 };
425 theme->btn_desk->toggled_mask =
426 RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
429 READ_MASK_COPY("desk_pressed.xbm", theme->btn_desk->pressed_mask,
430 theme->btn_desk->mask);
431 READ_MASK_COPY("desk_disabled.xbm", theme->btn_desk->disabled_mask,
432 theme->btn_desk->mask);
433 READ_MASK_COPY("desk_hover.xbm", theme->btn_desk->hover_mask, theme->btn_desk->mask);
434 READ_MASK_COPY("desk_toggled_pressed.xbm",
435 theme->btn_desk->toggled_pressed_mask, theme->btn_desk->toggled_mask);
436 READ_MASK_COPY("desk_toggled_hover.xbm", theme->btn_desk->toggled_hover_mask,
437 theme->btn_desk->toggled_mask);
439 /* shade button masks */
440 if (!read_mask(inst, path, theme, "shade.xbm", &theme->btn_shade->mask)) {
441 guchar data[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
442 theme->btn_shade->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
444 READ_MASK_COPY("shade_toggled.xbm", theme->btn_shade->toggled_mask,
445 theme->btn_shade->mask);
446 READ_MASK_COPY("shade_pressed.xbm", theme->btn_shade->pressed_mask,
447 theme->btn_shade->mask);
448 READ_MASK_COPY("shade_disabled.xbm", theme->btn_shade->disabled_mask,
449 theme->btn_shade->mask);
450 READ_MASK_COPY("shade_hover.xbm", theme->btn_shade->hover_mask,
451 theme->btn_shade->mask);
452 READ_MASK_COPY("shade_toggled_pressed.xbm",
453 theme->btn_shade->toggled_pressed_mask,
454 theme->btn_shade->toggled_mask);
455 READ_MASK_COPY("shade_toggled_hover.xbm",
456 theme->btn_shade->toggled_hover_mask,
457 theme->btn_shade->toggled_mask);
459 /* close button masks */
460 if (!read_mask(inst, path, theme, "close.xbm", &theme->btn_close->mask)) {
461 guchar data[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
462 theme->btn_close->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
464 READ_MASK_COPY("close_pressed.xbm", theme->btn_close->pressed_mask,
465 theme->btn_close->mask);
466 READ_MASK_COPY("close_disabled.xbm", theme->btn_close->disabled_mask,
467 theme->btn_close->mask);
468 READ_MASK_COPY("close_hover.xbm", theme->btn_close->hover_mask,
469 theme->btn_close->mask);
471 /* submenu bullet mask */
472 if (!read_mask(inst, path, theme, "bullet.xbm", &theme->menu_bullet_mask))
474 guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
475 theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data);
478 /* setup the default window icon */
479 theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
480 OB_DEFAULT_ICON_HEIGHT,
481 OB_DEFAULT_ICON_pixel_data);
483 /* read the decoration textures */
484 READ_APPEARANCE("window.active.title.bg", theme->a_focused_title, FALSE);
485 READ_APPEARANCE("window.inactive.title.bg", theme->a_unfocused_title,
487 READ_APPEARANCE("window.active.label.bg", theme->a_focused_label, TRUE);
488 READ_APPEARANCE("window.inactive.label.bg", theme->a_unfocused_label,
490 READ_APPEARANCE("window.active.handle.bg", theme->a_focused_handle, FALSE);
491 READ_APPEARANCE("window.inactive.handle.bg",theme->a_unfocused_handle,
493 READ_APPEARANCE("window.active.grip.bg", theme->a_focused_grip, TRUE);
494 READ_APPEARANCE("window.inactive.grip.bg", theme->a_unfocused_grip, TRUE);
495 READ_APPEARANCE("menu.items.bg", theme->a_menu, FALSE);
496 READ_APPEARANCE("menu.title.bg", theme->a_menu_title, TRUE);
497 READ_APPEARANCE("menu.items.active.bg", theme->a_menu_selected, TRUE);
499 theme->a_menu_disabled_selected =
500 RrAppearanceCopy(theme->a_menu_selected);
502 /* read appearances for non-decorations (on-screen-display) */
503 if (!read_appearance(db, inst, "osd.bg", theme->osd_hilite_bg, FALSE)) {
504 RrAppearanceFree(theme->osd_hilite_bg);
505 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_title);
507 if (!read_appearance(db, inst, "osd.label.bg",
508 theme->osd_hilite_label, TRUE)) {
509 RrAppearanceFree(theme->osd_hilite_label);
510 theme->osd_hilite_label = RrAppearanceCopy(theme->a_focused_label);
512 /* osd_hilite_fg can't be parentrel */
513 if (!read_appearance(db, inst, "osd.hilight.bg",
514 theme->osd_hilite_fg, FALSE)) {
515 RrAppearanceFree(theme->osd_hilite_fg);
516 if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL)
517 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_label);
519 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_title);
521 /* osd_unhilite_fg can't be parentrel either */
522 if (!read_appearance(db, inst, "osd.unhilight.bg",
523 theme->osd_unhilite_fg, FALSE)) {
524 RrAppearanceFree(theme->osd_unhilite_fg);
525 if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL)
526 theme->osd_unhilite_fg=RrAppearanceCopy(theme->a_unfocused_label);
528 theme->osd_unhilite_fg=RrAppearanceCopy(theme->a_unfocused_title);
531 /* read buttons textures */
533 /* bases: unpressed, pressed, disabled */
534 READ_APPEARANCE("window.active.button.unpressed.bg",
535 a_focused_unpressed_tmp, TRUE);
536 READ_APPEARANCE("window.inactive.button.unpressed.bg",
537 a_unfocused_unpressed_tmp, TRUE);
538 READ_APPEARANCE("window.active.button.pressed.bg",
539 a_focused_pressed_tmp, TRUE);
540 READ_APPEARANCE("window.inactive.button.pressed.bg",
541 a_unfocused_pressed_tmp, TRUE);
542 READ_APPEARANCE("window.active.button.disabled.bg",
543 a_disabled_focused_tmp, TRUE);
544 READ_APPEARANCE("window.inactive.button.disabled.bg",
545 a_disabled_unfocused_tmp, TRUE);
548 READ_APPEARANCE_COPY("window.active.button.hover.bg",
549 a_hover_focused_tmp, TRUE,
550 a_focused_unpressed_tmp);
551 READ_APPEARANCE_COPY("window.inactive.button.hover.bg",
552 a_hover_unfocused_tmp, TRUE,
553 a_unfocused_unpressed_tmp);
555 /* toggled unpressed */
556 READ_APPEARANCE_("window.active.button.toggled.unpressed.bg",
557 "window.active.button.toggled.bg",
558 a_toggled_focused_unpressed_tmp, TRUE,
559 a_focused_pressed_tmp);
560 READ_APPEARANCE_("window.inactive.button.toggled.unpressed.bg",
561 "window.inactive.button.toggled.bg",
562 a_toggled_unfocused_unpressed_tmp, TRUE,
563 a_unfocused_pressed_tmp);
565 /* toggled pressed */
566 READ_APPEARANCE_COPY("window.active.button.toggled.pressed.bg",
567 a_toggled_focused_pressed_tmp, TRUE,
568 a_focused_pressed_tmp);
569 READ_APPEARANCE_COPY("window.inactive.button.toggled.pressed.bg",
570 a_toggled_unfocused_pressed_tmp, TRUE,
571 a_unfocused_pressed_tmp);
574 READ_APPEARANCE_COPY("window.active.button.toggled.hover.bg",
575 a_toggled_hover_focused_tmp, TRUE,
576 a_toggled_focused_unpressed_tmp);
577 READ_APPEARANCE_COPY("window.inactive.button.toggled.hover.bg",
578 a_toggled_hover_unfocused_tmp, TRUE,
579 a_toggled_unfocused_unpressed_tmp);
582 /* now do individual buttons, if specified */
586 /* bases: unpressed, pressed, disabled */
587 READ_APPEARANCE_COPY("window.active.button-max.unpressed.bg",
588 theme->btn_max->a_focused_unpressed, TRUE,
589 a_focused_unpressed_tmp);
590 READ_APPEARANCE_COPY("window.inactive.button-max.unpressed.bg",
591 theme->btn_max->a_unfocused_unpressed, TRUE,
592 a_unfocused_unpressed_tmp);
593 READ_APPEARANCE_COPY("window.active.button-max.pressed.bg",
594 theme->btn_max->a_focused_pressed, TRUE,
595 a_focused_pressed_tmp);
596 READ_APPEARANCE_COPY("window.inactive.button-max.pressed.bg",
597 theme->btn_max->a_unfocused_pressed, TRUE,
598 a_unfocused_pressed_tmp);
599 READ_APPEARANCE_COPY("window.active.button-max.disabled.bg",
600 theme->btn_max->a_disabled_focused, TRUE,
601 a_disabled_focused_tmp);
602 READ_APPEARANCE_COPY("window.inactive.button-max.disabled.bg",
603 theme->btn_max->a_disabled_unfocused, TRUE,
604 a_disabled_unfocused_tmp);
607 READ_APPEARANCE_COPY("window.active.button-max.hover.bg",
608 theme->btn_max->a_hover_focused, TRUE,
609 theme->btn_max->a_focused_unpressed);
610 READ_APPEARANCE_COPY("window.inactive.button-max.hover.bg",
611 theme->btn_max->a_hover_unfocused, TRUE,
612 theme->btn_max->a_unfocused_unpressed);
614 /* toggled unpressed */
615 READ_APPEARANCE_("window.active.button-max.toggled.unpressed.bg",
616 "window.active.button-max.toggled.bg",
617 theme->btn_max->a_toggled_focused_unpressed, TRUE,
618 theme->btn_max->a_focused_pressed);
619 READ_APPEARANCE_("window.inactive.button-max.toggled.unpressed.bg",
620 "window.inactive.button-max.toggled.bg",
621 theme->btn_max->a_toggled_unfocused_unpressed, TRUE,
622 theme->btn_max->a_unfocused_pressed);
624 /* toggled pressed */
625 READ_APPEARANCE_COPY("window.active.button-max.toggled.pressed.bg",
626 theme->btn_max->a_toggled_focused_pressed, TRUE,
627 theme->btn_max->a_focused_pressed);
628 READ_APPEARANCE_COPY("window.inactive.button-max.toggled.pressed.bg",
629 theme->btn_max->a_toggled_unfocused_pressed, TRUE,
630 theme->btn_max->a_unfocused_pressed);
633 READ_APPEARANCE_COPY("window.active.button-max.toggled.hover.bg",
634 theme->btn_max->a_toggled_hover_focused, TRUE,
635 theme->btn_max->a_toggled_focused_unpressed);
636 READ_APPEARANCE_COPY("window.inactive.button-max.toggled.hover.bg",
637 theme->btn_max->a_toggled_hover_unfocused, TRUE,
638 theme->btn_max->a_toggled_unfocused_unpressed);
641 READ_APPEARANCE_COPY("window.active.button-close.unpressed.bg",
642 theme->btn_close->a_focused_unpressed, TRUE,
643 a_focused_unpressed_tmp);
644 READ_APPEARANCE_COPY("window.inactive.button-close.unpressed.bg",
645 theme->btn_close->a_unfocused_unpressed, TRUE,
646 a_unfocused_unpressed_tmp);
647 READ_APPEARANCE_COPY("window.active.button-close.pressed.bg",
648 theme->btn_close->a_focused_pressed, TRUE,
649 a_focused_pressed_tmp);
650 READ_APPEARANCE_COPY("window.inactive.button-close.pressed.bg",
651 theme->btn_close->a_unfocused_pressed, TRUE,
652 a_unfocused_pressed_tmp);
653 READ_APPEARANCE_COPY("window.active.button-close.disabled.bg",
654 theme->btn_close->a_disabled_focused, TRUE,
655 a_disabled_focused_tmp);
656 READ_APPEARANCE_COPY("window.inactive.button-close.disabled.bg",
657 theme->btn_close->a_disabled_unfocused, TRUE,
658 a_disabled_unfocused_tmp);
659 READ_APPEARANCE_COPY("window.active.button-close.hover.bg",
660 theme->btn_close->a_hover_focused, TRUE,
661 theme->btn_close->a_focused_unpressed);
662 READ_APPEARANCE_COPY("window.inactive.button-close.hover.bg",
663 theme->btn_close->a_hover_unfocused, TRUE,
664 theme->btn_close->a_unfocused_unpressed);
668 /* bases: unpressed, pressed, disabled */
669 READ_APPEARANCE_COPY("window.active.button-desk.unpressed.bg",
670 theme->btn_desk->a_focused_unpressed, TRUE,
671 a_focused_unpressed_tmp);
672 READ_APPEARANCE_COPY("window.inactive.button-desk.unpressed.bg",
673 theme->btn_desk->a_unfocused_unpressed, TRUE,
674 a_unfocused_unpressed_tmp);
675 READ_APPEARANCE_COPY("window.active.button-desk.pressed.bg",
676 theme->btn_desk->a_focused_pressed, TRUE,
677 a_focused_pressed_tmp);
678 READ_APPEARANCE_COPY("window.inactive.button-desk.pressed.bg",
679 theme->btn_desk->a_unfocused_pressed, TRUE,
680 a_unfocused_pressed_tmp);
681 READ_APPEARANCE_COPY("window.active.button-desk.disabled.bg",
682 theme->btn_desk->a_disabled_focused, TRUE,
683 a_disabled_focused_tmp);
684 READ_APPEARANCE_COPY("window.inactive.button-desk.disabled.bg",
685 theme->btn_desk->a_disabled_unfocused, TRUE,
686 a_disabled_unfocused_tmp);
689 READ_APPEARANCE_COPY("window.active.button-desk.hover.bg",
690 theme->btn_desk->a_hover_focused, TRUE,
691 theme->btn_desk->a_focused_unpressed);
692 READ_APPEARANCE_COPY("window.inactive.button-desk.hover.bg",
693 theme->btn_desk->a_hover_unfocused, TRUE,
694 theme->btn_desk->a_unfocused_unpressed);
696 /* toggled unpressed */
697 READ_APPEARANCE_("window.active.button-desk.toggled.unpressed.bg",
698 "window.active.button-desk.toggled.bg",
699 theme->btn_desk->a_toggled_focused_unpressed, TRUE,
700 theme->btn_desk->a_focused_pressed);
701 READ_APPEARANCE_("window.inactive.button-desk.toggled.unpressed.bg",
702 "window.inactive.button-desk.toggled.bg",
703 theme->btn_desk->a_toggled_unfocused_unpressed, TRUE,
704 theme->btn_desk->a_unfocused_pressed);
706 /* toggled pressed */
707 READ_APPEARANCE_COPY("window.active.button-desk.toggled.pressed.bg",
708 theme->btn_desk->a_toggled_focused_pressed, TRUE,
709 theme->btn_desk->a_focused_pressed);
710 READ_APPEARANCE_COPY("window.inactive.button-desk.toggled.pressed.bg",
711 theme->btn_desk->a_toggled_unfocused_pressed, TRUE,
712 theme->btn_desk->a_unfocused_pressed);
715 READ_APPEARANCE_COPY("window.active.button-desk.toggled.hover.bg",
716 theme->btn_desk->a_toggled_hover_focused, TRUE,
717 theme->btn_desk->a_toggled_focused_unpressed);
718 READ_APPEARANCE_COPY("window.inactive.button-desk.toggled.hover.bg",
719 theme->btn_desk->a_toggled_hover_unfocused, TRUE,
720 theme->btn_desk->a_toggled_unfocused_unpressed);
724 /* bases: unpressed, pressed, disabled */
725 READ_APPEARANCE_COPY("window.active.button-shade.unpressed.bg",
726 theme->btn_shade->a_focused_unpressed, TRUE,
727 a_focused_unpressed_tmp);
728 READ_APPEARANCE_COPY("window.inactive.button-shade.unpressed.bg",
729 theme->btn_shade->a_unfocused_unpressed, TRUE,
730 a_unfocused_unpressed_tmp);
731 READ_APPEARANCE_COPY("window.active.button-shade.pressed.bg",
732 theme->btn_shade->a_focused_pressed, TRUE,
733 a_focused_pressed_tmp);
734 READ_APPEARANCE_COPY("window.inactive.button-shade.pressed.bg",
735 theme->btn_shade->a_unfocused_pressed, TRUE,
736 a_unfocused_pressed_tmp);
737 READ_APPEARANCE_COPY("window.active.button-shade.disabled.bg",
738 theme->btn_shade->a_disabled_focused, TRUE,
739 a_disabled_focused_tmp);
740 READ_APPEARANCE_COPY("window.inactive.button-shade.disabled.bg",
741 theme->btn_shade->a_disabled_unfocused, TRUE,
742 a_disabled_unfocused_tmp);
745 READ_APPEARANCE_COPY("window.active.button-shade.hover.bg",
746 theme->btn_shade->a_hover_focused, TRUE,
747 theme->btn_shade->a_focused_unpressed);
748 READ_APPEARANCE_COPY("window.inactive.button-shade.hover.bg",
749 theme->btn_shade->a_hover_unfocused, TRUE,
750 theme->btn_shade->a_unfocused_unpressed);
752 /* toggled unpressed */
753 READ_APPEARANCE_("window.active.button-shade.toggled.unpressed.bg",
754 "window.active.button-shade.toggled.bg",
755 theme->btn_shade->a_toggled_focused_unpressed, TRUE,
756 theme->btn_shade->a_focused_pressed);
757 READ_APPEARANCE_("window.inactive.button-shade.toggled.unpressed.bg",
758 "window.inactive.button-shade.toggled.bg",
759 theme->btn_shade->a_toggled_unfocused_unpressed, TRUE,
760 theme->btn_shade->a_unfocused_pressed);
762 /* toggled pressed */
763 READ_APPEARANCE_COPY("window.active.button-shade.toggled.pressed.bg",
764 theme->btn_shade->a_toggled_focused_pressed, TRUE,
765 theme->btn_shade->a_focused_pressed);
766 READ_APPEARANCE_COPY("window.inactive.button-shade.toggled.pressed.bg",
767 theme->btn_shade->a_toggled_unfocused_pressed, TRUE,
768 theme->btn_shade->a_unfocused_pressed);
771 READ_APPEARANCE_COPY("window.active.button-shade.toggled.hover.bg",
772 theme->btn_shade->a_toggled_hover_focused, TRUE,
773 theme->btn_shade->a_toggled_focused_unpressed);
774 READ_APPEARANCE_COPY("window.inactive.button-shade.toggled.hover.bg",
775 theme->btn_shade->a_toggled_hover_unfocused, TRUE,
776 theme->btn_shade->a_toggled_unfocused_unpressed);
779 READ_APPEARANCE_COPY("window.active.button-iconify.unpressed.bg",
780 theme->btn_iconify->a_focused_unpressed, TRUE,
781 a_focused_unpressed_tmp);
782 READ_APPEARANCE_COPY("window.inactive.button-iconify.unpressed.bg",
783 theme->btn_iconify->a_unfocused_unpressed, TRUE,
784 a_unfocused_unpressed_tmp);
785 READ_APPEARANCE_COPY("window.active.button-iconify.pressed.bg",
786 theme->btn_iconify->a_focused_pressed, TRUE,
787 a_focused_pressed_tmp);
788 READ_APPEARANCE_COPY("window.inactive.button-iconify.pressed.bg",
789 theme->btn_iconify->a_unfocused_pressed, TRUE,
790 a_unfocused_pressed_tmp);
791 READ_APPEARANCE_COPY("window.active.button-iconify.disabled.bg",
792 theme->btn_iconify->a_disabled_focused, TRUE,
793 a_disabled_focused_tmp);
794 READ_APPEARANCE_COPY("window.inactive.button-iconify.disabled.bg",
795 theme->btn_iconify->a_disabled_unfocused, TRUE,
796 a_disabled_unfocused_tmp);
797 READ_APPEARANCE_COPY("window.active.button-iconify.hover.bg",
798 theme->btn_iconify->a_hover_focused, TRUE,
799 theme->btn_iconify->a_focused_unpressed);
800 READ_APPEARANCE_COPY("window.inactive.button-iconify.hover.bg",
801 theme->btn_iconify->a_hover_unfocused, TRUE,
802 theme->btn_iconify->a_unfocused_unpressed);
804 theme->a_icon->surface.grad =
805 theme->a_clear->surface.grad =
806 theme->a_clear_tex->surface.grad =
807 theme->a_menu_text_title->surface.grad =
808 theme->a_menu_normal->surface.grad =
809 theme->a_menu_disabled->surface.grad =
810 theme->a_menu_text_normal->surface.grad =
811 theme->a_menu_text_selected->surface.grad =
812 theme->a_menu_text_disabled->surface.grad =
813 theme->a_menu_text_disabled_selected->surface.grad =
814 theme->a_menu_bullet_normal->surface.grad =
815 theme->a_menu_bullet_selected->surface.grad = RR_SURFACE_PARENTREL;
817 /* set up the textures */
818 theme->a_focused_label->texture[0].type = RR_TEXTURE_TEXT;
819 theme->a_focused_label->texture[0].data.text.justify = winjust;
820 theme->a_focused_label->texture[0].data.text.font=theme->win_font_focused;
821 theme->a_focused_label->texture[0].data.text.color =
822 theme->title_focused_color;
824 if (read_string(db, "window.active.label.text.font", &str)) {
828 if (strstr(str, "shadow=y")) {
829 if ((p = strstr(str, "shadowoffset=")))
830 i = parse_inline_number(p + strlen("shadowoffset="));
833 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
834 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
836 if ((p = strstr(str, "shadowtint=")))
838 i = parse_inline_number(p + strlen("shadowtint="));
839 j = (i > 0 ? 0 : 255);
842 theme->title_focused_shadow_color = RrColorNew(inst, j, j, j);
843 theme->title_focused_shadow_alpha = i;
845 theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
846 theme->title_focused_shadow_alpha = 50;
850 theme->a_focused_label->texture[0].data.text.shadow_color =
851 theme->title_focused_shadow_color;
852 theme->a_focused_label->texture[0].data.text.shadow_alpha =
853 theme->title_focused_shadow_alpha;
855 theme->osd_hilite_label->texture[0].type = RR_TEXTURE_TEXT;
856 theme->osd_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
857 theme->osd_hilite_label->texture[0].data.text.font = theme->osd_font;
858 theme->osd_hilite_label->texture[0].data.text.color = theme->osd_color;
860 if (read_string(db, "osd.label.text.font", &str)) {
864 if (strstr(str, "shadow=y")) {
865 if ((p = strstr(str, "shadowoffset=")))
866 i = parse_inline_number(p + strlen("shadowoffset="));
869 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
870 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
871 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x = i;
872 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y = i;
874 if ((p = strstr(str, "shadowtint=")))
876 i = parse_inline_number(p + strlen("shadowtint="));
877 j = (i > 0 ? 0 : 255);
880 theme->title_focused_shadow_color = RrColorNew(inst, j, j, j);
881 theme->title_focused_shadow_alpha = i;
882 theme->osd_shadow_color = RrColorNew(inst, j, j, j);
883 theme->osd_shadow_alpha = i;
885 theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
886 theme->title_focused_shadow_alpha = 50;
887 theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0);
888 theme->osd_shadow_alpha = 50;
891 /* inherit the font settings from the focused label */
892 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x =
893 theme->a_focused_label->texture[0].data.text.shadow_offset_x;
894 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y =
895 theme->a_focused_label->texture[0].data.text.shadow_offset_y;
896 if (theme->title_focused_shadow_color)
897 theme->osd_shadow_color =
899 theme->title_focused_shadow_color->r,
900 theme->title_focused_shadow_color->g,
901 theme->title_focused_shadow_color->b);
903 theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0);
904 theme->osd_shadow_alpha = theme->title_focused_shadow_alpha;
907 theme->osd_hilite_label->texture[0].data.text.shadow_color =
908 theme->osd_shadow_color;
909 theme->osd_hilite_label->texture[0].data.text.shadow_alpha =
910 theme->osd_shadow_alpha;
912 theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT;
913 theme->a_unfocused_label->texture[0].data.text.justify = winjust;
914 theme->a_unfocused_label->texture[0].data.text.font =
915 theme->win_font_unfocused;
916 theme->a_unfocused_label->texture[0].data.text.color =
917 theme->title_unfocused_color;
919 if (read_string(db, "window.inactive.label.text.font", &str)) {
923 if (strstr(str, "shadow=y")) {
924 if ((p = strstr(str, "shadowoffset=")))
925 i = parse_inline_number(p + strlen("shadowoffset="));
928 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x = i;
929 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y = i;
931 if ((p = strstr(str, "shadowtint=")))
933 i = parse_inline_number(p + strlen("shadowtint="));
934 j = (i > 0 ? 0 : 255);
937 theme->title_unfocused_shadow_color = RrColorNew(inst, j, j, j);
938 theme->title_unfocused_shadow_alpha = i;
940 theme->title_unfocused_shadow_color = RrColorNew(inst, 0, 0, 0);
941 theme->title_unfocused_shadow_alpha = 50;
945 theme->a_unfocused_label->texture[0].data.text.shadow_color =
946 theme->title_unfocused_shadow_color;
947 theme->a_unfocused_label->texture[0].data.text.shadow_alpha =
948 theme->title_unfocused_shadow_alpha;
950 theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
951 theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
952 theme->a_menu_text_title->texture[0].data.text.font =
953 theme->menu_title_font;
954 theme->a_menu_text_title->texture[0].data.text.color =
955 theme->menu_title_color;
957 if (read_string(db, "menu.title.text.font", &str)) {
961 if (strstr(str, "shadow=y")) {
962 if ((p = strstr(str, "shadowoffset=")))
963 i = parse_inline_number(p + strlen("shadowoffset="));
966 theme->a_menu_text_title->texture[0].data.text.shadow_offset_x = i;
967 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y = i;
969 if ((p = strstr(str, "shadowtint=")))
971 i = parse_inline_number(p + strlen("shadowtint="));
972 j = (i > 0 ? 0 : 255);
975 theme->menu_title_shadow_color = RrColorNew(inst, j, j, j);
976 theme->menu_title_shadow_alpha = i;
978 theme->menu_title_shadow_color = RrColorNew(inst, 0, 0, 0);
979 theme->menu_title_shadow_alpha = 50;
983 theme->a_menu_text_title->texture[0].data.text.shadow_color =
984 theme->menu_title_shadow_color;
985 theme->a_menu_text_title->texture[0].data.text.shadow_alpha =
986 theme->menu_title_shadow_alpha;
988 theme->a_menu_text_normal->texture[0].type =
989 theme->a_menu_text_selected->texture[0].type =
990 theme->a_menu_text_disabled->texture[0].type =
991 theme->a_menu_text_disabled_selected->texture[0].type =
993 theme->a_menu_text_normal->texture[0].data.text.justify =
994 theme->a_menu_text_selected->texture[0].data.text.justify =
995 theme->a_menu_text_disabled->texture[0].data.text.justify =
996 theme->a_menu_text_disabled_selected->texture[0].data.text.justify =
998 theme->a_menu_text_normal->texture[0].data.text.font =
999 theme->a_menu_text_selected->texture[0].data.text.font =
1000 theme->a_menu_text_disabled->texture[0].data.text.font =
1001 theme->a_menu_text_disabled_selected->texture[0].data.text.font =
1003 theme->a_menu_text_normal->texture[0].data.text.color = theme->menu_color;
1004 theme->a_menu_text_selected->texture[0].data.text.color =
1005 theme->menu_selected_color;
1006 theme->a_menu_text_disabled->texture[0].data.text.color =
1007 theme->menu_disabled_color;
1008 theme->a_menu_text_disabled_selected->texture[0].data.text.color =
1009 theme->menu_disabled_selected_color;
1011 if (read_string(db, "menu.items.font", &str)) {
1015 if (strstr(str, "shadow=y")) {
1016 if ((p = strstr(str, "shadowoffset=")))
1017 i = parse_inline_number(p + strlen("shadowoffset="));
1020 theme->a_menu_text_normal->
1021 texture[0].data.text.shadow_offset_x = i;
1022 theme->a_menu_text_normal->
1023 texture[0].data.text.shadow_offset_y = i;
1024 theme->a_menu_text_selected->
1025 texture[0].data.text.shadow_offset_x = i;
1026 theme->a_menu_text_selected->
1027 texture[0].data.text.shadow_offset_y = i;
1028 theme->a_menu_text_disabled->
1029 texture[0].data.text.shadow_offset_x = i;
1030 theme->a_menu_text_disabled->
1031 texture[0].data.text.shadow_offset_y = i;
1032 theme->a_menu_text_disabled_selected->
1033 texture[0].data.text.shadow_offset_x = i;
1034 theme->a_menu_text_disabled_selected->
1035 texture[0].data.text.shadow_offset_y = i;
1037 if ((p = strstr(str, "shadowtint=")))
1039 i = parse_inline_number(p + strlen("shadowtint="));
1040 j = (i > 0 ? 0 : 255);
1043 theme->menu_text_normal_shadow_color = RrColorNew(inst, j, j, j);
1044 theme->menu_text_selected_shadow_color = RrColorNew(inst, j, j, j);
1045 theme->menu_text_disabled_shadow_color = RrColorNew(inst, j, j, j);
1046 theme->menu_text_normal_shadow_alpha = i;
1047 theme->menu_text_selected_shadow_alpha = i;
1048 theme->menu_text_disabled_shadow_alpha = i;
1049 theme->menu_text_disabled_selected_shadow_alpha = i;
1051 theme->menu_text_normal_shadow_color = RrColorNew(inst, 0, 0, 0);
1052 theme->menu_text_selected_shadow_color = RrColorNew(inst, 0, 0, 0);
1053 theme->menu_text_disabled_shadow_color = RrColorNew(inst, 0, 0, 0);
1054 theme->menu_text_normal_shadow_alpha = 50;
1055 theme->menu_text_selected_shadow_alpha = 50;
1056 theme->menu_text_disabled_selected_shadow_alpha = 50;
1060 theme->a_menu_text_normal->texture[0].data.text.shadow_color =
1061 theme->menu_text_normal_shadow_color;
1062 theme->a_menu_text_normal->texture[0].data.text.shadow_alpha =
1063 theme->menu_text_normal_shadow_alpha;
1064 theme->a_menu_text_selected->texture[0].data.text.shadow_color =
1065 theme->menu_text_selected_shadow_color;
1066 theme->a_menu_text_selected->texture[0].data.text.shadow_alpha =
1067 theme->menu_text_selected_shadow_alpha;
1068 theme->a_menu_text_disabled->texture[0].data.text.shadow_color =
1069 theme->menu_text_disabled_shadow_color;
1070 theme->a_menu_text_disabled->texture[0].data.text.shadow_alpha =
1071 theme->menu_text_disabled_shadow_alpha;
1072 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_color =
1073 theme->menu_text_disabled_shadow_color;
1074 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_alpha =
1075 theme->menu_text_disabled_shadow_alpha;
1077 theme->btn_max->a_disabled_focused->texture[0].type =
1078 theme->btn_max->a_disabled_unfocused->texture[0].type =
1079 theme->btn_max->a_hover_focused->texture[0].type =
1080 theme->btn_max->a_hover_unfocused->texture[0].type =
1081 theme->btn_max->a_toggled_hover_focused->texture[0].type =
1082 theme->btn_max->a_toggled_hover_unfocused->texture[0].type =
1083 theme->btn_max->a_toggled_focused_unpressed->texture[0].type =
1084 theme->btn_max->a_toggled_unfocused_unpressed->texture[0].type =
1085 theme->btn_max->a_toggled_focused_pressed->texture[0].type =
1086 theme->btn_max->a_toggled_unfocused_pressed->texture[0].type =
1087 theme->btn_max->a_focused_unpressed->texture[0].type =
1088 theme->btn_max->a_focused_pressed->texture[0].type =
1089 theme->btn_max->a_unfocused_unpressed->texture[0].type =
1090 theme->btn_max->a_unfocused_pressed->texture[0].type =
1091 theme->btn_close->a_disabled_focused->texture[0].type =
1092 theme->btn_close->a_disabled_unfocused->texture[0].type =
1093 theme->btn_close->a_hover_focused->texture[0].type =
1094 theme->btn_close->a_hover_unfocused->texture[0].type =
1095 theme->btn_close->a_focused_unpressed->texture[0].type =
1096 theme->btn_close->a_focused_pressed->texture[0].type =
1097 theme->btn_close->a_unfocused_unpressed->texture[0].type =
1098 theme->btn_close->a_unfocused_pressed->texture[0].type =
1099 theme->btn_desk->a_disabled_focused->texture[0].type =
1100 theme->btn_desk->a_disabled_unfocused->texture[0].type =
1101 theme->btn_desk->a_hover_focused->texture[0].type =
1102 theme->btn_desk->a_hover_unfocused->texture[0].type =
1103 theme->btn_desk->a_toggled_hover_focused->texture[0].type =
1104 theme->btn_desk->a_toggled_hover_unfocused->texture[0].type =
1105 theme->btn_desk->a_toggled_focused_unpressed->texture[0].type =
1106 theme->btn_desk->a_toggled_unfocused_unpressed->texture[0].type =
1107 theme->btn_desk->a_toggled_focused_pressed->texture[0].type =
1108 theme->btn_desk->a_toggled_unfocused_pressed->texture[0].type =
1109 theme->btn_desk->a_focused_unpressed->texture[0].type =
1110 theme->btn_desk->a_focused_pressed->texture[0].type =
1111 theme->btn_desk->a_unfocused_unpressed->texture[0].type =
1112 theme->btn_desk->a_unfocused_pressed->texture[0].type =
1113 theme->btn_shade->a_disabled_focused->texture[0].type =
1114 theme->btn_shade->a_disabled_unfocused->texture[0].type =
1115 theme->btn_shade->a_hover_focused->texture[0].type =
1116 theme->btn_shade->a_hover_unfocused->texture[0].type =
1117 theme->btn_shade->a_toggled_hover_focused->texture[0].type =
1118 theme->btn_shade->a_toggled_hover_unfocused->texture[0].type =
1119 theme->btn_shade->a_toggled_focused_unpressed->texture[0].type =
1120 theme->btn_shade->a_toggled_unfocused_unpressed->texture[0].type =
1121 theme->btn_shade->a_toggled_focused_pressed->texture[0].type =
1122 theme->btn_shade->a_toggled_unfocused_pressed->texture[0].type =
1123 theme->btn_shade->a_focused_unpressed->texture[0].type =
1124 theme->btn_shade->a_focused_pressed->texture[0].type =
1125 theme->btn_shade->a_unfocused_unpressed->texture[0].type =
1126 theme->btn_shade->a_unfocused_pressed->texture[0].type =
1127 theme->btn_iconify->a_disabled_focused->texture[0].type =
1128 theme->btn_iconify->a_disabled_unfocused->texture[0].type =
1129 theme->btn_iconify->a_hover_focused->texture[0].type =
1130 theme->btn_iconify->a_hover_unfocused->texture[0].type =
1131 theme->btn_iconify->a_focused_unpressed->texture[0].type =
1132 theme->btn_iconify->a_focused_pressed->texture[0].type =
1133 theme->btn_iconify->a_unfocused_unpressed->texture[0].type =
1134 theme->btn_iconify->a_unfocused_pressed->texture[0].type =
1135 theme->a_menu_bullet_normal->texture[0].type =
1136 theme->a_menu_bullet_selected->texture[0].type = RR_TEXTURE_MASK;
1138 theme->btn_max->a_disabled_focused->texture[0].data.mask.mask =
1139 theme->btn_max->a_disabled_unfocused->texture[0].data.mask.mask =
1140 theme->btn_max->disabled_mask;
1141 theme->btn_max->a_hover_focused->texture[0].data.mask.mask =
1142 theme->btn_max->a_hover_unfocused->texture[0].data.mask.mask =
1143 theme->btn_max->hover_mask;
1144 theme->btn_max->a_focused_pressed->texture[0].data.mask.mask =
1145 theme->btn_max->a_unfocused_pressed->texture[0].data.mask.mask =
1146 theme->btn_max->pressed_mask;
1147 theme->btn_max->a_focused_unpressed->texture[0].data.mask.mask =
1148 theme->btn_max->a_unfocused_unpressed->texture[0].data.mask.mask =
1149 theme->btn_max->mask;
1150 theme->btn_max->a_toggled_hover_focused->texture[0].data.mask.mask =
1151 theme->btn_max->a_toggled_hover_unfocused->texture[0].data.mask.mask =
1152 theme->btn_max->toggled_hover_mask;
1153 theme->btn_max->a_toggled_focused_unpressed->texture[0].data.mask.mask =
1154 theme->btn_max->a_toggled_unfocused_unpressed->texture[0].data.mask.mask =
1155 theme->btn_max->toggled_mask;
1156 theme->btn_max->a_toggled_focused_pressed->texture[0].data.mask.mask =
1157 theme->btn_max->a_toggled_unfocused_pressed->texture[0].data.mask.mask =
1158 theme->btn_max->toggled_pressed_mask;
1159 theme->btn_close->a_disabled_focused->texture[0].data.mask.mask =
1160 theme->btn_close->a_disabled_unfocused->texture[0].data.mask.mask =
1161 theme->btn_close->disabled_mask;
1162 theme->btn_close->a_hover_focused->texture[0].data.mask.mask =
1163 theme->btn_close->a_hover_unfocused->texture[0].data.mask.mask =
1164 theme->btn_close->hover_mask;
1165 theme->btn_close->a_focused_pressed->texture[0].data.mask.mask =
1166 theme->btn_close->a_unfocused_pressed->texture[0].data.mask.mask =
1167 theme->btn_close->pressed_mask;
1168 theme->btn_close->a_focused_unpressed->texture[0].data.mask.mask =
1169 theme->btn_close->a_unfocused_unpressed->texture[0].data.mask.mask =
1170 theme->btn_close->mask;
1171 theme->btn_desk->a_disabled_focused->texture[0].data.mask.mask =
1172 theme->btn_desk->a_disabled_unfocused->texture[0].data.mask.mask =
1173 theme->btn_desk->disabled_mask;
1174 theme->btn_desk->a_hover_focused->texture[0].data.mask.mask =
1175 theme->btn_desk->a_hover_unfocused->texture[0].data.mask.mask =
1176 theme->btn_desk->hover_mask;
1177 theme->btn_desk->a_focused_pressed->texture[0].data.mask.mask =
1178 theme->btn_desk->a_unfocused_pressed->texture[0].data.mask.mask =
1179 theme->btn_desk->pressed_mask;
1180 theme->btn_desk->a_focused_unpressed->texture[0].data.mask.mask =
1181 theme->btn_desk->a_unfocused_unpressed->texture[0].data.mask.mask =
1182 theme->btn_desk->mask;
1183 theme->btn_desk->a_toggled_hover_focused->texture[0].data.mask.mask =
1184 theme->btn_desk->a_toggled_hover_unfocused->texture[0].data.mask.mask =
1185 theme->btn_desk->toggled_hover_mask;
1186 theme->btn_desk->a_toggled_focused_unpressed->texture[0].data.mask.mask =
1187 theme->btn_desk->a_toggled_unfocused_unpressed->texture[0].data.mask.mask =
1188 theme->btn_desk->toggled_mask;
1189 theme->btn_desk->a_toggled_focused_pressed->texture[0].data.mask.mask =
1190 theme->btn_desk->a_toggled_unfocused_pressed->texture[0].data.mask.mask =
1191 theme->btn_desk->toggled_pressed_mask;
1192 theme->btn_shade->a_disabled_focused->texture[0].data.mask.mask =
1193 theme->btn_shade->a_disabled_unfocused->texture[0].data.mask.mask =
1194 theme->btn_shade->disabled_mask;
1195 theme->btn_shade->a_hover_focused->texture[0].data.mask.mask =
1196 theme->btn_shade->a_hover_unfocused->texture[0].data.mask.mask =
1197 theme->btn_shade->hover_mask;
1198 theme->btn_shade->a_focused_pressed->texture[0].data.mask.mask =
1199 theme->btn_shade->a_unfocused_pressed->texture[0].data.mask.mask =
1200 theme->btn_shade->pressed_mask;
1201 theme->btn_shade->a_focused_unpressed->texture[0].data.mask.mask =
1202 theme->btn_shade->a_unfocused_unpressed->texture[0].data.mask.mask =
1203 theme->btn_shade->mask;
1204 theme->btn_shade->a_toggled_hover_focused->texture[0].data.mask.mask =
1205 theme->btn_shade->a_toggled_hover_unfocused->texture[0].data.mask.mask =
1206 theme->btn_shade->toggled_hover_mask;
1207 theme->btn_shade->a_toggled_focused_unpressed->texture[0].data.mask.mask =
1208 theme->btn_shade->a_toggled_unfocused_unpressed->texture[0].data.mask.mask =
1209 theme->btn_shade->toggled_mask;
1210 theme->btn_shade->a_toggled_focused_pressed->texture[0].data.mask.mask =
1211 theme->btn_shade->a_toggled_unfocused_pressed->texture[0].data.mask.mask =
1212 theme->btn_shade->toggled_pressed_mask;
1213 theme->btn_iconify->a_disabled_focused->texture[0].data.mask.mask =
1214 theme->btn_iconify->a_disabled_unfocused->texture[0].data.mask.mask =
1215 theme->btn_iconify->disabled_mask;
1216 theme->btn_iconify->a_hover_focused->texture[0].data.mask.mask =
1217 theme->btn_iconify->a_hover_unfocused->texture[0].data.mask.mask =
1218 theme->btn_iconify->hover_mask;
1219 theme->btn_iconify->a_focused_pressed->texture[0].data.mask.mask =
1220 theme->btn_iconify->a_unfocused_pressed->texture[0].data.mask.mask =
1221 theme->btn_iconify->pressed_mask;
1222 theme->btn_iconify->a_focused_unpressed->texture[0].data.mask.mask =
1223 theme->btn_iconify->a_unfocused_unpressed->texture[0].data.mask.mask =
1224 theme->btn_iconify->mask;
1225 theme->a_menu_bullet_normal->texture[0].data.mask.mask =
1226 theme->a_menu_bullet_selected->texture[0].data.mask.mask =
1227 theme->menu_bullet_mask;
1228 theme->btn_max->a_disabled_focused->texture[0].data.mask.color =
1229 theme->btn_close->a_disabled_focused->texture[0].data.mask.color =
1230 theme->btn_desk->a_disabled_focused->texture[0].data.mask.color =
1231 theme->btn_shade->a_disabled_focused->texture[0].data.mask.color =
1232 theme->btn_iconify->a_disabled_focused->texture[0].data.mask.color =
1233 theme->titlebut_disabled_focused_color;
1234 theme->btn_max->a_disabled_unfocused->texture[0].data.mask.color =
1235 theme->btn_close->a_disabled_unfocused->texture[0].data.mask.color =
1236 theme->btn_desk->a_disabled_unfocused->texture[0].data.mask.color =
1237 theme->btn_shade->a_disabled_unfocused->texture[0].data.mask.color =
1238 theme->btn_iconify->a_disabled_unfocused->texture[0].data.mask.color =
1239 theme->titlebut_disabled_unfocused_color;
1240 theme->btn_max->a_hover_focused->texture[0].data.mask.color =
1241 theme->btn_close->a_hover_focused->texture[0].data.mask.color =
1242 theme->btn_desk->a_hover_focused->texture[0].data.mask.color =
1243 theme->btn_shade->a_hover_focused->texture[0].data.mask.color =
1244 theme->btn_iconify->a_hover_focused->texture[0].data.mask.color =
1245 theme->titlebut_hover_focused_color;
1246 theme->btn_max->a_hover_unfocused->texture[0].data.mask.color =
1247 theme->btn_close->a_hover_unfocused->texture[0].data.mask.color =
1248 theme->btn_desk->a_hover_unfocused->texture[0].data.mask.color =
1249 theme->btn_shade->a_hover_unfocused->texture[0].data.mask.color =
1250 theme->btn_iconify->a_hover_unfocused->texture[0].data.mask.color =
1251 theme->titlebut_hover_unfocused_color;
1252 theme->btn_max->a_toggled_hover_focused->texture[0].data.mask.color =
1253 theme->btn_desk->a_toggled_hover_focused->texture[0].data.mask.color =
1254 theme->btn_shade->a_toggled_hover_focused->texture[0].data.mask.color =
1255 theme->titlebut_toggled_hover_focused_color;
1256 theme->btn_max->a_toggled_hover_unfocused->texture[0].data.mask.color =
1257 theme->btn_desk->a_toggled_hover_unfocused->texture[0].data.mask.color =
1258 theme->btn_shade->a_toggled_hover_unfocused->texture[0].data.mask.color =
1259 theme->titlebut_toggled_hover_unfocused_color;
1260 theme->btn_max->a_toggled_focused_unpressed->texture[0].data.mask.color =
1261 theme->btn_desk->a_toggled_focused_unpressed->texture[0].data.mask.color =
1262 theme->btn_shade->a_toggled_focused_unpressed->texture[0].data.mask.color =
1263 theme->titlebut_toggled_focused_unpressed_color;
1264 theme->btn_max->a_toggled_unfocused_unpressed->texture[0].data.mask.color =
1265 theme->btn_desk->a_toggled_unfocused_unpressed->texture[0].data.mask.color =
1266 theme->btn_shade->a_toggled_unfocused_unpressed->texture[0].data.mask.color=
1267 theme->titlebut_toggled_unfocused_unpressed_color;
1268 theme->btn_max->a_toggled_focused_pressed->texture[0].data.mask.color =
1269 theme->btn_desk->a_toggled_focused_pressed->texture[0].data.mask.color =
1270 theme->btn_shade->a_toggled_focused_pressed->texture[0].data.mask.color =
1271 theme->titlebut_toggled_focused_pressed_color;
1272 theme->btn_max->a_toggled_unfocused_pressed->texture[0].data.mask.color =
1273 theme->btn_desk->a_toggled_unfocused_pressed->texture[0].data.mask.color =
1274 theme->btn_shade->a_toggled_unfocused_pressed->texture[0].data.mask.color =
1275 theme->titlebut_toggled_unfocused_pressed_color;
1276 theme->btn_max->a_focused_unpressed->texture[0].data.mask.color =
1277 theme->btn_close->a_focused_unpressed->texture[0].data.mask.color =
1278 theme->btn_desk->a_focused_unpressed->texture[0].data.mask.color =
1279 theme->btn_shade->a_focused_unpressed->texture[0].data.mask.color =
1280 theme->btn_iconify->a_focused_unpressed->texture[0].data.mask.color =
1281 theme->titlebut_focused_unpressed_color;
1282 theme->btn_max->a_focused_pressed->texture[0].data.mask.color =
1283 theme->btn_close->a_focused_pressed->texture[0].data.mask.color =
1284 theme->btn_desk->a_focused_pressed->texture[0].data.mask.color =
1285 theme->btn_shade->a_focused_pressed->texture[0].data.mask.color =
1286 theme->btn_iconify->a_focused_pressed->texture[0].data.mask.color =
1287 theme->titlebut_focused_pressed_color;
1288 theme->btn_max->a_unfocused_unpressed->texture[0].data.mask.color =
1289 theme->btn_close->a_unfocused_unpressed->texture[0].data.mask.color =
1290 theme->btn_desk->a_unfocused_unpressed->texture[0].data.mask.color =
1291 theme->btn_shade->a_unfocused_unpressed->texture[0].data.mask.color =
1292 theme->btn_iconify->a_unfocused_unpressed->texture[0].data.mask.color =
1293 theme->titlebut_unfocused_unpressed_color;
1294 theme->btn_max->a_unfocused_pressed->texture[0].data.mask.color =
1295 theme->btn_close->a_unfocused_pressed->texture[0].data.mask.color =
1296 theme->btn_desk->a_unfocused_pressed->texture[0].data.mask.color =
1297 theme->btn_shade->a_unfocused_pressed->texture[0].data.mask.color =
1298 theme->btn_iconify->a_unfocused_pressed->texture[0].data.mask.color =
1299 theme->titlebut_unfocused_pressed_color;
1300 theme->a_menu_bullet_normal->texture[0].data.mask.color =
1302 theme->a_menu_bullet_selected->texture[0].data.mask.color =
1303 theme->menu_selected_color;
1306 XrmDestroyDatabase(db);
1308 /* set the font heights */
1309 theme->win_font_height = RrFontHeight
1310 (theme->win_font_focused,
1311 theme->a_focused_label->texture[0].data.text.shadow_offset_y);
1312 theme->win_font_height =
1313 MAX(theme->win_font_height,
1315 (theme->win_font_focused,
1316 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y));
1317 theme->menu_title_font_height = RrFontHeight
1318 (theme->menu_title_font,
1319 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y);
1320 theme->menu_font_height = RrFontHeight
1322 theme->a_menu_text_normal->texture[0].data.text.shadow_offset_y);
1324 /* calculate some last extents */
1326 gint ft, fb, fl, fr, ut, ub, ul, ur;
1328 RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb);
1329 RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub);
1330 theme->label_height = theme->win_font_height + MAX(ft + fb, ut + ub);
1331 theme->label_height += theme->label_height % 2;
1333 /* this would be nice I think, since padding.width can now be 0,
1334 but it breaks frame.c horribly and I don't feel like fixing that
1335 right now, so if anyone complains, here is how to keep text from
1336 going over the title's bevel/border with a padding.width of 0 and a
1337 bevelless/borderless label
1338 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1339 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1340 theme->title_height = theme->label_height +
1341 MAX(MAX(theme->padding * 2, ft + fb),
1342 MAX(theme->padding * 2, ut + ub));
1344 theme->title_height = theme->label_height + theme->paddingy * 2;
1346 RrMargins(theme->a_menu_title, &ul, &ut, &ur, &ub);
1347 theme->menu_title_label_height = theme->menu_title_font_height+ut+ub;
1348 theme->menu_title_height = theme->menu_title_label_height +
1349 theme->paddingy * 2;
1351 theme->button_size = theme->label_height - 2;
1352 theme->grip_width = 25;
1354 RrAppearanceFree(a_disabled_focused_tmp);
1355 RrAppearanceFree(a_disabled_unfocused_tmp);
1356 RrAppearanceFree(a_hover_focused_tmp);
1357 RrAppearanceFree(a_hover_unfocused_tmp);
1358 RrAppearanceFree(a_focused_unpressed_tmp);
1359 RrAppearanceFree(a_focused_pressed_tmp);
1360 RrAppearanceFree(a_unfocused_unpressed_tmp);
1361 RrAppearanceFree(a_unfocused_pressed_tmp);
1362 RrAppearanceFree(a_toggled_hover_focused_tmp);
1363 RrAppearanceFree(a_toggled_hover_unfocused_tmp);
1364 RrAppearanceFree(a_toggled_focused_unpressed_tmp);
1365 RrAppearanceFree(a_toggled_focused_pressed_tmp);
1366 RrAppearanceFree(a_toggled_unfocused_unpressed_tmp);
1367 RrAppearanceFree(a_toggled_unfocused_pressed_tmp);
1372 void RrThemeFree(RrTheme *theme)
1375 g_free(theme->name);
1377 RrButtonFree(theme->btn_max);
1378 RrButtonFree(theme->btn_close);
1379 RrButtonFree(theme->btn_desk);
1380 RrButtonFree(theme->btn_shade);
1381 RrButtonFree(theme->btn_iconify);
1383 RrColorFree(theme->menu_border_color);
1384 RrColorFree(theme->osd_border_color);
1385 RrColorFree(theme->frame_focused_border_color);
1386 RrColorFree(theme->frame_unfocused_border_color);
1387 RrColorFree(theme->title_separator_focused_color);
1388 RrColorFree(theme->title_separator_unfocused_color);
1389 RrColorFree(theme->cb_unfocused_color);
1390 RrColorFree(theme->cb_focused_color);
1391 RrColorFree(theme->title_focused_color);
1392 RrColorFree(theme->title_unfocused_color);
1393 RrColorFree(theme->titlebut_disabled_focused_color);
1394 RrColorFree(theme->titlebut_disabled_unfocused_color);
1395 RrColorFree(theme->titlebut_hover_focused_color);
1396 RrColorFree(theme->titlebut_hover_unfocused_color);
1397 RrColorFree(theme->titlebut_toggled_hover_focused_color);
1398 RrColorFree(theme->titlebut_toggled_hover_unfocused_color);
1399 RrColorFree(theme->titlebut_toggled_focused_pressed_color);
1400 RrColorFree(theme->titlebut_toggled_unfocused_pressed_color);
1401 RrColorFree(theme->titlebut_toggled_focused_unpressed_color);
1402 RrColorFree(theme->titlebut_toggled_unfocused_unpressed_color);
1403 RrColorFree(theme->titlebut_focused_pressed_color);
1404 RrColorFree(theme->titlebut_unfocused_pressed_color);
1405 RrColorFree(theme->titlebut_focused_unpressed_color);
1406 RrColorFree(theme->titlebut_unfocused_unpressed_color);
1407 RrColorFree(theme->menu_title_color);
1408 RrColorFree(theme->menu_color);
1409 RrColorFree(theme->menu_selected_color);
1410 RrColorFree(theme->menu_disabled_color);
1411 RrColorFree(theme->menu_disabled_selected_color);
1412 RrColorFree(theme->title_focused_shadow_color);
1413 RrColorFree(theme->title_unfocused_shadow_color);
1414 RrColorFree(theme->osd_color);
1415 RrColorFree(theme->osd_shadow_color);
1416 RrColorFree(theme->menu_title_shadow_color);
1417 RrColorFree(theme->menu_text_normal_shadow_color);
1418 RrColorFree(theme->menu_text_selected_shadow_color);
1419 RrColorFree(theme->menu_text_disabled_shadow_color);
1420 RrColorFree(theme->menu_text_disabled_selected_shadow_color);
1422 g_free(theme->def_win_icon);
1424 RrPixmapMaskFree(theme->menu_bullet_mask);
1426 RrFontClose(theme->win_font_focused);
1427 RrFontClose(theme->win_font_unfocused);
1428 RrFontClose(theme->menu_title_font);
1429 RrFontClose(theme->menu_font);
1431 RrAppearanceFree(theme->a_focused_grip);
1432 RrAppearanceFree(theme->a_unfocused_grip);
1433 RrAppearanceFree(theme->a_focused_title);
1434 RrAppearanceFree(theme->a_unfocused_title);
1435 RrAppearanceFree(theme->a_focused_label);
1436 RrAppearanceFree(theme->a_unfocused_label);
1437 RrAppearanceFree(theme->a_icon);
1438 RrAppearanceFree(theme->a_focused_handle);
1439 RrAppearanceFree(theme->a_unfocused_handle);
1440 RrAppearanceFree(theme->a_menu);
1441 RrAppearanceFree(theme->a_menu_title);
1442 RrAppearanceFree(theme->a_menu_text_title);
1443 RrAppearanceFree(theme->a_menu_normal);
1444 RrAppearanceFree(theme->a_menu_selected);
1445 RrAppearanceFree(theme->a_menu_disabled);
1446 RrAppearanceFree(theme->a_menu_disabled_selected);
1447 RrAppearanceFree(theme->a_menu_text_normal);
1448 RrAppearanceFree(theme->a_menu_text_selected);
1449 RrAppearanceFree(theme->a_menu_text_disabled);
1450 RrAppearanceFree(theme->a_menu_text_disabled_selected);
1451 RrAppearanceFree(theme->a_menu_bullet_normal);
1452 RrAppearanceFree(theme->a_menu_bullet_selected);
1453 RrAppearanceFree(theme->a_clear);
1454 RrAppearanceFree(theme->a_clear_tex);
1455 RrAppearanceFree(theme->osd_hilite_bg);
1456 RrAppearanceFree(theme->osd_hilite_fg);
1457 RrAppearanceFree(theme->osd_hilite_label);
1458 RrAppearanceFree(theme->osd_unhilite_fg);
1464 static XrmDatabase loaddb(const gchar *name, gchar **path)
1467 XrmDatabase db = NULL;
1470 if (name[0] == '/') {
1471 s = g_build_filename(name, "openbox-3", "themerc", NULL);
1472 if ((db = XrmGetFileDatabase(s)))
1473 *path = g_path_get_dirname(s);
1476 /* XXX backwards compatibility, remove me sometime later */
1477 s = g_build_filename(g_get_home_dir(), ".themes", name,
1478 "openbox-3", "themerc", NULL);
1479 if ((db = XrmGetFileDatabase(s)))
1480 *path = g_path_get_dirname(s);
1483 for (it = parse_xdg_data_dir_paths(); !db && it;
1484 it = g_slist_next(it))
1486 s = g_build_filename(it->data, "themes", name,
1487 "openbox-3", "themerc", NULL);
1488 if ((db = XrmGetFileDatabase(s)))
1489 *path = g_path_get_dirname(s);
1495 s = g_build_filename(name, "themerc", NULL);
1496 if ((db = XrmGetFileDatabase(s)))
1497 *path = g_path_get_dirname(s);
1504 static gchar *create_class_name(const gchar *rname)
1506 gchar *rclass = g_strdup(rname);
1511 p = strchr(p+1, '.');
1512 if (p == NULL) break;
1514 if (*p == '\0') break;
1519 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value)
1521 gboolean ret = FALSE;
1522 gchar *rclass = create_class_name(rname);
1523 gchar *rettype, *end;
1526 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1527 retvalue.addr != NULL) {
1528 *value = (gint)strtol(retvalue.addr, &end, 10);
1529 if (end != retvalue.addr)
1537 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value)
1539 gboolean ret = FALSE;
1540 gchar *rclass = create_class_name(rname);
1544 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1545 retvalue.addr != NULL) {
1546 *value = retvalue.addr;
1554 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
1555 const gchar *rname, RrColor **value)
1557 gboolean ret = FALSE;
1558 gchar *rclass = create_class_name(rname);
1562 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1563 retvalue.addr != NULL) {
1564 RrColor *c = RrColorParse(inst, retvalue.addr);
1575 static gboolean read_mask(const RrInstance *inst, const gchar *path,
1576 RrTheme *theme, const gchar *maskname,
1577 RrPixmapMask **value)
1579 gboolean ret = FALSE;
1581 gint hx, hy; /* ignored */
1585 s = g_build_filename(path, maskname, NULL);
1586 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
1588 *value = RrPixmapMaskNew(inst, w, h, (gchar*)b);
1596 static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
1597 RrReliefType *relief, RrBevelType *bevel,
1598 gboolean *interlaced, gboolean *border,
1599 gboolean allow_trans)
1603 /* convert to all lowercase */
1604 for (t = tex; *t != '\0'; ++t)
1605 *t = g_ascii_tolower(*t);
1607 if (allow_trans && strstr(tex, "parentrelative") != NULL) {
1608 *grad = RR_SURFACE_PARENTREL;
1610 if (strstr(tex, "gradient") != NULL) {
1611 if (strstr(tex, "crossdiagonal") != NULL)
1612 *grad = RR_SURFACE_CROSS_DIAGONAL;
1613 else if (strstr(tex, "pyramid") != NULL)
1614 *grad = RR_SURFACE_PYRAMID;
1615 else if (strstr(tex, "mirrorhorizontal") != NULL)
1616 *grad = RR_SURFACE_MIRROR_HORIZONTAL;
1617 else if (strstr(tex, "horizontal") != NULL)
1618 *grad = RR_SURFACE_HORIZONTAL;
1619 else if (strstr(tex, "splitvertical") != NULL)
1620 *grad = RR_SURFACE_SPLIT_VERTICAL;
1621 else if (strstr(tex, "vertical") != NULL)
1622 *grad = RR_SURFACE_VERTICAL;
1624 *grad = RR_SURFACE_DIAGONAL;
1626 *grad = RR_SURFACE_SOLID;
1630 if (strstr(tex, "sunken") != NULL)
1631 *relief = RR_RELIEF_SUNKEN;
1632 else if (strstr(tex, "flat") != NULL)
1633 *relief = RR_RELIEF_FLAT;
1634 else if (strstr(tex, "raised") != NULL)
1635 *relief = RR_RELIEF_RAISED;
1637 *relief = (*grad == RR_SURFACE_PARENTREL) ?
1638 RR_RELIEF_FLAT : RR_RELIEF_RAISED;
1641 if (*relief == RR_RELIEF_FLAT) {
1642 if (strstr(tex, "border") != NULL)
1645 if (strstr(tex, "bevel2") != NULL)
1646 *bevel = RR_BEVEL_2;
1648 *bevel = RR_BEVEL_1;
1651 if (strstr(tex, "interlaced") != NULL)
1654 *interlaced = FALSE;
1658 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
1659 const gchar *rname, RrAppearance *value,
1660 gboolean allow_trans)
1662 gboolean ret = FALSE;
1663 gchar *rclass = create_class_name(rname);
1664 gchar *cname, *ctoname, *bcname, *icname, *hname, *sname;
1665 gchar *csplitname, *ctosplitname;
1670 cname = g_strconcat(rname, ".color", NULL);
1671 ctoname = g_strconcat(rname, ".colorTo", NULL);
1672 bcname = g_strconcat(rname, ".border.color", NULL);
1673 icname = g_strconcat(rname, ".interlace.color", NULL);
1674 hname = g_strconcat(rname, ".highlight", NULL);
1675 sname = g_strconcat(rname, ".shadow", NULL);
1676 csplitname = g_strconcat(rname, ".color.splitTo", NULL);
1677 ctosplitname = g_strconcat(rname, ".colorTo.splitTo", NULL);
1679 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1680 retvalue.addr != NULL) {
1681 parse_appearance(retvalue.addr,
1682 &value->surface.grad,
1683 &value->surface.relief,
1684 &value->surface.bevel,
1685 &value->surface.interlaced,
1686 &value->surface.border,
1688 if (!read_color(db, inst, cname, &value->surface.primary))
1689 value->surface.primary = RrColorNew(inst, 0, 0, 0);
1690 if (!read_color(db, inst, ctoname, &value->surface.secondary))
1691 value->surface.secondary = RrColorNew(inst, 0, 0, 0);
1692 if (value->surface.border)
1693 if (!read_color(db, inst, bcname,
1694 &value->surface.border_color))
1695 value->surface.border_color = RrColorNew(inst, 0, 0, 0);
1696 if (value->surface.interlaced)
1697 if (!read_color(db, inst, icname,
1698 &value->surface.interlace_color))
1699 value->surface.interlace_color = RrColorNew(inst, 0, 0, 0);
1700 if (read_int(db, hname, &i) && i >= 0)
1701 value->surface.bevel_light_adjust = i;
1702 if (read_int(db, sname, &i) && i >= 0 && i <= 256)
1703 value->surface.bevel_dark_adjust = i;
1705 if (value->surface.grad == RR_SURFACE_SPLIT_VERTICAL) {
1708 if (!read_color(db, inst, csplitname,
1709 &value->surface.split_primary))
1711 r = value->surface.primary->r;
1713 g = value->surface.primary->g;
1715 b = value->surface.primary->b;
1717 if (r > 0xFF) r = 0xFF;
1718 if (g > 0xFF) g = 0xFF;
1719 if (b > 0xFF) b = 0xFF;
1720 value->surface.split_primary = RrColorNew(inst, r, g, b);
1723 if (!read_color(db, inst, ctosplitname,
1724 &value->surface.split_secondary))
1726 r = value->surface.secondary->r;
1728 g = value->surface.secondary->g;
1730 b = value->surface.secondary->b;
1732 if (r > 0xFF) r = 0xFF;
1733 if (g > 0xFF) g = 0xFF;
1734 if (b > 0xFF) b = 0xFF;
1735 value->surface.split_secondary = RrColorNew(inst, r, g, b);
1742 g_free(ctosplitname);
1754 static int parse_inline_number(const char *p)
1762 for (; isdigit(*p); ++p)
1763 res = res * 10 + *p - '0';
1768 static void set_default_appearance(RrAppearance *a)
1770 a->surface.grad = RR_SURFACE_SOLID;
1771 a->surface.relief = RR_RELIEF_FLAT;
1772 a->surface.bevel = RR_BEVEL_1;
1773 a->surface.interlaced = FALSE;
1774 a->surface.border = FALSE;
1775 a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
1776 a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
1779 /* Reads the output from gimp's C-Source file format into valid RGBA data for
1780 an RrTextureRGBA. */
1781 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data)
1786 p = im = g_memdup(data, width * height * sizeof(RrPixel32));
1788 for (i = 0; i < width * height; ++i) {
1789 guchar a = ((*p >> 24) & 0xff);
1790 guchar b = ((*p >> 16) & 0xff);
1791 guchar g = ((*p >> 8) & 0xff);
1792 guchar r = ((*p >> 0) & 0xff);
1794 *p = ((r << RrDefaultRedOffset) +
1795 (g << RrDefaultGreenOffset) +
1796 (b << RrDefaultBlueOffset) +
1797 (a << RrDefaultAlphaOffset));