1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 theme.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 See the COPYING file for a copy of the GNU General Public License.
26 #include "parser/parse.h"
29 #include <X11/Xresource.h>
34 static XrmDatabase loaddb(const gchar *name, gchar **path);
35 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value);
36 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value);
37 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
38 const gchar *rname, RrColor **value);
39 static gboolean read_mask(const RrInstance *inst, const gchar *path,
40 RrTheme *theme, const gchar *maskname,
41 RrPixmapMask **value);
42 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
43 const gchar *rname, RrAppearance *value,
44 gboolean allow_trans);
45 static int parse_inline_number(const char *p);
46 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data);
47 static void set_default_appearance(RrAppearance *a);
49 RrTheme* RrThemeNew(const RrInstance *inst, gchar *name,
50 gboolean allow_fallback,
51 RrFont *active_window_font, RrFont *inactive_window_font,
52 RrFont *menu_title_font, RrFont *menu_item_font,
55 XrmDatabase db = NULL;
56 RrJustify winjust, mtitlejust;
63 db = loaddb(name, &path);
65 g_message("Unable to load the theme '%s'", name);
67 g_message("Falling back to the default theme '%s'",
69 /* fallback to the default theme */
73 if (name == NULL && allow_fallback) {
74 db = loaddb(DEFAULT_THEME, &path);
76 g_message("Unable to load the theme '%s'", DEFAULT_THEME);
83 theme = g_new0(RrTheme, 1);
86 theme->name = g_strdup(name ? name : DEFAULT_THEME);
88 theme->a_disabled_focused_max = RrAppearanceNew(inst, 1);
89 theme->a_disabled_unfocused_max = RrAppearanceNew(inst, 1);
90 theme->a_hover_focused_max = RrAppearanceNew(inst, 1);
91 theme->a_hover_unfocused_max = RrAppearanceNew(inst, 1);
92 theme->a_toggled_focused_unpressed_max = RrAppearanceNew(inst, 1);
93 theme->a_toggled_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
94 theme->a_focused_unpressed_max = RrAppearanceNew(inst, 1);
95 theme->a_focused_pressed_max = RrAppearanceNew(inst, 1);
96 theme->a_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
97 theme->a_unfocused_pressed_max = RrAppearanceNew(inst, 1);
98 theme->a_focused_grip = RrAppearanceNew(inst, 0);
99 theme->a_unfocused_grip = RrAppearanceNew(inst, 0);
100 theme->a_focused_title = RrAppearanceNew(inst, 0);
101 theme->a_unfocused_title = RrAppearanceNew(inst, 0);
102 theme->a_focused_label = RrAppearanceNew(inst, 1);
103 theme->a_unfocused_label = RrAppearanceNew(inst, 1);
104 theme->a_icon = RrAppearanceNew(inst, 1);
105 theme->a_focused_handle = RrAppearanceNew(inst, 0);
106 theme->a_unfocused_handle = RrAppearanceNew(inst, 0);
107 theme->a_menu = RrAppearanceNew(inst, 0);
108 theme->a_menu_title = RrAppearanceNew(inst, 0);
109 theme->a_menu_text_title = RrAppearanceNew(inst, 1);
110 theme->a_menu_normal = RrAppearanceNew(inst, 0);
111 theme->a_menu_selected = RrAppearanceNew(inst, 0);
112 theme->a_menu_disabled = RrAppearanceNew(inst, 0);
113 theme->a_menu_disabled_selected = RrAppearanceNew(inst, 0);
114 theme->a_menu_text_normal = RrAppearanceNew(inst, 1);
115 theme->a_menu_text_selected = RrAppearanceNew(inst, 1);
116 theme->a_menu_text_disabled = RrAppearanceNew(inst, 1);
117 theme->a_menu_text_disabled_selected = RrAppearanceNew(inst, 1);
118 theme->a_menu_bullet_normal = RrAppearanceNew(inst, 1);
119 theme->a_menu_bullet_selected = RrAppearanceNew(inst, 1);
120 theme->a_clear = RrAppearanceNew(inst, 0);
121 theme->a_clear_tex = RrAppearanceNew(inst, 1);
123 /* load the font stuff */
124 if (active_window_font) {
125 theme->win_font_focused = active_window_font;
126 RrFontRef(active_window_font);
128 theme->win_font_focused = RrFontOpenDefault(inst);
130 if (inactive_window_font) {
131 theme->win_font_unfocused = inactive_window_font;
132 RrFontRef(inactive_window_font);
134 theme->win_font_unfocused = RrFontOpenDefault(inst);
136 winjust = RR_JUSTIFY_LEFT;
137 if (read_string(db, "window.label.text.justify", &str)) {
138 if (!g_ascii_strcasecmp(str, "right"))
139 winjust = RR_JUSTIFY_RIGHT;
140 else if (!g_ascii_strcasecmp(str, "center"))
141 winjust = RR_JUSTIFY_CENTER;
144 if (menu_title_font) {
145 theme->menu_title_font = menu_title_font;
146 RrFontRef(menu_title_font);
148 theme->menu_title_font = RrFontOpenDefault(inst);
150 mtitlejust = RR_JUSTIFY_LEFT;
151 if (read_string(db, "menu.title.text.justify", &str)) {
152 if (!g_ascii_strcasecmp(str, "right"))
153 mtitlejust = RR_JUSTIFY_RIGHT;
154 else if (!g_ascii_strcasecmp(str, "center"))
155 mtitlejust = RR_JUSTIFY_CENTER;
158 if (menu_item_font) {
159 theme->menu_font = menu_item_font;
160 RrFontRef(menu_item_font);
162 theme->menu_font = RrFontOpenDefault(inst);
165 theme->osd_font = osd_font;
168 theme->osd_font = RrFontOpenDefault(inst);
170 /* load direct dimensions */
171 if (!read_int(db, "menu.overlap", &theme->menu_overlap) ||
172 theme->menu_overlap < 0 || theme->menu_overlap > 20)
173 theme->menu_overlap = 0;
174 if (!read_int(db, "window.handle.width", &theme->handle_height) ||
175 theme->handle_height < 0 || theme->handle_height > 100)
176 theme->handle_height = 6;
177 if (!read_int(db, "padding.width", &theme->paddingx) ||
178 theme->paddingx < 0 || theme->paddingx > 100)
180 theme->paddingy = theme->paddingx;
181 if (!read_int(db, "border.width", &theme->fbwidth) ||
182 theme->fbwidth < 0 || theme->fbwidth > 100)
184 /* menu border width inherits from the frame border width */
185 if (!read_int(db, "menu.border.width", &theme->mbwidth) ||
186 theme->mbwidth < 0 || theme->mbwidth > 100)
187 theme->mbwidth = theme->fbwidth;
188 theme->mbwidth = theme->fbwidth;
189 if (!read_int(db, "window.client.padding.width", &theme->cbwidthx) ||
190 theme->cbwidthx < 0 || theme->cbwidthx > 100)
191 theme->cbwidthx = theme->paddingx;
192 theme->cbwidthy = theme->cbwidthx;
195 if (!read_color(db, inst,
196 "window.active.border.color",
197 &theme->frame_focused_border_color) &&
198 !read_color(db, inst,
200 &theme->frame_focused_border_color))
201 theme->frame_focused_border_color = RrColorNew(inst, 0, 0, 0);
202 /* unfocused border color inherits from frame focused border color */
203 if (!read_color(db, inst,
204 "window.inactive.border.color",
205 &theme->frame_unfocused_border_color))
206 theme->frame_unfocused_border_color = RrColorNew(inst, 0, 0, 0);
207 /* menu border color inherits from frame focused border color */
208 if (!read_color(db, inst,
210 &theme->menu_border_color))
211 theme->menu_border_color = RrColorNew(inst,
212 theme->frame_focused_border_color->r,
213 theme->frame_focused_border_color->g,
214 theme->frame_focused_border_color->b);
215 if (!read_color(db, inst,
216 "window.active.client.color",
217 &theme->cb_focused_color))
218 theme->cb_focused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
219 if (!read_color(db, inst,
220 "window.inactive.client.color",
221 &theme->cb_unfocused_color))
222 theme->cb_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
223 if (!read_color(db, inst,
224 "window.active.label.text.color",
225 &theme->title_focused_color))
226 theme->title_focused_color = RrColorNew(inst, 0x0, 0x0, 0x0);
227 theme->osd_color = RrColorNew(inst,
228 theme->title_focused_color->r,
229 theme->title_focused_color->g,
230 theme->title_focused_color->b);
231 if (!read_color(db, inst,
232 "window.inactive.label.text.color",
233 &theme->title_unfocused_color))
234 theme->title_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
235 if (!read_color(db, inst,
236 "window.active.button.unpressed.image.color",
237 &theme->titlebut_focused_unpressed_color))
238 theme->titlebut_focused_unpressed_color = RrColorNew(inst, 0, 0, 0);
239 if (!read_color(db, inst,
240 "window.inactive.button.unpressed.image.color",
241 &theme->titlebut_unfocused_unpressed_color))
242 theme->titlebut_unfocused_unpressed_color =
243 RrColorNew(inst, 0xff, 0xff, 0xff);
244 if (!read_color(db, inst,
245 "window.active.button.pressed.image.color",
246 &theme->titlebut_focused_pressed_color))
247 theme->titlebut_focused_pressed_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.pressed.image.color",
254 &theme->titlebut_unfocused_pressed_color))
255 theme->titlebut_unfocused_pressed_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.disabled.image.color",
262 &theme->titlebut_disabled_focused_color))
263 theme->titlebut_disabled_focused_color =
264 RrColorNew(inst, 0xff, 0xff, 0xff);
265 if (!read_color(db, inst,
266 "window.inactive.button.disabled.image.color",
267 &theme->titlebut_disabled_unfocused_color))
268 theme->titlebut_disabled_unfocused_color = RrColorNew(inst, 0, 0, 0);
269 if (!read_color(db, inst,
270 "window.active.button.hover.image.color",
271 &theme->titlebut_hover_focused_color))
272 theme->titlebut_hover_focused_color =
274 theme->titlebut_focused_unpressed_color->r,
275 theme->titlebut_focused_unpressed_color->g,
276 theme->titlebut_focused_unpressed_color->b);
277 if (!read_color(db, inst,
278 "window.inactive.button.hover.image.color",
279 &theme->titlebut_hover_unfocused_color))
280 theme->titlebut_hover_unfocused_color =
282 theme->titlebut_unfocused_unpressed_color->r,
283 theme->titlebut_unfocused_unpressed_color->g,
284 theme->titlebut_unfocused_unpressed_color->b);
285 if (!read_color(db, inst,
286 "window.active.button.toggled.image.color",
287 &theme->titlebut_toggled_focused_unpressed_color))
288 theme->titlebut_toggled_focused_unpressed_color =
290 theme->titlebut_focused_pressed_color->r,
291 theme->titlebut_focused_pressed_color->g,
292 theme->titlebut_focused_pressed_color->b);
293 if (!read_color(db, inst,
294 "window.inactive.button.toggled.image.color",
295 &theme->titlebut_toggled_unfocused_unpressed_color))
296 theme->titlebut_toggled_unfocused_unpressed_color =
298 theme->titlebut_unfocused_pressed_color->r,
299 theme->titlebut_unfocused_pressed_color->g,
300 theme->titlebut_unfocused_pressed_color->b);
301 if (!read_color(db, inst,
302 "menu.title.text.color", &theme->menu_title_color))
303 theme->menu_title_color = RrColorNew(inst, 0, 0, 0);
304 if (!read_color(db, inst,
305 "menu.items.text.color", &theme->menu_color))
306 theme->menu_color = RrColorNew(inst, 0xff, 0xff, 0xff);
307 if (!read_color(db, inst,
308 "menu.items.disabled.text.color",
309 &theme->menu_disabled_color))
310 theme->menu_disabled_color = RrColorNew(inst, 0, 0, 0);
311 if (!read_color(db, inst,
312 "menu.items.activedisabled.text.color",
313 &theme->menu_disabled_selected_color))
314 theme->menu_disabled_selected_color =
316 theme->menu_disabled_color->r,
317 theme->menu_disabled_color->g,
318 theme->menu_disabled_color->b);
319 if (!read_color(db, inst,
320 "menu.items.active.text.color",
321 &theme->menu_selected_color))
322 theme->menu_selected_color = RrColorNew(inst, 0, 0, 0);
324 /* toggled hover = toggled unpressed (i.e. no change) */
325 theme->titlebut_toggled_hover_focused_color =
327 theme->titlebut_toggled_focused_unpressed_color->r,
328 theme->titlebut_toggled_focused_unpressed_color->g,
329 theme->titlebut_toggled_focused_unpressed_color->b);
330 theme->titlebut_toggled_hover_unfocused_color =
332 theme->titlebut_toggled_unfocused_unpressed_color->r,
333 theme->titlebut_toggled_unfocused_unpressed_color->g,
334 theme->titlebut_toggled_unfocused_unpressed_color->b);
335 /* toggled pressed = pressed (which is the toggled unpressed fallback..) */
336 theme->titlebut_toggled_focused_pressed_color =
338 theme->titlebut_focused_pressed_color->r,
339 theme->titlebut_focused_pressed_color->g,
340 theme->titlebut_focused_pressed_color->b);
341 theme->titlebut_toggled_unfocused_pressed_color =
343 theme->titlebut_unfocused_pressed_color->r,
344 theme->titlebut_unfocused_pressed_color->g,
345 theme->titlebut_unfocused_pressed_color->b);
347 /* load the image masks */
349 /* maximize button masks */
351 if (!read_mask(inst, path, theme, "max.xbm", &theme->max_mask)) {
352 guchar data[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
353 theme->max_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
356 if (!read_mask(inst, path, theme, "max_toggled.xbm",
357 &theme->max_toggled_mask))
360 theme->max_toggled_mask = RrPixmapMaskCopy(theme->max_mask);
362 guchar data[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
363 theme->max_toggled_mask = RrPixmapMaskNew(inst, 6, 6,(gchar*)data);
366 if (!read_mask(inst, path, theme, "max_pressed.xbm",
367 &theme->max_pressed_mask))
368 theme->max_pressed_mask = RrPixmapMaskCopy(theme->max_mask);
369 if (!read_mask(inst,path,theme,"max_disabled.xbm",
370 &theme->max_disabled_mask))
371 theme->max_disabled_mask = RrPixmapMaskCopy(theme->max_mask);
372 if (!read_mask(inst, path, theme, "max_hover.xbm", &theme->max_hover_mask))
373 theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask);
374 if (!read_mask(inst, path, theme, "max_toggled_pressed.xbm",
375 &theme->max_toggled_pressed_mask))
376 theme->max_toggled_pressed_mask =
377 RrPixmapMaskCopy(theme->max_toggled_mask);
378 if (!read_mask(inst, path, theme, "max_toggled_hover.xbm",
379 &theme->max_toggled_hover_mask))
380 theme->max_toggled_hover_mask =
381 RrPixmapMaskCopy(theme->max_toggled_mask);
383 /* iconify button masks */
384 if (!read_mask(inst, path, theme, "iconify.xbm", &theme->iconify_mask)) {
385 guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
386 theme->iconify_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
388 if (!read_mask(inst, path, theme, "iconify_pressed.xbm",
389 &theme->iconify_pressed_mask))
390 theme->iconify_pressed_mask = RrPixmapMaskCopy(theme->iconify_mask);
391 if (!read_mask(inst, path, theme, "iconify_disabled.xbm",
392 &theme->iconify_disabled_mask))
393 theme->iconify_disabled_mask = RrPixmapMaskCopy(theme->iconify_mask);
394 if (!read_mask(inst, path, theme, "iconify_hover.xbm",
395 &theme->iconify_hover_mask))
396 theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
398 /* all desktops button masks */
400 if (!read_mask(inst, path, theme, "desk.xbm", &theme->desk_mask)) {
401 guchar data[] = { 0x33, 0x33, 0x00, 0x00, 0x33, 0x33 };
402 theme->desk_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
405 if (!read_mask(inst, path, theme, "desk_toggled.xbm",
406 &theme->desk_toggled_mask)) {
408 theme->desk_toggled_mask = RrPixmapMaskCopy(theme->desk_mask);
410 guchar data[] = { 0x00, 0x1e, 0x1a, 0x16, 0x1e, 0x00 };
411 theme->desk_toggled_mask =
412 RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
415 if (!read_mask(inst, path, theme, "desk_pressed.xbm",
416 &theme->desk_pressed_mask))
417 theme->desk_pressed_mask = RrPixmapMaskCopy(theme->desk_mask);
418 if (!read_mask(inst, path, theme, "desk_disabled.xbm",
419 &theme->desk_disabled_mask))
420 theme->desk_disabled_mask = RrPixmapMaskCopy(theme->desk_mask);
421 if (!read_mask(inst, path, theme, "desk_hover.xbm",
422 &theme->desk_hover_mask))
423 theme->desk_hover_mask = RrPixmapMaskCopy(theme->desk_mask);
424 if (!read_mask(inst, path, theme, "desk_toggled_pressed.xbm",
425 &theme->desk_toggled_pressed_mask))
426 theme->desk_toggled_pressed_mask =
427 RrPixmapMaskCopy(theme->desk_toggled_mask);
428 if (!read_mask(inst, path, theme, "desk_toggled_hover.xbm",
429 &theme->desk_toggled_hover_mask))
430 theme->desk_toggled_hover_mask =
431 RrPixmapMaskCopy(theme->desk_toggled_mask);
433 /* shade button masks */
434 if (!read_mask(inst, path, theme, "shade.xbm", &theme->shade_mask)) {
435 guchar data[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
436 theme->shade_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
438 if (!read_mask(inst, path, theme, "shade_toggled.xbm",
439 &theme->shade_toggled_mask))
440 theme->shade_toggled_mask = RrPixmapMaskCopy(theme->shade_mask);
441 if (!read_mask(inst, path, theme, "shade_pressed.xbm",
442 &theme->shade_pressed_mask))
443 theme->shade_pressed_mask = RrPixmapMaskCopy(theme->shade_mask);
444 if (!read_mask(inst, path, theme, "shade_disabled.xbm",
445 &theme->shade_disabled_mask))
446 theme->shade_disabled_mask = RrPixmapMaskCopy(theme->shade_mask);
447 if (!read_mask(inst, path, theme, "shade_hover.xbm",
448 &theme->shade_hover_mask))
449 theme->shade_hover_mask = RrPixmapMaskCopy(theme->shade_mask);
450 if (!read_mask(inst, path, theme, "shade_toggled_pressed.xbm",
451 &theme->shade_toggled_pressed_mask))
452 theme->shade_toggled_pressed_mask =
453 RrPixmapMaskCopy(theme->shade_toggled_mask);
454 if (!read_mask(inst, path, theme, "shade_toggled_hover.xbm",
455 &theme->shade_toggled_hover_mask))
456 theme->shade_toggled_hover_mask =
457 RrPixmapMaskCopy(theme->shade_toggled_mask);
459 /* close button masks */
460 if (!read_mask(inst, path, theme, "close.xbm", &theme->close_mask)) {
461 guchar data[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
462 theme->close_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
464 if (!read_mask(inst, path, theme, "close_pressed.xbm",
465 &theme->close_pressed_mask))
466 theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask);
467 if (!read_mask(inst, path, theme, "close_disabled.xbm",
468 &theme->close_disabled_mask))
469 theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask);
470 if (!read_mask(inst, path, theme, "close_hover.xbm",
471 &theme->close_hover_mask))
472 theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask);
474 /* submenu bullet mask */
475 if (!read_mask(inst, path, theme, "bullet.xbm", &theme->menu_bullet_mask))
477 guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
478 theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data);
481 /* setup the default window icon */
482 theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
483 OB_DEFAULT_ICON_HEIGHT,
484 OB_DEFAULT_ICON_pixel_data);
486 /* the toggled hover mask = the toggled unpressed mask (i.e. no change) */
487 theme->max_toggled_hover_mask =
488 RrPixmapMaskCopy(theme->max_toggled_mask);
489 theme->desk_toggled_hover_mask =
490 RrPixmapMaskCopy(theme->desk_toggled_mask);
491 theme->shade_toggled_hover_mask =
492 RrPixmapMaskCopy(theme->shade_toggled_mask);
493 /* the toggled pressed mask = the toggled unpressed mask (i.e. no change)*/
494 theme->max_toggled_pressed_mask =
495 RrPixmapMaskCopy(theme->max_toggled_mask);
496 theme->desk_toggled_pressed_mask =
497 RrPixmapMaskCopy(theme->desk_toggled_mask);
498 theme->shade_toggled_pressed_mask =
499 RrPixmapMaskCopy(theme->shade_toggled_mask);
501 /* read the decoration textures */
502 if (!read_appearance(db, inst,
503 "window.active.title.bg", theme->a_focused_title,
505 set_default_appearance(theme->a_focused_title);
506 if (!read_appearance(db, inst,
507 "window.inactive.title.bg", theme->a_unfocused_title,
509 set_default_appearance(theme->a_unfocused_title);
510 if (!read_appearance(db, inst,
511 "window.active.label.bg", theme->a_focused_label,
513 set_default_appearance(theme->a_focused_label);
514 if (!read_appearance(db, inst,
515 "window.inactive.label.bg", theme->a_unfocused_label,
517 set_default_appearance(theme->a_unfocused_label);
518 if (!read_appearance(db, inst,
519 "window.active.handle.bg", theme->a_focused_handle,
521 set_default_appearance(theme->a_focused_handle);
522 if (!read_appearance(db, inst,
523 "window.inactive.handle.bg",theme->a_unfocused_handle,
525 set_default_appearance(theme->a_unfocused_handle);
526 if (!read_appearance(db, inst,
527 "window.active.grip.bg", theme->a_focused_grip,
529 set_default_appearance(theme->a_focused_grip);
530 if (!read_appearance(db, inst,
531 "window.inactive.grip.bg", theme->a_unfocused_grip,
533 set_default_appearance(theme->a_unfocused_grip);
534 if (!read_appearance(db, inst,
535 "menu.items.bg", theme->a_menu,
537 set_default_appearance(theme->a_menu);
538 if (!read_appearance(db, inst,
539 "menu.title.bg", theme->a_menu_title,
541 set_default_appearance(theme->a_menu_title);
542 if (!read_appearance(db, inst,
543 "menu.items.active.bg", theme->a_menu_selected,
545 set_default_appearance(theme->a_menu_selected);
546 theme->a_menu_disabled_selected =
547 RrAppearanceCopy(theme->a_menu_selected);
549 /* read the appearances for rendering non-decorations */
550 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_title);
551 theme->osd_hilite_label = RrAppearanceCopy(theme->a_focused_label);
552 if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL)
553 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_label);
555 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_title);
556 if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL)
557 theme->osd_unhilite_fg = RrAppearanceCopy(theme->a_unfocused_label);
559 theme->osd_unhilite_fg = RrAppearanceCopy(theme->a_unfocused_title);
561 /* read buttons textures */
562 if (!read_appearance(db, inst,
563 "window.active.button.disabled.bg",
564 theme->a_disabled_focused_max,
566 set_default_appearance(theme->a_disabled_focused_max);
567 if (!read_appearance(db, inst,
568 "window.inactive.button.disabled.bg",
569 theme->a_disabled_unfocused_max,
571 set_default_appearance(theme->a_disabled_unfocused_max);
572 if (!read_appearance(db, inst,
573 "window.active.button.pressed.bg",
574 theme->a_focused_pressed_max,
576 set_default_appearance(theme->a_focused_pressed_max);
577 if (!read_appearance(db, inst,
578 "window.inactive.button.pressed.bg",
579 theme->a_unfocused_pressed_max,
581 set_default_appearance(theme->a_unfocused_pressed_max);
582 if (!read_appearance(db, inst,
583 "window.active.button.toggled.bg",
584 theme->a_toggled_focused_unpressed_max,
587 RrAppearanceFree(theme->a_toggled_focused_unpressed_max);
588 theme->a_toggled_focused_unpressed_max =
589 RrAppearanceCopy(theme->a_focused_pressed_max);
591 if (!read_appearance(db, inst,
592 "window.inactive.button.toggled.bg",
593 theme->a_toggled_unfocused_unpressed_max,
596 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_max);
597 theme->a_toggled_unfocused_unpressed_max =
598 RrAppearanceCopy(theme->a_unfocused_pressed_max);
600 if (!read_appearance(db, inst,
601 "window.active.button.unpressed.bg",
602 theme->a_focused_unpressed_max,
604 set_default_appearance(theme->a_focused_unpressed_max);
605 if (!read_appearance(db, inst,
606 "window.inactive.button.unpressed.bg",
607 theme->a_unfocused_unpressed_max,
609 set_default_appearance(theme->a_unfocused_unpressed_max);
610 if (!read_appearance(db, inst,
611 "window.active.button.hover.bg",
612 theme->a_hover_focused_max,
615 RrAppearanceFree(theme->a_hover_focused_max);
616 theme->a_hover_focused_max =
617 RrAppearanceCopy(theme->a_focused_unpressed_max);
619 if (!read_appearance(db, inst,
620 "window.inactive.button.hover.bg",
621 theme->a_hover_unfocused_max,
624 RrAppearanceFree(theme->a_hover_unfocused_max);
625 theme->a_hover_unfocused_max =
626 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
629 /* toggled + hover = toggled unpressed (i.e. no change) */
630 theme->a_toggled_hover_focused_max =
631 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
632 theme->a_toggled_hover_unfocused_max =
633 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
634 /* toggled + pressed = pressed (which is the toggled fallback..) */
635 theme->a_toggled_focused_pressed_max =
636 RrAppearanceCopy(theme->a_focused_pressed_max);
637 theme->a_toggled_unfocused_pressed_max =
638 RrAppearanceCopy(theme->a_unfocused_pressed_max);
640 theme->a_disabled_focused_close =
641 RrAppearanceCopy(theme->a_disabled_focused_max);
642 theme->a_disabled_unfocused_close =
643 RrAppearanceCopy(theme->a_disabled_unfocused_max);
644 theme->a_hover_focused_close =
645 RrAppearanceCopy(theme->a_hover_focused_max);
646 theme->a_hover_unfocused_close =
647 RrAppearanceCopy(theme->a_hover_unfocused_max);
648 theme->a_unfocused_unpressed_close =
649 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
650 theme->a_unfocused_pressed_close =
651 RrAppearanceCopy(theme->a_unfocused_pressed_max);
652 theme->a_focused_unpressed_close =
653 RrAppearanceCopy(theme->a_focused_unpressed_max);
654 theme->a_focused_pressed_close =
655 RrAppearanceCopy(theme->a_focused_pressed_max);
656 theme->a_disabled_focused_desk =
657 RrAppearanceCopy(theme->a_disabled_focused_max);
658 theme->a_disabled_unfocused_desk =
659 RrAppearanceCopy(theme->a_disabled_unfocused_max);
660 theme->a_hover_focused_desk =
661 RrAppearanceCopy(theme->a_hover_focused_max);
662 theme->a_hover_unfocused_desk =
663 RrAppearanceCopy(theme->a_hover_unfocused_max);
664 theme->a_toggled_hover_focused_desk =
665 RrAppearanceCopy(theme->a_toggled_hover_focused_max);
666 theme->a_toggled_hover_unfocused_desk =
667 RrAppearanceCopy(theme->a_toggled_hover_unfocused_max);
668 theme->a_toggled_focused_unpressed_desk =
669 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
670 theme->a_toggled_unfocused_unpressed_desk =
671 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
672 theme->a_toggled_focused_pressed_desk =
673 RrAppearanceCopy(theme->a_toggled_focused_pressed_max);
674 theme->a_toggled_unfocused_pressed_desk =
675 RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max);
676 theme->a_unfocused_unpressed_desk =
677 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
678 theme->a_unfocused_pressed_desk =
679 RrAppearanceCopy(theme->a_unfocused_pressed_max);
680 theme->a_focused_unpressed_desk =
681 RrAppearanceCopy(theme->a_focused_unpressed_max);
682 theme->a_focused_pressed_desk =
683 RrAppearanceCopy(theme->a_focused_pressed_max);
684 theme->a_disabled_focused_shade =
685 RrAppearanceCopy(theme->a_disabled_focused_max);
686 theme->a_disabled_unfocused_shade =
687 RrAppearanceCopy(theme->a_disabled_unfocused_max);
688 theme->a_hover_focused_shade =
689 RrAppearanceCopy(theme->a_hover_focused_max);
690 theme->a_hover_unfocused_shade =
691 RrAppearanceCopy(theme->a_hover_unfocused_max);
692 theme->a_toggled_hover_focused_shade =
693 RrAppearanceCopy(theme->a_toggled_hover_focused_max);
694 theme->a_toggled_hover_unfocused_shade =
695 RrAppearanceCopy(theme->a_toggled_hover_unfocused_max);
696 theme->a_toggled_focused_unpressed_shade =
697 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
698 theme->a_toggled_unfocused_unpressed_shade =
699 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
700 theme->a_toggled_focused_pressed_shade =
701 RrAppearanceCopy(theme->a_toggled_focused_pressed_max);
702 theme->a_toggled_unfocused_pressed_shade =
703 RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max);
704 theme->a_unfocused_unpressed_shade =
705 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
706 theme->a_unfocused_pressed_shade =
707 RrAppearanceCopy(theme->a_unfocused_pressed_max);
708 theme->a_focused_unpressed_shade =
709 RrAppearanceCopy(theme->a_focused_unpressed_max);
710 theme->a_focused_pressed_shade =
711 RrAppearanceCopy(theme->a_focused_pressed_max);
712 theme->a_disabled_focused_iconify =
713 RrAppearanceCopy(theme->a_disabled_focused_max);
714 theme->a_disabled_unfocused_iconify =
715 RrAppearanceCopy(theme->a_disabled_focused_max);
716 theme->a_hover_focused_iconify =
717 RrAppearanceCopy(theme->a_hover_focused_max);
718 theme->a_hover_unfocused_iconify =
719 RrAppearanceCopy(theme->a_hover_unfocused_max);
720 theme->a_unfocused_unpressed_iconify =
721 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
722 theme->a_unfocused_pressed_iconify =
723 RrAppearanceCopy(theme->a_unfocused_pressed_max);
724 theme->a_focused_unpressed_iconify =
725 RrAppearanceCopy(theme->a_focused_unpressed_max);
726 theme->a_focused_pressed_iconify =
727 RrAppearanceCopy(theme->a_focused_pressed_max);
729 theme->a_icon->surface.grad =
730 theme->a_clear->surface.grad =
731 theme->a_clear_tex->surface.grad =
732 theme->a_menu_text_title->surface.grad =
733 theme->a_menu_normal->surface.grad =
734 theme->a_menu_disabled->surface.grad =
735 theme->a_menu_text_normal->surface.grad =
736 theme->a_menu_text_selected->surface.grad =
737 theme->a_menu_text_disabled->surface.grad =
738 theme->a_menu_text_disabled_selected->surface.grad =
739 theme->a_menu_bullet_normal->surface.grad =
740 theme->a_menu_bullet_selected->surface.grad = RR_SURFACE_PARENTREL;
742 /* set up the textures */
743 theme->a_focused_label->texture[0].type =
744 theme->osd_hilite_label->texture[0].type = RR_TEXTURE_TEXT;
745 theme->a_focused_label->texture[0].data.text.justify = winjust;
746 theme->osd_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
747 theme->a_focused_label->texture[0].data.text.font =
748 theme->win_font_focused;
749 theme->osd_hilite_label->texture[0].data.text.font = theme->osd_font;
750 theme->a_focused_label->texture[0].data.text.color =
751 theme->title_focused_color;
752 theme->osd_hilite_label->texture[0].data.text.color =
755 if (read_string(db, "window.active.label.text.font", &str)) {
759 if (strstr(str, "shadow=y")) {
760 if ((p = strstr(str, "shadowoffset=")))
761 i = parse_inline_number(p + strlen("shadowoffset="));
764 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
765 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
766 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x = i;
767 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y = i;
769 if ((p = strstr(str, "shadowtint=")))
771 i = parse_inline_number(p + strlen("shadowtint="));
772 j = (i > 0 ? 0 : 255);
775 theme->title_focused_shadow_color = RrColorNew(inst, j, j, j);
776 theme->title_focused_shadow_alpha = i;
777 theme->osd_shadow_color = RrColorNew(inst, j, j, j);
778 theme->osd_shadow_alpha = i;
780 theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
781 theme->title_focused_shadow_alpha = 50;
782 theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0);
783 theme->osd_shadow_alpha = 50;
787 theme->a_focused_label->texture[0].data.text.shadow_color =
788 theme->title_focused_shadow_color;
789 theme->a_focused_label->texture[0].data.text.shadow_alpha =
790 theme->title_focused_shadow_alpha;
791 theme->osd_hilite_label->texture[0].data.text.shadow_color =
792 theme->osd_shadow_color;
793 theme->osd_hilite_label->texture[0].data.text.shadow_alpha =
794 theme->osd_shadow_alpha;
796 theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT;
797 theme->a_unfocused_label->texture[0].data.text.justify = winjust;
798 theme->a_unfocused_label->texture[0].data.text.font =
799 theme->win_font_unfocused;
800 theme->a_unfocused_label->texture[0].data.text.color =
801 theme->title_unfocused_color;
803 if (read_string(db, "window.inactive.label.text.font", &str)) {
807 if (strstr(str, "shadow=y")) {
808 if ((p = strstr(str, "shadowoffset=")))
809 i = parse_inline_number(p + strlen("shadowoffset="));
812 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x = i;
813 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y = i;
815 if ((p = strstr(str, "shadowtint=")))
817 i = parse_inline_number(p + strlen("shadowtint="));
818 j = (i > 0 ? 0 : 255);
821 theme->title_unfocused_shadow_color = RrColorNew(inst, j, j, j);
822 theme->title_unfocused_shadow_alpha = i;
824 theme->title_unfocused_shadow_color = RrColorNew(inst, 0, 0, 0);
825 theme->title_unfocused_shadow_alpha = 50;
829 theme->a_unfocused_label->texture[0].data.text.shadow_color =
830 theme->title_unfocused_shadow_color;
831 theme->a_unfocused_label->texture[0].data.text.shadow_alpha =
832 theme->title_unfocused_shadow_alpha;
834 theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
835 theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
836 theme->a_menu_text_title->texture[0].data.text.font =
837 theme->menu_title_font;
838 theme->a_menu_text_title->texture[0].data.text.color =
839 theme->menu_title_color;
841 if (read_string(db, "menu.title.text.font", &str)) {
845 if (strstr(str, "shadow=y")) {
846 if ((p = strstr(str, "shadowoffset=")))
847 i = parse_inline_number(p + strlen("shadowoffset="));
850 theme->a_menu_text_title->texture[0].data.text.shadow_offset_x = i;
851 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y = i;
853 if ((p = strstr(str, "shadowtint=")))
855 i = parse_inline_number(p + strlen("shadowtint="));
856 j = (i > 0 ? 0 : 255);
859 theme->menu_title_shadow_color = RrColorNew(inst, j, j, j);
860 theme->menu_title_shadow_alpha = i;
862 theme->menu_title_shadow_color = RrColorNew(inst, 0, 0, 0);
863 theme->menu_title_shadow_alpha = 50;
867 theme->a_menu_text_title->texture[0].data.text.shadow_color =
868 theme->menu_title_shadow_color;
869 theme->a_menu_text_title->texture[0].data.text.shadow_alpha =
870 theme->menu_title_shadow_alpha;
872 theme->a_menu_text_normal->texture[0].type =
873 theme->a_menu_text_selected->texture[0].type =
874 theme->a_menu_text_disabled->texture[0].type =
875 theme->a_menu_text_disabled_selected->texture[0].type =
877 theme->a_menu_text_normal->texture[0].data.text.justify =
878 theme->a_menu_text_selected->texture[0].data.text.justify =
879 theme->a_menu_text_disabled->texture[0].data.text.justify =
880 theme->a_menu_text_disabled_selected->texture[0].data.text.justify =
882 theme->a_menu_text_normal->texture[0].data.text.font =
883 theme->a_menu_text_selected->texture[0].data.text.font =
884 theme->a_menu_text_disabled->texture[0].data.text.font =
885 theme->a_menu_text_disabled_selected->texture[0].data.text.font =
887 theme->a_menu_text_normal->texture[0].data.text.color = theme->menu_color;
888 theme->a_menu_text_selected->texture[0].data.text.color =
889 theme->menu_selected_color;
890 theme->a_menu_text_disabled->texture[0].data.text.color =
891 theme->menu_disabled_color;
892 theme->a_menu_text_disabled_selected->texture[0].data.text.color =
893 theme->menu_disabled_selected_color;
895 if (read_string(db, "menu.items.font", &str)) {
899 if (strstr(str, "shadow=y")) {
900 if ((p = strstr(str, "shadowoffset=")))
901 i = parse_inline_number(p + strlen("shadowoffset="));
904 theme->a_menu_text_normal->
905 texture[0].data.text.shadow_offset_x = i;
906 theme->a_menu_text_normal->
907 texture[0].data.text.shadow_offset_y = i;
908 theme->a_menu_text_selected->
909 texture[0].data.text.shadow_offset_x = i;
910 theme->a_menu_text_selected->
911 texture[0].data.text.shadow_offset_y = i;
912 theme->a_menu_text_disabled->
913 texture[0].data.text.shadow_offset_x = i;
914 theme->a_menu_text_disabled->
915 texture[0].data.text.shadow_offset_y = i;
916 theme->a_menu_text_disabled_selected->
917 texture[0].data.text.shadow_offset_x = i;
918 theme->a_menu_text_disabled_selected->
919 texture[0].data.text.shadow_offset_y = i;
921 if ((p = strstr(str, "shadowtint=")))
923 i = parse_inline_number(p + strlen("shadowtint="));
924 j = (i > 0 ? 0 : 255);
927 theme->menu_text_normal_shadow_color = RrColorNew(inst, j, j, j);
928 theme->menu_text_selected_shadow_color = RrColorNew(inst, j, j, j);
929 theme->menu_text_disabled_shadow_color = RrColorNew(inst, j, j, j);
930 theme->menu_text_normal_shadow_alpha = i;
931 theme->menu_text_selected_shadow_alpha = i;
932 theme->menu_text_disabled_shadow_alpha = i;
933 theme->menu_text_disabled_selected_shadow_alpha = i;
935 theme->menu_text_normal_shadow_color = RrColorNew(inst, 0, 0, 0);
936 theme->menu_text_selected_shadow_color = RrColorNew(inst, 0, 0, 0);
937 theme->menu_text_disabled_shadow_color = RrColorNew(inst, 0, 0, 0);
938 theme->menu_text_normal_shadow_alpha = 50;
939 theme->menu_text_selected_shadow_alpha = 50;
940 theme->menu_text_disabled_selected_shadow_alpha = 50;
944 theme->a_menu_text_normal->texture[0].data.text.shadow_color =
945 theme->menu_text_normal_shadow_color;
946 theme->a_menu_text_normal->texture[0].data.text.shadow_alpha =
947 theme->menu_text_normal_shadow_alpha;
948 theme->a_menu_text_selected->texture[0].data.text.shadow_color =
949 theme->menu_text_selected_shadow_color;
950 theme->a_menu_text_selected->texture[0].data.text.shadow_alpha =
951 theme->menu_text_selected_shadow_alpha;
952 theme->a_menu_text_disabled->texture[0].data.text.shadow_color =
953 theme->menu_text_disabled_shadow_color;
954 theme->a_menu_text_disabled->texture[0].data.text.shadow_alpha =
955 theme->menu_text_disabled_shadow_alpha;
956 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_color =
957 theme->menu_text_disabled_shadow_color;
958 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_alpha =
959 theme->menu_text_disabled_shadow_alpha;
961 theme->a_disabled_focused_max->texture[0].type =
962 theme->a_disabled_unfocused_max->texture[0].type =
963 theme->a_hover_focused_max->texture[0].type =
964 theme->a_hover_unfocused_max->texture[0].type =
965 theme->a_toggled_hover_focused_max->texture[0].type =
966 theme->a_toggled_hover_unfocused_max->texture[0].type =
967 theme->a_toggled_focused_unpressed_max->texture[0].type =
968 theme->a_toggled_unfocused_unpressed_max->texture[0].type =
969 theme->a_toggled_focused_pressed_max->texture[0].type =
970 theme->a_toggled_unfocused_pressed_max->texture[0].type =
971 theme->a_focused_unpressed_max->texture[0].type =
972 theme->a_focused_pressed_max->texture[0].type =
973 theme->a_unfocused_unpressed_max->texture[0].type =
974 theme->a_unfocused_pressed_max->texture[0].type =
975 theme->a_disabled_focused_close->texture[0].type =
976 theme->a_disabled_unfocused_close->texture[0].type =
977 theme->a_hover_focused_close->texture[0].type =
978 theme->a_hover_unfocused_close->texture[0].type =
979 theme->a_focused_unpressed_close->texture[0].type =
980 theme->a_focused_pressed_close->texture[0].type =
981 theme->a_unfocused_unpressed_close->texture[0].type =
982 theme->a_unfocused_pressed_close->texture[0].type =
983 theme->a_disabled_focused_desk->texture[0].type =
984 theme->a_disabled_unfocused_desk->texture[0].type =
985 theme->a_hover_focused_desk->texture[0].type =
986 theme->a_hover_unfocused_desk->texture[0].type =
987 theme->a_toggled_hover_focused_desk->texture[0].type =
988 theme->a_toggled_hover_unfocused_desk->texture[0].type =
989 theme->a_toggled_focused_unpressed_desk->texture[0].type =
990 theme->a_toggled_unfocused_unpressed_desk->texture[0].type =
991 theme->a_toggled_focused_pressed_desk->texture[0].type =
992 theme->a_toggled_unfocused_pressed_desk->texture[0].type =
993 theme->a_focused_unpressed_desk->texture[0].type =
994 theme->a_focused_pressed_desk->texture[0].type =
995 theme->a_unfocused_unpressed_desk->texture[0].type =
996 theme->a_unfocused_pressed_desk->texture[0].type =
997 theme->a_disabled_focused_shade->texture[0].type =
998 theme->a_disabled_unfocused_shade->texture[0].type =
999 theme->a_hover_focused_shade->texture[0].type =
1000 theme->a_hover_unfocused_shade->texture[0].type =
1001 theme->a_toggled_hover_focused_shade->texture[0].type =
1002 theme->a_toggled_hover_unfocused_shade->texture[0].type =
1003 theme->a_toggled_focused_unpressed_shade->texture[0].type =
1004 theme->a_toggled_unfocused_unpressed_shade->texture[0].type =
1005 theme->a_toggled_focused_pressed_shade->texture[0].type =
1006 theme->a_toggled_unfocused_pressed_shade->texture[0].type =
1007 theme->a_focused_unpressed_shade->texture[0].type =
1008 theme->a_focused_pressed_shade->texture[0].type =
1009 theme->a_unfocused_unpressed_shade->texture[0].type =
1010 theme->a_unfocused_pressed_shade->texture[0].type =
1011 theme->a_disabled_focused_iconify->texture[0].type =
1012 theme->a_disabled_unfocused_iconify->texture[0].type =
1013 theme->a_hover_focused_iconify->texture[0].type =
1014 theme->a_hover_unfocused_iconify->texture[0].type =
1015 theme->a_focused_unpressed_iconify->texture[0].type =
1016 theme->a_focused_pressed_iconify->texture[0].type =
1017 theme->a_unfocused_unpressed_iconify->texture[0].type =
1018 theme->a_unfocused_pressed_iconify->texture[0].type =
1019 theme->a_menu_bullet_normal->texture[0].type =
1020 theme->a_menu_bullet_selected->texture[0].type = RR_TEXTURE_MASK;
1022 theme->a_disabled_focused_max->texture[0].data.mask.mask =
1023 theme->a_disabled_unfocused_max->texture[0].data.mask.mask =
1024 theme->max_disabled_mask;
1025 theme->a_hover_focused_max->texture[0].data.mask.mask =
1026 theme->a_hover_unfocused_max->texture[0].data.mask.mask =
1027 theme->max_hover_mask;
1028 theme->a_focused_pressed_max->texture[0].data.mask.mask =
1029 theme->a_unfocused_pressed_max->texture[0].data.mask.mask =
1030 theme->max_pressed_mask;
1031 theme->a_focused_unpressed_max->texture[0].data.mask.mask =
1032 theme->a_unfocused_unpressed_max->texture[0].data.mask.mask =
1034 theme->a_toggled_hover_focused_max->texture[0].data.mask.mask =
1035 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.mask =
1036 theme->max_toggled_hover_mask;
1037 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.mask =
1038 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.mask =
1039 theme->max_toggled_mask;
1040 theme->a_toggled_focused_pressed_max->texture[0].data.mask.mask =
1041 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.mask =
1042 theme->max_toggled_pressed_mask;
1043 theme->a_disabled_focused_close->texture[0].data.mask.mask =
1044 theme->a_disabled_unfocused_close->texture[0].data.mask.mask =
1045 theme->close_disabled_mask;
1046 theme->a_hover_focused_close->texture[0].data.mask.mask =
1047 theme->a_hover_unfocused_close->texture[0].data.mask.mask =
1048 theme->close_hover_mask;
1049 theme->a_focused_pressed_close->texture[0].data.mask.mask =
1050 theme->a_unfocused_pressed_close->texture[0].data.mask.mask =
1051 theme->close_pressed_mask;
1052 theme->a_focused_unpressed_close->texture[0].data.mask.mask =
1053 theme->a_unfocused_unpressed_close->texture[0].data.mask.mask =
1055 theme->a_disabled_focused_desk->texture[0].data.mask.mask =
1056 theme->a_disabled_unfocused_desk->texture[0].data.mask.mask =
1057 theme->desk_disabled_mask;
1058 theme->a_hover_focused_desk->texture[0].data.mask.mask =
1059 theme->a_hover_unfocused_desk->texture[0].data.mask.mask =
1060 theme->desk_hover_mask;
1061 theme->a_focused_pressed_desk->texture[0].data.mask.mask =
1062 theme->a_unfocused_pressed_desk->texture[0].data.mask.mask =
1063 theme->desk_pressed_mask;
1064 theme->a_focused_unpressed_desk->texture[0].data.mask.mask =
1065 theme->a_unfocused_unpressed_desk->texture[0].data.mask.mask =
1067 theme->a_toggled_hover_focused_desk->texture[0].data.mask.mask =
1068 theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.mask =
1069 theme->desk_toggled_hover_mask;
1070 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.mask =
1071 theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.mask =
1072 theme->desk_toggled_mask;
1073 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.mask =
1074 theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.mask =
1075 theme->desk_toggled_pressed_mask;
1076 theme->a_disabled_focused_shade->texture[0].data.mask.mask =
1077 theme->a_disabled_unfocused_shade->texture[0].data.mask.mask =
1078 theme->shade_disabled_mask;
1079 theme->a_hover_focused_shade->texture[0].data.mask.mask =
1080 theme->a_hover_unfocused_shade->texture[0].data.mask.mask =
1081 theme->shade_hover_mask;
1082 theme->a_focused_pressed_shade->texture[0].data.mask.mask =
1083 theme->a_unfocused_pressed_shade->texture[0].data.mask.mask =
1084 theme->shade_pressed_mask;
1085 theme->a_focused_unpressed_shade->texture[0].data.mask.mask =
1086 theme->a_unfocused_unpressed_shade->texture[0].data.mask.mask =
1088 theme->a_toggled_hover_focused_shade->texture[0].data.mask.mask =
1089 theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.mask =
1090 theme->shade_toggled_hover_mask;
1091 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.mask =
1092 theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.mask =
1093 theme->shade_toggled_mask;
1094 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.mask =
1095 theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.mask =
1096 theme->shade_toggled_pressed_mask;
1097 theme->a_disabled_focused_iconify->texture[0].data.mask.mask =
1098 theme->a_disabled_unfocused_iconify->texture[0].data.mask.mask =
1099 theme->iconify_disabled_mask;
1100 theme->a_hover_focused_iconify->texture[0].data.mask.mask =
1101 theme->a_hover_unfocused_iconify->texture[0].data.mask.mask =
1102 theme->iconify_hover_mask;
1103 theme->a_focused_pressed_iconify->texture[0].data.mask.mask =
1104 theme->a_unfocused_pressed_iconify->texture[0].data.mask.mask =
1105 theme->iconify_pressed_mask;
1106 theme->a_focused_unpressed_iconify->texture[0].data.mask.mask =
1107 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.mask =
1108 theme->iconify_mask;
1109 theme->a_menu_bullet_normal->texture[0].data.mask.mask =
1110 theme->a_menu_bullet_selected->texture[0].data.mask.mask =
1111 theme->menu_bullet_mask;
1112 theme->a_disabled_focused_max->texture[0].data.mask.color =
1113 theme->a_disabled_focused_close->texture[0].data.mask.color =
1114 theme->a_disabled_focused_desk->texture[0].data.mask.color =
1115 theme->a_disabled_focused_shade->texture[0].data.mask.color =
1116 theme->a_disabled_focused_iconify->texture[0].data.mask.color =
1117 theme->titlebut_disabled_focused_color;
1118 theme->a_disabled_unfocused_max->texture[0].data.mask.color =
1119 theme->a_disabled_unfocused_close->texture[0].data.mask.color =
1120 theme->a_disabled_unfocused_desk->texture[0].data.mask.color =
1121 theme->a_disabled_unfocused_shade->texture[0].data.mask.color =
1122 theme->a_disabled_unfocused_iconify->texture[0].data.mask.color =
1123 theme->titlebut_disabled_unfocused_color;
1124 theme->a_hover_focused_max->texture[0].data.mask.color =
1125 theme->a_hover_focused_close->texture[0].data.mask.color =
1126 theme->a_hover_focused_desk->texture[0].data.mask.color =
1127 theme->a_hover_focused_shade->texture[0].data.mask.color =
1128 theme->a_hover_focused_iconify->texture[0].data.mask.color =
1129 theme->titlebut_hover_focused_color;
1130 theme->a_hover_unfocused_max->texture[0].data.mask.color =
1131 theme->a_hover_unfocused_close->texture[0].data.mask.color =
1132 theme->a_hover_unfocused_desk->texture[0].data.mask.color =
1133 theme->a_hover_unfocused_shade->texture[0].data.mask.color =
1134 theme->a_hover_unfocused_iconify->texture[0].data.mask.color =
1135 theme->titlebut_hover_unfocused_color;
1136 theme->a_toggled_hover_focused_max->texture[0].data.mask.color =
1137 theme->a_toggled_hover_focused_desk->texture[0].data.mask.color =
1138 theme->a_toggled_hover_focused_shade->texture[0].data.mask.color =
1139 theme->titlebut_toggled_hover_focused_color;
1140 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.color =
1141 theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.color =
1142 theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.color =
1143 theme->titlebut_toggled_hover_unfocused_color;
1144 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.color =
1145 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.color =
1146 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.color =
1147 theme->titlebut_toggled_focused_unpressed_color;
1148 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.color =
1149 theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.color =
1150 theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.color=
1151 theme->titlebut_toggled_unfocused_unpressed_color;
1152 theme->a_toggled_focused_pressed_max->texture[0].data.mask.color =
1153 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.color =
1154 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.color =
1155 theme->titlebut_toggled_focused_pressed_color;
1156 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.color =
1157 theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.color =
1158 theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.color =
1159 theme->titlebut_toggled_unfocused_pressed_color;
1160 theme->a_focused_unpressed_max->texture[0].data.mask.color =
1161 theme->a_focused_unpressed_close->texture[0].data.mask.color =
1162 theme->a_focused_unpressed_desk->texture[0].data.mask.color =
1163 theme->a_focused_unpressed_shade->texture[0].data.mask.color =
1164 theme->a_focused_unpressed_iconify->texture[0].data.mask.color =
1165 theme->titlebut_focused_unpressed_color;
1166 theme->a_focused_pressed_max->texture[0].data.mask.color =
1167 theme->a_focused_pressed_close->texture[0].data.mask.color =
1168 theme->a_focused_pressed_desk->texture[0].data.mask.color =
1169 theme->a_focused_pressed_shade->texture[0].data.mask.color =
1170 theme->a_focused_pressed_iconify->texture[0].data.mask.color =
1171 theme->titlebut_focused_pressed_color;
1172 theme->a_unfocused_unpressed_max->texture[0].data.mask.color =
1173 theme->a_unfocused_unpressed_close->texture[0].data.mask.color =
1174 theme->a_unfocused_unpressed_desk->texture[0].data.mask.color =
1175 theme->a_unfocused_unpressed_shade->texture[0].data.mask.color =
1176 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.color =
1177 theme->titlebut_unfocused_unpressed_color;
1178 theme->a_unfocused_pressed_max->texture[0].data.mask.color =
1179 theme->a_unfocused_pressed_close->texture[0].data.mask.color =
1180 theme->a_unfocused_pressed_desk->texture[0].data.mask.color =
1181 theme->a_unfocused_pressed_shade->texture[0].data.mask.color =
1182 theme->a_unfocused_pressed_iconify->texture[0].data.mask.color =
1183 theme->titlebut_unfocused_pressed_color;
1184 theme->a_menu_bullet_normal->texture[0].data.mask.color =
1186 theme->a_menu_bullet_selected->texture[0].data.mask.color =
1187 theme->menu_selected_color;
1190 XrmDestroyDatabase(db);
1192 /* set the font heights */
1193 theme->win_font_height = RrFontHeight
1194 (theme->win_font_focused,
1195 theme->a_focused_label->texture[0].data.text.shadow_offset_y);
1196 theme->win_font_height =
1197 MAX(theme->win_font_height,
1199 (theme->win_font_focused,
1200 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y));
1201 theme->menu_title_font_height = RrFontHeight
1202 (theme->menu_title_font,
1203 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y);
1204 theme->menu_font_height = RrFontHeight
1206 theme->a_menu_text_normal->texture[0].data.text.shadow_offset_y);
1208 /* calculate some last extents */
1210 gint ft, fb, fl, fr, ut, ub, ul, ur;
1212 RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb);
1213 RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub);
1214 theme->label_height = theme->win_font_height + MAX(ft + fb, ut + ub);
1215 theme->label_height += theme->label_height % 2;
1217 /* this would be nice I think, since padding.width can now be 0,
1218 but it breaks frame.c horribly and I don't feel like fixing that
1219 right now, so if anyone complains, here is how to keep text from
1220 going over the title's bevel/border with a padding.width of 0 and a
1221 bevelless/borderless label
1222 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1223 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1224 theme->title_height = theme->label_height +
1225 MAX(MAX(theme->padding * 2, ft + fb),
1226 MAX(theme->padding * 2, ut + ub));
1228 theme->title_height = theme->label_height + theme->paddingy * 2;
1230 RrMargins(theme->a_menu_title, &ul, &ut, &ur, &ub);
1231 theme->menu_title_label_height = theme->menu_title_font_height+ut+ub;
1232 theme->menu_title_height = theme->menu_title_label_height +
1233 theme->paddingy * 2;
1235 theme->button_size = theme->label_height - 2;
1236 theme->grip_width = 25;
1241 void RrThemeFree(RrTheme *theme)
1244 g_free(theme->name);
1246 RrColorFree(theme->menu_border_color);
1247 RrColorFree(theme->frame_focused_border_color);
1248 RrColorFree(theme->frame_unfocused_border_color);
1249 RrColorFree(theme->cb_unfocused_color);
1250 RrColorFree(theme->cb_focused_color);
1251 RrColorFree(theme->title_focused_color);
1252 RrColorFree(theme->title_unfocused_color);
1253 RrColorFree(theme->titlebut_disabled_focused_color);
1254 RrColorFree(theme->titlebut_disabled_unfocused_color);
1255 RrColorFree(theme->titlebut_hover_focused_color);
1256 RrColorFree(theme->titlebut_hover_unfocused_color);
1257 RrColorFree(theme->titlebut_toggled_hover_focused_color);
1258 RrColorFree(theme->titlebut_toggled_hover_unfocused_color);
1259 RrColorFree(theme->titlebut_toggled_focused_pressed_color);
1260 RrColorFree(theme->titlebut_toggled_unfocused_pressed_color);
1261 RrColorFree(theme->titlebut_toggled_focused_unpressed_color);
1262 RrColorFree(theme->titlebut_toggled_unfocused_unpressed_color);
1263 RrColorFree(theme->titlebut_focused_pressed_color);
1264 RrColorFree(theme->titlebut_unfocused_pressed_color);
1265 RrColorFree(theme->titlebut_focused_unpressed_color);
1266 RrColorFree(theme->titlebut_unfocused_unpressed_color);
1267 RrColorFree(theme->menu_title_color);
1268 RrColorFree(theme->menu_color);
1269 RrColorFree(theme->menu_selected_color);
1270 RrColorFree(theme->menu_disabled_color);
1271 RrColorFree(theme->menu_disabled_selected_color);
1272 RrColorFree(theme->title_focused_shadow_color);
1273 RrColorFree(theme->title_unfocused_shadow_color);
1274 RrColorFree(theme->osd_color);
1275 RrColorFree(theme->osd_shadow_color);
1276 RrColorFree(theme->menu_title_shadow_color);
1277 RrColorFree(theme->menu_text_normal_shadow_color);
1278 RrColorFree(theme->menu_text_selected_shadow_color);
1279 RrColorFree(theme->menu_text_disabled_shadow_color);
1280 RrColorFree(theme->menu_text_disabled_selected_shadow_color);
1282 g_free(theme->def_win_icon);
1284 RrPixmapMaskFree(theme->max_mask);
1285 RrPixmapMaskFree(theme->max_toggled_mask);
1286 RrPixmapMaskFree(theme->max_toggled_hover_mask);
1287 RrPixmapMaskFree(theme->max_toggled_pressed_mask);
1288 RrPixmapMaskFree(theme->max_disabled_mask);
1289 RrPixmapMaskFree(theme->max_hover_mask);
1290 RrPixmapMaskFree(theme->max_pressed_mask);
1291 RrPixmapMaskFree(theme->desk_mask);
1292 RrPixmapMaskFree(theme->desk_toggled_mask);
1293 RrPixmapMaskFree(theme->desk_toggled_hover_mask);
1294 RrPixmapMaskFree(theme->desk_toggled_pressed_mask);
1295 RrPixmapMaskFree(theme->desk_disabled_mask);
1296 RrPixmapMaskFree(theme->desk_hover_mask);
1297 RrPixmapMaskFree(theme->desk_pressed_mask);
1298 RrPixmapMaskFree(theme->shade_mask);
1299 RrPixmapMaskFree(theme->shade_toggled_mask);
1300 RrPixmapMaskFree(theme->shade_toggled_hover_mask);
1301 RrPixmapMaskFree(theme->shade_toggled_pressed_mask);
1302 RrPixmapMaskFree(theme->shade_disabled_mask);
1303 RrPixmapMaskFree(theme->shade_hover_mask);
1304 RrPixmapMaskFree(theme->shade_pressed_mask);
1305 RrPixmapMaskFree(theme->iconify_mask);
1306 RrPixmapMaskFree(theme->iconify_disabled_mask);
1307 RrPixmapMaskFree(theme->iconify_hover_mask);
1308 RrPixmapMaskFree(theme->iconify_pressed_mask);
1309 RrPixmapMaskFree(theme->close_mask);
1310 RrPixmapMaskFree(theme->close_disabled_mask);
1311 RrPixmapMaskFree(theme->close_hover_mask);
1312 RrPixmapMaskFree(theme->close_pressed_mask);
1313 RrPixmapMaskFree(theme->menu_bullet_mask);
1315 RrFontClose(theme->win_font_focused);
1316 RrFontClose(theme->win_font_unfocused);
1317 RrFontClose(theme->menu_title_font);
1318 RrFontClose(theme->menu_font);
1320 RrAppearanceFree(theme->a_disabled_focused_max);
1321 RrAppearanceFree(theme->a_disabled_unfocused_max);
1322 RrAppearanceFree(theme->a_hover_focused_max);
1323 RrAppearanceFree(theme->a_hover_unfocused_max);
1324 RrAppearanceFree(theme->a_toggled_hover_focused_max);
1325 RrAppearanceFree(theme->a_toggled_hover_unfocused_max);
1326 RrAppearanceFree(theme->a_toggled_focused_unpressed_max);
1327 RrAppearanceFree(theme->a_toggled_focused_pressed_max);
1328 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_max);
1329 RrAppearanceFree(theme->a_toggled_unfocused_pressed_max);
1330 RrAppearanceFree(theme->a_focused_unpressed_max);
1331 RrAppearanceFree(theme->a_focused_pressed_max);
1332 RrAppearanceFree(theme->a_unfocused_unpressed_max);
1333 RrAppearanceFree(theme->a_unfocused_pressed_max);
1334 RrAppearanceFree(theme->a_disabled_focused_close);
1335 RrAppearanceFree(theme->a_disabled_unfocused_close);
1336 RrAppearanceFree(theme->a_hover_focused_close);
1337 RrAppearanceFree(theme->a_hover_unfocused_close);
1338 RrAppearanceFree(theme->a_focused_unpressed_close);
1339 RrAppearanceFree(theme->a_focused_pressed_close);
1340 RrAppearanceFree(theme->a_unfocused_unpressed_close);
1341 RrAppearanceFree(theme->a_unfocused_pressed_close);
1342 RrAppearanceFree(theme->a_disabled_focused_desk);
1343 RrAppearanceFree(theme->a_disabled_unfocused_desk);
1344 RrAppearanceFree(theme->a_hover_focused_desk);
1345 RrAppearanceFree(theme->a_hover_unfocused_desk);
1346 RrAppearanceFree(theme->a_toggled_hover_focused_desk);
1347 RrAppearanceFree(theme->a_toggled_hover_unfocused_desk);
1348 RrAppearanceFree(theme->a_toggled_focused_unpressed_desk);
1349 RrAppearanceFree(theme->a_toggled_focused_pressed_desk);
1350 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_desk);
1351 RrAppearanceFree(theme->a_toggled_unfocused_pressed_desk);
1352 RrAppearanceFree(theme->a_focused_unpressed_desk);
1353 RrAppearanceFree(theme->a_focused_pressed_desk);
1354 RrAppearanceFree(theme->a_unfocused_unpressed_desk);
1355 RrAppearanceFree(theme->a_unfocused_pressed_desk);
1356 RrAppearanceFree(theme->a_disabled_focused_shade);
1357 RrAppearanceFree(theme->a_disabled_unfocused_shade);
1358 RrAppearanceFree(theme->a_hover_focused_shade);
1359 RrAppearanceFree(theme->a_hover_unfocused_shade);
1360 RrAppearanceFree(theme->a_toggled_hover_focused_shade);
1361 RrAppearanceFree(theme->a_toggled_hover_unfocused_shade);
1362 RrAppearanceFree(theme->a_toggled_focused_unpressed_shade);
1363 RrAppearanceFree(theme->a_toggled_focused_pressed_shade);
1364 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_shade);
1365 RrAppearanceFree(theme->a_toggled_unfocused_pressed_shade);
1366 RrAppearanceFree(theme->a_focused_unpressed_shade);
1367 RrAppearanceFree(theme->a_focused_pressed_shade);
1368 RrAppearanceFree(theme->a_unfocused_unpressed_shade);
1369 RrAppearanceFree(theme->a_unfocused_pressed_shade);
1370 RrAppearanceFree(theme->a_disabled_focused_iconify);
1371 RrAppearanceFree(theme->a_disabled_unfocused_iconify);
1372 RrAppearanceFree(theme->a_hover_focused_iconify);
1373 RrAppearanceFree(theme->a_hover_unfocused_iconify);
1374 RrAppearanceFree(theme->a_focused_unpressed_iconify);
1375 RrAppearanceFree(theme->a_focused_pressed_iconify);
1376 RrAppearanceFree(theme->a_unfocused_unpressed_iconify);
1377 RrAppearanceFree(theme->a_unfocused_pressed_iconify);
1378 RrAppearanceFree(theme->a_focused_grip);
1379 RrAppearanceFree(theme->a_unfocused_grip);
1380 RrAppearanceFree(theme->a_focused_title);
1381 RrAppearanceFree(theme->a_unfocused_title);
1382 RrAppearanceFree(theme->a_focused_label);
1383 RrAppearanceFree(theme->a_unfocused_label);
1384 RrAppearanceFree(theme->a_icon);
1385 RrAppearanceFree(theme->a_focused_handle);
1386 RrAppearanceFree(theme->a_unfocused_handle);
1387 RrAppearanceFree(theme->a_menu);
1388 RrAppearanceFree(theme->a_menu_title);
1389 RrAppearanceFree(theme->a_menu_text_title);
1390 RrAppearanceFree(theme->a_menu_normal);
1391 RrAppearanceFree(theme->a_menu_selected);
1392 RrAppearanceFree(theme->a_menu_disabled);
1393 RrAppearanceFree(theme->a_menu_disabled_selected);
1394 RrAppearanceFree(theme->a_menu_text_normal);
1395 RrAppearanceFree(theme->a_menu_text_selected);
1396 RrAppearanceFree(theme->a_menu_text_disabled);
1397 RrAppearanceFree(theme->a_menu_text_disabled_selected);
1398 RrAppearanceFree(theme->a_menu_bullet_normal);
1399 RrAppearanceFree(theme->a_menu_bullet_selected);
1400 RrAppearanceFree(theme->a_clear);
1401 RrAppearanceFree(theme->a_clear_tex);
1402 RrAppearanceFree(theme->osd_hilite_bg);
1403 RrAppearanceFree(theme->osd_hilite_fg);
1404 RrAppearanceFree(theme->osd_hilite_label);
1405 RrAppearanceFree(theme->osd_unhilite_fg);
1411 static XrmDatabase loaddb(const gchar *name, gchar **path)
1414 XrmDatabase db = NULL;
1417 if (name[0] == '/') {
1418 s = g_build_filename(name, "openbox-3", "themerc", NULL);
1419 if ((db = XrmGetFileDatabase(s)))
1420 *path = g_path_get_dirname(s);
1423 /* XXX backwards compatibility, remove me sometime later */
1424 s = g_build_filename(g_get_home_dir(), ".themes", name,
1425 "openbox-3", "themerc", NULL);
1426 if ((db = XrmGetFileDatabase(s)))
1427 *path = g_path_get_dirname(s);
1430 for (it = parse_xdg_data_dir_paths(); !db && it;
1431 it = g_slist_next(it))
1433 s = g_build_filename(it->data, "themes", name,
1434 "openbox-3", "themerc", NULL);
1435 if ((db = XrmGetFileDatabase(s)))
1436 *path = g_path_get_dirname(s);
1442 s = g_build_filename(name, "themerc", NULL);
1443 if ((db = XrmGetFileDatabase(s)))
1444 *path = g_path_get_dirname(s);
1451 static gchar *create_class_name(const gchar *rname)
1453 gchar *rclass = g_strdup(rname);
1458 p = strchr(p+1, '.');
1459 if (p == NULL) break;
1461 if (*p == '\0') break;
1466 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value)
1468 gboolean ret = FALSE;
1469 gchar *rclass = create_class_name(rname);
1470 gchar *rettype, *end;
1473 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1474 retvalue.addr != NULL) {
1475 *value = (gint)strtol(retvalue.addr, &end, 10);
1476 if (end != retvalue.addr)
1484 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value)
1486 gboolean ret = FALSE;
1487 gchar *rclass = create_class_name(rname);
1491 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1492 retvalue.addr != NULL) {
1493 *value = retvalue.addr;
1501 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
1502 const gchar *rname, RrColor **value)
1504 gboolean ret = FALSE;
1505 gchar *rclass = create_class_name(rname);
1509 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1510 retvalue.addr != NULL) {
1511 RrColor *c = RrColorParse(inst, retvalue.addr);
1522 static gboolean read_mask(const RrInstance *inst, const gchar *path,
1523 RrTheme *theme, const gchar *maskname,
1524 RrPixmapMask **value)
1526 gboolean ret = FALSE;
1528 gint hx, hy; /* ignored */
1532 s = g_build_filename(path, maskname, NULL);
1533 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
1535 *value = RrPixmapMaskNew(inst, w, h, (gchar*)b);
1543 static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
1544 RrReliefType *relief, RrBevelType *bevel,
1545 gboolean *interlaced, gboolean *border,
1546 gboolean allow_trans)
1550 /* convert to all lowercase */
1551 for (t = tex; *t != '\0'; ++t)
1552 *t = g_ascii_tolower(*t);
1554 if (allow_trans && strstr(tex, "parentrelative") != NULL) {
1555 *grad = RR_SURFACE_PARENTREL;
1557 if (strstr(tex, "gradient") != NULL) {
1558 if (strstr(tex, "crossdiagonal") != NULL)
1559 *grad = RR_SURFACE_CROSS_DIAGONAL;
1560 else if (strstr(tex, "pyramid") != NULL)
1561 *grad = RR_SURFACE_PYRAMID;
1562 else if (strstr(tex, "mirrorhorizontal") != NULL)
1563 *grad = RR_SURFACE_MIRROR_HORIZONTAL;
1564 else if (strstr(tex, "horizontal") != NULL)
1565 *grad = RR_SURFACE_HORIZONTAL;
1566 else if (strstr(tex, "splitvertical") != NULL)
1567 *grad = RR_SURFACE_SPLIT_VERTICAL;
1568 else if (strstr(tex, "vertical") != NULL)
1569 *grad = RR_SURFACE_VERTICAL;
1571 *grad = RR_SURFACE_DIAGONAL;
1573 *grad = RR_SURFACE_SOLID;
1576 if (strstr(tex, "sunken") != NULL)
1577 *relief = RR_RELIEF_SUNKEN;
1578 else if (strstr(tex, "flat") != NULL)
1579 *relief = RR_RELIEF_FLAT;
1581 *relief = RR_RELIEF_RAISED;
1584 if (*relief == RR_RELIEF_FLAT) {
1585 if (strstr(tex, "border") != NULL)
1588 if (strstr(tex, "bevel2") != NULL)
1589 *bevel = RR_BEVEL_2;
1591 *bevel = RR_BEVEL_1;
1594 if (strstr(tex, "interlaced") != NULL)
1597 *interlaced = FALSE;
1602 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
1603 const gchar *rname, RrAppearance *value,
1604 gboolean allow_trans)
1606 gboolean ret = FALSE;
1607 gchar *rclass = create_class_name(rname);
1608 gchar *cname, *ctoname, *bcname, *icname;
1612 cname = g_strconcat(rname, ".color", NULL);
1613 ctoname = g_strconcat(rname, ".colorTo", NULL);
1614 bcname = g_strconcat(rname, ".border.color", NULL);
1615 icname = g_strconcat(rname, ".interlace.color", NULL);
1617 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1618 retvalue.addr != NULL) {
1619 parse_appearance(retvalue.addr,
1620 &value->surface.grad,
1621 &value->surface.relief,
1622 &value->surface.bevel,
1623 &value->surface.interlaced,
1624 &value->surface.border,
1626 if (!read_color(db, inst, cname, &value->surface.primary))
1627 value->surface.primary = RrColorNew(inst, 0, 0, 0);
1628 if (!read_color(db, inst, ctoname, &value->surface.secondary))
1629 value->surface.secondary = RrColorNew(inst, 0, 0, 0);
1630 if (value->surface.border)
1631 if (!read_color(db, inst, bcname,
1632 &value->surface.border_color))
1633 value->surface.border_color = RrColorNew(inst, 0, 0, 0);
1634 if (value->surface.interlaced)
1635 if (!read_color(db, inst, icname,
1636 &value->surface.interlace_color))
1637 value->surface.interlace_color = RrColorNew(inst, 0, 0, 0);
1649 static int parse_inline_number(const char *p)
1657 for (; isdigit(*p); ++p)
1658 res = res * 10 + *p - '0';
1663 static void set_default_appearance(RrAppearance *a)
1665 a->surface.grad = RR_SURFACE_SOLID;
1666 a->surface.relief = RR_RELIEF_FLAT;
1667 a->surface.bevel = RR_BEVEL_1;
1668 a->surface.interlaced = FALSE;
1669 a->surface.border = FALSE;
1670 a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
1671 a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
1674 /* Reads the output from gimp's C-Source file format into valid RGBA data for
1675 an RrTextureRGBA. */
1676 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data)
1681 p = im = g_memdup(data, width * height * sizeof(RrPixel32));
1683 for (i = 0; i < width * height; ++i) {
1684 guchar a = ((*p >> 24) & 0xff);
1685 guchar b = ((*p >> 16) & 0xff);
1686 guchar g = ((*p >> 8) & 0xff);
1687 guchar r = ((*p >> 0) & 0xff);
1689 *p = ((r << RrDefaultRedOffset) +
1690 (g << RrDefaultGreenOffset) +
1691 (b << RrDefaultBlueOffset) +
1692 (a << RrDefaultAlphaOffset));