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(RrTheme *theme, 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 const gchar *maskname, RrTheme *theme,
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 RrTheme* RrThemeNew(const RrInstance *inst, gchar *name,
50 RrFont *active_window_font, RrFont *inactive_window_font,
51 RrFont *menu_title_font, RrFont *menu_item_font,
54 XrmDatabase db = NULL;
55 RrJustify winjust, mtitlejust;
60 theme = g_new0(RrTheme, 1);
64 theme->a_disabled_focused_max = RrAppearanceNew(inst, 1);
65 theme->a_disabled_unfocused_max = RrAppearanceNew(inst, 1);
66 theme->a_hover_focused_max = RrAppearanceNew(inst, 1);
67 theme->a_hover_unfocused_max = RrAppearanceNew(inst, 1);
68 theme->a_toggled_focused_max = RrAppearanceNew(inst, 1);
69 theme->a_toggled_unfocused_max = RrAppearanceNew(inst, 1);
70 theme->a_focused_unpressed_max = RrAppearanceNew(inst, 1);
71 theme->a_focused_pressed_max = RrAppearanceNew(inst, 1);
72 theme->a_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
73 theme->a_unfocused_pressed_max = RrAppearanceNew(inst, 1);
74 theme->a_focused_grip = RrAppearanceNew(inst, 0);
75 theme->a_unfocused_grip = RrAppearanceNew(inst, 0);
76 theme->a_focused_title = RrAppearanceNew(inst, 0);
77 theme->a_unfocused_title = RrAppearanceNew(inst, 0);
78 theme->a_focused_label = RrAppearanceNew(inst, 1);
79 theme->a_unfocused_label = RrAppearanceNew(inst, 1);
80 theme->a_icon = RrAppearanceNew(inst, 1);
81 theme->a_focused_handle = RrAppearanceNew(inst, 0);
82 theme->a_unfocused_handle = RrAppearanceNew(inst, 0);
83 theme->a_menu = RrAppearanceNew(inst, 0);
84 theme->a_menu_title = RrAppearanceNew(inst, 0);
85 theme->a_menu_text_title = RrAppearanceNew(inst, 1);
86 theme->a_menu_normal = RrAppearanceNew(inst, 0);
87 theme->a_menu_selected = RrAppearanceNew(inst, 0);
88 theme->a_menu_disabled = RrAppearanceNew(inst, 0);
89 theme->a_menu_disabled_selected = RrAppearanceNew(inst, 0);
90 theme->a_menu_text_normal = RrAppearanceNew(inst, 1);
91 theme->a_menu_text_selected = RrAppearanceNew(inst, 1);
92 theme->a_menu_text_disabled = RrAppearanceNew(inst, 1);
93 theme->a_menu_text_disabled_selected = RrAppearanceNew(inst, 1);
94 theme->a_menu_bullet_normal = RrAppearanceNew(inst, 1);
95 theme->a_menu_bullet_selected = RrAppearanceNew(inst, 1);
96 theme->a_clear = RrAppearanceNew(inst, 0);
97 theme->a_clear_tex = RrAppearanceNew(inst, 1);
100 db = loaddb(theme, name, &path);
102 g_message("Unable to load the theme '%s'", name);
103 g_message("Falling back to the default theme '%s'",
108 db = loaddb(theme, DEFAULT_THEME, &path);
110 g_message("Unable to load the theme '%s'", DEFAULT_THEME);
115 /* load the font stuff */
116 if (active_window_font) {
117 theme->win_font_focused = active_window_font;
118 RrFontRef(active_window_font);
120 theme->win_font_focused = RrFontOpenDefault(inst);
122 if (inactive_window_font) {
123 theme->win_font_unfocused = inactive_window_font;
124 RrFontRef(inactive_window_font);
126 theme->win_font_unfocused = RrFontOpenDefault(inst);
128 winjust = RR_JUSTIFY_LEFT;
129 if (read_string(db, "window.label.text.justify", &str)) {
130 if (!g_ascii_strcasecmp(str, "right"))
131 winjust = RR_JUSTIFY_RIGHT;
132 else if (!g_ascii_strcasecmp(str, "center"))
133 winjust = RR_JUSTIFY_CENTER;
136 if (menu_title_font) {
137 theme->menu_title_font = menu_title_font;
138 RrFontRef(menu_title_font);
140 theme->menu_title_font = RrFontOpenDefault(inst);
142 mtitlejust = RR_JUSTIFY_LEFT;
143 if (read_string(db, "menu.title.text.justify", &str)) {
144 if (!g_ascii_strcasecmp(str, "right"))
145 mtitlejust = RR_JUSTIFY_RIGHT;
146 else if (!g_ascii_strcasecmp(str, "center"))
147 mtitlejust = RR_JUSTIFY_CENTER;
150 if (menu_item_font) {
151 theme->menu_font = menu_item_font;
152 RrFontRef(menu_item_font);
154 theme->menu_font = RrFontOpenDefault(inst);
157 theme->osd_font = osd_font;
160 theme->osd_font = RrFontOpenDefault(inst);
162 /* load direct dimensions */
163 if (!read_int(db, "menu.overlap", &theme->menu_overlap) ||
164 theme->menu_overlap < 0 || theme->menu_overlap > 20)
165 theme->menu_overlap = 0;
166 if (!read_int(db, "window.handle.width", &theme->handle_height) ||
167 theme->handle_height < 0 || theme->handle_height > 100)
168 theme->handle_height = 6;
169 if (!read_int(db, "padding.width", &theme->paddingx) ||
170 theme->paddingx < 0 || theme->paddingx > 100)
172 theme->paddingy = theme->paddingx;
173 if (!read_int(db, "border.width", &theme->fbwidth) ||
174 theme->fbwidth < 0 || theme->fbwidth > 100)
176 theme->mbwidth = theme->fbwidth;
177 if (!read_int(db, "window.client.padding.width", &theme->cbwidthx) ||
178 theme->cbwidthx < 0 || theme->cbwidthx > 100)
179 theme->cbwidthx = theme->paddingx;
180 theme->cbwidthy = theme->cbwidthx;
183 if (!read_color(db, inst,
184 "border.color", &theme->frame_b_color))
185 theme->frame_b_color = RrColorNew(inst, 0, 0, 0);
186 theme->menu_b_color = RrColorNew(inst,
187 theme->frame_b_color->r,
188 theme->frame_b_color->g,
189 theme->frame_b_color->b);
190 if (!read_color(db, inst,
191 "window.active.client.color",
192 &theme->cb_focused_color))
193 theme->cb_focused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
194 if (!read_color(db, inst,
195 "window.inactive.client.color",
196 &theme->cb_unfocused_color))
197 theme->cb_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
198 if (!read_color(db, inst,
199 "window.active.label.text.color",
200 &theme->title_focused_color))
201 theme->title_focused_color = RrColorNew(inst, 0x0, 0x0, 0x0);
202 theme->osd_color = RrColorNew(inst,
203 theme->title_focused_color->r,
204 theme->title_focused_color->g,
205 theme->title_focused_color->b);
206 if (!read_color(db, inst,
207 "window.inactive.label.text.color",
208 &theme->title_unfocused_color))
209 theme->title_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
210 if (!read_color(db, inst,
211 "window.active.button.unpressed.image.color",
212 &theme->titlebut_focused_unpressed_color))
213 theme->titlebut_focused_unpressed_color = RrColorNew(inst, 0, 0, 0);
214 if (!read_color(db, inst,
215 "window.inactive.button.unpressed.image.color",
216 &theme->titlebut_unfocused_unpressed_color))
217 theme->titlebut_unfocused_unpressed_color =
218 RrColorNew(inst, 0xff, 0xff, 0xff);
219 if (!read_color(db, inst,
220 "window.active.button.pressed.image.color",
221 &theme->titlebut_focused_pressed_color))
222 theme->titlebut_focused_pressed_color =
224 theme->titlebut_focused_unpressed_color->r,
225 theme->titlebut_focused_unpressed_color->g,
226 theme->titlebut_focused_unpressed_color->b);
227 if (!read_color(db, inst,
228 "window.inactive.button.pressed.image.color",
229 &theme->titlebut_unfocused_pressed_color))
230 theme->titlebut_unfocused_pressed_color =
232 theme->titlebut_unfocused_unpressed_color->r,
233 theme->titlebut_unfocused_unpressed_color->g,
234 theme->titlebut_unfocused_unpressed_color->b);
235 if (!read_color(db, inst,
236 "window.active.button.disabled.image.color",
237 &theme->titlebut_disabled_focused_color))
238 theme->titlebut_disabled_focused_color =
239 RrColorNew(inst, 0xff, 0xff, 0xff);
240 if (!read_color(db, inst,
241 "window.inactive.button.disabled.image.color",
242 &theme->titlebut_disabled_unfocused_color))
243 theme->titlebut_disabled_unfocused_color = RrColorNew(inst, 0, 0, 0);
244 if (!read_color(db, inst,
245 "window.active.button.hover.image.color",
246 &theme->titlebut_hover_focused_color))
247 theme->titlebut_hover_focused_color =
249 theme->titlebut_focused_unpressed_color->r,
250 theme->titlebut_focused_unpressed_color->g,
251 theme->titlebut_focused_unpressed_color->b);
252 if (!read_color(db, inst,
253 "window.inactive.button.hover.image.color",
254 &theme->titlebut_hover_unfocused_color))
255 theme->titlebut_hover_unfocused_color =
257 theme->titlebut_unfocused_unpressed_color->r,
258 theme->titlebut_unfocused_unpressed_color->g,
259 theme->titlebut_unfocused_unpressed_color->b);
260 if (!read_color(db, inst,
261 "window.active.button.toggled.image.color",
262 &theme->titlebut_toggled_focused_color))
263 theme->titlebut_toggled_focused_color =
265 theme->titlebut_focused_pressed_color->r,
266 theme->titlebut_focused_pressed_color->g,
267 theme->titlebut_focused_pressed_color->b);
268 if (!read_color(db, inst,
269 "window.inactive.button.toggled.image.color",
270 &theme->titlebut_toggled_unfocused_color))
271 theme->titlebut_toggled_unfocused_color =
273 theme->titlebut_unfocused_pressed_color->r,
274 theme->titlebut_unfocused_pressed_color->g,
275 theme->titlebut_unfocused_pressed_color->b);
276 if (!read_color(db, inst,
277 "menu.title.text.color", &theme->menu_title_color))
278 theme->menu_title_color = RrColorNew(inst, 0, 0, 0);
279 if (!read_color(db, inst,
280 "menu.items.text.color", &theme->menu_color))
281 theme->menu_color = RrColorNew(inst, 0xff, 0xff, 0xff);
282 if (!read_color(db, inst,
283 "menu.items.disabled.text.color",
284 &theme->menu_disabled_color))
285 theme->menu_disabled_color = RrColorNew(inst, 0, 0, 0);
286 if (!read_color(db, inst,
287 "menu.items.activedisabled.text.color",
288 &theme->menu_disabled_selected_color))
289 theme->menu_disabled_selected_color =
291 theme->menu_disabled_color->r,
292 theme->menu_disabled_color->g,
293 theme->menu_disabled_color->b);
294 if (!read_color(db, inst,
295 "menu.items.active.text.color",
296 &theme->menu_selected_color))
297 theme->menu_selected_color = RrColorNew(inst, 0, 0, 0);
299 if (read_mask(inst, path, "max.xbm", theme, &theme->max_mask)) {
300 if (!read_mask(inst, path, "max_pressed.xbm", theme,
301 &theme->max_pressed_mask)) {
302 theme->max_pressed_mask = RrPixmapMaskCopy(theme->max_mask);
304 if (!read_mask(inst, path, "max_toggled.xbm", theme,
305 &theme->max_toggled_mask)) {
306 theme->max_toggled_mask =
307 RrPixmapMaskCopy(theme->max_pressed_mask);
309 if (!read_mask(inst, path, "max_disabled.xbm", theme,
310 &theme->max_disabled_mask)) {
311 theme->max_disabled_mask = RrPixmapMaskCopy(theme->max_mask);
313 if (!read_mask(inst, path, "max_hover.xbm", theme,
314 &theme->max_hover_mask)) {
315 theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask);
319 guchar data[] = { 0x7f, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f };
320 theme->max_mask = RrPixmapMaskNew(inst, 7, 7, (gchar*)data);
323 guchar data[] = { 0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
324 theme->max_toggled_mask = RrPixmapMaskNew(inst, 7, 7, (gchar*)data);
326 theme->max_pressed_mask = RrPixmapMaskCopy(theme->max_mask);
327 theme->max_disabled_mask = RrPixmapMaskCopy(theme->max_mask);
328 theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask);
331 if (read_mask(inst, path, "iconify.xbm", theme, &theme->iconify_mask)) {
332 if (!read_mask(inst, path, "iconify_pressed.xbm", theme,
333 &theme->iconify_pressed_mask)) {
334 theme->iconify_pressed_mask =
335 RrPixmapMaskCopy(theme->iconify_mask);
337 if (!read_mask(inst, path, "iconify_disabled.xbm", theme,
338 &theme->iconify_disabled_mask)) {
339 theme->iconify_disabled_mask =
340 RrPixmapMaskCopy(theme->iconify_mask);
342 if (!read_mask(inst, path, "iconify_hover.xbm", theme,
343 &theme->iconify_hover_mask)) {
344 theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
348 guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x7f };
349 theme->iconify_mask = RrPixmapMaskNew(inst, 7, 7, (gchar*)data);
351 theme->iconify_pressed_mask = RrPixmapMaskCopy(theme->iconify_mask);
352 theme->iconify_disabled_mask = RrPixmapMaskCopy(theme->iconify_mask);
353 theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
356 theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
357 OB_DEFAULT_ICON_HEIGHT,
358 OB_DEFAULT_ICON_pixel_data);
360 if (read_mask(inst, path, "desk.xbm", theme, &theme->desk_mask)) {
361 if (!read_mask(inst, path, "desk_pressed.xbm", theme,
362 &theme->desk_pressed_mask)) {
363 theme->desk_pressed_mask = RrPixmapMaskCopy(theme->desk_mask);
365 if (!read_mask(inst, path, "desk_toggled.xbm", theme,
366 &theme->desk_toggled_mask)) {
367 theme->desk_toggled_mask =
368 RrPixmapMaskCopy(theme->desk_pressed_mask);
370 if (!read_mask(inst, path, "desk_disabled.xbm", theme,
371 &theme->desk_disabled_mask)) {
372 theme->desk_disabled_mask = RrPixmapMaskCopy(theme->desk_mask);
374 if (!read_mask(inst, path, "desk_hover.xbm", theme,
375 &theme->desk_hover_mask)) {
376 theme->desk_hover_mask = RrPixmapMaskCopy(theme->desk_mask);
380 guchar data[] = { 0x63, 0x63, 0x00, 0x00, 0x00, 0x63, 0x63 };
381 theme->desk_mask = RrPixmapMaskNew(inst, 7, 7, (gchar*)data);
384 guchar data[] = { 0x00, 0x36, 0x36, 0x08, 0x36, 0x36, 0x00 };
385 theme->desk_toggled_mask = RrPixmapMaskNew(inst, 7, 7,
388 theme->desk_pressed_mask = RrPixmapMaskCopy(theme->desk_mask);
389 theme->desk_disabled_mask = RrPixmapMaskCopy(theme->desk_mask);
390 theme->desk_hover_mask = RrPixmapMaskCopy(theme->desk_mask);
393 if (read_mask(inst, path, "shade.xbm", theme, &theme->shade_mask)) {
394 if (!read_mask(inst, path, "shade_pressed.xbm", theme,
395 &theme->shade_pressed_mask)) {
396 theme->shade_pressed_mask = RrPixmapMaskCopy(theme->shade_mask);
398 if (!read_mask(inst, path, "shade_toggled.xbm", theme,
399 &theme->shade_toggled_mask)) {
400 theme->shade_toggled_mask =
401 RrPixmapMaskCopy(theme->shade_pressed_mask);
403 if (!read_mask(inst, path, "shade_disabled.xbm", theme,
404 &theme->shade_disabled_mask)) {
405 theme->shade_disabled_mask = RrPixmapMaskCopy(theme->shade_mask);
407 if (!read_mask(inst, path, "shade_hover.xbm", theme,
408 &theme->shade_hover_mask)) {
409 theme->shade_hover_mask = RrPixmapMaskCopy(theme->shade_mask);
413 guchar data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00 };
414 theme->shade_mask = RrPixmapMaskNew(inst, 7, 7, (gchar*)data);
417 guchar data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x7f };
418 theme->shade_toggled_mask = RrPixmapMaskNew(inst, 7, 7,
421 theme->shade_pressed_mask = RrPixmapMaskCopy(theme->shade_mask);
422 theme->shade_disabled_mask = RrPixmapMaskCopy(theme->shade_mask);
423 theme->shade_hover_mask = RrPixmapMaskCopy(theme->shade_mask);
426 if (read_mask(inst, path, "close.xbm", theme, &theme->close_mask)) {
427 if (!read_mask(inst, path, "close_pressed.xbm", theme,
428 &theme->close_pressed_mask)) {
429 theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask);
431 if (!read_mask(inst, path, "close_disabled.xbm", theme,
432 &theme->close_disabled_mask)) {
433 theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask);
435 if (!read_mask(inst, path, "close_hover.xbm", theme,
436 &theme->close_hover_mask)) {
437 theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask);
441 guchar data[] = { 0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63 };
442 theme->close_mask = RrPixmapMaskNew(inst, 7, 7, (gchar*)data);
444 theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask);
445 theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask);
446 theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask);
449 if (!read_mask(inst, path, "bullet.xbm", theme,
450 &theme->menu_bullet_mask)) {
451 guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
452 theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data);
455 /* read the decoration textures */
456 if (!read_appearance(db, inst,
457 "window.active.title.bg", theme->a_focused_title,
459 set_default_appearance(theme->a_focused_title);
460 if (!read_appearance(db, inst,
461 "window.inactive.title.bg", theme->a_unfocused_title,
463 set_default_appearance(theme->a_unfocused_title);
464 if (!read_appearance(db, inst,
465 "window.active.label.bg", theme->a_focused_label,
467 set_default_appearance(theme->a_focused_label);
468 if (!read_appearance(db, inst,
469 "window.inactive.label.bg", theme->a_unfocused_label,
471 set_default_appearance(theme->a_unfocused_label);
472 if (!read_appearance(db, inst,
473 "window.active.handle.bg", theme->a_focused_handle,
475 set_default_appearance(theme->a_focused_handle);
476 if (!read_appearance(db, inst,
477 "window.inactive.handle.bg",theme->a_unfocused_handle,
479 set_default_appearance(theme->a_unfocused_handle);
480 if (!read_appearance(db, inst,
481 "window.active.grip.bg", theme->a_focused_grip,
483 set_default_appearance(theme->a_focused_grip);
484 if (!read_appearance(db, inst,
485 "window.inactive.grip.bg", theme->a_unfocused_grip,
487 set_default_appearance(theme->a_unfocused_grip);
488 if (!read_appearance(db, inst,
489 "menu.items.bg", theme->a_menu,
491 set_default_appearance(theme->a_menu);
492 if (!read_appearance(db, inst,
493 "menu.title.bg", theme->a_menu_title,
495 set_default_appearance(theme->a_menu_title);
496 if (!read_appearance(db, inst,
497 "menu.items.active.bg", theme->a_menu_selected,
499 set_default_appearance(theme->a_menu_selected);
500 theme->a_menu_disabled_selected =
501 RrAppearanceCopy(theme->a_menu_selected);
503 /* read the appearances for rendering non-decorations */
504 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_title);
505 theme->osd_hilite_label = RrAppearanceCopy(theme->a_focused_label);
506 if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL)
507 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_label);
509 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_title);
510 if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL)
511 theme->osd_unhilite_fg = RrAppearanceCopy(theme->a_unfocused_label);
513 theme->osd_unhilite_fg = RrAppearanceCopy(theme->a_unfocused_title);
515 /* read buttons textures */
516 if (!read_appearance(db, inst,
517 "window.active.button.disabled.bg",
518 theme->a_disabled_focused_max,
520 set_default_appearance(theme->a_disabled_focused_max);
521 if (!read_appearance(db, inst,
522 "window.inactive.button.disabled.bg",
523 theme->a_disabled_unfocused_max,
525 set_default_appearance(theme->a_disabled_unfocused_max);
526 if (!read_appearance(db, inst,
527 "window.active.button.pressed.bg",
528 theme->a_focused_pressed_max,
530 set_default_appearance(theme->a_focused_pressed_max);
531 if (!read_appearance(db, inst,
532 "window.inactive.button.pressed.bg",
533 theme->a_unfocused_pressed_max,
535 set_default_appearance(theme->a_unfocused_pressed_max);
536 if (!read_appearance(db, inst,
537 "window.active.button.toggled.bg",
538 theme->a_toggled_focused_max,
541 RrAppearanceFree(theme->a_toggled_focused_max);
542 theme->a_toggled_focused_max =
543 RrAppearanceCopy(theme->a_focused_pressed_max);
545 if (!read_appearance(db, inst,
546 "window.inactive.button.toggled.bg",
547 theme->a_toggled_unfocused_max,
550 RrAppearanceFree(theme->a_toggled_unfocused_max);
551 theme->a_toggled_unfocused_max =
552 RrAppearanceCopy(theme->a_unfocused_pressed_max);
554 if (!read_appearance(db, inst,
555 "window.active.button.unpressed.bg",
556 theme->a_focused_unpressed_max,
558 set_default_appearance(theme->a_focused_unpressed_max);
559 if (!read_appearance(db, inst,
560 "window.inactive.button.unpressed.bg",
561 theme->a_unfocused_unpressed_max,
563 set_default_appearance(theme->a_unfocused_unpressed_max);
564 if (!read_appearance(db, inst,
565 "window.active.button.hover.bg",
566 theme->a_hover_focused_max,
569 RrAppearanceFree(theme->a_hover_focused_max);
570 theme->a_hover_focused_max =
571 RrAppearanceCopy(theme->a_focused_unpressed_max);
573 if (!read_appearance(db, inst,
574 "window.inactive.button.hover.bg",
575 theme->a_hover_unfocused_max,
578 RrAppearanceFree(theme->a_hover_unfocused_max);
579 theme->a_hover_unfocused_max =
580 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
583 theme->a_disabled_focused_close =
584 RrAppearanceCopy(theme->a_disabled_focused_max);
585 theme->a_disabled_unfocused_close =
586 RrAppearanceCopy(theme->a_disabled_unfocused_max);
587 theme->a_hover_focused_close =
588 RrAppearanceCopy(theme->a_hover_focused_max);
589 theme->a_hover_unfocused_close =
590 RrAppearanceCopy(theme->a_hover_unfocused_max);
591 theme->a_unfocused_unpressed_close =
592 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
593 theme->a_unfocused_pressed_close =
594 RrAppearanceCopy(theme->a_unfocused_pressed_max);
595 theme->a_focused_unpressed_close =
596 RrAppearanceCopy(theme->a_focused_unpressed_max);
597 theme->a_focused_pressed_close =
598 RrAppearanceCopy(theme->a_focused_pressed_max);
599 theme->a_disabled_focused_desk =
600 RrAppearanceCopy(theme->a_disabled_focused_max);
601 theme->a_disabled_unfocused_desk =
602 RrAppearanceCopy(theme->a_disabled_unfocused_max);
603 theme->a_hover_focused_desk =
604 RrAppearanceCopy(theme->a_hover_focused_max);
605 theme->a_hover_unfocused_desk =
606 RrAppearanceCopy(theme->a_hover_unfocused_max);
607 theme->a_toggled_focused_desk =
608 RrAppearanceCopy(theme->a_toggled_focused_max);
609 theme->a_toggled_unfocused_desk =
610 RrAppearanceCopy(theme->a_toggled_unfocused_max);
611 theme->a_unfocused_unpressed_desk =
612 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
613 theme->a_unfocused_pressed_desk =
614 RrAppearanceCopy(theme->a_unfocused_pressed_max);
615 theme->a_focused_unpressed_desk =
616 RrAppearanceCopy(theme->a_focused_unpressed_max);
617 theme->a_focused_pressed_desk =
618 RrAppearanceCopy(theme->a_focused_pressed_max);
619 theme->a_disabled_focused_shade =
620 RrAppearanceCopy(theme->a_disabled_focused_max);
621 theme->a_disabled_unfocused_shade =
622 RrAppearanceCopy(theme->a_disabled_unfocused_max);
623 theme->a_hover_focused_shade =
624 RrAppearanceCopy(theme->a_hover_focused_max);
625 theme->a_hover_unfocused_shade =
626 RrAppearanceCopy(theme->a_hover_unfocused_max);
627 theme->a_toggled_focused_shade =
628 RrAppearanceCopy(theme->a_toggled_focused_max);
629 theme->a_toggled_unfocused_shade =
630 RrAppearanceCopy(theme->a_toggled_unfocused_max);
631 theme->a_unfocused_unpressed_shade =
632 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
633 theme->a_unfocused_pressed_shade =
634 RrAppearanceCopy(theme->a_unfocused_pressed_max);
635 theme->a_focused_unpressed_shade =
636 RrAppearanceCopy(theme->a_focused_unpressed_max);
637 theme->a_focused_pressed_shade =
638 RrAppearanceCopy(theme->a_focused_pressed_max);
639 theme->a_disabled_focused_iconify =
640 RrAppearanceCopy(theme->a_disabled_focused_max);
641 theme->a_disabled_unfocused_iconify =
642 RrAppearanceCopy(theme->a_disabled_focused_max);
643 theme->a_hover_focused_iconify =
644 RrAppearanceCopy(theme->a_hover_focused_max);
645 theme->a_hover_unfocused_iconify =
646 RrAppearanceCopy(theme->a_hover_unfocused_max);
647 theme->a_unfocused_unpressed_iconify =
648 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
649 theme->a_unfocused_pressed_iconify =
650 RrAppearanceCopy(theme->a_unfocused_pressed_max);
651 theme->a_focused_unpressed_iconify =
652 RrAppearanceCopy(theme->a_focused_unpressed_max);
653 theme->a_focused_pressed_iconify =
654 RrAppearanceCopy(theme->a_focused_pressed_max);
656 theme->a_icon->surface.grad =
657 theme->a_clear->surface.grad =
658 theme->a_clear_tex->surface.grad =
659 theme->a_menu_text_title->surface.grad =
660 theme->a_menu_normal->surface.grad =
661 theme->a_menu_disabled->surface.grad =
662 theme->a_menu_text_normal->surface.grad =
663 theme->a_menu_text_selected->surface.grad =
664 theme->a_menu_text_disabled->surface.grad =
665 theme->a_menu_text_disabled_selected->surface.grad =
666 theme->a_menu_bullet_normal->surface.grad =
667 theme->a_menu_bullet_selected->surface.grad = RR_SURFACE_PARENTREL;
669 /* set up the textures */
670 theme->a_focused_label->texture[0].type =
671 theme->osd_hilite_label->texture[0].type = RR_TEXTURE_TEXT;
672 theme->a_focused_label->texture[0].data.text.justify = winjust;
673 theme->osd_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
674 theme->a_focused_label->texture[0].data.text.font =
675 theme->win_font_focused;
676 theme->osd_hilite_label->texture[0].data.text.font = theme->osd_font;
677 theme->a_focused_label->texture[0].data.text.color =
678 theme->title_focused_color;
679 theme->osd_hilite_label->texture[0].data.text.color =
682 if (read_string(db, "window.active.label.text.font", &str)) {
686 if (strstr(str, "shadow=y")) {
687 if ((p = strstr(str, "shadowoffset=")))
688 i = parse_inline_number(p + strlen("shadowoffset="));
691 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
692 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
693 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x = i;
694 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y = i;
696 if ((p = strstr(str, "shadowtint=")))
698 i = parse_inline_number(p + strlen("shadowtint="));
699 j = (i > 0 ? 0 : 255);
702 theme->title_focused_shadow_color = RrColorNew(inst, j, j, j);
703 theme->title_focused_shadow_alpha = i;
704 theme->osd_shadow_color = RrColorNew(inst, j, j, j);
705 theme->osd_shadow_alpha = i;
707 theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
708 theme->title_focused_shadow_alpha = 50;
709 theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0);
710 theme->osd_shadow_alpha = 50;
714 theme->a_focused_label->texture[0].data.text.shadow_color =
715 theme->title_focused_shadow_color;
716 theme->a_focused_label->texture[0].data.text.shadow_alpha =
717 theme->title_focused_shadow_alpha;
718 theme->osd_hilite_label->texture[0].data.text.shadow_color =
719 theme->osd_shadow_color;
720 theme->osd_hilite_label->texture[0].data.text.shadow_alpha =
721 theme->osd_shadow_alpha;
723 theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT;
724 theme->a_unfocused_label->texture[0].data.text.justify = winjust;
725 theme->a_unfocused_label->texture[0].data.text.font =
726 theme->win_font_unfocused;
727 theme->a_unfocused_label->texture[0].data.text.color =
728 theme->title_unfocused_color;
730 if (read_string(db, "window.inactive.label.text.font", &str)) {
734 if (strstr(str, "shadow=y")) {
735 if ((p = strstr(str, "shadowoffset=")))
736 i = parse_inline_number(p + strlen("shadowoffset="));
739 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x = i;
740 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y = i;
742 if ((p = strstr(str, "shadowtint=")))
744 i = parse_inline_number(p + strlen("shadowtint="));
745 j = (i > 0 ? 0 : 255);
748 theme->title_unfocused_shadow_color = RrColorNew(inst, j, j, j);
749 theme->title_unfocused_shadow_alpha = i;
751 theme->title_unfocused_shadow_color = RrColorNew(inst, 0, 0, 0);
752 theme->title_unfocused_shadow_alpha = 50;
756 theme->a_unfocused_label->texture[0].data.text.shadow_color =
757 theme->title_unfocused_shadow_color;
758 theme->a_unfocused_label->texture[0].data.text.shadow_alpha =
759 theme->title_unfocused_shadow_alpha;
761 theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
762 theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
763 theme->a_menu_text_title->texture[0].data.text.font =
764 theme->menu_title_font;
765 theme->a_menu_text_title->texture[0].data.text.color =
766 theme->menu_title_color;
768 if (read_string(db, "menu.title.text.font", &str)) {
772 if (strstr(str, "shadow=y")) {
773 if ((p = strstr(str, "shadowoffset=")))
774 i = parse_inline_number(p + strlen("shadowoffset="));
777 theme->a_menu_text_title->texture[0].data.text.shadow_offset_x = i;
778 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y = i;
780 if ((p = strstr(str, "shadowtint=")))
782 i = parse_inline_number(p + strlen("shadowtint="));
783 j = (i > 0 ? 0 : 255);
786 theme->menu_title_shadow_color = RrColorNew(inst, j, j, j);
787 theme->menu_title_shadow_alpha = i;
789 theme->menu_title_shadow_color = RrColorNew(inst, 0, 0, 0);
790 theme->menu_title_shadow_alpha = 50;
794 theme->a_menu_text_title->texture[0].data.text.shadow_color =
795 theme->menu_title_shadow_color;
796 theme->a_menu_text_title->texture[0].data.text.shadow_alpha =
797 theme->menu_title_shadow_alpha;
799 theme->a_menu_text_normal->texture[0].type =
800 theme->a_menu_text_selected->texture[0].type =
801 theme->a_menu_text_disabled->texture[0].type =
802 theme->a_menu_text_disabled_selected->texture[0].type =
804 theme->a_menu_text_normal->texture[0].data.text.justify =
805 theme->a_menu_text_selected->texture[0].data.text.justify =
806 theme->a_menu_text_disabled->texture[0].data.text.justify =
807 theme->a_menu_text_disabled_selected->texture[0].data.text.justify =
809 theme->a_menu_text_normal->texture[0].data.text.font =
810 theme->a_menu_text_selected->texture[0].data.text.font =
811 theme->a_menu_text_disabled->texture[0].data.text.font =
812 theme->a_menu_text_disabled_selected->texture[0].data.text.font =
814 theme->a_menu_text_normal->texture[0].data.text.color = theme->menu_color;
815 theme->a_menu_text_selected->texture[0].data.text.color =
816 theme->menu_selected_color;
817 theme->a_menu_text_disabled->texture[0].data.text.color =
818 theme->menu_disabled_color;
819 theme->a_menu_text_disabled_selected->texture[0].data.text.color =
820 theme->menu_disabled_selected_color;
822 if (read_string(db, "menu.items.font", &str)) {
826 if (strstr(str, "shadow=y")) {
827 if ((p = strstr(str, "shadowoffset=")))
828 i = parse_inline_number(p + strlen("shadowoffset="));
831 theme->a_menu_text_normal->
832 texture[0].data.text.shadow_offset_x = i;
833 theme->a_menu_text_normal->
834 texture[0].data.text.shadow_offset_y = i;
835 theme->a_menu_text_selected->
836 texture[0].data.text.shadow_offset_x = i;
837 theme->a_menu_text_selected->
838 texture[0].data.text.shadow_offset_y = i;
839 theme->a_menu_text_disabled->
840 texture[0].data.text.shadow_offset_x = i;
841 theme->a_menu_text_disabled->
842 texture[0].data.text.shadow_offset_y = i;
843 theme->a_menu_text_disabled_selected->
844 texture[0].data.text.shadow_offset_x = i;
845 theme->a_menu_text_disabled_selected->
846 texture[0].data.text.shadow_offset_y = i;
848 if ((p = strstr(str, "shadowtint=")))
850 i = parse_inline_number(p + strlen("shadowtint="));
851 j = (i > 0 ? 0 : 255);
854 theme->menu_text_normal_shadow_color = RrColorNew(inst, j, j, j);
855 theme->menu_text_selected_shadow_color = RrColorNew(inst, j, j, j);
856 theme->menu_text_disabled_shadow_color = RrColorNew(inst, j, j, j);
857 theme->menu_text_normal_shadow_alpha = i;
858 theme->menu_text_selected_shadow_alpha = i;
859 theme->menu_text_disabled_shadow_alpha = i;
860 theme->menu_text_disabled_selected_shadow_alpha = i;
862 theme->menu_text_normal_shadow_color = RrColorNew(inst, 0, 0, 0);
863 theme->menu_text_selected_shadow_color = RrColorNew(inst, 0, 0, 0);
864 theme->menu_text_disabled_shadow_color = RrColorNew(inst, 0, 0, 0);
865 theme->menu_text_normal_shadow_alpha = 50;
866 theme->menu_text_selected_shadow_alpha = 50;
867 theme->menu_text_disabled_selected_shadow_alpha = 50;
871 theme->a_menu_text_normal->texture[0].data.text.shadow_color =
872 theme->menu_text_normal_shadow_color;
873 theme->a_menu_text_normal->texture[0].data.text.shadow_alpha =
874 theme->menu_text_normal_shadow_alpha;
875 theme->a_menu_text_selected->texture[0].data.text.shadow_color =
876 theme->menu_text_selected_shadow_color;
877 theme->a_menu_text_selected->texture[0].data.text.shadow_alpha =
878 theme->menu_text_selected_shadow_alpha;
879 theme->a_menu_text_disabled->texture[0].data.text.shadow_color =
880 theme->menu_text_disabled_shadow_color;
881 theme->a_menu_text_disabled->texture[0].data.text.shadow_alpha =
882 theme->menu_text_disabled_shadow_alpha;
883 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_color =
884 theme->menu_text_disabled_shadow_color;
885 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_alpha =
886 theme->menu_text_disabled_shadow_alpha;
888 theme->a_disabled_focused_max->texture[0].type =
889 theme->a_disabled_unfocused_max->texture[0].type =
890 theme->a_hover_focused_max->texture[0].type =
891 theme->a_hover_unfocused_max->texture[0].type =
892 theme->a_toggled_focused_max->texture[0].type =
893 theme->a_toggled_unfocused_max->texture[0].type =
894 theme->a_focused_unpressed_max->texture[0].type =
895 theme->a_focused_pressed_max->texture[0].type =
896 theme->a_unfocused_unpressed_max->texture[0].type =
897 theme->a_unfocused_pressed_max->texture[0].type =
898 theme->a_disabled_focused_close->texture[0].type =
899 theme->a_disabled_unfocused_close->texture[0].type =
900 theme->a_hover_focused_close->texture[0].type =
901 theme->a_hover_unfocused_close->texture[0].type =
902 theme->a_focused_unpressed_close->texture[0].type =
903 theme->a_focused_pressed_close->texture[0].type =
904 theme->a_unfocused_unpressed_close->texture[0].type =
905 theme->a_unfocused_pressed_close->texture[0].type =
906 theme->a_disabled_focused_desk->texture[0].type =
907 theme->a_disabled_unfocused_desk->texture[0].type =
908 theme->a_hover_focused_desk->texture[0].type =
909 theme->a_hover_unfocused_desk->texture[0].type =
910 theme->a_toggled_focused_desk->texture[0].type =
911 theme->a_toggled_unfocused_desk->texture[0].type =
912 theme->a_focused_unpressed_desk->texture[0].type =
913 theme->a_focused_pressed_desk->texture[0].type =
914 theme->a_unfocused_unpressed_desk->texture[0].type =
915 theme->a_unfocused_pressed_desk->texture[0].type =
916 theme->a_disabled_focused_shade->texture[0].type =
917 theme->a_disabled_unfocused_shade->texture[0].type =
918 theme->a_hover_focused_shade->texture[0].type =
919 theme->a_hover_unfocused_shade->texture[0].type =
920 theme->a_toggled_focused_shade->texture[0].type =
921 theme->a_toggled_unfocused_shade->texture[0].type =
922 theme->a_focused_unpressed_shade->texture[0].type =
923 theme->a_focused_pressed_shade->texture[0].type =
924 theme->a_unfocused_unpressed_shade->texture[0].type =
925 theme->a_unfocused_pressed_shade->texture[0].type =
926 theme->a_disabled_focused_iconify->texture[0].type =
927 theme->a_disabled_unfocused_iconify->texture[0].type =
928 theme->a_hover_focused_iconify->texture[0].type =
929 theme->a_hover_unfocused_iconify->texture[0].type =
930 theme->a_focused_unpressed_iconify->texture[0].type =
931 theme->a_focused_pressed_iconify->texture[0].type =
932 theme->a_unfocused_unpressed_iconify->texture[0].type =
933 theme->a_unfocused_pressed_iconify->texture[0].type =
934 theme->a_menu_bullet_normal->texture[0].type =
935 theme->a_menu_bullet_selected->texture[0].type = RR_TEXTURE_MASK;
937 theme->a_disabled_focused_max->texture[0].data.mask.mask =
938 theme->a_disabled_unfocused_max->texture[0].data.mask.mask =
939 theme->max_disabled_mask;
940 theme->a_hover_focused_max->texture[0].data.mask.mask =
941 theme->a_hover_unfocused_max->texture[0].data.mask.mask =
942 theme->max_hover_mask;
943 theme->a_focused_pressed_max->texture[0].data.mask.mask =
944 theme->a_unfocused_pressed_max->texture[0].data.mask.mask =
945 theme->max_pressed_mask;
946 theme->a_focused_unpressed_max->texture[0].data.mask.mask =
947 theme->a_unfocused_unpressed_max->texture[0].data.mask.mask =
949 theme->a_toggled_focused_max->texture[0].data.mask.mask =
950 theme->a_toggled_unfocused_max->texture[0].data.mask.mask =
951 theme->max_toggled_mask;
952 theme->a_disabled_focused_close->texture[0].data.mask.mask =
953 theme->a_disabled_unfocused_close->texture[0].data.mask.mask =
954 theme->close_disabled_mask;
955 theme->a_hover_focused_close->texture[0].data.mask.mask =
956 theme->a_hover_unfocused_close->texture[0].data.mask.mask =
957 theme->close_hover_mask;
958 theme->a_focused_pressed_close->texture[0].data.mask.mask =
959 theme->a_unfocused_pressed_close->texture[0].data.mask.mask =
960 theme->close_pressed_mask;
961 theme->a_focused_unpressed_close->texture[0].data.mask.mask =
962 theme->a_unfocused_unpressed_close->texture[0].data.mask.mask =
964 theme->a_disabled_focused_desk->texture[0].data.mask.mask =
965 theme->a_disabled_unfocused_desk->texture[0].data.mask.mask =
966 theme->desk_disabled_mask;
967 theme->a_hover_focused_desk->texture[0].data.mask.mask =
968 theme->a_hover_unfocused_desk->texture[0].data.mask.mask =
969 theme->desk_hover_mask;
970 theme->a_focused_pressed_desk->texture[0].data.mask.mask =
971 theme->a_unfocused_pressed_desk->texture[0].data.mask.mask =
972 theme->desk_pressed_mask;
973 theme->a_focused_unpressed_desk->texture[0].data.mask.mask =
974 theme->a_unfocused_unpressed_desk->texture[0].data.mask.mask =
976 theme->a_toggled_focused_desk->texture[0].data.mask.mask =
977 theme->a_toggled_unfocused_desk->texture[0].data.mask.mask =
978 theme->desk_toggled_mask;
979 theme->a_disabled_focused_shade->texture[0].data.mask.mask =
980 theme->a_disabled_unfocused_shade->texture[0].data.mask.mask =
981 theme->shade_disabled_mask;
982 theme->a_hover_focused_shade->texture[0].data.mask.mask =
983 theme->a_hover_unfocused_shade->texture[0].data.mask.mask =
984 theme->shade_hover_mask;
985 theme->a_focused_pressed_shade->texture[0].data.mask.mask =
986 theme->a_unfocused_pressed_shade->texture[0].data.mask.mask =
987 theme->shade_pressed_mask;
988 theme->a_focused_unpressed_shade->texture[0].data.mask.mask =
989 theme->a_unfocused_unpressed_shade->texture[0].data.mask.mask =
991 theme->a_toggled_focused_shade->texture[0].data.mask.mask =
992 theme->a_toggled_unfocused_shade->texture[0].data.mask.mask =
993 theme->shade_toggled_mask;
994 theme->a_disabled_focused_iconify->texture[0].data.mask.mask =
995 theme->a_disabled_unfocused_iconify->texture[0].data.mask.mask =
996 theme->iconify_disabled_mask;
997 theme->a_hover_focused_iconify->texture[0].data.mask.mask =
998 theme->a_hover_unfocused_iconify->texture[0].data.mask.mask =
999 theme->iconify_hover_mask;
1000 theme->a_focused_pressed_iconify->texture[0].data.mask.mask =
1001 theme->a_unfocused_pressed_iconify->texture[0].data.mask.mask =
1002 theme->iconify_pressed_mask;
1003 theme->a_focused_unpressed_iconify->texture[0].data.mask.mask =
1004 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.mask =
1005 theme->iconify_mask;
1006 theme->a_menu_bullet_normal->texture[0].data.mask.mask =
1007 theme->a_menu_bullet_selected->texture[0].data.mask.mask =
1008 theme->menu_bullet_mask;
1009 theme->a_disabled_focused_max->texture[0].data.mask.color =
1010 theme->a_disabled_focused_close->texture[0].data.mask.color =
1011 theme->a_disabled_focused_desk->texture[0].data.mask.color =
1012 theme->a_disabled_focused_shade->texture[0].data.mask.color =
1013 theme->a_disabled_focused_iconify->texture[0].data.mask.color =
1014 theme->titlebut_disabled_focused_color;
1015 theme->a_disabled_unfocused_max->texture[0].data.mask.color =
1016 theme->a_disabled_unfocused_close->texture[0].data.mask.color =
1017 theme->a_disabled_unfocused_desk->texture[0].data.mask.color =
1018 theme->a_disabled_unfocused_shade->texture[0].data.mask.color =
1019 theme->a_disabled_unfocused_iconify->texture[0].data.mask.color =
1020 theme->titlebut_disabled_unfocused_color;
1021 theme->a_hover_focused_max->texture[0].data.mask.color =
1022 theme->a_hover_focused_close->texture[0].data.mask.color =
1023 theme->a_hover_focused_desk->texture[0].data.mask.color =
1024 theme->a_hover_focused_shade->texture[0].data.mask.color =
1025 theme->a_hover_focused_iconify->texture[0].data.mask.color =
1026 theme->titlebut_hover_focused_color;
1027 theme->a_hover_unfocused_max->texture[0].data.mask.color =
1028 theme->a_hover_unfocused_close->texture[0].data.mask.color =
1029 theme->a_hover_unfocused_desk->texture[0].data.mask.color =
1030 theme->a_hover_unfocused_shade->texture[0].data.mask.color =
1031 theme->a_hover_unfocused_iconify->texture[0].data.mask.color =
1032 theme->titlebut_hover_unfocused_color;
1033 theme->a_toggled_focused_max->texture[0].data.mask.color =
1034 theme->a_toggled_focused_desk->texture[0].data.mask.color =
1035 theme->a_toggled_focused_shade->texture[0].data.mask.color =
1036 theme->titlebut_toggled_focused_color;
1037 theme->a_toggled_unfocused_max->texture[0].data.mask.color =
1038 theme->a_toggled_unfocused_desk->texture[0].data.mask.color =
1039 theme->a_toggled_unfocused_shade->texture[0].data.mask.color =
1040 theme->titlebut_toggled_unfocused_color;
1041 theme->a_focused_unpressed_max->texture[0].data.mask.color =
1042 theme->a_focused_unpressed_close->texture[0].data.mask.color =
1043 theme->a_focused_unpressed_desk->texture[0].data.mask.color =
1044 theme->a_focused_unpressed_shade->texture[0].data.mask.color =
1045 theme->a_focused_unpressed_iconify->texture[0].data.mask.color =
1046 theme->titlebut_focused_unpressed_color;
1047 theme->a_focused_pressed_max->texture[0].data.mask.color =
1048 theme->a_focused_pressed_close->texture[0].data.mask.color =
1049 theme->a_focused_pressed_desk->texture[0].data.mask.color =
1050 theme->a_focused_pressed_shade->texture[0].data.mask.color =
1051 theme->a_focused_pressed_iconify->texture[0].data.mask.color =
1052 theme->titlebut_focused_pressed_color;
1053 theme->a_unfocused_unpressed_max->texture[0].data.mask.color =
1054 theme->a_unfocused_unpressed_close->texture[0].data.mask.color =
1055 theme->a_unfocused_unpressed_desk->texture[0].data.mask.color =
1056 theme->a_unfocused_unpressed_shade->texture[0].data.mask.color =
1057 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.color =
1058 theme->titlebut_unfocused_unpressed_color;
1059 theme->a_unfocused_pressed_max->texture[0].data.mask.color =
1060 theme->a_unfocused_pressed_close->texture[0].data.mask.color =
1061 theme->a_unfocused_pressed_desk->texture[0].data.mask.color =
1062 theme->a_unfocused_pressed_shade->texture[0].data.mask.color =
1063 theme->a_unfocused_pressed_iconify->texture[0].data.mask.color =
1064 theme->titlebut_unfocused_pressed_color;
1065 theme->a_menu_bullet_normal->texture[0].data.mask.color =
1067 theme->a_menu_bullet_selected->texture[0].data.mask.color =
1068 theme->menu_selected_color;
1071 XrmDestroyDatabase(db);
1073 /* set the font heights */
1074 theme->win_font_height = RrFontHeight
1075 (theme->win_font_focused,
1076 theme->a_focused_label->texture[0].data.text.shadow_offset_y);
1077 theme->win_font_height =
1078 MAX(theme->win_font_height,
1080 (theme->win_font_focused,
1081 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y));
1082 theme->menu_title_font_height = RrFontHeight
1083 (theme->menu_title_font,
1084 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y);
1085 theme->menu_font_height = RrFontHeight
1087 theme->a_menu_text_normal->texture[0].data.text.shadow_offset_y);
1089 /* calculate some last extents */
1091 gint ft, fb, fl, fr, ut, ub, ul, ur;
1093 RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb);
1094 RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub);
1095 theme->label_height = theme->win_font_height + MAX(ft + fb, ut + ub);
1097 /* this would be nice I think, since padding.width can now be 0,
1098 but it breaks frame.c horribly and I don't feel like fixing that
1099 right now, so if anyone complains, here is how to keep text from
1100 going over the title's bevel/border with a padding.width of 0 and a
1101 bevelless/borderless label
1102 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1103 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1104 theme->title_height = theme->label_height +
1105 MAX(MAX(theme->padding * 2, ft + fb),
1106 MAX(theme->padding * 2, ut + ub));
1108 theme->title_height = theme->label_height + theme->paddingy * 2;
1110 RrMargins(theme->a_menu_title, &ul, &ut, &ur, &ub);
1111 theme->menu_title_label_height = theme->menu_title_font_height+ut+ub;
1112 theme->menu_title_height = theme->menu_title_label_height +
1113 theme->paddingy * 2;
1115 theme->button_size = theme->label_height - 2;
1116 theme->grip_width = 25;
1121 void RrThemeFree(RrTheme *theme)
1124 RrColorFree(theme->menu_b_color);
1125 RrColorFree(theme->frame_b_color);
1126 RrColorFree(theme->cb_unfocused_color);
1127 RrColorFree(theme->cb_focused_color);
1128 RrColorFree(theme->title_focused_color);
1129 RrColorFree(theme->title_unfocused_color);
1130 RrColorFree(theme->titlebut_disabled_focused_color);
1131 RrColorFree(theme->titlebut_disabled_unfocused_color);
1132 RrColorFree(theme->titlebut_hover_focused_color);
1133 RrColorFree(theme->titlebut_hover_unfocused_color);
1134 RrColorFree(theme->titlebut_toggled_focused_color);
1135 RrColorFree(theme->titlebut_toggled_unfocused_color);
1136 RrColorFree(theme->titlebut_focused_pressed_color);
1137 RrColorFree(theme->titlebut_unfocused_pressed_color);
1138 RrColorFree(theme->titlebut_focused_unpressed_color);
1139 RrColorFree(theme->titlebut_unfocused_unpressed_color);
1140 RrColorFree(theme->menu_title_color);
1141 RrColorFree(theme->menu_color);
1142 RrColorFree(theme->menu_selected_color);
1143 RrColorFree(theme->menu_disabled_color);
1144 RrColorFree(theme->menu_disabled_selected_color);
1145 RrColorFree(theme->title_focused_shadow_color);
1146 RrColorFree(theme->title_unfocused_shadow_color);
1147 RrColorFree(theme->osd_color);
1148 RrColorFree(theme->osd_shadow_color);
1149 RrColorFree(theme->menu_title_shadow_color);
1150 RrColorFree(theme->menu_text_normal_shadow_color);
1151 RrColorFree(theme->menu_text_selected_shadow_color);
1152 RrColorFree(theme->menu_text_disabled_shadow_color);
1153 RrColorFree(theme->menu_text_disabled_selected_shadow_color);
1155 g_free(theme->def_win_icon);
1157 RrPixmapMaskFree(theme->max_mask);
1158 RrPixmapMaskFree(theme->max_toggled_mask);
1159 RrPixmapMaskFree(theme->max_disabled_mask);
1160 RrPixmapMaskFree(theme->max_hover_mask);
1161 RrPixmapMaskFree(theme->max_pressed_mask);
1162 RrPixmapMaskFree(theme->desk_mask);
1163 RrPixmapMaskFree(theme->desk_toggled_mask);
1164 RrPixmapMaskFree(theme->desk_disabled_mask);
1165 RrPixmapMaskFree(theme->desk_hover_mask);
1166 RrPixmapMaskFree(theme->desk_pressed_mask);
1167 RrPixmapMaskFree(theme->shade_mask);
1168 RrPixmapMaskFree(theme->shade_toggled_mask);
1169 RrPixmapMaskFree(theme->shade_disabled_mask);
1170 RrPixmapMaskFree(theme->shade_hover_mask);
1171 RrPixmapMaskFree(theme->shade_pressed_mask);
1172 RrPixmapMaskFree(theme->iconify_mask);
1173 RrPixmapMaskFree(theme->iconify_disabled_mask);
1174 RrPixmapMaskFree(theme->iconify_hover_mask);
1175 RrPixmapMaskFree(theme->iconify_pressed_mask);
1176 RrPixmapMaskFree(theme->close_mask);
1177 RrPixmapMaskFree(theme->close_disabled_mask);
1178 RrPixmapMaskFree(theme->close_hover_mask);
1179 RrPixmapMaskFree(theme->close_pressed_mask);
1180 RrPixmapMaskFree(theme->menu_bullet_mask);
1182 RrFontClose(theme->win_font_focused);
1183 RrFontClose(theme->win_font_unfocused);
1184 RrFontClose(theme->menu_title_font);
1185 RrFontClose(theme->menu_font);
1187 RrAppearanceFree(theme->a_disabled_focused_max);
1188 RrAppearanceFree(theme->a_disabled_unfocused_max);
1189 RrAppearanceFree(theme->a_hover_focused_max);
1190 RrAppearanceFree(theme->a_hover_unfocused_max);
1191 RrAppearanceFree(theme->a_toggled_focused_max);
1192 RrAppearanceFree(theme->a_toggled_unfocused_max);
1193 RrAppearanceFree(theme->a_focused_unpressed_max);
1194 RrAppearanceFree(theme->a_focused_pressed_max);
1195 RrAppearanceFree(theme->a_unfocused_unpressed_max);
1196 RrAppearanceFree(theme->a_unfocused_pressed_max);
1197 RrAppearanceFree(theme->a_disabled_focused_close);
1198 RrAppearanceFree(theme->a_disabled_unfocused_close);
1199 RrAppearanceFree(theme->a_hover_focused_close);
1200 RrAppearanceFree(theme->a_hover_unfocused_close);
1201 RrAppearanceFree(theme->a_focused_unpressed_close);
1202 RrAppearanceFree(theme->a_focused_pressed_close);
1203 RrAppearanceFree(theme->a_unfocused_unpressed_close);
1204 RrAppearanceFree(theme->a_unfocused_pressed_close);
1205 RrAppearanceFree(theme->a_disabled_focused_desk);
1206 RrAppearanceFree(theme->a_disabled_unfocused_desk);
1207 RrAppearanceFree(theme->a_hover_focused_desk);
1208 RrAppearanceFree(theme->a_hover_unfocused_desk);
1209 RrAppearanceFree(theme->a_toggled_focused_desk);
1210 RrAppearanceFree(theme->a_toggled_unfocused_desk);
1211 RrAppearanceFree(theme->a_focused_unpressed_desk);
1212 RrAppearanceFree(theme->a_focused_pressed_desk);
1213 RrAppearanceFree(theme->a_unfocused_unpressed_desk);
1214 RrAppearanceFree(theme->a_unfocused_pressed_desk);
1215 RrAppearanceFree(theme->a_disabled_focused_shade);
1216 RrAppearanceFree(theme->a_disabled_unfocused_shade);
1217 RrAppearanceFree(theme->a_hover_focused_shade);
1218 RrAppearanceFree(theme->a_hover_unfocused_shade);
1219 RrAppearanceFree(theme->a_toggled_focused_shade);
1220 RrAppearanceFree(theme->a_toggled_unfocused_shade);
1221 RrAppearanceFree(theme->a_focused_unpressed_shade);
1222 RrAppearanceFree(theme->a_focused_pressed_shade);
1223 RrAppearanceFree(theme->a_unfocused_unpressed_shade);
1224 RrAppearanceFree(theme->a_unfocused_pressed_shade);
1225 RrAppearanceFree(theme->a_disabled_focused_iconify);
1226 RrAppearanceFree(theme->a_disabled_unfocused_iconify);
1227 RrAppearanceFree(theme->a_hover_focused_iconify);
1228 RrAppearanceFree(theme->a_hover_unfocused_iconify);
1229 RrAppearanceFree(theme->a_focused_unpressed_iconify);
1230 RrAppearanceFree(theme->a_focused_pressed_iconify);
1231 RrAppearanceFree(theme->a_unfocused_unpressed_iconify);
1232 RrAppearanceFree(theme->a_unfocused_pressed_iconify);
1233 RrAppearanceFree(theme->a_focused_grip);
1234 RrAppearanceFree(theme->a_unfocused_grip);
1235 RrAppearanceFree(theme->a_focused_title);
1236 RrAppearanceFree(theme->a_unfocused_title);
1237 RrAppearanceFree(theme->a_focused_label);
1238 RrAppearanceFree(theme->a_unfocused_label);
1239 RrAppearanceFree(theme->a_icon);
1240 RrAppearanceFree(theme->a_focused_handle);
1241 RrAppearanceFree(theme->a_unfocused_handle);
1242 RrAppearanceFree(theme->a_menu);
1243 RrAppearanceFree(theme->a_menu_title);
1244 RrAppearanceFree(theme->a_menu_text_title);
1245 RrAppearanceFree(theme->a_menu_normal);
1246 RrAppearanceFree(theme->a_menu_selected);
1247 RrAppearanceFree(theme->a_menu_disabled);
1248 RrAppearanceFree(theme->a_menu_disabled_selected);
1249 RrAppearanceFree(theme->a_menu_text_normal);
1250 RrAppearanceFree(theme->a_menu_text_selected);
1251 RrAppearanceFree(theme->a_menu_text_disabled);
1252 RrAppearanceFree(theme->a_menu_text_disabled_selected);
1253 RrAppearanceFree(theme->a_menu_bullet_normal);
1254 RrAppearanceFree(theme->a_menu_bullet_selected);
1255 RrAppearanceFree(theme->a_clear);
1256 RrAppearanceFree(theme->a_clear_tex);
1257 RrAppearanceFree(theme->osd_hilite_bg);
1258 RrAppearanceFree(theme->osd_hilite_fg);
1259 RrAppearanceFree(theme->osd_hilite_label);
1260 RrAppearanceFree(theme->osd_unhilite_fg);
1266 static XrmDatabase loaddb(RrTheme *theme, const gchar *name, gchar **path)
1269 XrmDatabase db = NULL;
1272 if (name[0] == '/') {
1273 s = g_build_filename(name, "openbox-3", "themerc", NULL);
1274 if ((db = XrmGetFileDatabase(s)))
1275 *path = g_path_get_dirname(s);
1278 /* XXX backwards compatibility, remove me sometime later */
1279 s = g_build_filename(g_get_home_dir(), ".themes", name,
1280 "openbox-3", "themerc", NULL);
1281 if ((db = XrmGetFileDatabase(s)))
1282 *path = g_path_get_dirname(s);
1285 for (it = parse_xdg_data_dir_paths(); !db && it;
1286 it = g_slist_next(it))
1288 s = g_build_filename(it->data, "themes", name,
1289 "openbox-3", "themerc", NULL);
1290 if ((db = XrmGetFileDatabase(s)))
1291 *path = g_path_get_dirname(s);
1297 s = g_build_filename(name, "themerc", NULL);
1298 if ((db = XrmGetFileDatabase(s)))
1299 *path = g_path_get_dirname(s);
1306 static gchar *create_class_name(const gchar *rname)
1308 gchar *rclass = g_strdup(rname);
1313 p = strchr(p+1, '.');
1314 if (p == NULL) break;
1316 if (*p == '\0') break;
1321 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value)
1323 gboolean ret = FALSE;
1324 gchar *rclass = create_class_name(rname);
1325 gchar *rettype, *end;
1328 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1329 retvalue.addr != NULL) {
1330 *value = (gint)strtol(retvalue.addr, &end, 10);
1331 if (end != retvalue.addr)
1339 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value)
1341 gboolean ret = FALSE;
1342 gchar *rclass = create_class_name(rname);
1346 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1347 retvalue.addr != NULL) {
1348 *value = retvalue.addr;
1356 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
1357 const gchar *rname, RrColor **value)
1359 gboolean ret = FALSE;
1360 gchar *rclass = create_class_name(rname);
1364 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1365 retvalue.addr != NULL) {
1366 RrColor *c = RrColorParse(inst, retvalue.addr);
1377 static gboolean read_mask(const RrInstance *inst, const gchar *path,
1378 const gchar *maskname, RrTheme *theme,
1379 RrPixmapMask **value)
1381 gboolean ret = FALSE;
1383 gint hx, hy; /* ignored */
1387 s = g_build_filename(path, maskname, NULL);
1388 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
1390 *value = RrPixmapMaskNew(inst, w, h, (gchar*)b);
1398 static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
1399 RrReliefType *relief, RrBevelType *bevel,
1400 gboolean *interlaced, gboolean *border,
1401 gboolean allow_trans)
1405 /* convert to all lowercase */
1406 for (t = tex; *t != '\0'; ++t)
1407 *t = g_ascii_tolower(*t);
1409 if (allow_trans && strstr(tex, "parentrelative") != NULL) {
1410 *grad = RR_SURFACE_PARENTREL;
1412 if (strstr(tex, "gradient") != NULL) {
1413 if (strstr(tex, "crossdiagonal") != NULL)
1414 *grad = RR_SURFACE_CROSS_DIAGONAL;
1415 else if (strstr(tex, "pyramid") != NULL)
1416 *grad = RR_SURFACE_PYRAMID;
1417 else if (strstr(tex, "mirrorhorizontal") != NULL)
1418 *grad = RR_SURFACE_MIRROR_HORIZONTAL;
1419 else if (strstr(tex, "horizontal") != NULL)
1420 *grad = RR_SURFACE_HORIZONTAL;
1421 else if (strstr(tex, "splitvertical") != NULL)
1422 *grad = RR_SURFACE_SPLIT_VERTICAL;
1423 else if (strstr(tex, "vertical") != NULL)
1424 *grad = RR_SURFACE_VERTICAL;
1426 *grad = RR_SURFACE_DIAGONAL;
1428 *grad = RR_SURFACE_SOLID;
1431 if (strstr(tex, "sunken") != NULL)
1432 *relief = RR_RELIEF_SUNKEN;
1433 else if (strstr(tex, "flat") != NULL)
1434 *relief = RR_RELIEF_FLAT;
1436 *relief = RR_RELIEF_RAISED;
1439 if (*relief == RR_RELIEF_FLAT) {
1440 if (strstr(tex, "border") != NULL)
1443 if (strstr(tex, "bevel2") != NULL)
1444 *bevel = RR_BEVEL_2;
1446 *bevel = RR_BEVEL_1;
1449 if (strstr(tex, "interlaced") != NULL)
1452 *interlaced = FALSE;
1457 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
1458 const gchar *rname, RrAppearance *value,
1459 gboolean allow_trans)
1461 gboolean ret = FALSE;
1462 gchar *rclass = create_class_name(rname);
1463 gchar *cname, *ctoname, *bcname, *icname;
1467 cname = g_strconcat(rname, ".color", NULL);
1468 ctoname = g_strconcat(rname, ".colorTo", NULL);
1469 bcname = g_strconcat(rname, ".border.color", NULL);
1470 icname = g_strconcat(rname, ".interlace.color", NULL);
1472 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1473 retvalue.addr != NULL) {
1474 parse_appearance(retvalue.addr,
1475 &value->surface.grad,
1476 &value->surface.relief,
1477 &value->surface.bevel,
1478 &value->surface.interlaced,
1479 &value->surface.border,
1481 if (!read_color(db, inst, cname, &value->surface.primary))
1482 value->surface.primary = RrColorNew(inst, 0, 0, 0);
1483 if (!read_color(db, inst, ctoname, &value->surface.secondary))
1484 value->surface.secondary = RrColorNew(inst, 0, 0, 0);
1485 if (value->surface.border)
1486 if (!read_color(db, inst, bcname,
1487 &value->surface.border_color))
1488 value->surface.border_color = RrColorNew(inst, 0, 0, 0);
1489 if (value->surface.interlaced)
1490 if (!read_color(db, inst, icname,
1491 &value->surface.interlace_color))
1492 value->surface.interlace_color = RrColorNew(inst, 0, 0, 0);
1504 static int parse_inline_number(const char *p)
1512 for (; isdigit(*p); ++p)
1513 res = res * 10 + *p - '0';
1518 static void set_default_appearance(RrAppearance *a)
1520 a->surface.grad = RR_SURFACE_SOLID;
1521 a->surface.relief = RR_RELIEF_FLAT;
1522 a->surface.bevel = RR_BEVEL_1;
1523 a->surface.interlaced = FALSE;
1524 a->surface.border = FALSE;
1525 a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
1526 a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
1529 /* Reads the output from gimp's C-Source file format into valid RGBA data for
1530 an RrTextureRGBA. */
1531 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data)
1536 p = im = g_memdup(data, width * height * sizeof(RrPixel32));
1538 for (i = 0; i < width * height; ++i) {
1539 guchar a = ((*p >> 24) & 0xff);
1540 guchar b = ((*p >> 16) & 0xff);
1541 guchar g = ((*p >> 8) & 0xff);
1542 guchar r = ((*p >> 0) & 0xff);
1544 *p = ((r << RrDefaultRedOffset) +
1545 (g << RrDefaultGreenOffset) +
1546 (b << RrDefaultBlueOffset) +
1547 (a << RrDefaultAlphaOffset));