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 "obt/paths.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 static RrFont *get_font(RrFont *target, RrFont **default_font,
50 const RrInstance *inst)
56 /* Only load the default font once */
58 RrFontRef(*default_font);
60 *default_font = RrFontOpenDefault(inst);
66 #define READ_INT(x_resstr, x_var, x_min, x_max, x_def) \
67 if (!read_int(db, x_resstr, & x_var) || \
68 x_var < x_min || x_var > x_max) \
71 #define READ_COLOR(x_resstr, x_var, x_def) \
72 if (!read_color(db, inst, x_resstr, & x_var)) \
75 #define READ_COLOR_(x_res1, x_res2, x_var, x_def) \
76 if (!read_color(db, inst, x_res1, & x_var) && \
77 !read_color(db, inst, x_res2, & x_var)) \
80 #define READ_MASK_COPY(x_file, x_var, x_copysrc) \
81 if (!read_mask(inst, path, theme, x_file, & x_var)) \
82 x_var = RrPixmapMaskCopy(x_copysrc);
84 #define READ_APPEARANCE(x_resstr, x_var, x_parrel) \
85 if (!read_appearance(db, inst, x_resstr, x_var, x_parrel)) \
86 set_default_appearance(x_var);
88 #define READ_APPEARANCE_COPY(x_resstr, x_var, x_parrel, x_defval) \
89 if (!read_appearance(db, inst, x_resstr, x_var, x_parrel)) {\
90 RrAppearanceFree(x_var); \
91 x_var = RrAppearanceCopy(x_defval); }
93 #define READ_APPEARANCE_(x_res1, x_res2, x_var, x_parrel, x_defval) \
94 if (!read_appearance(db, inst, x_res1, x_var, x_parrel) && \
95 !read_appearance(db, inst, x_res2, x_var, x_parrel)) {\
96 RrAppearanceFree(x_var); \
97 x_var = RrAppearanceCopy(x_defval); }
99 RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
100 gboolean allow_fallback,
101 RrFont *active_window_font, RrFont *inactive_window_font,
102 RrFont *menu_title_font, RrFont *menu_item_font,
103 RrFont *active_osd_font, RrFont *inactive_osd_font)
105 XrmDatabase db = NULL;
106 RrJustify winjust, mtitlejust;
109 RrFont *default_font = NULL;
112 gint menu_overlap = 0;
113 RrAppearance *a_disabled_focused_tmp;
114 RrAppearance *a_disabled_unfocused_tmp;
115 RrAppearance *a_hover_focused_tmp;
116 RrAppearance *a_hover_unfocused_tmp;
117 RrAppearance *a_focused_unpressed_tmp;
118 RrAppearance *a_focused_pressed_tmp;
119 RrAppearance *a_unfocused_unpressed_tmp;
120 RrAppearance *a_unfocused_pressed_tmp;
121 RrAppearance *a_toggled_hover_focused_tmp;
122 RrAppearance *a_toggled_hover_unfocused_tmp;
123 RrAppearance *a_toggled_focused_unpressed_tmp;
124 RrAppearance *a_toggled_focused_pressed_tmp;
125 RrAppearance *a_toggled_unfocused_unpressed_tmp;
126 RrAppearance *a_toggled_unfocused_pressed_tmp;
129 db = loaddb(name, &path);
131 g_message("Unable to load the theme '%s'", name);
133 g_message("Falling back to the default theme '%s'",
135 /* fallback to the default theme */
140 if (allow_fallback) {
141 db = loaddb(DEFAULT_THEME, &path);
143 g_message("Unable to load the theme '%s'", DEFAULT_THEME);
150 /* initialize temp reading textures */
151 a_disabled_focused_tmp = RrAppearanceNew(inst, 1);
152 a_disabled_unfocused_tmp = RrAppearanceNew(inst, 1);
153 a_hover_focused_tmp = RrAppearanceNew(inst, 1);
154 a_hover_unfocused_tmp = RrAppearanceNew(inst, 1);
155 a_toggled_focused_unpressed_tmp = RrAppearanceNew(inst, 1);
156 a_toggled_unfocused_unpressed_tmp = RrAppearanceNew(inst, 1);
157 a_toggled_hover_focused_tmp = RrAppearanceNew(inst, 1);
158 a_toggled_hover_unfocused_tmp = RrAppearanceNew(inst, 1);
159 a_toggled_focused_pressed_tmp = RrAppearanceNew(inst, 1);
160 a_toggled_unfocused_pressed_tmp = RrAppearanceNew(inst, 1);
161 a_focused_unpressed_tmp = RrAppearanceNew(inst, 1);
162 a_focused_pressed_tmp = RrAppearanceNew(inst, 1);
163 a_unfocused_unpressed_tmp = RrAppearanceNew(inst, 1);
164 a_unfocused_pressed_tmp = RrAppearanceNew(inst, 1);
166 /* initialize theme */
167 theme = g_slice_new0(RrTheme, 1);
170 theme->name = g_strdup(name ? name : DEFAULT_THEME);
172 theme->a_disabled_focused_max = RrAppearanceNew(inst, 1);
173 theme->a_disabled_unfocused_max = RrAppearanceNew(inst, 1);
174 theme->a_hover_focused_max = RrAppearanceNew(inst, 1);
175 theme->a_hover_unfocused_max = RrAppearanceNew(inst, 1);
176 theme->a_toggled_focused_unpressed_max = RrAppearanceNew(inst, 1);
177 theme->a_toggled_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
178 theme->a_toggled_hover_focused_max = RrAppearanceNew(inst, 1);
179 theme->a_toggled_hover_unfocused_max = RrAppearanceNew(inst, 1);
180 theme->a_toggled_focused_pressed_max = RrAppearanceNew(inst, 1);
181 theme->a_toggled_unfocused_pressed_max = RrAppearanceNew(inst, 1);
182 theme->a_focused_unpressed_max = RrAppearanceNew(inst, 1);
183 theme->a_focused_pressed_max = RrAppearanceNew(inst, 1);
184 theme->a_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
185 theme->a_unfocused_pressed_max = RrAppearanceNew(inst, 1);
186 theme->a_focused_grip = RrAppearanceNew(inst, 0);
187 theme->a_unfocused_grip = RrAppearanceNew(inst, 0);
188 theme->a_focused_title = RrAppearanceNew(inst, 0);
189 theme->a_unfocused_title = RrAppearanceNew(inst, 0);
190 theme->a_focused_label = RrAppearanceNew(inst, 1);
191 theme->a_unfocused_label = RrAppearanceNew(inst, 1);
192 theme->a_icon = RrAppearanceNew(inst, 1);
193 theme->a_focused_handle = RrAppearanceNew(inst, 0);
194 theme->a_unfocused_handle = RrAppearanceNew(inst, 0);
195 theme->a_menu = RrAppearanceNew(inst, 0);
196 theme->a_menu_title = RrAppearanceNew(inst, 0);
197 theme->a_menu_text_title = RrAppearanceNew(inst, 1);
198 theme->a_menu_normal = RrAppearanceNew(inst, 0);
199 theme->a_menu_selected = RrAppearanceNew(inst, 0);
200 theme->a_menu_disabled = RrAppearanceNew(inst, 0);
201 /* a_menu_disabled_selected is copied from a_menu_selected */
202 theme->a_menu_text_normal = RrAppearanceNew(inst, 1);
203 theme->a_menu_text_selected = RrAppearanceNew(inst, 1);
204 theme->a_menu_text_disabled = RrAppearanceNew(inst, 1);
205 theme->a_menu_text_disabled_selected = RrAppearanceNew(inst, 1);
206 theme->a_menu_bullet_normal = RrAppearanceNew(inst, 1);
207 theme->a_menu_bullet_selected = RrAppearanceNew(inst, 1);
208 theme->a_clear = RrAppearanceNew(inst, 0);
209 theme->a_clear_tex = RrAppearanceNew(inst, 1);
210 theme->osd_bg = RrAppearanceNew(inst, 0);
211 theme->osd_hilite_label = RrAppearanceNew(inst, 1);
212 theme->osd_hilite_bg = RrAppearanceNew(inst, 0);
213 theme->osd_unhilite_label = RrAppearanceNew(inst, 1);
214 theme->osd_unhilite_bg = RrAppearanceNew(inst, 0);
216 /* load the font stuff */
217 theme->win_font_focused = get_font(active_window_font,
218 &default_font, inst);
219 theme->win_font_unfocused = get_font(inactive_window_font,
220 &default_font, inst);
222 winjust = RR_JUSTIFY_LEFT;
223 if (read_string(db, "window.label.text.justify", &str)) {
224 if (!g_ascii_strcasecmp(str, "right"))
225 winjust = RR_JUSTIFY_RIGHT;
226 else if (!g_ascii_strcasecmp(str, "center"))
227 winjust = RR_JUSTIFY_CENTER;
230 theme->menu_title_font = get_font(menu_title_font, &default_font, inst);
232 mtitlejust = RR_JUSTIFY_LEFT;
233 if (read_string(db, "menu.title.text.justify", &str)) {
234 if (!g_ascii_strcasecmp(str, "right"))
235 mtitlejust = RR_JUSTIFY_RIGHT;
236 else if (!g_ascii_strcasecmp(str, "center"))
237 mtitlejust = RR_JUSTIFY_CENTER;
240 theme->menu_font = get_font(menu_item_font, &default_font, inst);
242 theme->osd_font_hilite = get_font(active_osd_font, &default_font, inst);
243 theme->osd_font_unhilite = get_font(inactive_osd_font, &default_font,inst);
245 /* load direct dimensions */
246 READ_INT("menu.overlap", menu_overlap, -100, 100, 0);
247 READ_INT("menu.overlap.x", theme->menu_overlap_x, -100, 100, menu_overlap);
248 READ_INT("menu.overlap.y", theme->menu_overlap_y, -100, 100, menu_overlap);
249 READ_INT("window.handle.width", theme->handle_height, 0, 100, 6);
250 READ_INT("padding.width", theme->paddingx, 0, 100, 3);
251 READ_INT("padding.height", theme->paddingy, 0, 100, theme->paddingx);
252 READ_INT("border.width", theme->fbwidth, 0, 100, 1);
253 READ_INT("menu.border.width", theme->mbwidth, 0, 100, theme->fbwidth);
254 READ_INT("osd.border.width", theme->obwidth, 0, 100, theme->fbwidth);
255 READ_INT("menu.separator.width", theme->menu_sep_width, 1, 100, 1);
256 READ_INT("menu.separator.padding.width", theme->menu_sep_paddingx, 0, 100, 6);
257 READ_INT("menu.separator.padding.height", theme->menu_sep_paddingy, 0, 100, 3);
258 READ_INT("window.client.padding.width", theme->cbwidthx, 0, 100,
260 READ_INT("window.client.padding.height", theme->cbwidthy, 0, 100,
264 READ_COLOR_("window.active.border.color", "border.color",
265 theme->frame_focused_border_color, RrColorNew(inst, 0, 0, 0));
267 /* title separator focused color inherits from focused border color */
268 READ_COLOR("window.active.title.separator.color",
269 theme->title_separator_focused_color,
270 RrColorCopy(theme->frame_focused_border_color));
272 /* unfocused border color inherits from frame focused border color */
273 READ_COLOR("window.inactive.border.color",
274 theme->frame_unfocused_border_color,
275 RrColorCopy(theme->frame_focused_border_color));
277 /* title separator unfocused color inherits from unfocused border color */
278 READ_COLOR("window.inactive.title.separator.color",
279 theme->title_separator_unfocused_color,
280 RrColorCopy(theme->frame_unfocused_border_color));
282 /* menu border color inherits from frame focused border color */
283 READ_COLOR("menu.border.color", theme->menu_border_color,
284 RrColorCopy(theme->frame_focused_border_color));
286 /* osd border color inherits from frame focused border color */
287 READ_COLOR("osd.border.color", theme->osd_border_color,
288 RrColorCopy(theme->frame_focused_border_color));
290 READ_COLOR("window.active.client.color", theme->cb_focused_color,
291 RrColorNew(inst, 0xff, 0xff, 0xff));
293 READ_COLOR("window.inactive.client.color", theme->cb_unfocused_color,
294 RrColorNew(inst, 0xff, 0xff, 0xff));
296 READ_COLOR("window.active.label.text.color", theme->title_focused_color,
297 RrColorNew(inst, 0x0, 0x0, 0x0));
299 READ_COLOR_("osd.active.label.text.color",
300 "osd.label.text.color",
301 theme->osd_color, RrColorCopy(theme->title_focused_color));
303 READ_COLOR("window.inactive.label.text.color", theme->title_unfocused_color,
304 RrColorCopy(theme->title_unfocused_color));
306 READ_COLOR("osd.inactive.label.text.color", theme->osd_text_inactive_color,
307 RrColorNew(inst, 0xff, 0xff, 0xff));
309 READ_COLOR("window.inactive.label.text.color",
310 theme->title_unfocused_color,
311 RrColorNew(inst, 0xff, 0xff, 0xff));
313 READ_COLOR("window.active.button.unpressed.image.color",
314 theme->titlebut_focused_unpressed_color,
315 RrColorNew(inst, 0, 0, 0));
317 READ_COLOR("window.inactive.button.unpressed.image.color",
318 theme->titlebut_unfocused_unpressed_color,
319 RrColorNew(inst, 0xff, 0xff, 0xff));
321 READ_COLOR("window.active.button.pressed.image.color",
322 theme->titlebut_focused_pressed_color,
323 RrColorCopy(theme->titlebut_focused_unpressed_color));
325 READ_COLOR("window.inactive.button.pressed.image.color",
326 theme->titlebut_unfocused_pressed_color,
327 RrColorCopy(theme->titlebut_unfocused_unpressed_color));
329 READ_COLOR("window.active.button.disabled.image.color",
330 theme->titlebut_disabled_focused_color,
331 RrColorNew(inst, 0xff, 0xff, 0xff));
333 READ_COLOR("window.inactive.button.disabled.image.color",
334 theme->titlebut_disabled_unfocused_color,
335 RrColorNew(inst, 0, 0, 0));
337 READ_COLOR("window.active.button.hover.image.color",
338 theme->titlebut_hover_focused_color,
339 RrColorCopy(theme->titlebut_focused_unpressed_color));
341 READ_COLOR("window.inactive.button.hover.image.color",
342 theme->titlebut_hover_unfocused_color,
343 RrColorCopy(theme->titlebut_unfocused_unpressed_color));
345 READ_COLOR_("window.active.button.toggled.unpressed.image.color",
346 "window.active.button.toggled.image.color",
347 theme->titlebut_toggled_focused_unpressed_color,
348 RrColorCopy(theme->titlebut_focused_pressed_color));
350 READ_COLOR_("window.inactive.button.toggled.unpressed.image.color",
351 "window.inactive.button.toggled.image.color",
352 theme->titlebut_toggled_unfocused_unpressed_color,
353 RrColorCopy(theme->titlebut_unfocused_pressed_color));
355 READ_COLOR("window.active.button.toggled.hover.image.color",
356 theme->titlebut_toggled_hover_focused_color,
357 RrColorCopy(theme->titlebut_toggled_focused_unpressed_color));
359 READ_COLOR("window.inactive.button.toggled.hover.image.color",
360 theme->titlebut_toggled_hover_unfocused_color,
361 RrColorCopy(theme->titlebut_toggled_unfocused_unpressed_color));
363 READ_COLOR("window.active.button.toggled.pressed.image.color",
364 theme->titlebut_toggled_focused_pressed_color,
365 RrColorCopy(theme->titlebut_focused_pressed_color));
367 READ_COLOR("window.inactive.button.toggled.pressed.image.color",
368 theme->titlebut_toggled_unfocused_pressed_color,
369 RrColorCopy(theme->titlebut_unfocused_pressed_color));
371 READ_COLOR("menu.title.text.color", theme->menu_title_color,
372 RrColorNew(inst, 0, 0, 0));
374 READ_COLOR("menu.items.text.color", theme->menu_color,
375 RrColorNew(inst, 0xff, 0xff, 0xff));
377 READ_COLOR("menu.items.disabled.text.color", theme->menu_disabled_color,
378 RrColorNew(inst, 0, 0, 0));
380 READ_COLOR("menu.items.active.disabled.text.color",
381 theme->menu_disabled_selected_color,
382 RrColorCopy(theme->menu_disabled_color));
384 READ_COLOR("menu.items.active.text.color", theme->menu_selected_color,
385 RrColorNew(inst, 0, 0, 0));
387 READ_COLOR("menu.separator.color", theme->menu_sep_color,
388 RrColorCopy(theme->menu_color));
390 /* load the image masks */
392 /* maximize button masks */
394 if (!read_mask(inst, path, theme, "max.xbm", &theme->max_mask)) {
395 guchar data[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
396 theme->max_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
399 if (!read_mask(inst, path, theme, "max_toggled.xbm",
400 &theme->max_toggled_mask))
403 theme->max_toggled_mask = RrPixmapMaskCopy(theme->max_mask);
405 guchar data[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
406 theme->max_toggled_mask = RrPixmapMaskNew(inst, 6, 6,(gchar*)data);
409 READ_MASK_COPY("max_pressed.xbm", theme->max_pressed_mask,
411 READ_MASK_COPY("max_disabled.xbm", theme->max_disabled_mask,
413 READ_MASK_COPY("max_hover.xbm", theme->max_hover_mask, theme->max_mask);
414 READ_MASK_COPY("max_toggled_pressed.xbm", theme->max_toggled_pressed_mask,
415 theme->max_toggled_mask);
416 READ_MASK_COPY("max_toggled_hover.xbm", theme->max_toggled_hover_mask,
417 theme->max_toggled_mask);
419 /* iconify button masks */
420 if (!read_mask(inst, path, theme, "iconify.xbm", &theme->iconify_mask)) {
421 guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
422 theme->iconify_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
424 READ_MASK_COPY("iconify_pressed.xbm", theme->iconify_pressed_mask,
425 theme->iconify_mask);
426 READ_MASK_COPY("iconify_disabled.xbm", theme->iconify_disabled_mask,
427 theme->iconify_mask);
428 READ_MASK_COPY("iconify_hover.xbm", theme->iconify_hover_mask,
429 theme->iconify_mask);
431 /* all desktops button masks */
433 if (!read_mask(inst, path, theme, "desk.xbm", &theme->desk_mask)) {
434 guchar data[] = { 0x33, 0x33, 0x00, 0x00, 0x33, 0x33 };
435 theme->desk_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
438 if (!read_mask(inst, path, theme, "desk_toggled.xbm",
439 &theme->desk_toggled_mask)) {
441 theme->desk_toggled_mask = RrPixmapMaskCopy(theme->desk_mask);
443 guchar data[] = { 0x00, 0x1e, 0x1a, 0x16, 0x1e, 0x00 };
444 theme->desk_toggled_mask =
445 RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
448 READ_MASK_COPY("desk_pressed.xbm", theme->desk_pressed_mask,
450 READ_MASK_COPY("desk_disabled.xbm", theme->desk_disabled_mask,
452 READ_MASK_COPY("desk_hover.xbm", theme->desk_hover_mask, theme->desk_mask);
453 READ_MASK_COPY("desk_toggled_pressed.xbm",
454 theme->desk_toggled_pressed_mask, theme->desk_toggled_mask);
455 READ_MASK_COPY("desk_toggled_hover.xbm", theme->desk_toggled_hover_mask,
456 theme->desk_toggled_mask);
458 /* shade button masks */
459 if (!read_mask(inst, path, theme, "shade.xbm", &theme->shade_mask)) {
460 guchar data[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
461 theme->shade_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
463 READ_MASK_COPY("shade_toggled.xbm", theme->shade_toggled_mask,
465 READ_MASK_COPY("shade_pressed.xbm", theme->shade_pressed_mask,
467 READ_MASK_COPY("shade_disabled.xbm", theme->shade_disabled_mask,
469 READ_MASK_COPY("shade_hover.xbm", theme->shade_hover_mask,
471 READ_MASK_COPY("shade_toggled_pressed.xbm",
472 theme->shade_toggled_pressed_mask,
473 theme->shade_toggled_mask);
474 READ_MASK_COPY("shade_toggled_hover.xbm",
475 theme->shade_toggled_hover_mask, theme->shade_toggled_mask);
477 /* close button masks */
478 if (!read_mask(inst, path, theme, "close.xbm", &theme->close_mask)) {
479 guchar data[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
480 theme->close_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
482 READ_MASK_COPY("close_pressed.xbm", theme->close_pressed_mask,
484 READ_MASK_COPY("close_disabled.xbm", theme->close_disabled_mask,
486 READ_MASK_COPY("close_hover.xbm", theme->close_hover_mask,
489 /* submenu bullet mask */
490 if (!read_mask(inst, path, theme, "bullet.xbm", &theme->menu_bullet_mask))
492 guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
493 theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data);
496 /* up and down arrows */
498 guchar data[] = { 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00 };
499 theme->down_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data);
502 guchar data[] = { 0x10, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xfe, 0x00 };
503 theme->up_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data);
506 /* setup the default window icon */
507 theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
508 OB_DEFAULT_ICON_HEIGHT,
509 OB_DEFAULT_ICON_pixel_data);
510 theme->def_win_icon_w = OB_DEFAULT_ICON_WIDTH;
511 theme->def_win_icon_h = OB_DEFAULT_ICON_HEIGHT;
513 /* read the decoration textures */
514 READ_APPEARANCE("window.active.title.bg", theme->a_focused_title, FALSE);
515 READ_APPEARANCE("window.inactive.title.bg", theme->a_unfocused_title,
517 READ_APPEARANCE("window.active.label.bg", theme->a_focused_label, TRUE);
518 READ_APPEARANCE("window.inactive.label.bg", theme->a_unfocused_label,
520 READ_APPEARANCE("window.active.handle.bg", theme->a_focused_handle, FALSE);
521 READ_APPEARANCE("window.inactive.handle.bg",theme->a_unfocused_handle,
523 READ_APPEARANCE("window.active.grip.bg", theme->a_focused_grip, TRUE);
524 READ_APPEARANCE("window.inactive.grip.bg", theme->a_unfocused_grip, TRUE);
525 READ_APPEARANCE("menu.items.bg", theme->a_menu, FALSE);
526 READ_APPEARANCE("menu.title.bg", theme->a_menu_title, TRUE);
527 READ_APPEARANCE("menu.items.active.bg", theme->a_menu_selected, TRUE);
529 theme->a_menu_disabled_selected =
530 RrAppearanceCopy(theme->a_menu_selected);
532 /* read appearances for non-decorations (on-screen-display) */
533 if (!read_appearance(db, inst, "osd.bg", theme->osd_bg, FALSE)) {
534 RrAppearanceFree(theme->osd_bg);
535 theme->osd_bg = RrAppearanceCopy(theme->a_focused_title);
537 if (!read_appearance(db, inst, "osd.active.label.bg",
538 theme->osd_hilite_label, TRUE) &&
539 !read_appearance(db, inst, "osd.label.bg",
540 theme->osd_hilite_label, TRUE)) {
541 RrAppearanceFree(theme->osd_hilite_label);
542 theme->osd_hilite_label = RrAppearanceCopy(theme->a_focused_label);
544 if (!read_appearance(db, inst, "osd.inactive.label.bg",
545 theme->osd_unhilite_label, TRUE)) {
546 RrAppearanceFree(theme->osd_unhilite_label);
547 theme->osd_unhilite_label = RrAppearanceCopy(theme->a_unfocused_label);
549 /* osd_hilite_fg can't be parentrel */
550 if (!read_appearance(db, inst, "osd.hilight.bg",
551 theme->osd_hilite_bg, FALSE)) {
552 RrAppearanceFree(theme->osd_hilite_bg);
553 if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL)
554 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_label);
556 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_title);
558 /* osd_unhilite_fg can't be parentrel either */
559 if (!read_appearance(db, inst, "osd.unhilight.bg",
560 theme->osd_unhilite_bg, FALSE)) {
561 RrAppearanceFree(theme->osd_unhilite_bg);
562 if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL)
563 theme->osd_unhilite_bg=RrAppearanceCopy(theme->a_unfocused_label);
565 theme->osd_unhilite_bg=RrAppearanceCopy(theme->a_unfocused_title);
568 /* read buttons textures */
569 READ_APPEARANCE("window.active.button.disabled.bg",
570 a_disabled_focused_tmp, TRUE);
571 READ_APPEARANCE("window.inactive.button.disabled.bg",
572 a_disabled_unfocused_tmp, TRUE);
573 READ_APPEARANCE("window.active.button.pressed.bg",
574 a_focused_pressed_tmp, TRUE);
575 READ_APPEARANCE("window.inactive.button.pressed.bg",
576 a_unfocused_pressed_tmp, TRUE);
578 READ_APPEARANCE_("window.active.button.toggled.unpressed.bg",
579 "window.active.button.toggled.bg",
580 a_toggled_focused_unpressed_tmp, TRUE,
581 a_focused_pressed_tmp);
582 READ_APPEARANCE_("window.inactive.button.toggled.unpressed.bg",
583 "window.inactive.button.toggled.bg",
584 a_toggled_unfocused_unpressed_tmp, TRUE,
585 a_unfocused_pressed_tmp);
587 READ_APPEARANCE_COPY("window.active.button.toggled.hover.bg",
588 a_toggled_hover_focused_tmp, TRUE,
589 a_toggled_focused_unpressed_tmp);
590 READ_APPEARANCE_COPY("window.inactive.button.toggled.hover.bg",
591 a_toggled_hover_unfocused_tmp, TRUE,
592 a_toggled_unfocused_unpressed_tmp);
594 READ_APPEARANCE_COPY("window.active.button.toggled.pressed.bg",
595 a_toggled_focused_pressed_tmp, TRUE,
596 a_focused_pressed_tmp);
597 READ_APPEARANCE_COPY("window.inactive.button.toggled.pressed.bg",
598 a_toggled_unfocused_pressed_tmp, TRUE,
599 a_unfocused_pressed_tmp);
601 READ_APPEARANCE("window.active.button.unpressed.bg",
602 a_focused_unpressed_tmp, TRUE);
603 READ_APPEARANCE("window.inactive.button.unpressed.bg",
604 a_unfocused_unpressed_tmp, TRUE);
606 READ_APPEARANCE_COPY("window.active.button.hover.bg",
607 a_hover_focused_tmp, TRUE,
608 a_focused_unpressed_tmp);
609 READ_APPEARANCE_COPY("window.inactive.button.hover.bg",
610 a_hover_unfocused_tmp, TRUE,
611 a_unfocused_unpressed_tmp);
613 theme->a_disabled_focused_max =
614 RrAppearanceCopy(a_disabled_focused_tmp);
615 theme->a_disabled_unfocused_max =
616 RrAppearanceCopy(a_disabled_unfocused_tmp);
617 theme->a_hover_focused_max =
618 RrAppearanceCopy(a_hover_focused_tmp);
619 theme->a_hover_unfocused_max =
620 RrAppearanceCopy(a_hover_unfocused_tmp);
621 theme->a_unfocused_unpressed_max =
622 RrAppearanceCopy(a_unfocused_unpressed_tmp);
623 theme->a_unfocused_pressed_max =
624 RrAppearanceCopy(a_unfocused_pressed_tmp);
625 theme->a_focused_unpressed_max =
626 RrAppearanceCopy(a_focused_unpressed_tmp);
627 theme->a_focused_pressed_max =
628 RrAppearanceCopy(a_focused_pressed_tmp);
629 theme->a_disabled_focused_close =
630 RrAppearanceCopy(a_disabled_focused_tmp);
631 theme->a_disabled_unfocused_close =
632 RrAppearanceCopy(a_disabled_unfocused_tmp);
633 theme->a_hover_focused_close =
634 RrAppearanceCopy(a_hover_focused_tmp);
635 theme->a_hover_unfocused_close =
636 RrAppearanceCopy(a_hover_unfocused_tmp);
637 theme->a_unfocused_unpressed_close =
638 RrAppearanceCopy(a_unfocused_unpressed_tmp);
639 theme->a_unfocused_pressed_close =
640 RrAppearanceCopy(a_unfocused_pressed_tmp);
641 theme->a_focused_unpressed_close =
642 RrAppearanceCopy(a_focused_unpressed_tmp);
643 theme->a_focused_pressed_close =
644 RrAppearanceCopy(a_focused_pressed_tmp);
645 theme->a_disabled_focused_desk =
646 RrAppearanceCopy(a_disabled_focused_tmp);
647 theme->a_disabled_unfocused_desk =
648 RrAppearanceCopy(a_disabled_unfocused_tmp);
649 theme->a_hover_focused_desk =
650 RrAppearanceCopy(a_hover_focused_tmp);
651 theme->a_hover_unfocused_desk =
652 RrAppearanceCopy(a_hover_unfocused_tmp);
653 theme->a_toggled_hover_focused_desk =
654 RrAppearanceCopy(a_toggled_hover_focused_tmp);
655 theme->a_toggled_hover_unfocused_desk =
656 RrAppearanceCopy(a_toggled_hover_unfocused_tmp);
657 theme->a_toggled_focused_unpressed_desk =
658 RrAppearanceCopy(a_toggled_focused_unpressed_tmp);
659 theme->a_toggled_unfocused_unpressed_desk =
660 RrAppearanceCopy(a_toggled_unfocused_unpressed_tmp);
661 theme->a_toggled_focused_pressed_desk =
662 RrAppearanceCopy(a_toggled_focused_pressed_tmp);
663 theme->a_toggled_unfocused_pressed_desk =
664 RrAppearanceCopy(a_toggled_unfocused_pressed_tmp);
665 theme->a_unfocused_unpressed_desk =
666 RrAppearanceCopy(a_unfocused_unpressed_tmp);
667 theme->a_unfocused_pressed_desk =
668 RrAppearanceCopy(a_unfocused_pressed_tmp);
669 theme->a_focused_unpressed_desk =
670 RrAppearanceCopy(a_focused_unpressed_tmp);
671 theme->a_focused_pressed_desk =
672 RrAppearanceCopy(a_focused_pressed_tmp);
673 theme->a_disabled_focused_shade =
674 RrAppearanceCopy(a_disabled_focused_tmp);
675 theme->a_disabled_unfocused_shade =
676 RrAppearanceCopy(a_disabled_unfocused_tmp);
677 theme->a_hover_focused_shade =
678 RrAppearanceCopy(a_hover_focused_tmp);
679 theme->a_hover_unfocused_shade =
680 RrAppearanceCopy(a_hover_unfocused_tmp);
681 theme->a_toggled_hover_focused_shade =
682 RrAppearanceCopy(a_toggled_hover_focused_tmp);
683 theme->a_toggled_hover_unfocused_shade =
684 RrAppearanceCopy(a_toggled_hover_unfocused_tmp);
685 theme->a_toggled_focused_unpressed_shade =
686 RrAppearanceCopy(a_toggled_focused_unpressed_tmp);
687 theme->a_toggled_unfocused_unpressed_shade =
688 RrAppearanceCopy(a_toggled_unfocused_unpressed_tmp);
689 theme->a_toggled_focused_pressed_shade =
690 RrAppearanceCopy(a_toggled_focused_pressed_tmp);
691 theme->a_toggled_unfocused_pressed_shade =
692 RrAppearanceCopy(a_toggled_unfocused_pressed_tmp);
693 theme->a_unfocused_unpressed_shade =
694 RrAppearanceCopy(a_unfocused_unpressed_tmp);
695 theme->a_unfocused_pressed_shade =
696 RrAppearanceCopy(a_unfocused_pressed_tmp);
697 theme->a_focused_unpressed_shade =
698 RrAppearanceCopy(a_focused_unpressed_tmp);
699 theme->a_focused_pressed_shade =
700 RrAppearanceCopy(a_focused_pressed_tmp);
701 theme->a_disabled_focused_iconify =
702 RrAppearanceCopy(a_disabled_focused_tmp);
703 theme->a_disabled_unfocused_iconify =
704 RrAppearanceCopy(a_disabled_focused_tmp);
705 theme->a_hover_focused_iconify =
706 RrAppearanceCopy(a_hover_focused_tmp);
707 theme->a_hover_unfocused_iconify =
708 RrAppearanceCopy(a_hover_unfocused_tmp);
709 theme->a_unfocused_unpressed_iconify =
710 RrAppearanceCopy(a_unfocused_unpressed_tmp);
711 theme->a_unfocused_pressed_iconify =
712 RrAppearanceCopy(a_unfocused_pressed_tmp);
713 theme->a_focused_unpressed_iconify =
714 RrAppearanceCopy(a_focused_unpressed_tmp);
715 theme->a_focused_pressed_iconify =
716 RrAppearanceCopy(a_focused_pressed_tmp);
718 theme->a_icon->surface.grad =
719 theme->a_clear->surface.grad =
720 theme->a_clear_tex->surface.grad =
721 theme->a_menu_text_title->surface.grad =
722 theme->a_menu_normal->surface.grad =
723 theme->a_menu_disabled->surface.grad =
724 theme->a_menu_text_normal->surface.grad =
725 theme->a_menu_text_selected->surface.grad =
726 theme->a_menu_text_disabled->surface.grad =
727 theme->a_menu_text_disabled_selected->surface.grad =
728 theme->a_menu_bullet_normal->surface.grad =
729 theme->a_menu_bullet_selected->surface.grad = RR_SURFACE_PARENTREL;
731 /* set up the textures */
732 theme->a_focused_label->texture[0].type = RR_TEXTURE_TEXT;
733 theme->a_focused_label->texture[0].data.text.justify = winjust;
734 theme->a_focused_label->texture[0].data.text.font=theme->win_font_focused;
735 theme->a_focused_label->texture[0].data.text.color =
736 theme->title_focused_color;
738 if (read_string(db, "window.active.label.text.font", &str)) {
742 if (strstr(str, "shadow=y")) {
743 if ((p = strstr(str, "shadowoffset=")))
744 i = parse_inline_number(p + strlen("shadowoffset="));
747 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
748 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
750 if ((p = strstr(str, "shadowtint=")))
752 i = parse_inline_number(p + strlen("shadowtint="));
753 j = (i > 0 ? 0 : 255);
756 theme->title_focused_shadow_color = RrColorNew(inst, j, j, j);
757 theme->title_focused_shadow_alpha = i;
759 theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
760 theme->title_focused_shadow_alpha = 50;
764 theme->a_focused_label->texture[0].data.text.shadow_color =
765 theme->title_focused_shadow_color;
766 theme->a_focused_label->texture[0].data.text.shadow_alpha =
767 theme->title_focused_shadow_alpha;
769 theme->osd_hilite_label->texture[0].type = RR_TEXTURE_TEXT;
770 theme->osd_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
771 theme->osd_hilite_label->texture[0].data.text.font =
772 theme->osd_font_hilite;
773 theme->osd_hilite_label->texture[0].data.text.color =
774 theme->osd_text_active_color;
776 if (read_string(db, "osd.active.label.text.font", &str) ||
777 read_string(db, "osd.label.text.font", &str))
782 if (strstr(str, "shadow=y")) {
783 if ((p = strstr(str, "shadowoffset=")))
784 i = parse_inline_number(p + strlen("shadowoffset="));
787 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x = i;
788 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y = i;
790 if ((p = strstr(str, "shadowtint=")))
792 i = parse_inline_number(p + strlen("shadowtint="));
793 j = (i > 0 ? 0 : 255);
796 theme->osd_text_active_shadow_color = RrColorNew(inst, j, j, j);
797 theme->osd_text_active_shadow_alpha = i;
799 theme->osd_text_active_shadow_color = RrColorNew(inst, 0, 0, 0);
800 theme->osd_text_active_shadow_alpha = 50;
803 /* inherit the font settings from the focused label */
804 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x =
805 theme->a_focused_label->texture[0].data.text.shadow_offset_x;
806 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y =
807 theme->a_focused_label->texture[0].data.text.shadow_offset_y;
808 if (theme->title_focused_shadow_color)
809 theme->osd_text_active_shadow_color =
811 theme->title_focused_shadow_color->r,
812 theme->title_focused_shadow_color->g,
813 theme->title_focused_shadow_color->b);
815 theme->osd_text_active_shadow_color = RrColorNew(inst, 0, 0, 0);
816 theme->osd_text_active_shadow_alpha =
817 theme->title_focused_shadow_alpha;
820 theme->osd_hilite_label->texture[0].data.text.shadow_color =
821 theme->osd_text_active_shadow_color;
822 theme->osd_hilite_label->texture[0].data.text.shadow_alpha =
823 theme->osd_text_active_shadow_alpha;
825 theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT;
826 theme->a_unfocused_label->texture[0].data.text.justify = winjust;
827 theme->a_unfocused_label->texture[0].data.text.font =
828 theme->win_font_unfocused;
829 theme->a_unfocused_label->texture[0].data.text.color =
830 theme->title_unfocused_color;
832 if (read_string(db, "window.inactive.label.text.font", &str)) {
836 if (strstr(str, "shadow=y")) {
837 if ((p = strstr(str, "shadowoffset=")))
838 i = parse_inline_number(p + strlen("shadowoffset="));
841 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x = i;
842 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y = i;
844 if ((p = strstr(str, "shadowtint=")))
846 i = parse_inline_number(p + strlen("shadowtint="));
847 j = (i > 0 ? 0 : 255);
850 theme->title_unfocused_shadow_color = RrColorNew(inst, j, j, j);
851 theme->title_unfocused_shadow_alpha = i;
853 theme->title_unfocused_shadow_color = RrColorNew(inst, 0, 0, 0);
854 theme->title_unfocused_shadow_alpha = 50;
858 theme->a_unfocused_label->texture[0].data.text.shadow_color =
859 theme->title_unfocused_shadow_color;
860 theme->a_unfocused_label->texture[0].data.text.shadow_alpha =
861 theme->title_unfocused_shadow_alpha;
863 theme->osd_unhilite_label->texture[0].type = RR_TEXTURE_TEXT;
864 theme->osd_unhilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
865 theme->osd_unhilite_label->texture[0].data.text.font =
866 theme->osd_font_unhilite;
867 theme->osd_unhilite_label->texture[0].data.text.color =
868 theme->osd_text_inactive_color;
870 if (read_string(db, "osd.inactive.label.text.font", &str))
875 if (strstr(str, "shadow=y")) {
876 if ((p = strstr(str, "shadowoffset=")))
877 i = parse_inline_number(p + strlen("shadowoffset="));
880 theme->osd_unhilite_label->texture[0].data.text.shadow_offset_x=i;
881 theme->osd_unhilite_label->texture[0].data.text.shadow_offset_y=i;
883 if ((p = strstr(str, "shadowtint=")))
885 i = parse_inline_number(p + strlen("shadowtint="));
886 j = (i > 0 ? 0 : 255);
889 theme->osd_text_inactive_shadow_color = RrColorNew(inst, j, j, j);
890 theme->osd_text_inactive_shadow_alpha = i;
892 theme->osd_text_inactive_shadow_color = RrColorNew(inst, 0, 0, 0);
893 theme->osd_text_inactive_shadow_alpha = 50;
896 /* inherit the font settings from the unfocused label */
897 theme->osd_unhilite_label->texture[0].data.text.shadow_offset_x =
898 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x;
899 theme->osd_unhilite_label->texture[0].data.text.shadow_offset_y =
900 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y;
901 if (theme->title_unfocused_shadow_color)
902 theme->osd_text_inactive_shadow_color =
904 theme->title_unfocused_shadow_color->r,
905 theme->title_unfocused_shadow_color->g,
906 theme->title_unfocused_shadow_color->b);
908 theme->osd_text_inactive_shadow_color = RrColorNew(inst, 0, 0, 0);
909 theme->osd_text_inactive_shadow_alpha =
910 theme->title_unfocused_shadow_alpha;
913 theme->osd_unhilite_label->texture[0].data.text.shadow_color =
914 theme->osd_text_inactive_shadow_color;
915 theme->osd_unhilite_label->texture[0].data.text.shadow_alpha =
916 theme->osd_text_inactive_shadow_alpha;
918 theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
919 theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
920 theme->a_menu_text_title->texture[0].data.text.font =
921 theme->menu_title_font;
922 theme->a_menu_text_title->texture[0].data.text.color =
923 theme->menu_title_color;
925 if (read_string(db, "menu.title.text.font", &str)) {
929 if (strstr(str, "shadow=y")) {
930 if ((p = strstr(str, "shadowoffset=")))
931 i = parse_inline_number(p + strlen("shadowoffset="));
934 theme->a_menu_text_title->texture[0].data.text.shadow_offset_x = i;
935 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y = i;
937 if ((p = strstr(str, "shadowtint=")))
939 i = parse_inline_number(p + strlen("shadowtint="));
940 j = (i > 0 ? 0 : 255);
943 theme->menu_title_shadow_color = RrColorNew(inst, j, j, j);
944 theme->menu_title_shadow_alpha = i;
946 theme->menu_title_shadow_color = RrColorNew(inst, 0, 0, 0);
947 theme->menu_title_shadow_alpha = 50;
951 theme->a_menu_text_title->texture[0].data.text.shadow_color =
952 theme->menu_title_shadow_color;
953 theme->a_menu_text_title->texture[0].data.text.shadow_alpha =
954 theme->menu_title_shadow_alpha;
956 theme->a_menu_text_normal->texture[0].type =
957 theme->a_menu_text_selected->texture[0].type =
958 theme->a_menu_text_disabled->texture[0].type =
959 theme->a_menu_text_disabled_selected->texture[0].type =
961 theme->a_menu_text_normal->texture[0].data.text.justify =
962 theme->a_menu_text_selected->texture[0].data.text.justify =
963 theme->a_menu_text_disabled->texture[0].data.text.justify =
964 theme->a_menu_text_disabled_selected->texture[0].data.text.justify =
966 theme->a_menu_text_normal->texture[0].data.text.font =
967 theme->a_menu_text_selected->texture[0].data.text.font =
968 theme->a_menu_text_disabled->texture[0].data.text.font =
969 theme->a_menu_text_disabled_selected->texture[0].data.text.font =
971 theme->a_menu_text_normal->texture[0].data.text.color = theme->menu_color;
972 theme->a_menu_text_selected->texture[0].data.text.color =
973 theme->menu_selected_color;
974 theme->a_menu_text_disabled->texture[0].data.text.color =
975 theme->menu_disabled_color;
976 theme->a_menu_text_disabled_selected->texture[0].data.text.color =
977 theme->menu_disabled_selected_color;
979 if (read_string(db, "menu.items.font", &str)) {
983 if (strstr(str, "shadow=y")) {
984 if ((p = strstr(str, "shadowoffset=")))
985 i = parse_inline_number(p + strlen("shadowoffset="));
988 theme->a_menu_text_normal->
989 texture[0].data.text.shadow_offset_x = i;
990 theme->a_menu_text_normal->
991 texture[0].data.text.shadow_offset_y = i;
992 theme->a_menu_text_selected->
993 texture[0].data.text.shadow_offset_x = i;
994 theme->a_menu_text_selected->
995 texture[0].data.text.shadow_offset_y = i;
996 theme->a_menu_text_disabled->
997 texture[0].data.text.shadow_offset_x = i;
998 theme->a_menu_text_disabled->
999 texture[0].data.text.shadow_offset_y = i;
1000 theme->a_menu_text_disabled_selected->
1001 texture[0].data.text.shadow_offset_x = i;
1002 theme->a_menu_text_disabled_selected->
1003 texture[0].data.text.shadow_offset_y = i;
1005 if ((p = strstr(str, "shadowtint=")))
1007 i = parse_inline_number(p + strlen("shadowtint="));
1008 j = (i > 0 ? 0 : 255);
1011 theme->menu_text_normal_shadow_color = RrColorNew(inst, j, j, j);
1012 theme->menu_text_selected_shadow_color = RrColorNew(inst, j, j, j);
1013 theme->menu_text_disabled_shadow_color = RrColorNew(inst, j, j, j);
1014 theme->menu_text_normal_shadow_alpha = i;
1015 theme->menu_text_selected_shadow_alpha = i;
1016 theme->menu_text_disabled_shadow_alpha = i;
1017 theme->menu_text_disabled_selected_shadow_alpha = i;
1019 theme->menu_text_normal_shadow_color = RrColorNew(inst, 0, 0, 0);
1020 theme->menu_text_selected_shadow_color = RrColorNew(inst, 0, 0, 0);
1021 theme->menu_text_disabled_shadow_color = RrColorNew(inst, 0, 0, 0);
1022 theme->menu_text_normal_shadow_alpha = 50;
1023 theme->menu_text_selected_shadow_alpha = 50;
1024 theme->menu_text_disabled_selected_shadow_alpha = 50;
1028 theme->a_menu_text_normal->texture[0].data.text.shadow_color =
1029 theme->menu_text_normal_shadow_color;
1030 theme->a_menu_text_normal->texture[0].data.text.shadow_alpha =
1031 theme->menu_text_normal_shadow_alpha;
1032 theme->a_menu_text_selected->texture[0].data.text.shadow_color =
1033 theme->menu_text_selected_shadow_color;
1034 theme->a_menu_text_selected->texture[0].data.text.shadow_alpha =
1035 theme->menu_text_selected_shadow_alpha;
1036 theme->a_menu_text_disabled->texture[0].data.text.shadow_color =
1037 theme->menu_text_disabled_shadow_color;
1038 theme->a_menu_text_disabled->texture[0].data.text.shadow_alpha =
1039 theme->menu_text_disabled_shadow_alpha;
1040 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_color =
1041 theme->menu_text_disabled_shadow_color;
1042 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_alpha =
1043 theme->menu_text_disabled_shadow_alpha;
1045 theme->a_disabled_focused_max->texture[0].type =
1046 theme->a_disabled_unfocused_max->texture[0].type =
1047 theme->a_hover_focused_max->texture[0].type =
1048 theme->a_hover_unfocused_max->texture[0].type =
1049 theme->a_toggled_hover_focused_max->texture[0].type =
1050 theme->a_toggled_hover_unfocused_max->texture[0].type =
1051 theme->a_toggled_focused_unpressed_max->texture[0].type =
1052 theme->a_toggled_unfocused_unpressed_max->texture[0].type =
1053 theme->a_toggled_focused_pressed_max->texture[0].type =
1054 theme->a_toggled_unfocused_pressed_max->texture[0].type =
1055 theme->a_focused_unpressed_max->texture[0].type =
1056 theme->a_focused_pressed_max->texture[0].type =
1057 theme->a_unfocused_unpressed_max->texture[0].type =
1058 theme->a_unfocused_pressed_max->texture[0].type =
1059 theme->a_disabled_focused_close->texture[0].type =
1060 theme->a_disabled_unfocused_close->texture[0].type =
1061 theme->a_hover_focused_close->texture[0].type =
1062 theme->a_hover_unfocused_close->texture[0].type =
1063 theme->a_focused_unpressed_close->texture[0].type =
1064 theme->a_focused_pressed_close->texture[0].type =
1065 theme->a_unfocused_unpressed_close->texture[0].type =
1066 theme->a_unfocused_pressed_close->texture[0].type =
1067 theme->a_disabled_focused_desk->texture[0].type =
1068 theme->a_disabled_unfocused_desk->texture[0].type =
1069 theme->a_hover_focused_desk->texture[0].type =
1070 theme->a_hover_unfocused_desk->texture[0].type =
1071 theme->a_toggled_hover_focused_desk->texture[0].type =
1072 theme->a_toggled_hover_unfocused_desk->texture[0].type =
1073 theme->a_toggled_focused_unpressed_desk->texture[0].type =
1074 theme->a_toggled_unfocused_unpressed_desk->texture[0].type =
1075 theme->a_toggled_focused_pressed_desk->texture[0].type =
1076 theme->a_toggled_unfocused_pressed_desk->texture[0].type =
1077 theme->a_focused_unpressed_desk->texture[0].type =
1078 theme->a_focused_pressed_desk->texture[0].type =
1079 theme->a_unfocused_unpressed_desk->texture[0].type =
1080 theme->a_unfocused_pressed_desk->texture[0].type =
1081 theme->a_disabled_focused_shade->texture[0].type =
1082 theme->a_disabled_unfocused_shade->texture[0].type =
1083 theme->a_hover_focused_shade->texture[0].type =
1084 theme->a_hover_unfocused_shade->texture[0].type =
1085 theme->a_toggled_hover_focused_shade->texture[0].type =
1086 theme->a_toggled_hover_unfocused_shade->texture[0].type =
1087 theme->a_toggled_focused_unpressed_shade->texture[0].type =
1088 theme->a_toggled_unfocused_unpressed_shade->texture[0].type =
1089 theme->a_toggled_focused_pressed_shade->texture[0].type =
1090 theme->a_toggled_unfocused_pressed_shade->texture[0].type =
1091 theme->a_focused_unpressed_shade->texture[0].type =
1092 theme->a_focused_pressed_shade->texture[0].type =
1093 theme->a_unfocused_unpressed_shade->texture[0].type =
1094 theme->a_unfocused_pressed_shade->texture[0].type =
1095 theme->a_disabled_focused_iconify->texture[0].type =
1096 theme->a_disabled_unfocused_iconify->texture[0].type =
1097 theme->a_hover_focused_iconify->texture[0].type =
1098 theme->a_hover_unfocused_iconify->texture[0].type =
1099 theme->a_focused_unpressed_iconify->texture[0].type =
1100 theme->a_focused_pressed_iconify->texture[0].type =
1101 theme->a_unfocused_unpressed_iconify->texture[0].type =
1102 theme->a_unfocused_pressed_iconify->texture[0].type =
1103 theme->a_menu_bullet_normal->texture[0].type =
1104 theme->a_menu_bullet_selected->texture[0].type = RR_TEXTURE_MASK;
1106 theme->a_disabled_focused_max->texture[0].data.mask.mask =
1107 theme->a_disabled_unfocused_max->texture[0].data.mask.mask =
1108 theme->max_disabled_mask;
1109 theme->a_hover_focused_max->texture[0].data.mask.mask =
1110 theme->a_hover_unfocused_max->texture[0].data.mask.mask =
1111 theme->max_hover_mask;
1112 theme->a_focused_pressed_max->texture[0].data.mask.mask =
1113 theme->a_unfocused_pressed_max->texture[0].data.mask.mask =
1114 theme->max_pressed_mask;
1115 theme->a_focused_unpressed_max->texture[0].data.mask.mask =
1116 theme->a_unfocused_unpressed_max->texture[0].data.mask.mask =
1118 theme->a_toggled_hover_focused_max->texture[0].data.mask.mask =
1119 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.mask =
1120 theme->max_toggled_hover_mask;
1121 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.mask =
1122 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.mask =
1123 theme->max_toggled_mask;
1124 theme->a_toggled_focused_pressed_max->texture[0].data.mask.mask =
1125 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.mask =
1126 theme->max_toggled_pressed_mask;
1127 theme->a_disabled_focused_close->texture[0].data.mask.mask =
1128 theme->a_disabled_unfocused_close->texture[0].data.mask.mask =
1129 theme->close_disabled_mask;
1130 theme->a_hover_focused_close->texture[0].data.mask.mask =
1131 theme->a_hover_unfocused_close->texture[0].data.mask.mask =
1132 theme->close_hover_mask;
1133 theme->a_focused_pressed_close->texture[0].data.mask.mask =
1134 theme->a_unfocused_pressed_close->texture[0].data.mask.mask =
1135 theme->close_pressed_mask;
1136 theme->a_focused_unpressed_close->texture[0].data.mask.mask =
1137 theme->a_unfocused_unpressed_close->texture[0].data.mask.mask =
1139 theme->a_disabled_focused_desk->texture[0].data.mask.mask =
1140 theme->a_disabled_unfocused_desk->texture[0].data.mask.mask =
1141 theme->desk_disabled_mask;
1142 theme->a_hover_focused_desk->texture[0].data.mask.mask =
1143 theme->a_hover_unfocused_desk->texture[0].data.mask.mask =
1144 theme->desk_hover_mask;
1145 theme->a_focused_pressed_desk->texture[0].data.mask.mask =
1146 theme->a_unfocused_pressed_desk->texture[0].data.mask.mask =
1147 theme->desk_pressed_mask;
1148 theme->a_focused_unpressed_desk->texture[0].data.mask.mask =
1149 theme->a_unfocused_unpressed_desk->texture[0].data.mask.mask =
1151 theme->a_toggled_hover_focused_desk->texture[0].data.mask.mask =
1152 theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.mask =
1153 theme->desk_toggled_hover_mask;
1154 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.mask =
1155 theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.mask =
1156 theme->desk_toggled_mask;
1157 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.mask =
1158 theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.mask =
1159 theme->desk_toggled_pressed_mask;
1160 theme->a_disabled_focused_shade->texture[0].data.mask.mask =
1161 theme->a_disabled_unfocused_shade->texture[0].data.mask.mask =
1162 theme->shade_disabled_mask;
1163 theme->a_hover_focused_shade->texture[0].data.mask.mask =
1164 theme->a_hover_unfocused_shade->texture[0].data.mask.mask =
1165 theme->shade_hover_mask;
1166 theme->a_focused_pressed_shade->texture[0].data.mask.mask =
1167 theme->a_unfocused_pressed_shade->texture[0].data.mask.mask =
1168 theme->shade_pressed_mask;
1169 theme->a_focused_unpressed_shade->texture[0].data.mask.mask =
1170 theme->a_unfocused_unpressed_shade->texture[0].data.mask.mask =
1172 theme->a_toggled_hover_focused_shade->texture[0].data.mask.mask =
1173 theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.mask =
1174 theme->shade_toggled_hover_mask;
1175 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.mask =
1176 theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.mask =
1177 theme->shade_toggled_mask;
1178 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.mask =
1179 theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.mask =
1180 theme->shade_toggled_pressed_mask;
1181 theme->a_disabled_focused_iconify->texture[0].data.mask.mask =
1182 theme->a_disabled_unfocused_iconify->texture[0].data.mask.mask =
1183 theme->iconify_disabled_mask;
1184 theme->a_hover_focused_iconify->texture[0].data.mask.mask =
1185 theme->a_hover_unfocused_iconify->texture[0].data.mask.mask =
1186 theme->iconify_hover_mask;
1187 theme->a_focused_pressed_iconify->texture[0].data.mask.mask =
1188 theme->a_unfocused_pressed_iconify->texture[0].data.mask.mask =
1189 theme->iconify_pressed_mask;
1190 theme->a_focused_unpressed_iconify->texture[0].data.mask.mask =
1191 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.mask =
1192 theme->iconify_mask;
1193 theme->a_menu_bullet_normal->texture[0].data.mask.mask =
1194 theme->a_menu_bullet_selected->texture[0].data.mask.mask =
1195 theme->menu_bullet_mask;
1196 theme->a_disabled_focused_max->texture[0].data.mask.color =
1197 theme->a_disabled_focused_close->texture[0].data.mask.color =
1198 theme->a_disabled_focused_desk->texture[0].data.mask.color =
1199 theme->a_disabled_focused_shade->texture[0].data.mask.color =
1200 theme->a_disabled_focused_iconify->texture[0].data.mask.color =
1201 theme->titlebut_disabled_focused_color;
1202 theme->a_disabled_unfocused_max->texture[0].data.mask.color =
1203 theme->a_disabled_unfocused_close->texture[0].data.mask.color =
1204 theme->a_disabled_unfocused_desk->texture[0].data.mask.color =
1205 theme->a_disabled_unfocused_shade->texture[0].data.mask.color =
1206 theme->a_disabled_unfocused_iconify->texture[0].data.mask.color =
1207 theme->titlebut_disabled_unfocused_color;
1208 theme->a_hover_focused_max->texture[0].data.mask.color =
1209 theme->a_hover_focused_close->texture[0].data.mask.color =
1210 theme->a_hover_focused_desk->texture[0].data.mask.color =
1211 theme->a_hover_focused_shade->texture[0].data.mask.color =
1212 theme->a_hover_focused_iconify->texture[0].data.mask.color =
1213 theme->titlebut_hover_focused_color;
1214 theme->a_hover_unfocused_max->texture[0].data.mask.color =
1215 theme->a_hover_unfocused_close->texture[0].data.mask.color =
1216 theme->a_hover_unfocused_desk->texture[0].data.mask.color =
1217 theme->a_hover_unfocused_shade->texture[0].data.mask.color =
1218 theme->a_hover_unfocused_iconify->texture[0].data.mask.color =
1219 theme->titlebut_hover_unfocused_color;
1220 theme->a_toggled_hover_focused_max->texture[0].data.mask.color =
1221 theme->a_toggled_hover_focused_desk->texture[0].data.mask.color =
1222 theme->a_toggled_hover_focused_shade->texture[0].data.mask.color =
1223 theme->titlebut_toggled_hover_focused_color;
1224 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.color =
1225 theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.color =
1226 theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.color =
1227 theme->titlebut_toggled_hover_unfocused_color;
1228 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.color =
1229 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.color =
1230 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.color =
1231 theme->titlebut_toggled_focused_unpressed_color;
1232 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.color =
1233 theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.color =
1234 theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.color=
1235 theme->titlebut_toggled_unfocused_unpressed_color;
1236 theme->a_toggled_focused_pressed_max->texture[0].data.mask.color =
1237 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.color =
1238 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.color =
1239 theme->titlebut_toggled_focused_pressed_color;
1240 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.color =
1241 theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.color =
1242 theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.color =
1243 theme->titlebut_toggled_unfocused_pressed_color;
1244 theme->a_focused_unpressed_max->texture[0].data.mask.color =
1245 theme->a_focused_unpressed_close->texture[0].data.mask.color =
1246 theme->a_focused_unpressed_desk->texture[0].data.mask.color =
1247 theme->a_focused_unpressed_shade->texture[0].data.mask.color =
1248 theme->a_focused_unpressed_iconify->texture[0].data.mask.color =
1249 theme->titlebut_focused_unpressed_color;
1250 theme->a_focused_pressed_max->texture[0].data.mask.color =
1251 theme->a_focused_pressed_close->texture[0].data.mask.color =
1252 theme->a_focused_pressed_desk->texture[0].data.mask.color =
1253 theme->a_focused_pressed_shade->texture[0].data.mask.color =
1254 theme->a_focused_pressed_iconify->texture[0].data.mask.color =
1255 theme->titlebut_focused_pressed_color;
1256 theme->a_unfocused_unpressed_max->texture[0].data.mask.color =
1257 theme->a_unfocused_unpressed_close->texture[0].data.mask.color =
1258 theme->a_unfocused_unpressed_desk->texture[0].data.mask.color =
1259 theme->a_unfocused_unpressed_shade->texture[0].data.mask.color =
1260 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.color =
1261 theme->titlebut_unfocused_unpressed_color;
1262 theme->a_unfocused_pressed_max->texture[0].data.mask.color =
1263 theme->a_unfocused_pressed_close->texture[0].data.mask.color =
1264 theme->a_unfocused_pressed_desk->texture[0].data.mask.color =
1265 theme->a_unfocused_pressed_shade->texture[0].data.mask.color =
1266 theme->a_unfocused_pressed_iconify->texture[0].data.mask.color =
1267 theme->titlebut_unfocused_pressed_color;
1268 theme->a_menu_bullet_normal->texture[0].data.mask.color =
1270 theme->a_menu_bullet_selected->texture[0].data.mask.color =
1271 theme->menu_selected_color;
1274 XrmDestroyDatabase(db);
1276 /* set the font heights */
1277 theme->win_font_height = RrFontHeight
1278 (theme->win_font_focused,
1279 theme->a_focused_label->texture[0].data.text.shadow_offset_y);
1280 theme->win_font_height =
1281 MAX(theme->win_font_height,
1283 (theme->win_font_focused,
1284 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y));
1285 theme->menu_title_font_height = RrFontHeight
1286 (theme->menu_title_font,
1287 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y);
1288 theme->menu_font_height = RrFontHeight
1290 theme->a_menu_text_normal->texture[0].data.text.shadow_offset_y);
1292 /* calculate some last extents */
1294 gint ft, fb, fl, fr, ut, ub, ul, ur;
1296 RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb);
1297 RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub);
1298 theme->label_height = theme->win_font_height + MAX(ft + fb, ut + ub);
1299 theme->label_height += theme->label_height % 2;
1301 /* this would be nice I think, since padding.width can now be 0,
1302 but it breaks frame.c horribly and I don't feel like fixing that
1303 right now, so if anyone complains, here is how to keep text from
1304 going over the title's bevel/border with a padding.width of 0 and a
1305 bevelless/borderless label
1306 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1307 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1308 theme->title_height = theme->label_height +
1309 MAX(MAX(theme->padding * 2, ft + fb),
1310 MAX(theme->padding * 2, ut + ub));
1312 theme->title_height = theme->label_height + theme->paddingy * 2;
1314 RrMargins(theme->a_menu_title, &ul, &ut, &ur, &ub);
1315 theme->menu_title_label_height = theme->menu_title_font_height+ut+ub;
1316 theme->menu_title_height = theme->menu_title_label_height +
1317 theme->paddingy * 2;
1319 theme->button_size = theme->label_height - 2;
1320 theme->grip_width = 25;
1322 RrAppearanceFree(a_disabled_focused_tmp);
1323 RrAppearanceFree(a_disabled_unfocused_tmp);
1324 RrAppearanceFree(a_hover_focused_tmp);
1325 RrAppearanceFree(a_hover_unfocused_tmp);
1326 RrAppearanceFree(a_focused_unpressed_tmp);
1327 RrAppearanceFree(a_focused_pressed_tmp);
1328 RrAppearanceFree(a_unfocused_unpressed_tmp);
1329 RrAppearanceFree(a_unfocused_pressed_tmp);
1330 RrAppearanceFree(a_toggled_hover_focused_tmp);
1331 RrAppearanceFree(a_toggled_hover_unfocused_tmp);
1332 RrAppearanceFree(a_toggled_focused_unpressed_tmp);
1333 RrAppearanceFree(a_toggled_focused_pressed_tmp);
1334 RrAppearanceFree(a_toggled_unfocused_unpressed_tmp);
1335 RrAppearanceFree(a_toggled_unfocused_pressed_tmp);
1340 void RrThemeFree(RrTheme *theme)
1343 g_free(theme->name);
1345 RrColorFree(theme->menu_border_color);
1346 RrColorFree(theme->osd_border_color);
1347 RrColorFree(theme->frame_focused_border_color);
1348 RrColorFree(theme->frame_unfocused_border_color);
1349 RrColorFree(theme->title_separator_focused_color);
1350 RrColorFree(theme->title_separator_unfocused_color);
1351 RrColorFree(theme->cb_unfocused_color);
1352 RrColorFree(theme->cb_focused_color);
1353 RrColorFree(theme->title_focused_color);
1354 RrColorFree(theme->title_unfocused_color);
1355 RrColorFree(theme->titlebut_disabled_focused_color);
1356 RrColorFree(theme->titlebut_disabled_unfocused_color);
1357 RrColorFree(theme->titlebut_hover_focused_color);
1358 RrColorFree(theme->titlebut_hover_unfocused_color);
1359 RrColorFree(theme->titlebut_toggled_hover_focused_color);
1360 RrColorFree(theme->titlebut_toggled_hover_unfocused_color);
1361 RrColorFree(theme->titlebut_toggled_focused_pressed_color);
1362 RrColorFree(theme->titlebut_toggled_unfocused_pressed_color);
1363 RrColorFree(theme->titlebut_toggled_focused_unpressed_color);
1364 RrColorFree(theme->titlebut_toggled_unfocused_unpressed_color);
1365 RrColorFree(theme->titlebut_focused_pressed_color);
1366 RrColorFree(theme->titlebut_unfocused_pressed_color);
1367 RrColorFree(theme->titlebut_focused_unpressed_color);
1368 RrColorFree(theme->titlebut_unfocused_unpressed_color);
1369 RrColorFree(theme->menu_title_color);
1370 RrColorFree(theme->menu_sep_color);
1371 RrColorFree(theme->menu_color);
1372 RrColorFree(theme->menu_selected_color);
1373 RrColorFree(theme->menu_disabled_color);
1374 RrColorFree(theme->menu_disabled_selected_color);
1375 RrColorFree(theme->title_focused_shadow_color);
1376 RrColorFree(theme->title_unfocused_shadow_color);
1377 RrColorFree(theme->osd_text_active_color);
1378 RrColorFree(theme->osd_text_inactive_color);
1379 RrColorFree(theme->osd_text_active_shadow_color);
1380 RrColorFree(theme->osd_text_inactive_shadow_color);
1381 RrColorFree(theme->menu_title_shadow_color);
1382 RrColorFree(theme->menu_text_normal_shadow_color);
1383 RrColorFree(theme->menu_text_selected_shadow_color);
1384 RrColorFree(theme->menu_text_disabled_shadow_color);
1385 RrColorFree(theme->menu_text_disabled_selected_shadow_color);
1387 g_free(theme->def_win_icon);
1389 RrPixmapMaskFree(theme->max_mask);
1390 RrPixmapMaskFree(theme->max_toggled_mask);
1391 RrPixmapMaskFree(theme->max_toggled_hover_mask);
1392 RrPixmapMaskFree(theme->max_toggled_pressed_mask);
1393 RrPixmapMaskFree(theme->max_disabled_mask);
1394 RrPixmapMaskFree(theme->max_hover_mask);
1395 RrPixmapMaskFree(theme->max_pressed_mask);
1396 RrPixmapMaskFree(theme->desk_mask);
1397 RrPixmapMaskFree(theme->desk_toggled_mask);
1398 RrPixmapMaskFree(theme->desk_toggled_hover_mask);
1399 RrPixmapMaskFree(theme->desk_toggled_pressed_mask);
1400 RrPixmapMaskFree(theme->desk_disabled_mask);
1401 RrPixmapMaskFree(theme->desk_hover_mask);
1402 RrPixmapMaskFree(theme->desk_pressed_mask);
1403 RrPixmapMaskFree(theme->shade_mask);
1404 RrPixmapMaskFree(theme->shade_toggled_mask);
1405 RrPixmapMaskFree(theme->shade_toggled_hover_mask);
1406 RrPixmapMaskFree(theme->shade_toggled_pressed_mask);
1407 RrPixmapMaskFree(theme->shade_disabled_mask);
1408 RrPixmapMaskFree(theme->shade_hover_mask);
1409 RrPixmapMaskFree(theme->shade_pressed_mask);
1410 RrPixmapMaskFree(theme->iconify_mask);
1411 RrPixmapMaskFree(theme->iconify_disabled_mask);
1412 RrPixmapMaskFree(theme->iconify_hover_mask);
1413 RrPixmapMaskFree(theme->iconify_pressed_mask);
1414 RrPixmapMaskFree(theme->close_mask);
1415 RrPixmapMaskFree(theme->close_disabled_mask);
1416 RrPixmapMaskFree(theme->close_hover_mask);
1417 RrPixmapMaskFree(theme->close_pressed_mask);
1418 RrPixmapMaskFree(theme->menu_bullet_mask);
1419 RrPixmapMaskFree(theme->down_arrow_mask);
1420 RrPixmapMaskFree(theme->up_arrow_mask);
1422 RrFontClose(theme->win_font_focused);
1423 RrFontClose(theme->win_font_unfocused);
1424 RrFontClose(theme->menu_title_font);
1425 RrFontClose(theme->menu_font);
1426 RrFontClose(theme->osd_font_hilite);
1427 RrFontClose(theme->osd_font_unhilite);
1429 RrAppearanceFree(theme->a_disabled_focused_max);
1430 RrAppearanceFree(theme->a_disabled_unfocused_max);
1431 RrAppearanceFree(theme->a_hover_focused_max);
1432 RrAppearanceFree(theme->a_hover_unfocused_max);
1433 RrAppearanceFree(theme->a_toggled_hover_focused_max);
1434 RrAppearanceFree(theme->a_toggled_hover_unfocused_max);
1435 RrAppearanceFree(theme->a_toggled_focused_unpressed_max);
1436 RrAppearanceFree(theme->a_toggled_focused_pressed_max);
1437 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_max);
1438 RrAppearanceFree(theme->a_toggled_unfocused_pressed_max);
1439 RrAppearanceFree(theme->a_focused_unpressed_max);
1440 RrAppearanceFree(theme->a_focused_pressed_max);
1441 RrAppearanceFree(theme->a_unfocused_unpressed_max);
1442 RrAppearanceFree(theme->a_unfocused_pressed_max);
1443 RrAppearanceFree(theme->a_disabled_focused_close);
1444 RrAppearanceFree(theme->a_disabled_unfocused_close);
1445 RrAppearanceFree(theme->a_hover_focused_close);
1446 RrAppearanceFree(theme->a_hover_unfocused_close);
1447 RrAppearanceFree(theme->a_focused_unpressed_close);
1448 RrAppearanceFree(theme->a_focused_pressed_close);
1449 RrAppearanceFree(theme->a_unfocused_unpressed_close);
1450 RrAppearanceFree(theme->a_unfocused_pressed_close);
1451 RrAppearanceFree(theme->a_disabled_focused_desk);
1452 RrAppearanceFree(theme->a_disabled_unfocused_desk);
1453 RrAppearanceFree(theme->a_hover_focused_desk);
1454 RrAppearanceFree(theme->a_hover_unfocused_desk);
1455 RrAppearanceFree(theme->a_toggled_hover_focused_desk);
1456 RrAppearanceFree(theme->a_toggled_hover_unfocused_desk);
1457 RrAppearanceFree(theme->a_toggled_focused_unpressed_desk);
1458 RrAppearanceFree(theme->a_toggled_focused_pressed_desk);
1459 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_desk);
1460 RrAppearanceFree(theme->a_toggled_unfocused_pressed_desk);
1461 RrAppearanceFree(theme->a_focused_unpressed_desk);
1462 RrAppearanceFree(theme->a_focused_pressed_desk);
1463 RrAppearanceFree(theme->a_unfocused_unpressed_desk);
1464 RrAppearanceFree(theme->a_unfocused_pressed_desk);
1465 RrAppearanceFree(theme->a_disabled_focused_shade);
1466 RrAppearanceFree(theme->a_disabled_unfocused_shade);
1467 RrAppearanceFree(theme->a_hover_focused_shade);
1468 RrAppearanceFree(theme->a_hover_unfocused_shade);
1469 RrAppearanceFree(theme->a_toggled_hover_focused_shade);
1470 RrAppearanceFree(theme->a_toggled_hover_unfocused_shade);
1471 RrAppearanceFree(theme->a_toggled_focused_unpressed_shade);
1472 RrAppearanceFree(theme->a_toggled_focused_pressed_shade);
1473 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_shade);
1474 RrAppearanceFree(theme->a_toggled_unfocused_pressed_shade);
1475 RrAppearanceFree(theme->a_focused_unpressed_shade);
1476 RrAppearanceFree(theme->a_focused_pressed_shade);
1477 RrAppearanceFree(theme->a_unfocused_unpressed_shade);
1478 RrAppearanceFree(theme->a_unfocused_pressed_shade);
1479 RrAppearanceFree(theme->a_disabled_focused_iconify);
1480 RrAppearanceFree(theme->a_disabled_unfocused_iconify);
1481 RrAppearanceFree(theme->a_hover_focused_iconify);
1482 RrAppearanceFree(theme->a_hover_unfocused_iconify);
1483 RrAppearanceFree(theme->a_focused_unpressed_iconify);
1484 RrAppearanceFree(theme->a_focused_pressed_iconify);
1485 RrAppearanceFree(theme->a_unfocused_unpressed_iconify);
1486 RrAppearanceFree(theme->a_unfocused_pressed_iconify);
1487 RrAppearanceFree(theme->a_focused_grip);
1488 RrAppearanceFree(theme->a_unfocused_grip);
1489 RrAppearanceFree(theme->a_focused_title);
1490 RrAppearanceFree(theme->a_unfocused_title);
1491 RrAppearanceFree(theme->a_focused_label);
1492 RrAppearanceFree(theme->a_unfocused_label);
1493 RrAppearanceFree(theme->a_icon);
1494 RrAppearanceFree(theme->a_focused_handle);
1495 RrAppearanceFree(theme->a_unfocused_handle);
1496 RrAppearanceFree(theme->a_menu);
1497 RrAppearanceFree(theme->a_menu_title);
1498 RrAppearanceFree(theme->a_menu_text_title);
1499 RrAppearanceFree(theme->a_menu_normal);
1500 RrAppearanceFree(theme->a_menu_selected);
1501 RrAppearanceFree(theme->a_menu_disabled);
1502 RrAppearanceFree(theme->a_menu_disabled_selected);
1503 RrAppearanceFree(theme->a_menu_text_normal);
1504 RrAppearanceFree(theme->a_menu_text_selected);
1505 RrAppearanceFree(theme->a_menu_text_disabled);
1506 RrAppearanceFree(theme->a_menu_text_disabled_selected);
1507 RrAppearanceFree(theme->a_menu_bullet_normal);
1508 RrAppearanceFree(theme->a_menu_bullet_selected);
1509 RrAppearanceFree(theme->a_clear);
1510 RrAppearanceFree(theme->a_clear_tex);
1511 RrAppearanceFree(theme->osd_bg);
1512 RrAppearanceFree(theme->osd_hilite_bg);
1513 RrAppearanceFree(theme->osd_hilite_label);
1514 RrAppearanceFree(theme->osd_unhilite_bg);
1515 RrAppearanceFree(theme->osd_unhilite_label);
1517 g_slice_free(RrTheme, theme);
1521 static XrmDatabase loaddb(const gchar *name, gchar **path)
1524 XrmDatabase db = NULL;
1527 if (name[0] == '/') {
1528 s = g_build_filename(name, "openbox-3", "themerc", NULL);
1529 if ((db = XrmGetFileDatabase(s)))
1530 *path = g_path_get_dirname(s);
1535 p = obt_paths_new();
1537 /* XXX backwards compatibility, remove me sometime later */
1538 s = g_build_filename(g_get_home_dir(), ".themes", name,
1539 "openbox-3", "themerc", NULL);
1540 if ((db = XrmGetFileDatabase(s)))
1541 *path = g_path_get_dirname(s);
1544 for (it = obt_paths_data_dirs(p); !db && it; it = g_slist_next(it))
1546 s = g_build_filename(it->data, "themes", name,
1547 "openbox-3", "themerc", NULL);
1548 if ((db = XrmGetFileDatabase(s)))
1549 *path = g_path_get_dirname(s);
1557 s = g_build_filename(name, "themerc", NULL);
1558 if ((db = XrmGetFileDatabase(s)))
1559 *path = g_path_get_dirname(s);
1566 static gchar *create_class_name(const gchar *rname)
1568 gchar *rclass = g_strdup(rname);
1573 p = strchr(p+1, '.');
1574 if (p == NULL) break;
1576 if (*p == '\0') break;
1581 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value)
1583 gboolean ret = FALSE;
1584 gchar *rclass = create_class_name(rname);
1585 gchar *rettype, *end;
1588 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1589 retvalue.addr != NULL) {
1590 *value = (gint)strtol(retvalue.addr, &end, 10);
1591 if (end != retvalue.addr)
1599 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value)
1601 gboolean ret = FALSE;
1602 gchar *rclass = create_class_name(rname);
1606 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1607 retvalue.addr != NULL) {
1608 *value = retvalue.addr;
1616 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
1617 const gchar *rname, RrColor **value)
1619 gboolean ret = FALSE;
1620 gchar *rclass = create_class_name(rname);
1624 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1625 retvalue.addr != NULL) {
1626 RrColor *c = RrColorParse(inst, retvalue.addr);
1637 static gboolean read_mask(const RrInstance *inst, const gchar *path,
1638 RrTheme *theme, const gchar *maskname,
1639 RrPixmapMask **value)
1641 gboolean ret = FALSE;
1643 gint hx, hy; /* ignored */
1647 s = g_build_filename(path, maskname, NULL);
1648 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
1650 *value = RrPixmapMaskNew(inst, w, h, (gchar*)b);
1658 static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
1659 RrReliefType *relief, RrBevelType *bevel,
1660 gboolean *interlaced, gboolean *border,
1661 gboolean allow_trans)
1665 /* convert to all lowercase */
1666 for (t = tex; *t != '\0'; ++t)
1667 *t = g_ascii_tolower(*t);
1669 if (allow_trans && strstr(tex, "parentrelative") != NULL) {
1670 *grad = RR_SURFACE_PARENTREL;
1672 if (strstr(tex, "gradient") != NULL) {
1673 if (strstr(tex, "crossdiagonal") != NULL)
1674 *grad = RR_SURFACE_CROSS_DIAGONAL;
1675 else if (strstr(tex, "pyramid") != NULL)
1676 *grad = RR_SURFACE_PYRAMID;
1677 else if (strstr(tex, "mirrorhorizontal") != NULL)
1678 *grad = RR_SURFACE_MIRROR_HORIZONTAL;
1679 else if (strstr(tex, "horizontal") != NULL)
1680 *grad = RR_SURFACE_HORIZONTAL;
1681 else if (strstr(tex, "splitvertical") != NULL)
1682 *grad = RR_SURFACE_SPLIT_VERTICAL;
1683 else if (strstr(tex, "vertical") != NULL)
1684 *grad = RR_SURFACE_VERTICAL;
1686 *grad = RR_SURFACE_DIAGONAL;
1688 *grad = RR_SURFACE_SOLID;
1692 if (strstr(tex, "sunken") != NULL)
1693 *relief = RR_RELIEF_SUNKEN;
1694 else if (strstr(tex, "flat") != NULL)
1695 *relief = RR_RELIEF_FLAT;
1696 else if (strstr(tex, "raised") != NULL)
1697 *relief = RR_RELIEF_RAISED;
1699 *relief = (*grad == RR_SURFACE_PARENTREL) ?
1700 RR_RELIEF_FLAT : RR_RELIEF_RAISED;
1703 if (*relief == RR_RELIEF_FLAT) {
1704 if (strstr(tex, "border") != NULL)
1707 if (strstr(tex, "bevel2") != NULL)
1708 *bevel = RR_BEVEL_2;
1710 *bevel = RR_BEVEL_1;
1713 if (strstr(tex, "interlaced") != NULL)
1716 *interlaced = FALSE;
1719 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
1720 const gchar *rname, RrAppearance *value,
1721 gboolean allow_trans)
1723 gboolean ret = FALSE;
1724 gchar *rclass = create_class_name(rname);
1725 gchar *cname, *ctoname, *bcname, *icname, *hname, *sname;
1726 gchar *csplitname, *ctosplitname;
1731 cname = g_strconcat(rname, ".color", NULL);
1732 ctoname = g_strconcat(rname, ".colorTo", NULL);
1733 bcname = g_strconcat(rname, ".border.color", NULL);
1734 icname = g_strconcat(rname, ".interlace.color", NULL);
1735 hname = g_strconcat(rname, ".highlight", NULL);
1736 sname = g_strconcat(rname, ".shadow", NULL);
1737 csplitname = g_strconcat(rname, ".color.splitTo", NULL);
1738 ctosplitname = g_strconcat(rname, ".colorTo.splitTo", NULL);
1740 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1741 retvalue.addr != NULL) {
1742 parse_appearance(retvalue.addr,
1743 &value->surface.grad,
1744 &value->surface.relief,
1745 &value->surface.bevel,
1746 &value->surface.interlaced,
1747 &value->surface.border,
1749 if (!read_color(db, inst, cname, &value->surface.primary))
1750 value->surface.primary = RrColorNew(inst, 0, 0, 0);
1751 if (!read_color(db, inst, ctoname, &value->surface.secondary))
1752 value->surface.secondary = RrColorNew(inst, 0, 0, 0);
1753 if (value->surface.border)
1754 if (!read_color(db, inst, bcname,
1755 &value->surface.border_color))
1756 value->surface.border_color = RrColorNew(inst, 0, 0, 0);
1757 if (value->surface.interlaced)
1758 if (!read_color(db, inst, icname,
1759 &value->surface.interlace_color))
1760 value->surface.interlace_color = RrColorNew(inst, 0, 0, 0);
1761 if (read_int(db, hname, &i) && i >= 0)
1762 value->surface.bevel_light_adjust = i;
1763 if (read_int(db, sname, &i) && i >= 0 && i <= 256)
1764 value->surface.bevel_dark_adjust = i;
1766 if (value->surface.grad == RR_SURFACE_SPLIT_VERTICAL) {
1769 if (!read_color(db, inst, csplitname,
1770 &value->surface.split_primary))
1772 r = value->surface.primary->r;
1774 g = value->surface.primary->g;
1776 b = value->surface.primary->b;
1778 if (r > 0xFF) r = 0xFF;
1779 if (g > 0xFF) g = 0xFF;
1780 if (b > 0xFF) b = 0xFF;
1781 value->surface.split_primary = RrColorNew(inst, r, g, b);
1784 if (!read_color(db, inst, ctosplitname,
1785 &value->surface.split_secondary))
1787 r = value->surface.secondary->r;
1789 g = value->surface.secondary->g;
1791 b = value->surface.secondary->b;
1793 if (r > 0xFF) r = 0xFF;
1794 if (g > 0xFF) g = 0xFF;
1795 if (b > 0xFF) b = 0xFF;
1796 value->surface.split_secondary = RrColorNew(inst, r, g, b);
1803 g_free(ctosplitname);
1815 static int parse_inline_number(const char *p)
1823 for (; isdigit(*p); ++p)
1824 res = res * 10 + *p - '0';
1829 static void set_default_appearance(RrAppearance *a)
1831 a->surface.grad = RR_SURFACE_SOLID;
1832 a->surface.relief = RR_RELIEF_FLAT;
1833 a->surface.bevel = RR_BEVEL_1;
1834 a->surface.interlaced = FALSE;
1835 a->surface.border = FALSE;
1836 a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
1837 a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
1840 /* Reads the output from gimp's C-Source file format into valid RGBA data for
1841 an RrTextureRGBA. */
1842 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data)
1847 p = im = g_memdup(data, width * height * sizeof(RrPixel32));
1849 for (i = 0; i < width * height; ++i) {
1850 guchar a = ((*p >> 24) & 0xff);
1851 guchar b = ((*p >> 16) & 0xff);
1852 guchar g = ((*p >> 8) & 0xff);
1853 guchar r = ((*p >> 0) & 0xff);
1855 *p = ((r << RrDefaultRedOffset) +
1856 (g << RrDefaultGreenOffset) +
1857 (b << RrDefaultBlueOffset) +
1858 (a << RrDefaultAlphaOffset));