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_unpressed_max = RrAppearanceNew(inst, 1);
69 theme->a_toggled_unfocused_unpressed_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 /* menu border width inherits from the frame border width */
177 if (!read_int(db, "menu.border.width", &theme->mbwidth) ||
178 theme->mbwidth < 0 || theme->mbwidth > 100)
179 theme->mbwidth = theme->fbwidth;
180 theme->mbwidth = theme->fbwidth;
181 if (!read_int(db, "window.client.padding.width", &theme->cbwidthx) ||
182 theme->cbwidthx < 0 || theme->cbwidthx > 100)
183 theme->cbwidthx = theme->paddingx;
184 theme->cbwidthy = theme->cbwidthx;
187 if (!read_color(db, inst,
188 "window.active.border.color",
189 &theme->frame_focused_border_color) &&
190 !read_color(db, inst,
192 &theme->frame_focused_border_color))
193 theme->frame_focused_border_color = RrColorNew(inst, 0, 0, 0);
194 /* unfocused border color inherits from frame focused border color */
195 if (!read_color(db, inst,
196 "window.inactive.border.color",
197 &theme->frame_unfocused_border_color))
198 theme->frame_unfocused_border_color = RrColorNew(inst, 0, 0, 0);
199 /* menu border color inherits from frame focused border color */
200 if (!read_color(db, inst,
202 &theme->menu_border_color))
203 theme->menu_border_color = RrColorNew(inst,
204 theme->frame_focused_border_color->r,
205 theme->frame_focused_border_color->g,
206 theme->frame_focused_border_color->b);
207 if (!read_color(db, inst,
208 "window.active.client.color",
209 &theme->cb_focused_color))
210 theme->cb_focused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
211 if (!read_color(db, inst,
212 "window.inactive.client.color",
213 &theme->cb_unfocused_color))
214 theme->cb_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
215 if (!read_color(db, inst,
216 "window.active.label.text.color",
217 &theme->title_focused_color))
218 theme->title_focused_color = RrColorNew(inst, 0x0, 0x0, 0x0);
219 theme->osd_color = RrColorNew(inst,
220 theme->title_focused_color->r,
221 theme->title_focused_color->g,
222 theme->title_focused_color->b);
223 if (!read_color(db, inst,
224 "window.inactive.label.text.color",
225 &theme->title_unfocused_color))
226 theme->title_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
227 if (!read_color(db, inst,
228 "window.active.button.unpressed.image.color",
229 &theme->titlebut_focused_unpressed_color))
230 theme->titlebut_focused_unpressed_color = RrColorNew(inst, 0, 0, 0);
231 if (!read_color(db, inst,
232 "window.inactive.button.unpressed.image.color",
233 &theme->titlebut_unfocused_unpressed_color))
234 theme->titlebut_unfocused_unpressed_color =
235 RrColorNew(inst, 0xff, 0xff, 0xff);
236 if (!read_color(db, inst,
237 "window.active.button.pressed.image.color",
238 &theme->titlebut_focused_pressed_color))
239 theme->titlebut_focused_pressed_color =
241 theme->titlebut_focused_unpressed_color->r,
242 theme->titlebut_focused_unpressed_color->g,
243 theme->titlebut_focused_unpressed_color->b);
244 if (!read_color(db, inst,
245 "window.inactive.button.pressed.image.color",
246 &theme->titlebut_unfocused_pressed_color))
247 theme->titlebut_unfocused_pressed_color =
249 theme->titlebut_unfocused_unpressed_color->r,
250 theme->titlebut_unfocused_unpressed_color->g,
251 theme->titlebut_unfocused_unpressed_color->b);
252 if (!read_color(db, inst,
253 "window.active.button.disabled.image.color",
254 &theme->titlebut_disabled_focused_color))
255 theme->titlebut_disabled_focused_color =
256 RrColorNew(inst, 0xff, 0xff, 0xff);
257 if (!read_color(db, inst,
258 "window.inactive.button.disabled.image.color",
259 &theme->titlebut_disabled_unfocused_color))
260 theme->titlebut_disabled_unfocused_color = RrColorNew(inst, 0, 0, 0);
261 if (!read_color(db, inst,
262 "window.active.button.hover.image.color",
263 &theme->titlebut_hover_focused_color))
264 theme->titlebut_hover_focused_color =
266 theme->titlebut_focused_unpressed_color->r,
267 theme->titlebut_focused_unpressed_color->g,
268 theme->titlebut_focused_unpressed_color->b);
269 if (!read_color(db, inst,
270 "window.inactive.button.hover.image.color",
271 &theme->titlebut_hover_unfocused_color))
272 theme->titlebut_hover_unfocused_color =
274 theme->titlebut_unfocused_unpressed_color->r,
275 theme->titlebut_unfocused_unpressed_color->g,
276 theme->titlebut_unfocused_unpressed_color->b);
277 if (!read_color(db, inst,
278 "window.active.button.toggled.image.color",
279 &theme->titlebut_toggled_focused_unpressed_color))
280 theme->titlebut_toggled_focused_unpressed_color =
282 theme->titlebut_focused_pressed_color->r,
283 theme->titlebut_focused_pressed_color->g,
284 theme->titlebut_focused_pressed_color->b);
285 if (!read_color(db, inst,
286 "window.inactive.button.toggled.image.color",
287 &theme->titlebut_toggled_unfocused_unpressed_color))
288 theme->titlebut_toggled_unfocused_unpressed_color =
290 theme->titlebut_unfocused_pressed_color->r,
291 theme->titlebut_unfocused_pressed_color->g,
292 theme->titlebut_unfocused_pressed_color->b);
293 if (!read_color(db, inst,
294 "menu.title.text.color", &theme->menu_title_color))
295 theme->menu_title_color = RrColorNew(inst, 0, 0, 0);
296 if (!read_color(db, inst,
297 "menu.items.text.color", &theme->menu_color))
298 theme->menu_color = RrColorNew(inst, 0xff, 0xff, 0xff);
299 if (!read_color(db, inst,
300 "menu.items.disabled.text.color",
301 &theme->menu_disabled_color))
302 theme->menu_disabled_color = RrColorNew(inst, 0, 0, 0);
303 if (!read_color(db, inst,
304 "menu.items.activedisabled.text.color",
305 &theme->menu_disabled_selected_color))
306 theme->menu_disabled_selected_color =
308 theme->menu_disabled_color->r,
309 theme->menu_disabled_color->g,
310 theme->menu_disabled_color->b);
311 if (!read_color(db, inst,
312 "menu.items.active.text.color",
313 &theme->menu_selected_color))
314 theme->menu_selected_color = RrColorNew(inst, 0, 0, 0);
316 /* toggled hover = toggled unpressed (i.e. no change) */
317 theme->titlebut_toggled_hover_focused_color =
319 theme->titlebut_toggled_focused_unpressed_color->r,
320 theme->titlebut_toggled_focused_unpressed_color->g,
321 theme->titlebut_toggled_focused_unpressed_color->b);
322 theme->titlebut_toggled_hover_unfocused_color =
324 theme->titlebut_toggled_unfocused_unpressed_color->r,
325 theme->titlebut_toggled_unfocused_unpressed_color->g,
326 theme->titlebut_toggled_unfocused_unpressed_color->b);
327 /* toggled pressed = pressed (which is the toggled unpressed fallback..) */
328 theme->titlebut_toggled_focused_pressed_color =
330 theme->titlebut_focused_pressed_color->r,
331 theme->titlebut_focused_pressed_color->g,
332 theme->titlebut_focused_pressed_color->b);
333 theme->titlebut_toggled_unfocused_pressed_color =
335 theme->titlebut_unfocused_pressed_color->r,
336 theme->titlebut_unfocused_pressed_color->g,
337 theme->titlebut_unfocused_pressed_color->b);
339 if (read_mask(inst, path, "max.xbm", theme, &theme->max_mask)) {
340 if (!read_mask(inst, path, "max_pressed.xbm", theme,
341 &theme->max_pressed_mask)) {
342 theme->max_pressed_mask = RrPixmapMaskCopy(theme->max_mask);
344 if (!read_mask(inst, path, "max_toggled.xbm", theme,
345 &theme->max_toggled_mask)) {
346 theme->max_toggled_mask =
347 RrPixmapMaskCopy(theme->max_pressed_mask);
349 if (!read_mask(inst, path, "max_disabled.xbm", theme,
350 &theme->max_disabled_mask)) {
351 theme->max_disabled_mask = RrPixmapMaskCopy(theme->max_mask);
353 if (!read_mask(inst, path, "max_hover.xbm", theme,
354 &theme->max_hover_mask)) {
355 theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask);
359 guchar data[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
360 theme->max_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
363 guchar data[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
364 theme->max_toggled_mask = RrPixmapMaskNew(inst, 6, 6,(gchar*)data);
366 theme->max_pressed_mask = RrPixmapMaskCopy(theme->max_mask);
367 theme->max_disabled_mask = RrPixmapMaskCopy(theme->max_mask);
368 theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask);
371 if (read_mask(inst, path, "iconify.xbm", theme, &theme->iconify_mask)) {
372 if (!read_mask(inst, path, "iconify_pressed.xbm", theme,
373 &theme->iconify_pressed_mask)) {
374 theme->iconify_pressed_mask =
375 RrPixmapMaskCopy(theme->iconify_mask);
377 if (!read_mask(inst, path, "iconify_disabled.xbm", theme,
378 &theme->iconify_disabled_mask)) {
379 theme->iconify_disabled_mask =
380 RrPixmapMaskCopy(theme->iconify_mask);
382 if (!read_mask(inst, path, "iconify_hover.xbm", theme,
383 &theme->iconify_hover_mask)) {
384 theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
388 guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
389 theme->iconify_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
391 theme->iconify_pressed_mask = RrPixmapMaskCopy(theme->iconify_mask);
392 theme->iconify_disabled_mask = RrPixmapMaskCopy(theme->iconify_mask);
393 theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
396 theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
397 OB_DEFAULT_ICON_HEIGHT,
398 OB_DEFAULT_ICON_pixel_data);
400 if (read_mask(inst, path, "desk.xbm", theme, &theme->desk_mask)) {
401 if (!read_mask(inst, path, "desk_pressed.xbm", theme,
402 &theme->desk_pressed_mask)) {
403 theme->desk_pressed_mask = RrPixmapMaskCopy(theme->desk_mask);
405 if (!read_mask(inst, path, "desk_toggled.xbm", theme,
406 &theme->desk_toggled_mask)) {
407 theme->desk_toggled_mask =
408 RrPixmapMaskCopy(theme->desk_pressed_mask);
410 if (!read_mask(inst, path, "desk_disabled.xbm", theme,
411 &theme->desk_disabled_mask)) {
412 theme->desk_disabled_mask = RrPixmapMaskCopy(theme->desk_mask);
414 if (!read_mask(inst, path, "desk_hover.xbm", theme,
415 &theme->desk_hover_mask)) {
416 theme->desk_hover_mask = RrPixmapMaskCopy(theme->desk_mask);
420 guchar data[] = { 0x33, 0x33, 0x00, 0x00, 0x33, 0x33 };
421 theme->desk_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
424 guchar data[] = { 0x00, 0x1e, 0x1a, 0x16, 0x1e, 0x00 };
425 theme->desk_toggled_mask = RrPixmapMaskNew(inst,6,6,(gchar*)data);
427 theme->desk_pressed_mask = RrPixmapMaskCopy(theme->desk_mask);
428 theme->desk_disabled_mask = RrPixmapMaskCopy(theme->desk_mask);
429 theme->desk_hover_mask = RrPixmapMaskCopy(theme->desk_mask);
432 if (read_mask(inst, path, "shade.xbm", theme, &theme->shade_mask)) {
433 if (!read_mask(inst, path, "shade_pressed.xbm", theme,
434 &theme->shade_pressed_mask)) {
435 theme->shade_pressed_mask = RrPixmapMaskCopy(theme->shade_mask);
437 if (!read_mask(inst, path, "shade_toggled.xbm", theme,
438 &theme->shade_toggled_mask)) {
439 theme->shade_toggled_mask =
440 RrPixmapMaskCopy(theme->shade_pressed_mask);
442 if (!read_mask(inst, path, "shade_disabled.xbm", theme,
443 &theme->shade_disabled_mask)) {
444 theme->shade_disabled_mask = RrPixmapMaskCopy(theme->shade_mask);
446 if (!read_mask(inst, path, "shade_hover.xbm", theme,
447 &theme->shade_hover_mask)) {
448 theme->shade_hover_mask = RrPixmapMaskCopy(theme->shade_mask);
452 guchar data[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
453 theme->shade_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
456 guchar data[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
457 theme->shade_toggled_mask = RrPixmapMaskNew(inst,6,6,(gchar*)data);
459 theme->shade_pressed_mask = RrPixmapMaskCopy(theme->shade_mask);
460 theme->shade_disabled_mask = RrPixmapMaskCopy(theme->shade_mask);
461 theme->shade_hover_mask = RrPixmapMaskCopy(theme->shade_mask);
464 if (read_mask(inst, path, "close.xbm", theme, &theme->close_mask)) {
465 if (!read_mask(inst, path, "close_pressed.xbm", theme,
466 &theme->close_pressed_mask)) {
467 theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask);
469 if (!read_mask(inst, path, "close_disabled.xbm", theme,
470 &theme->close_disabled_mask)) {
471 theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask);
473 if (!read_mask(inst, path, "close_hover.xbm", theme,
474 &theme->close_hover_mask)) {
475 theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask);
479 guchar data[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
480 theme->close_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
482 theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask);
483 theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask);
484 theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask);
487 if (!read_mask(inst, path, "bullet.xbm", theme,
488 &theme->menu_bullet_mask)) {
489 guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
490 theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data);
493 /* the toggled hover mask = the toggled unpressed mask (i.e. no change) */
494 theme->max_toggled_hover_mask =
495 RrPixmapMaskCopy(theme->max_toggled_mask);
496 theme->desk_toggled_hover_mask =
497 RrPixmapMaskCopy(theme->desk_toggled_mask);
498 theme->shade_toggled_hover_mask =
499 RrPixmapMaskCopy(theme->shade_toggled_mask);
500 /* the toggled pressed mask = the toggled unpressed mask (i.e. no change)*/
501 theme->max_toggled_pressed_mask =
502 RrPixmapMaskCopy(theme->max_toggled_mask);
503 theme->desk_toggled_pressed_mask =
504 RrPixmapMaskCopy(theme->desk_toggled_mask);
505 theme->shade_toggled_pressed_mask =
506 RrPixmapMaskCopy(theme->shade_toggled_mask);
508 /* read the decoration textures */
509 if (!read_appearance(db, inst,
510 "window.active.title.bg", theme->a_focused_title,
512 set_default_appearance(theme->a_focused_title);
513 if (!read_appearance(db, inst,
514 "window.inactive.title.bg", theme->a_unfocused_title,
516 set_default_appearance(theme->a_unfocused_title);
517 if (!read_appearance(db, inst,
518 "window.active.label.bg", theme->a_focused_label,
520 set_default_appearance(theme->a_focused_label);
521 if (!read_appearance(db, inst,
522 "window.inactive.label.bg", theme->a_unfocused_label,
524 set_default_appearance(theme->a_unfocused_label);
525 if (!read_appearance(db, inst,
526 "window.active.handle.bg", theme->a_focused_handle,
528 set_default_appearance(theme->a_focused_handle);
529 if (!read_appearance(db, inst,
530 "window.inactive.handle.bg",theme->a_unfocused_handle,
532 set_default_appearance(theme->a_unfocused_handle);
533 if (!read_appearance(db, inst,
534 "window.active.grip.bg", theme->a_focused_grip,
536 set_default_appearance(theme->a_focused_grip);
537 if (!read_appearance(db, inst,
538 "window.inactive.grip.bg", theme->a_unfocused_grip,
540 set_default_appearance(theme->a_unfocused_grip);
541 if (!read_appearance(db, inst,
542 "menu.items.bg", theme->a_menu,
544 set_default_appearance(theme->a_menu);
545 if (!read_appearance(db, inst,
546 "menu.title.bg", theme->a_menu_title,
548 set_default_appearance(theme->a_menu_title);
549 if (!read_appearance(db, inst,
550 "menu.items.active.bg", theme->a_menu_selected,
552 set_default_appearance(theme->a_menu_selected);
553 theme->a_menu_disabled_selected =
554 RrAppearanceCopy(theme->a_menu_selected);
556 /* read the appearances for rendering non-decorations */
557 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_title);
558 theme->osd_hilite_label = RrAppearanceCopy(theme->a_focused_label);
559 if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL)
560 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_label);
562 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_title);
563 if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL)
564 theme->osd_unhilite_fg = RrAppearanceCopy(theme->a_unfocused_label);
566 theme->osd_unhilite_fg = RrAppearanceCopy(theme->a_unfocused_title);
568 /* read buttons textures */
569 if (!read_appearance(db, inst,
570 "window.active.button.disabled.bg",
571 theme->a_disabled_focused_max,
573 set_default_appearance(theme->a_disabled_focused_max);
574 if (!read_appearance(db, inst,
575 "window.inactive.button.disabled.bg",
576 theme->a_disabled_unfocused_max,
578 set_default_appearance(theme->a_disabled_unfocused_max);
579 if (!read_appearance(db, inst,
580 "window.active.button.pressed.bg",
581 theme->a_focused_pressed_max,
583 set_default_appearance(theme->a_focused_pressed_max);
584 if (!read_appearance(db, inst,
585 "window.inactive.button.pressed.bg",
586 theme->a_unfocused_pressed_max,
588 set_default_appearance(theme->a_unfocused_pressed_max);
589 if (!read_appearance(db, inst,
590 "window.active.button.toggled.bg",
591 theme->a_toggled_focused_unpressed_max,
594 RrAppearanceFree(theme->a_toggled_focused_unpressed_max);
595 theme->a_toggled_focused_unpressed_max =
596 RrAppearanceCopy(theme->a_focused_pressed_max);
598 if (!read_appearance(db, inst,
599 "window.inactive.button.toggled.bg",
600 theme->a_toggled_unfocused_unpressed_max,
603 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_max);
604 theme->a_toggled_unfocused_unpressed_max =
605 RrAppearanceCopy(theme->a_unfocused_pressed_max);
607 if (!read_appearance(db, inst,
608 "window.active.button.unpressed.bg",
609 theme->a_focused_unpressed_max,
611 set_default_appearance(theme->a_focused_unpressed_max);
612 if (!read_appearance(db, inst,
613 "window.inactive.button.unpressed.bg",
614 theme->a_unfocused_unpressed_max,
616 set_default_appearance(theme->a_unfocused_unpressed_max);
617 if (!read_appearance(db, inst,
618 "window.active.button.hover.bg",
619 theme->a_hover_focused_max,
622 RrAppearanceFree(theme->a_hover_focused_max);
623 theme->a_hover_focused_max =
624 RrAppearanceCopy(theme->a_focused_unpressed_max);
626 if (!read_appearance(db, inst,
627 "window.inactive.button.hover.bg",
628 theme->a_hover_unfocused_max,
631 RrAppearanceFree(theme->a_hover_unfocused_max);
632 theme->a_hover_unfocused_max =
633 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
636 /* toggled + hover = toggled unpressed (i.e. no change) */
637 theme->a_toggled_hover_focused_max =
638 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
639 theme->a_toggled_hover_unfocused_max =
640 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
641 /* toggled + pressed = pressed (which is the toggled fallback..) */
642 theme->a_toggled_focused_pressed_max =
643 RrAppearanceCopy(theme->a_focused_pressed_max);
644 theme->a_toggled_unfocused_pressed_max =
645 RrAppearanceCopy(theme->a_unfocused_pressed_max);
647 theme->a_disabled_focused_close =
648 RrAppearanceCopy(theme->a_disabled_focused_max);
649 theme->a_disabled_unfocused_close =
650 RrAppearanceCopy(theme->a_disabled_unfocused_max);
651 theme->a_hover_focused_close =
652 RrAppearanceCopy(theme->a_hover_focused_max);
653 theme->a_hover_unfocused_close =
654 RrAppearanceCopy(theme->a_hover_unfocused_max);
655 theme->a_unfocused_unpressed_close =
656 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
657 theme->a_unfocused_pressed_close =
658 RrAppearanceCopy(theme->a_unfocused_pressed_max);
659 theme->a_focused_unpressed_close =
660 RrAppearanceCopy(theme->a_focused_unpressed_max);
661 theme->a_focused_pressed_close =
662 RrAppearanceCopy(theme->a_focused_pressed_max);
663 theme->a_disabled_focused_desk =
664 RrAppearanceCopy(theme->a_disabled_focused_max);
665 theme->a_disabled_unfocused_desk =
666 RrAppearanceCopy(theme->a_disabled_unfocused_max);
667 theme->a_hover_focused_desk =
668 RrAppearanceCopy(theme->a_hover_focused_max);
669 theme->a_hover_unfocused_desk =
670 RrAppearanceCopy(theme->a_hover_unfocused_max);
671 theme->a_toggled_hover_focused_desk =
672 RrAppearanceCopy(theme->a_toggled_hover_focused_max);
673 theme->a_toggled_hover_unfocused_desk =
674 RrAppearanceCopy(theme->a_toggled_hover_unfocused_max);
675 theme->a_toggled_focused_unpressed_desk =
676 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
677 theme->a_toggled_unfocused_unpressed_desk =
678 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
679 theme->a_toggled_focused_pressed_desk =
680 RrAppearanceCopy(theme->a_toggled_focused_pressed_max);
681 theme->a_toggled_unfocused_pressed_desk =
682 RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max);
683 theme->a_unfocused_unpressed_desk =
684 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
685 theme->a_unfocused_pressed_desk =
686 RrAppearanceCopy(theme->a_unfocused_pressed_max);
687 theme->a_focused_unpressed_desk =
688 RrAppearanceCopy(theme->a_focused_unpressed_max);
689 theme->a_focused_pressed_desk =
690 RrAppearanceCopy(theme->a_focused_pressed_max);
691 theme->a_disabled_focused_shade =
692 RrAppearanceCopy(theme->a_disabled_focused_max);
693 theme->a_disabled_unfocused_shade =
694 RrAppearanceCopy(theme->a_disabled_unfocused_max);
695 theme->a_hover_focused_shade =
696 RrAppearanceCopy(theme->a_hover_focused_max);
697 theme->a_hover_unfocused_shade =
698 RrAppearanceCopy(theme->a_hover_unfocused_max);
699 theme->a_toggled_hover_focused_shade =
700 RrAppearanceCopy(theme->a_toggled_hover_focused_max);
701 theme->a_toggled_hover_unfocused_shade =
702 RrAppearanceCopy(theme->a_toggled_hover_unfocused_max);
703 theme->a_toggled_focused_unpressed_shade =
704 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
705 theme->a_toggled_unfocused_unpressed_shade =
706 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
707 theme->a_toggled_focused_pressed_shade =
708 RrAppearanceCopy(theme->a_toggled_focused_pressed_max);
709 theme->a_toggled_unfocused_pressed_shade =
710 RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max);
711 theme->a_unfocused_unpressed_shade =
712 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
713 theme->a_unfocused_pressed_shade =
714 RrAppearanceCopy(theme->a_unfocused_pressed_max);
715 theme->a_focused_unpressed_shade =
716 RrAppearanceCopy(theme->a_focused_unpressed_max);
717 theme->a_focused_pressed_shade =
718 RrAppearanceCopy(theme->a_focused_pressed_max);
719 theme->a_disabled_focused_iconify =
720 RrAppearanceCopy(theme->a_disabled_focused_max);
721 theme->a_disabled_unfocused_iconify =
722 RrAppearanceCopy(theme->a_disabled_focused_max);
723 theme->a_hover_focused_iconify =
724 RrAppearanceCopy(theme->a_hover_focused_max);
725 theme->a_hover_unfocused_iconify =
726 RrAppearanceCopy(theme->a_hover_unfocused_max);
727 theme->a_unfocused_unpressed_iconify =
728 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
729 theme->a_unfocused_pressed_iconify =
730 RrAppearanceCopy(theme->a_unfocused_pressed_max);
731 theme->a_focused_unpressed_iconify =
732 RrAppearanceCopy(theme->a_focused_unpressed_max);
733 theme->a_focused_pressed_iconify =
734 RrAppearanceCopy(theme->a_focused_pressed_max);
736 theme->a_icon->surface.grad =
737 theme->a_clear->surface.grad =
738 theme->a_clear_tex->surface.grad =
739 theme->a_menu_text_title->surface.grad =
740 theme->a_menu_normal->surface.grad =
741 theme->a_menu_disabled->surface.grad =
742 theme->a_menu_text_normal->surface.grad =
743 theme->a_menu_text_selected->surface.grad =
744 theme->a_menu_text_disabled->surface.grad =
745 theme->a_menu_text_disabled_selected->surface.grad =
746 theme->a_menu_bullet_normal->surface.grad =
747 theme->a_menu_bullet_selected->surface.grad = RR_SURFACE_PARENTREL;
749 /* set up the textures */
750 theme->a_focused_label->texture[0].type =
751 theme->osd_hilite_label->texture[0].type = RR_TEXTURE_TEXT;
752 theme->a_focused_label->texture[0].data.text.justify = winjust;
753 theme->osd_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
754 theme->a_focused_label->texture[0].data.text.font =
755 theme->win_font_focused;
756 theme->osd_hilite_label->texture[0].data.text.font = theme->osd_font;
757 theme->a_focused_label->texture[0].data.text.color =
758 theme->title_focused_color;
759 theme->osd_hilite_label->texture[0].data.text.color =
762 if (read_string(db, "window.active.label.text.font", &str)) {
766 if (strstr(str, "shadow=y")) {
767 if ((p = strstr(str, "shadowoffset=")))
768 i = parse_inline_number(p + strlen("shadowoffset="));
771 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
772 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
773 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x = i;
774 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y = i;
776 if ((p = strstr(str, "shadowtint=")))
778 i = parse_inline_number(p + strlen("shadowtint="));
779 j = (i > 0 ? 0 : 255);
782 theme->title_focused_shadow_color = RrColorNew(inst, j, j, j);
783 theme->title_focused_shadow_alpha = i;
784 theme->osd_shadow_color = RrColorNew(inst, j, j, j);
785 theme->osd_shadow_alpha = i;
787 theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
788 theme->title_focused_shadow_alpha = 50;
789 theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0);
790 theme->osd_shadow_alpha = 50;
794 theme->a_focused_label->texture[0].data.text.shadow_color =
795 theme->title_focused_shadow_color;
796 theme->a_focused_label->texture[0].data.text.shadow_alpha =
797 theme->title_focused_shadow_alpha;
798 theme->osd_hilite_label->texture[0].data.text.shadow_color =
799 theme->osd_shadow_color;
800 theme->osd_hilite_label->texture[0].data.text.shadow_alpha =
801 theme->osd_shadow_alpha;
803 theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT;
804 theme->a_unfocused_label->texture[0].data.text.justify = winjust;
805 theme->a_unfocused_label->texture[0].data.text.font =
806 theme->win_font_unfocused;
807 theme->a_unfocused_label->texture[0].data.text.color =
808 theme->title_unfocused_color;
810 if (read_string(db, "window.inactive.label.text.font", &str)) {
814 if (strstr(str, "shadow=y")) {
815 if ((p = strstr(str, "shadowoffset=")))
816 i = parse_inline_number(p + strlen("shadowoffset="));
819 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x = i;
820 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y = i;
822 if ((p = strstr(str, "shadowtint=")))
824 i = parse_inline_number(p + strlen("shadowtint="));
825 j = (i > 0 ? 0 : 255);
828 theme->title_unfocused_shadow_color = RrColorNew(inst, j, j, j);
829 theme->title_unfocused_shadow_alpha = i;
831 theme->title_unfocused_shadow_color = RrColorNew(inst, 0, 0, 0);
832 theme->title_unfocused_shadow_alpha = 50;
836 theme->a_unfocused_label->texture[0].data.text.shadow_color =
837 theme->title_unfocused_shadow_color;
838 theme->a_unfocused_label->texture[0].data.text.shadow_alpha =
839 theme->title_unfocused_shadow_alpha;
841 theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
842 theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
843 theme->a_menu_text_title->texture[0].data.text.font =
844 theme->menu_title_font;
845 theme->a_menu_text_title->texture[0].data.text.color =
846 theme->menu_title_color;
848 if (read_string(db, "menu.title.text.font", &str)) {
852 if (strstr(str, "shadow=y")) {
853 if ((p = strstr(str, "shadowoffset=")))
854 i = parse_inline_number(p + strlen("shadowoffset="));
857 theme->a_menu_text_title->texture[0].data.text.shadow_offset_x = i;
858 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y = i;
860 if ((p = strstr(str, "shadowtint=")))
862 i = parse_inline_number(p + strlen("shadowtint="));
863 j = (i > 0 ? 0 : 255);
866 theme->menu_title_shadow_color = RrColorNew(inst, j, j, j);
867 theme->menu_title_shadow_alpha = i;
869 theme->menu_title_shadow_color = RrColorNew(inst, 0, 0, 0);
870 theme->menu_title_shadow_alpha = 50;
874 theme->a_menu_text_title->texture[0].data.text.shadow_color =
875 theme->menu_title_shadow_color;
876 theme->a_menu_text_title->texture[0].data.text.shadow_alpha =
877 theme->menu_title_shadow_alpha;
879 theme->a_menu_text_normal->texture[0].type =
880 theme->a_menu_text_selected->texture[0].type =
881 theme->a_menu_text_disabled->texture[0].type =
882 theme->a_menu_text_disabled_selected->texture[0].type =
884 theme->a_menu_text_normal->texture[0].data.text.justify =
885 theme->a_menu_text_selected->texture[0].data.text.justify =
886 theme->a_menu_text_disabled->texture[0].data.text.justify =
887 theme->a_menu_text_disabled_selected->texture[0].data.text.justify =
889 theme->a_menu_text_normal->texture[0].data.text.font =
890 theme->a_menu_text_selected->texture[0].data.text.font =
891 theme->a_menu_text_disabled->texture[0].data.text.font =
892 theme->a_menu_text_disabled_selected->texture[0].data.text.font =
894 theme->a_menu_text_normal->texture[0].data.text.color = theme->menu_color;
895 theme->a_menu_text_selected->texture[0].data.text.color =
896 theme->menu_selected_color;
897 theme->a_menu_text_disabled->texture[0].data.text.color =
898 theme->menu_disabled_color;
899 theme->a_menu_text_disabled_selected->texture[0].data.text.color =
900 theme->menu_disabled_selected_color;
902 if (read_string(db, "menu.items.font", &str)) {
906 if (strstr(str, "shadow=y")) {
907 if ((p = strstr(str, "shadowoffset=")))
908 i = parse_inline_number(p + strlen("shadowoffset="));
911 theme->a_menu_text_normal->
912 texture[0].data.text.shadow_offset_x = i;
913 theme->a_menu_text_normal->
914 texture[0].data.text.shadow_offset_y = i;
915 theme->a_menu_text_selected->
916 texture[0].data.text.shadow_offset_x = i;
917 theme->a_menu_text_selected->
918 texture[0].data.text.shadow_offset_y = i;
919 theme->a_menu_text_disabled->
920 texture[0].data.text.shadow_offset_x = i;
921 theme->a_menu_text_disabled->
922 texture[0].data.text.shadow_offset_y = i;
923 theme->a_menu_text_disabled_selected->
924 texture[0].data.text.shadow_offset_x = i;
925 theme->a_menu_text_disabled_selected->
926 texture[0].data.text.shadow_offset_y = i;
928 if ((p = strstr(str, "shadowtint=")))
930 i = parse_inline_number(p + strlen("shadowtint="));
931 j = (i > 0 ? 0 : 255);
934 theme->menu_text_normal_shadow_color = RrColorNew(inst, j, j, j);
935 theme->menu_text_selected_shadow_color = RrColorNew(inst, j, j, j);
936 theme->menu_text_disabled_shadow_color = RrColorNew(inst, j, j, j);
937 theme->menu_text_normal_shadow_alpha = i;
938 theme->menu_text_selected_shadow_alpha = i;
939 theme->menu_text_disabled_shadow_alpha = i;
940 theme->menu_text_disabled_selected_shadow_alpha = i;
942 theme->menu_text_normal_shadow_color = RrColorNew(inst, 0, 0, 0);
943 theme->menu_text_selected_shadow_color = RrColorNew(inst, 0, 0, 0);
944 theme->menu_text_disabled_shadow_color = RrColorNew(inst, 0, 0, 0);
945 theme->menu_text_normal_shadow_alpha = 50;
946 theme->menu_text_selected_shadow_alpha = 50;
947 theme->menu_text_disabled_selected_shadow_alpha = 50;
951 theme->a_menu_text_normal->texture[0].data.text.shadow_color =
952 theme->menu_text_normal_shadow_color;
953 theme->a_menu_text_normal->texture[0].data.text.shadow_alpha =
954 theme->menu_text_normal_shadow_alpha;
955 theme->a_menu_text_selected->texture[0].data.text.shadow_color =
956 theme->menu_text_selected_shadow_color;
957 theme->a_menu_text_selected->texture[0].data.text.shadow_alpha =
958 theme->menu_text_selected_shadow_alpha;
959 theme->a_menu_text_disabled->texture[0].data.text.shadow_color =
960 theme->menu_text_disabled_shadow_color;
961 theme->a_menu_text_disabled->texture[0].data.text.shadow_alpha =
962 theme->menu_text_disabled_shadow_alpha;
963 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_color =
964 theme->menu_text_disabled_shadow_color;
965 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_alpha =
966 theme->menu_text_disabled_shadow_alpha;
968 theme->a_disabled_focused_max->texture[0].type =
969 theme->a_disabled_unfocused_max->texture[0].type =
970 theme->a_hover_focused_max->texture[0].type =
971 theme->a_hover_unfocused_max->texture[0].type =
972 theme->a_toggled_hover_focused_max->texture[0].type =
973 theme->a_toggled_hover_unfocused_max->texture[0].type =
974 theme->a_toggled_focused_unpressed_max->texture[0].type =
975 theme->a_toggled_unfocused_unpressed_max->texture[0].type =
976 theme->a_toggled_focused_pressed_max->texture[0].type =
977 theme->a_toggled_unfocused_pressed_max->texture[0].type =
978 theme->a_focused_unpressed_max->texture[0].type =
979 theme->a_focused_pressed_max->texture[0].type =
980 theme->a_unfocused_unpressed_max->texture[0].type =
981 theme->a_unfocused_pressed_max->texture[0].type =
982 theme->a_disabled_focused_close->texture[0].type =
983 theme->a_disabled_unfocused_close->texture[0].type =
984 theme->a_hover_focused_close->texture[0].type =
985 theme->a_hover_unfocused_close->texture[0].type =
986 theme->a_focused_unpressed_close->texture[0].type =
987 theme->a_focused_pressed_close->texture[0].type =
988 theme->a_unfocused_unpressed_close->texture[0].type =
989 theme->a_unfocused_pressed_close->texture[0].type =
990 theme->a_disabled_focused_desk->texture[0].type =
991 theme->a_disabled_unfocused_desk->texture[0].type =
992 theme->a_hover_focused_desk->texture[0].type =
993 theme->a_hover_unfocused_desk->texture[0].type =
994 theme->a_toggled_hover_focused_desk->texture[0].type =
995 theme->a_toggled_hover_unfocused_desk->texture[0].type =
996 theme->a_toggled_focused_unpressed_desk->texture[0].type =
997 theme->a_toggled_unfocused_unpressed_desk->texture[0].type =
998 theme->a_toggled_focused_pressed_desk->texture[0].type =
999 theme->a_toggled_unfocused_pressed_desk->texture[0].type =
1000 theme->a_focused_unpressed_desk->texture[0].type =
1001 theme->a_focused_pressed_desk->texture[0].type =
1002 theme->a_unfocused_unpressed_desk->texture[0].type =
1003 theme->a_unfocused_pressed_desk->texture[0].type =
1004 theme->a_disabled_focused_shade->texture[0].type =
1005 theme->a_disabled_unfocused_shade->texture[0].type =
1006 theme->a_hover_focused_shade->texture[0].type =
1007 theme->a_hover_unfocused_shade->texture[0].type =
1008 theme->a_toggled_hover_focused_shade->texture[0].type =
1009 theme->a_toggled_hover_unfocused_shade->texture[0].type =
1010 theme->a_toggled_focused_unpressed_shade->texture[0].type =
1011 theme->a_toggled_unfocused_unpressed_shade->texture[0].type =
1012 theme->a_toggled_focused_pressed_shade->texture[0].type =
1013 theme->a_toggled_unfocused_pressed_shade->texture[0].type =
1014 theme->a_focused_unpressed_shade->texture[0].type =
1015 theme->a_focused_pressed_shade->texture[0].type =
1016 theme->a_unfocused_unpressed_shade->texture[0].type =
1017 theme->a_unfocused_pressed_shade->texture[0].type =
1018 theme->a_disabled_focused_iconify->texture[0].type =
1019 theme->a_disabled_unfocused_iconify->texture[0].type =
1020 theme->a_hover_focused_iconify->texture[0].type =
1021 theme->a_hover_unfocused_iconify->texture[0].type =
1022 theme->a_focused_unpressed_iconify->texture[0].type =
1023 theme->a_focused_pressed_iconify->texture[0].type =
1024 theme->a_unfocused_unpressed_iconify->texture[0].type =
1025 theme->a_unfocused_pressed_iconify->texture[0].type =
1026 theme->a_menu_bullet_normal->texture[0].type =
1027 theme->a_menu_bullet_selected->texture[0].type = RR_TEXTURE_MASK;
1029 theme->a_disabled_focused_max->texture[0].data.mask.mask =
1030 theme->a_disabled_unfocused_max->texture[0].data.mask.mask =
1031 theme->max_disabled_mask;
1032 theme->a_hover_focused_max->texture[0].data.mask.mask =
1033 theme->a_hover_unfocused_max->texture[0].data.mask.mask =
1034 theme->max_hover_mask;
1035 theme->a_focused_pressed_max->texture[0].data.mask.mask =
1036 theme->a_unfocused_pressed_max->texture[0].data.mask.mask =
1037 theme->max_pressed_mask;
1038 theme->a_focused_unpressed_max->texture[0].data.mask.mask =
1039 theme->a_unfocused_unpressed_max->texture[0].data.mask.mask =
1041 theme->a_toggled_hover_focused_max->texture[0].data.mask.mask =
1042 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.mask =
1043 theme->max_toggled_hover_mask;
1044 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.mask =
1045 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.mask =
1046 theme->max_toggled_mask;
1047 theme->a_toggled_focused_pressed_max->texture[0].data.mask.mask =
1048 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.mask =
1049 theme->max_toggled_pressed_mask;
1050 theme->a_disabled_focused_close->texture[0].data.mask.mask =
1051 theme->a_disabled_unfocused_close->texture[0].data.mask.mask =
1052 theme->close_disabled_mask;
1053 theme->a_hover_focused_close->texture[0].data.mask.mask =
1054 theme->a_hover_unfocused_close->texture[0].data.mask.mask =
1055 theme->close_hover_mask;
1056 theme->a_focused_pressed_close->texture[0].data.mask.mask =
1057 theme->a_unfocused_pressed_close->texture[0].data.mask.mask =
1058 theme->close_pressed_mask;
1059 theme->a_focused_unpressed_close->texture[0].data.mask.mask =
1060 theme->a_unfocused_unpressed_close->texture[0].data.mask.mask =
1062 theme->a_disabled_focused_desk->texture[0].data.mask.mask =
1063 theme->a_disabled_unfocused_desk->texture[0].data.mask.mask =
1064 theme->desk_disabled_mask;
1065 theme->a_hover_focused_desk->texture[0].data.mask.mask =
1066 theme->a_hover_unfocused_desk->texture[0].data.mask.mask =
1067 theme->desk_hover_mask;
1068 theme->a_focused_pressed_desk->texture[0].data.mask.mask =
1069 theme->a_unfocused_pressed_desk->texture[0].data.mask.mask =
1070 theme->desk_pressed_mask;
1071 theme->a_focused_unpressed_desk->texture[0].data.mask.mask =
1072 theme->a_unfocused_unpressed_desk->texture[0].data.mask.mask =
1074 theme->a_toggled_hover_focused_desk->texture[0].data.mask.mask =
1075 theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.mask =
1076 theme->desk_toggled_hover_mask;
1077 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.mask =
1078 theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.mask =
1079 theme->desk_toggled_mask;
1080 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.mask =
1081 theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.mask =
1082 theme->desk_toggled_pressed_mask;
1083 theme->a_disabled_focused_shade->texture[0].data.mask.mask =
1084 theme->a_disabled_unfocused_shade->texture[0].data.mask.mask =
1085 theme->shade_disabled_mask;
1086 theme->a_hover_focused_shade->texture[0].data.mask.mask =
1087 theme->a_hover_unfocused_shade->texture[0].data.mask.mask =
1088 theme->shade_hover_mask;
1089 theme->a_focused_pressed_shade->texture[0].data.mask.mask =
1090 theme->a_unfocused_pressed_shade->texture[0].data.mask.mask =
1091 theme->shade_pressed_mask;
1092 theme->a_focused_unpressed_shade->texture[0].data.mask.mask =
1093 theme->a_unfocused_unpressed_shade->texture[0].data.mask.mask =
1095 theme->a_toggled_hover_focused_shade->texture[0].data.mask.mask =
1096 theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.mask =
1097 theme->shade_toggled_hover_mask;
1098 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.mask =
1099 theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.mask =
1100 theme->shade_toggled_mask;
1101 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.mask =
1102 theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.mask =
1103 theme->shade_toggled_pressed_mask;
1104 theme->a_disabled_focused_iconify->texture[0].data.mask.mask =
1105 theme->a_disabled_unfocused_iconify->texture[0].data.mask.mask =
1106 theme->iconify_disabled_mask;
1107 theme->a_hover_focused_iconify->texture[0].data.mask.mask =
1108 theme->a_hover_unfocused_iconify->texture[0].data.mask.mask =
1109 theme->iconify_hover_mask;
1110 theme->a_focused_pressed_iconify->texture[0].data.mask.mask =
1111 theme->a_unfocused_pressed_iconify->texture[0].data.mask.mask =
1112 theme->iconify_pressed_mask;
1113 theme->a_focused_unpressed_iconify->texture[0].data.mask.mask =
1114 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.mask =
1115 theme->iconify_mask;
1116 theme->a_menu_bullet_normal->texture[0].data.mask.mask =
1117 theme->a_menu_bullet_selected->texture[0].data.mask.mask =
1118 theme->menu_bullet_mask;
1119 theme->a_disabled_focused_max->texture[0].data.mask.color =
1120 theme->a_disabled_focused_close->texture[0].data.mask.color =
1121 theme->a_disabled_focused_desk->texture[0].data.mask.color =
1122 theme->a_disabled_focused_shade->texture[0].data.mask.color =
1123 theme->a_disabled_focused_iconify->texture[0].data.mask.color =
1124 theme->titlebut_disabled_focused_color;
1125 theme->a_disabled_unfocused_max->texture[0].data.mask.color =
1126 theme->a_disabled_unfocused_close->texture[0].data.mask.color =
1127 theme->a_disabled_unfocused_desk->texture[0].data.mask.color =
1128 theme->a_disabled_unfocused_shade->texture[0].data.mask.color =
1129 theme->a_disabled_unfocused_iconify->texture[0].data.mask.color =
1130 theme->titlebut_disabled_unfocused_color;
1131 theme->a_hover_focused_max->texture[0].data.mask.color =
1132 theme->a_hover_focused_close->texture[0].data.mask.color =
1133 theme->a_hover_focused_desk->texture[0].data.mask.color =
1134 theme->a_hover_focused_shade->texture[0].data.mask.color =
1135 theme->a_hover_focused_iconify->texture[0].data.mask.color =
1136 theme->titlebut_hover_focused_color;
1137 theme->a_hover_unfocused_max->texture[0].data.mask.color =
1138 theme->a_hover_unfocused_close->texture[0].data.mask.color =
1139 theme->a_hover_unfocused_desk->texture[0].data.mask.color =
1140 theme->a_hover_unfocused_shade->texture[0].data.mask.color =
1141 theme->a_hover_unfocused_iconify->texture[0].data.mask.color =
1142 theme->titlebut_hover_unfocused_color;
1143 theme->a_toggled_hover_focused_max->texture[0].data.mask.color =
1144 theme->a_toggled_hover_focused_desk->texture[0].data.mask.color =
1145 theme->a_toggled_hover_focused_shade->texture[0].data.mask.color =
1146 theme->titlebut_toggled_hover_focused_color;
1147 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.color =
1148 theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.color =
1149 theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.color =
1150 theme->titlebut_toggled_hover_unfocused_color;
1151 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.color =
1152 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.color =
1153 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.color =
1154 theme->titlebut_toggled_focused_unpressed_color;
1155 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.color =
1156 theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.color =
1157 theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.color=
1158 theme->titlebut_toggled_unfocused_unpressed_color;
1159 theme->a_toggled_focused_pressed_max->texture[0].data.mask.color =
1160 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.color =
1161 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.color =
1162 theme->titlebut_toggled_focused_pressed_color;
1163 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.color =
1164 theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.color =
1165 theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.color =
1166 theme->titlebut_toggled_unfocused_pressed_color;
1167 theme->a_focused_unpressed_max->texture[0].data.mask.color =
1168 theme->a_focused_unpressed_close->texture[0].data.mask.color =
1169 theme->a_focused_unpressed_desk->texture[0].data.mask.color =
1170 theme->a_focused_unpressed_shade->texture[0].data.mask.color =
1171 theme->a_focused_unpressed_iconify->texture[0].data.mask.color =
1172 theme->titlebut_focused_unpressed_color;
1173 theme->a_focused_pressed_max->texture[0].data.mask.color =
1174 theme->a_focused_pressed_close->texture[0].data.mask.color =
1175 theme->a_focused_pressed_desk->texture[0].data.mask.color =
1176 theme->a_focused_pressed_shade->texture[0].data.mask.color =
1177 theme->a_focused_pressed_iconify->texture[0].data.mask.color =
1178 theme->titlebut_focused_pressed_color;
1179 theme->a_unfocused_unpressed_max->texture[0].data.mask.color =
1180 theme->a_unfocused_unpressed_close->texture[0].data.mask.color =
1181 theme->a_unfocused_unpressed_desk->texture[0].data.mask.color =
1182 theme->a_unfocused_unpressed_shade->texture[0].data.mask.color =
1183 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.color =
1184 theme->titlebut_unfocused_unpressed_color;
1185 theme->a_unfocused_pressed_max->texture[0].data.mask.color =
1186 theme->a_unfocused_pressed_close->texture[0].data.mask.color =
1187 theme->a_unfocused_pressed_desk->texture[0].data.mask.color =
1188 theme->a_unfocused_pressed_shade->texture[0].data.mask.color =
1189 theme->a_unfocused_pressed_iconify->texture[0].data.mask.color =
1190 theme->titlebut_unfocused_pressed_color;
1191 theme->a_menu_bullet_normal->texture[0].data.mask.color =
1193 theme->a_menu_bullet_selected->texture[0].data.mask.color =
1194 theme->menu_selected_color;
1197 XrmDestroyDatabase(db);
1199 /* set the font heights */
1200 theme->win_font_height = RrFontHeight
1201 (theme->win_font_focused,
1202 theme->a_focused_label->texture[0].data.text.shadow_offset_y);
1203 theme->win_font_height =
1204 MAX(theme->win_font_height,
1206 (theme->win_font_focused,
1207 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y));
1208 theme->menu_title_font_height = RrFontHeight
1209 (theme->menu_title_font,
1210 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y);
1211 theme->menu_font_height = RrFontHeight
1213 theme->a_menu_text_normal->texture[0].data.text.shadow_offset_y);
1215 /* calculate some last extents */
1217 gint ft, fb, fl, fr, ut, ub, ul, ur;
1219 RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb);
1220 RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub);
1221 theme->label_height = theme->win_font_height + MAX(ft + fb, ut + ub);
1222 theme->label_height += theme->label_height % 2;
1224 /* this would be nice I think, since padding.width can now be 0,
1225 but it breaks frame.c horribly and I don't feel like fixing that
1226 right now, so if anyone complains, here is how to keep text from
1227 going over the title's bevel/border with a padding.width of 0 and a
1228 bevelless/borderless label
1229 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1230 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1231 theme->title_height = theme->label_height +
1232 MAX(MAX(theme->padding * 2, ft + fb),
1233 MAX(theme->padding * 2, ut + ub));
1235 theme->title_height = theme->label_height + theme->paddingy * 2;
1237 RrMargins(theme->a_menu_title, &ul, &ut, &ur, &ub);
1238 theme->menu_title_label_height = theme->menu_title_font_height+ut+ub;
1239 theme->menu_title_height = theme->menu_title_label_height +
1240 theme->paddingy * 2;
1242 theme->button_size = theme->label_height - 2;
1243 theme->grip_width = 25;
1248 void RrThemeFree(RrTheme *theme)
1251 RrColorFree(theme->menu_border_color);
1252 RrColorFree(theme->frame_focused_border_color);
1253 RrColorFree(theme->frame_unfocused_border_color);
1254 RrColorFree(theme->cb_unfocused_color);
1255 RrColorFree(theme->cb_focused_color);
1256 RrColorFree(theme->title_focused_color);
1257 RrColorFree(theme->title_unfocused_color);
1258 RrColorFree(theme->titlebut_disabled_focused_color);
1259 RrColorFree(theme->titlebut_disabled_unfocused_color);
1260 RrColorFree(theme->titlebut_hover_focused_color);
1261 RrColorFree(theme->titlebut_hover_unfocused_color);
1262 RrColorFree(theme->titlebut_toggled_hover_focused_color);
1263 RrColorFree(theme->titlebut_toggled_hover_unfocused_color);
1264 RrColorFree(theme->titlebut_toggled_focused_pressed_color);
1265 RrColorFree(theme->titlebut_toggled_unfocused_pressed_color);
1266 RrColorFree(theme->titlebut_toggled_focused_unpressed_color);
1267 RrColorFree(theme->titlebut_toggled_unfocused_unpressed_color);
1268 RrColorFree(theme->titlebut_focused_pressed_color);
1269 RrColorFree(theme->titlebut_unfocused_pressed_color);
1270 RrColorFree(theme->titlebut_focused_unpressed_color);
1271 RrColorFree(theme->titlebut_unfocused_unpressed_color);
1272 RrColorFree(theme->menu_title_color);
1273 RrColorFree(theme->menu_color);
1274 RrColorFree(theme->menu_selected_color);
1275 RrColorFree(theme->menu_disabled_color);
1276 RrColorFree(theme->menu_disabled_selected_color);
1277 RrColorFree(theme->title_focused_shadow_color);
1278 RrColorFree(theme->title_unfocused_shadow_color);
1279 RrColorFree(theme->osd_color);
1280 RrColorFree(theme->osd_shadow_color);
1281 RrColorFree(theme->menu_title_shadow_color);
1282 RrColorFree(theme->menu_text_normal_shadow_color);
1283 RrColorFree(theme->menu_text_selected_shadow_color);
1284 RrColorFree(theme->menu_text_disabled_shadow_color);
1285 RrColorFree(theme->menu_text_disabled_selected_shadow_color);
1287 g_free(theme->def_win_icon);
1289 RrPixmapMaskFree(theme->max_mask);
1290 RrPixmapMaskFree(theme->max_toggled_mask);
1291 RrPixmapMaskFree(theme->max_toggled_hover_mask);
1292 RrPixmapMaskFree(theme->max_toggled_pressed_mask);
1293 RrPixmapMaskFree(theme->max_disabled_mask);
1294 RrPixmapMaskFree(theme->max_hover_mask);
1295 RrPixmapMaskFree(theme->max_pressed_mask);
1296 RrPixmapMaskFree(theme->desk_mask);
1297 RrPixmapMaskFree(theme->desk_toggled_mask);
1298 RrPixmapMaskFree(theme->desk_toggled_hover_mask);
1299 RrPixmapMaskFree(theme->desk_toggled_pressed_mask);
1300 RrPixmapMaskFree(theme->desk_disabled_mask);
1301 RrPixmapMaskFree(theme->desk_hover_mask);
1302 RrPixmapMaskFree(theme->desk_pressed_mask);
1303 RrPixmapMaskFree(theme->shade_mask);
1304 RrPixmapMaskFree(theme->shade_toggled_mask);
1305 RrPixmapMaskFree(theme->shade_toggled_hover_mask);
1306 RrPixmapMaskFree(theme->shade_toggled_pressed_mask);
1307 RrPixmapMaskFree(theme->shade_disabled_mask);
1308 RrPixmapMaskFree(theme->shade_hover_mask);
1309 RrPixmapMaskFree(theme->shade_pressed_mask);
1310 RrPixmapMaskFree(theme->iconify_mask);
1311 RrPixmapMaskFree(theme->iconify_disabled_mask);
1312 RrPixmapMaskFree(theme->iconify_hover_mask);
1313 RrPixmapMaskFree(theme->iconify_pressed_mask);
1314 RrPixmapMaskFree(theme->close_mask);
1315 RrPixmapMaskFree(theme->close_disabled_mask);
1316 RrPixmapMaskFree(theme->close_hover_mask);
1317 RrPixmapMaskFree(theme->close_pressed_mask);
1318 RrPixmapMaskFree(theme->menu_bullet_mask);
1320 RrFontClose(theme->win_font_focused);
1321 RrFontClose(theme->win_font_unfocused);
1322 RrFontClose(theme->menu_title_font);
1323 RrFontClose(theme->menu_font);
1325 RrAppearanceFree(theme->a_disabled_focused_max);
1326 RrAppearanceFree(theme->a_disabled_unfocused_max);
1327 RrAppearanceFree(theme->a_hover_focused_max);
1328 RrAppearanceFree(theme->a_hover_unfocused_max);
1329 RrAppearanceFree(theme->a_toggled_hover_focused_max);
1330 RrAppearanceFree(theme->a_toggled_hover_unfocused_max);
1331 RrAppearanceFree(theme->a_toggled_focused_unpressed_max);
1332 RrAppearanceFree(theme->a_toggled_focused_pressed_max);
1333 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_max);
1334 RrAppearanceFree(theme->a_toggled_unfocused_pressed_max);
1335 RrAppearanceFree(theme->a_focused_unpressed_max);
1336 RrAppearanceFree(theme->a_focused_pressed_max);
1337 RrAppearanceFree(theme->a_unfocused_unpressed_max);
1338 RrAppearanceFree(theme->a_unfocused_pressed_max);
1339 RrAppearanceFree(theme->a_disabled_focused_close);
1340 RrAppearanceFree(theme->a_disabled_unfocused_close);
1341 RrAppearanceFree(theme->a_hover_focused_close);
1342 RrAppearanceFree(theme->a_hover_unfocused_close);
1343 RrAppearanceFree(theme->a_focused_unpressed_close);
1344 RrAppearanceFree(theme->a_focused_pressed_close);
1345 RrAppearanceFree(theme->a_unfocused_unpressed_close);
1346 RrAppearanceFree(theme->a_unfocused_pressed_close);
1347 RrAppearanceFree(theme->a_disabled_focused_desk);
1348 RrAppearanceFree(theme->a_disabled_unfocused_desk);
1349 RrAppearanceFree(theme->a_hover_focused_desk);
1350 RrAppearanceFree(theme->a_hover_unfocused_desk);
1351 RrAppearanceFree(theme->a_toggled_hover_focused_desk);
1352 RrAppearanceFree(theme->a_toggled_hover_unfocused_desk);
1353 RrAppearanceFree(theme->a_toggled_focused_unpressed_desk);
1354 RrAppearanceFree(theme->a_toggled_focused_pressed_desk);
1355 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_desk);
1356 RrAppearanceFree(theme->a_toggled_unfocused_pressed_desk);
1357 RrAppearanceFree(theme->a_focused_unpressed_desk);
1358 RrAppearanceFree(theme->a_focused_pressed_desk);
1359 RrAppearanceFree(theme->a_unfocused_unpressed_desk);
1360 RrAppearanceFree(theme->a_unfocused_pressed_desk);
1361 RrAppearanceFree(theme->a_disabled_focused_shade);
1362 RrAppearanceFree(theme->a_disabled_unfocused_shade);
1363 RrAppearanceFree(theme->a_hover_focused_shade);
1364 RrAppearanceFree(theme->a_hover_unfocused_shade);
1365 RrAppearanceFree(theme->a_toggled_hover_focused_shade);
1366 RrAppearanceFree(theme->a_toggled_hover_unfocused_shade);
1367 RrAppearanceFree(theme->a_toggled_focused_unpressed_shade);
1368 RrAppearanceFree(theme->a_toggled_focused_pressed_shade);
1369 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_shade);
1370 RrAppearanceFree(theme->a_toggled_unfocused_pressed_shade);
1371 RrAppearanceFree(theme->a_focused_unpressed_shade);
1372 RrAppearanceFree(theme->a_focused_pressed_shade);
1373 RrAppearanceFree(theme->a_unfocused_unpressed_shade);
1374 RrAppearanceFree(theme->a_unfocused_pressed_shade);
1375 RrAppearanceFree(theme->a_disabled_focused_iconify);
1376 RrAppearanceFree(theme->a_disabled_unfocused_iconify);
1377 RrAppearanceFree(theme->a_hover_focused_iconify);
1378 RrAppearanceFree(theme->a_hover_unfocused_iconify);
1379 RrAppearanceFree(theme->a_focused_unpressed_iconify);
1380 RrAppearanceFree(theme->a_focused_pressed_iconify);
1381 RrAppearanceFree(theme->a_unfocused_unpressed_iconify);
1382 RrAppearanceFree(theme->a_unfocused_pressed_iconify);
1383 RrAppearanceFree(theme->a_focused_grip);
1384 RrAppearanceFree(theme->a_unfocused_grip);
1385 RrAppearanceFree(theme->a_focused_title);
1386 RrAppearanceFree(theme->a_unfocused_title);
1387 RrAppearanceFree(theme->a_focused_label);
1388 RrAppearanceFree(theme->a_unfocused_label);
1389 RrAppearanceFree(theme->a_icon);
1390 RrAppearanceFree(theme->a_focused_handle);
1391 RrAppearanceFree(theme->a_unfocused_handle);
1392 RrAppearanceFree(theme->a_menu);
1393 RrAppearanceFree(theme->a_menu_title);
1394 RrAppearanceFree(theme->a_menu_text_title);
1395 RrAppearanceFree(theme->a_menu_normal);
1396 RrAppearanceFree(theme->a_menu_selected);
1397 RrAppearanceFree(theme->a_menu_disabled);
1398 RrAppearanceFree(theme->a_menu_disabled_selected);
1399 RrAppearanceFree(theme->a_menu_text_normal);
1400 RrAppearanceFree(theme->a_menu_text_selected);
1401 RrAppearanceFree(theme->a_menu_text_disabled);
1402 RrAppearanceFree(theme->a_menu_text_disabled_selected);
1403 RrAppearanceFree(theme->a_menu_bullet_normal);
1404 RrAppearanceFree(theme->a_menu_bullet_selected);
1405 RrAppearanceFree(theme->a_clear);
1406 RrAppearanceFree(theme->a_clear_tex);
1407 RrAppearanceFree(theme->osd_hilite_bg);
1408 RrAppearanceFree(theme->osd_hilite_fg);
1409 RrAppearanceFree(theme->osd_hilite_label);
1410 RrAppearanceFree(theme->osd_unhilite_fg);
1416 static XrmDatabase loaddb(RrTheme *theme, const gchar *name, gchar **path)
1419 XrmDatabase db = NULL;
1422 if (name[0] == '/') {
1423 s = g_build_filename(name, "openbox-3", "themerc", NULL);
1424 if ((db = XrmGetFileDatabase(s)))
1425 *path = g_path_get_dirname(s);
1428 /* XXX backwards compatibility, remove me sometime later */
1429 s = g_build_filename(g_get_home_dir(), ".themes", name,
1430 "openbox-3", "themerc", NULL);
1431 if ((db = XrmGetFileDatabase(s)))
1432 *path = g_path_get_dirname(s);
1435 for (it = parse_xdg_data_dir_paths(); !db && it;
1436 it = g_slist_next(it))
1438 s = g_build_filename(it->data, "themes", name,
1439 "openbox-3", "themerc", NULL);
1440 if ((db = XrmGetFileDatabase(s)))
1441 *path = g_path_get_dirname(s);
1447 s = g_build_filename(name, "themerc", NULL);
1448 if ((db = XrmGetFileDatabase(s)))
1449 *path = g_path_get_dirname(s);
1456 static gchar *create_class_name(const gchar *rname)
1458 gchar *rclass = g_strdup(rname);
1463 p = strchr(p+1, '.');
1464 if (p == NULL) break;
1466 if (*p == '\0') break;
1471 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value)
1473 gboolean ret = FALSE;
1474 gchar *rclass = create_class_name(rname);
1475 gchar *rettype, *end;
1478 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1479 retvalue.addr != NULL) {
1480 *value = (gint)strtol(retvalue.addr, &end, 10);
1481 if (end != retvalue.addr)
1489 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value)
1491 gboolean ret = FALSE;
1492 gchar *rclass = create_class_name(rname);
1496 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1497 retvalue.addr != NULL) {
1498 *value = retvalue.addr;
1506 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
1507 const gchar *rname, RrColor **value)
1509 gboolean ret = FALSE;
1510 gchar *rclass = create_class_name(rname);
1514 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1515 retvalue.addr != NULL) {
1516 RrColor *c = RrColorParse(inst, retvalue.addr);
1527 static gboolean read_mask(const RrInstance *inst, const gchar *path,
1528 const gchar *maskname, RrTheme *theme,
1529 RrPixmapMask **value)
1531 gboolean ret = FALSE;
1533 gint hx, hy; /* ignored */
1537 s = g_build_filename(path, maskname, NULL);
1538 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
1540 *value = RrPixmapMaskNew(inst, w, h, (gchar*)b);
1548 static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
1549 RrReliefType *relief, RrBevelType *bevel,
1550 gboolean *interlaced, gboolean *border,
1551 gboolean allow_trans)
1555 /* convert to all lowercase */
1556 for (t = tex; *t != '\0'; ++t)
1557 *t = g_ascii_tolower(*t);
1559 if (allow_trans && strstr(tex, "parentrelative") != NULL) {
1560 *grad = RR_SURFACE_PARENTREL;
1562 if (strstr(tex, "gradient") != NULL) {
1563 if (strstr(tex, "crossdiagonal") != NULL)
1564 *grad = RR_SURFACE_CROSS_DIAGONAL;
1565 else if (strstr(tex, "pyramid") != NULL)
1566 *grad = RR_SURFACE_PYRAMID;
1567 else if (strstr(tex, "mirrorhorizontal") != NULL)
1568 *grad = RR_SURFACE_MIRROR_HORIZONTAL;
1569 else if (strstr(tex, "horizontal") != NULL)
1570 *grad = RR_SURFACE_HORIZONTAL;
1571 else if (strstr(tex, "splitvertical") != NULL)
1572 *grad = RR_SURFACE_SPLIT_VERTICAL;
1573 else if (strstr(tex, "vertical") != NULL)
1574 *grad = RR_SURFACE_VERTICAL;
1576 *grad = RR_SURFACE_DIAGONAL;
1578 *grad = RR_SURFACE_SOLID;
1581 if (strstr(tex, "sunken") != NULL)
1582 *relief = RR_RELIEF_SUNKEN;
1583 else if (strstr(tex, "flat") != NULL)
1584 *relief = RR_RELIEF_FLAT;
1586 *relief = RR_RELIEF_RAISED;
1589 if (*relief == RR_RELIEF_FLAT) {
1590 if (strstr(tex, "border") != NULL)
1593 if (strstr(tex, "bevel2") != NULL)
1594 *bevel = RR_BEVEL_2;
1596 *bevel = RR_BEVEL_1;
1599 if (strstr(tex, "interlaced") != NULL)
1602 *interlaced = FALSE;
1607 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
1608 const gchar *rname, RrAppearance *value,
1609 gboolean allow_trans)
1611 gboolean ret = FALSE;
1612 gchar *rclass = create_class_name(rname);
1613 gchar *cname, *ctoname, *bcname, *icname;
1617 cname = g_strconcat(rname, ".color", NULL);
1618 ctoname = g_strconcat(rname, ".colorTo", NULL);
1619 bcname = g_strconcat(rname, ".border.color", NULL);
1620 icname = g_strconcat(rname, ".interlace.color", NULL);
1622 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1623 retvalue.addr != NULL) {
1624 parse_appearance(retvalue.addr,
1625 &value->surface.grad,
1626 &value->surface.relief,
1627 &value->surface.bevel,
1628 &value->surface.interlaced,
1629 &value->surface.border,
1631 if (!read_color(db, inst, cname, &value->surface.primary))
1632 value->surface.primary = RrColorNew(inst, 0, 0, 0);
1633 if (!read_color(db, inst, ctoname, &value->surface.secondary))
1634 value->surface.secondary = RrColorNew(inst, 0, 0, 0);
1635 if (value->surface.border)
1636 if (!read_color(db, inst, bcname,
1637 &value->surface.border_color))
1638 value->surface.border_color = RrColorNew(inst, 0, 0, 0);
1639 if (value->surface.interlaced)
1640 if (!read_color(db, inst, icname,
1641 &value->surface.interlace_color))
1642 value->surface.interlace_color = RrColorNew(inst, 0, 0, 0);
1654 static int parse_inline_number(const char *p)
1662 for (; isdigit(*p); ++p)
1663 res = res * 10 + *p - '0';
1668 static void set_default_appearance(RrAppearance *a)
1670 a->surface.grad = RR_SURFACE_SOLID;
1671 a->surface.relief = RR_RELIEF_FLAT;
1672 a->surface.bevel = RR_BEVEL_1;
1673 a->surface.interlaced = FALSE;
1674 a->surface.border = FALSE;
1675 a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
1676 a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
1679 /* Reads the output from gimp's C-Source file format into valid RGBA data for
1680 an RrTextureRGBA. */
1681 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data)
1686 p = im = g_memdup(data, width * height * sizeof(RrPixel32));
1688 for (i = 0; i < width * height; ++i) {
1689 guchar a = ((*p >> 24) & 0xff);
1690 guchar b = ((*p >> 16) & 0xff);
1691 guchar g = ((*p >> 8) & 0xff);
1692 guchar r = ((*p >> 0) & 0xff);
1694 *p = ((r << RrDefaultRedOffset) +
1695 (g << RrDefaultGreenOffset) +
1696 (b << RrDefaultBlueOffset) +
1697 (a << RrDefaultAlphaOffset));