1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 theme.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 See the COPYING file for a copy of the GNU General Public License.
26 #include "obt/paths.h"
29 #include <X11/Xresource.h>
34 static XrmDatabase
loaddb(const gchar
*name
, gchar
**path
);
35 static gboolean
read_int(XrmDatabase db
, const gchar
*rname
, gint
*value
);
36 static gboolean
read_string(XrmDatabase db
, const gchar
*rname
, gchar
**value
);
37 static gboolean
read_color(XrmDatabase db
, const RrInstance
*inst
,
38 const gchar
*rname
, RrColor
**value
);
39 static gboolean
read_mask(const RrInstance
*inst
, const gchar
*path
,
40 RrTheme
*theme
, const gchar
*maskname
,
41 RrPixmapMask
**value
);
42 static gboolean
read_appearance(XrmDatabase db
, const RrInstance
*inst
,
43 const gchar
*rname
, RrAppearance
*value
,
44 gboolean allow_trans
);
45 static int parse_inline_number(const char *p
);
46 static RrPixel32
* read_c_image(gint width
, gint height
, const guint8
*data
);
47 static void set_default_appearance(RrAppearance
*a
);
49 static RrFont
*get_font(RrFont
*target
, RrFont
**default_font
,
50 const RrInstance
*inst
)
56 /* Only load the default font once */
58 RrFontRef(*default_font
);
60 *default_font
= RrFontOpenDefault(inst
);
66 #define READ_INT(x_resstr, x_var, x_min, x_max, x_def) \
67 if (!read_int(db, x_resstr, & x_var) || \
68 x_var < x_min || x_var > x_max) \
71 #define READ_COLOR(x_resstr, x_var, x_def) \
72 if (!read_color(db, inst, x_resstr, & x_var)) \
75 #define READ_COLOR_(x_res1, x_res2, x_var, x_def) \
76 if (!read_color(db, inst, x_res1, & x_var) && \
77 !read_color(db, inst, x_res2, & x_var)) \
80 #define READ_MASK_COPY(x_file, x_var, x_copysrc) \
81 if (!read_mask(inst, path, theme, x_file, & x_var)) \
82 x_var = RrPixmapMaskCopy(x_copysrc);
84 #define READ_APPEARANCE(x_resstr, x_var, x_parrel) \
85 if (!read_appearance(db, inst, x_resstr, x_var, x_parrel)) \
86 set_default_appearance(x_var);
88 #define READ_APPEARANCE_COPY(x_resstr, x_var, x_parrel, x_defval) \
89 if (!read_appearance(db, inst, x_resstr, x_var, x_parrel)) {\
90 RrAppearanceFree(x_var); \
91 x_var = RrAppearanceCopy(x_defval); }
93 #define READ_APPEARANCE_(x_res1, x_res2, x_var, x_parrel, x_defval) \
94 if (!read_appearance(db, inst, x_res1, x_var, x_parrel) && \
95 !read_appearance(db, inst, x_res2, x_var, x_parrel)) {\
96 RrAppearanceFree(x_var); \
97 x_var = RrAppearanceCopy(x_defval); }
99 RrTheme
* RrThemeNew(const RrInstance
*inst
, const gchar
*name
,
100 gboolean allow_fallback
,
101 RrFont
*active_window_font
, RrFont
*inactive_window_font
,
102 RrFont
*menu_title_font
, RrFont
*menu_item_font
,
103 RrFont
*active_osd_font
, RrFont
*inactive_osd_font
)
105 XrmDatabase db
= NULL
;
106 RrJustify winjust
, mtitlejust
;
109 RrFont
*default_font
= NULL
;
112 gint menu_overlap
= 0;
115 db
= loaddb(name
, &path
);
117 g_message("Unable to load the theme '%s'", name
);
119 g_message("Falling back to the default theme '%s'",
121 /* fallback to the default theme */
126 if (allow_fallback
) {
127 db
= loaddb(DEFAULT_THEME
, &path
);
129 g_message("Unable to load the theme '%s'", DEFAULT_THEME
);
136 theme
= g_slice_new0(RrTheme
);
139 theme
->name
= g_strdup(name
? name
: DEFAULT_THEME
);
141 theme
->a_disabled_focused_max
= RrAppearanceNew(inst
, 1);
142 theme
->a_disabled_unfocused_max
= RrAppearanceNew(inst
, 1);
143 theme
->a_hover_focused_max
= RrAppearanceNew(inst
, 1);
144 theme
->a_hover_unfocused_max
= RrAppearanceNew(inst
, 1);
145 theme
->a_toggled_focused_unpressed_max
= RrAppearanceNew(inst
, 1);
146 theme
->a_toggled_unfocused_unpressed_max
= RrAppearanceNew(inst
, 1);
147 theme
->a_toggled_hover_focused_max
= RrAppearanceNew(inst
, 1);
148 theme
->a_toggled_hover_unfocused_max
= RrAppearanceNew(inst
, 1);
149 theme
->a_toggled_focused_pressed_max
= RrAppearanceNew(inst
, 1);
150 theme
->a_toggled_unfocused_pressed_max
= RrAppearanceNew(inst
, 1);
151 theme
->a_focused_unpressed_max
= RrAppearanceNew(inst
, 1);
152 theme
->a_focused_pressed_max
= RrAppearanceNew(inst
, 1);
153 theme
->a_unfocused_unpressed_max
= RrAppearanceNew(inst
, 1);
154 theme
->a_unfocused_pressed_max
= RrAppearanceNew(inst
, 1);
155 theme
->a_focused_grip
= RrAppearanceNew(inst
, 0);
156 theme
->a_unfocused_grip
= RrAppearanceNew(inst
, 0);
157 theme
->a_focused_title
= RrAppearanceNew(inst
, 0);
158 theme
->a_unfocused_title
= RrAppearanceNew(inst
, 0);
159 theme
->a_focused_label
= RrAppearanceNew(inst
, 1);
160 theme
->a_unfocused_label
= RrAppearanceNew(inst
, 1);
161 theme
->a_icon
= RrAppearanceNew(inst
, 1);
162 theme
->a_focused_handle
= RrAppearanceNew(inst
, 0);
163 theme
->a_unfocused_handle
= RrAppearanceNew(inst
, 0);
164 theme
->a_menu
= RrAppearanceNew(inst
, 0);
165 theme
->a_menu_title
= RrAppearanceNew(inst
, 0);
166 theme
->a_menu_text_title
= RrAppearanceNew(inst
, 1);
167 theme
->a_menu_normal
= RrAppearanceNew(inst
, 0);
168 theme
->a_menu_selected
= RrAppearanceNew(inst
, 0);
169 theme
->a_menu_disabled
= RrAppearanceNew(inst
, 0);
170 /* a_menu_disabled_selected is copied from a_menu_selected */
171 theme
->a_menu_text_normal
= RrAppearanceNew(inst
, 1);
172 theme
->a_menu_text_selected
= RrAppearanceNew(inst
, 1);
173 theme
->a_menu_text_disabled
= RrAppearanceNew(inst
, 1);
174 theme
->a_menu_text_disabled_selected
= RrAppearanceNew(inst
, 1);
175 theme
->a_menu_bullet_normal
= RrAppearanceNew(inst
, 1);
176 theme
->a_menu_bullet_selected
= RrAppearanceNew(inst
, 1);
177 theme
->a_clear
= RrAppearanceNew(inst
, 0);
178 theme
->a_clear_tex
= RrAppearanceNew(inst
, 1);
179 theme
->osd_bg
= RrAppearanceNew(inst
, 0);
180 theme
->osd_hilite_label
= RrAppearanceNew(inst
, 1);
181 theme
->osd_hilite_bg
= RrAppearanceNew(inst
, 0);
182 theme
->osd_unhilite_label
= RrAppearanceNew(inst
, 1);
183 theme
->osd_unhilite_bg
= RrAppearanceNew(inst
, 0);
185 /* load the font stuff */
186 theme
->win_font_focused
= get_font(active_window_font
,
187 &default_font
, inst
);
188 theme
->win_font_unfocused
= get_font(inactive_window_font
,
189 &default_font
, inst
);
191 winjust
= RR_JUSTIFY_LEFT
;
192 if (read_string(db
, "window.label.text.justify", &str
)) {
193 if (!g_ascii_strcasecmp(str
, "right"))
194 winjust
= RR_JUSTIFY_RIGHT
;
195 else if (!g_ascii_strcasecmp(str
, "center"))
196 winjust
= RR_JUSTIFY_CENTER
;
199 theme
->menu_title_font
= get_font(menu_title_font
, &default_font
, inst
);
201 mtitlejust
= RR_JUSTIFY_LEFT
;
202 if (read_string(db
, "menu.title.text.justify", &str
)) {
203 if (!g_ascii_strcasecmp(str
, "right"))
204 mtitlejust
= RR_JUSTIFY_RIGHT
;
205 else if (!g_ascii_strcasecmp(str
, "center"))
206 mtitlejust
= RR_JUSTIFY_CENTER
;
209 theme
->menu_font
= get_font(menu_item_font
, &default_font
, inst
);
211 theme
->osd_font_hilite
= get_font(active_osd_font
, &default_font
, inst
);
212 theme
->osd_font_unhilite
= get_font(inactive_osd_font
, &default_font
,inst
);
214 /* load direct dimensions */
215 READ_INT("menu.overlap", menu_overlap
, -100, 100, 0);
216 READ_INT("menu.overlap.x", theme
->menu_overlap_x
, -100, 100, menu_overlap
);
217 READ_INT("menu.overlap.y", theme
->menu_overlap_y
, -100, 100, menu_overlap
);
218 READ_INT("window.handle.width", theme
->handle_height
, 0, 100, 6);
219 READ_INT("padding.width", theme
->paddingx
, 0, 100, 3);
220 READ_INT("padding.height", theme
->paddingy
, 0, 100, theme
->paddingx
);
221 READ_INT("border.width", theme
->fbwidth
, 0, 100, 1);
222 READ_INT("menu.border.width", theme
->mbwidth
, 0, 100, theme
->fbwidth
);
223 READ_INT("osd.border.width", theme
->obwidth
, 0, 100, theme
->fbwidth
);
224 READ_INT("menu.separator.width", theme
->menu_sep_width
, 1, 100, 1);
225 READ_INT("menu.separator.padding.width", theme
->menu_sep_paddingx
, 0, 100, 6);
226 READ_INT("menu.separator.padding.height", theme
->menu_sep_paddingy
, 0, 100, 3);
227 READ_INT("window.client.padding.width", theme
->cbwidthx
, 0, 100,
229 READ_INT("window.client.padding.height", theme
->cbwidthy
, 0, 100,
233 READ_COLOR_("window.active.border.color", "border.color",
234 theme
->frame_focused_border_color
, RrColorNew(inst
, 0, 0, 0));
236 /* title separator focused color inherits from focused border color */
237 READ_COLOR("window.active.title.separator.color",
238 theme
->title_separator_focused_color
,
239 RrColorCopy(theme
->frame_focused_border_color
));
241 /* unfocused border color inherits from frame focused border color */
242 READ_COLOR("window.inactive.border.color",
243 theme
->frame_unfocused_border_color
,
244 RrColorCopy(theme
->frame_focused_border_color
));
246 /* title separator unfocused color inherits from unfocused border color */
247 READ_COLOR("window.inactive.title.separator.color",
248 theme
->title_separator_unfocused_color
,
249 RrColorCopy(theme
->frame_unfocused_border_color
));
251 /* menu border color inherits from frame focused border color */
252 READ_COLOR("menu.border.color", theme
->menu_border_color
,
253 RrColorCopy(theme
->frame_focused_border_color
));
255 /* osd border color inherits from frame focused border color */
256 READ_COLOR("osd.border.color", theme
->osd_border_color
,
257 RrColorCopy(theme
->frame_focused_border_color
));
259 READ_COLOR("window.active.client.color", theme
->cb_focused_color
,
260 RrColorNew(inst
, 0xff, 0xff, 0xff));
262 READ_COLOR("window.inactive.client.color", theme
->cb_unfocused_color
,
263 RrColorNew(inst
, 0xff, 0xff, 0xff));
265 READ_COLOR("window.active.label.text.color", theme
->title_focused_color
,
266 RrColorNew(inst
, 0x0, 0x0, 0x0));
268 READ_COLOR_("osd.active.label.text.color",
269 "osd.label.text.color",
270 theme
->osd_color
, RrColorCopy(theme
->title_focused_color
));
272 READ_COLOR("window.inactive.label.text.color", theme
->title_unfocused_color
,
273 RrColorCopy(theme
->title_unfocused_color
));
275 READ_COLOR("osd.inactive.label.text.color", theme
->osd_text_inactive_color
,
276 RrColorNew(inst
, 0xff, 0xff, 0xff));
278 READ_COLOR("window.inactive.label.text.color",
279 theme
->title_unfocused_color
,
280 RrColorNew(inst
, 0xff, 0xff, 0xff));
282 READ_COLOR("window.active.button.unpressed.image.color",
283 theme
->titlebut_focused_unpressed_color
,
284 RrColorNew(inst
, 0, 0, 0));
286 READ_COLOR("window.inactive.button.unpressed.image.color",
287 theme
->titlebut_unfocused_unpressed_color
,
288 RrColorNew(inst
, 0xff, 0xff, 0xff));
290 READ_COLOR("window.active.button.pressed.image.color",
291 theme
->titlebut_focused_pressed_color
,
292 RrColorCopy(theme
->titlebut_focused_unpressed_color
));
294 READ_COLOR("window.inactive.button.pressed.image.color",
295 theme
->titlebut_unfocused_pressed_color
,
296 RrColorCopy(theme
->titlebut_unfocused_unpressed_color
));
298 READ_COLOR("window.active.button.disabled.image.color",
299 theme
->titlebut_disabled_focused_color
,
300 RrColorNew(inst
, 0xff, 0xff, 0xff));
302 READ_COLOR("window.inactive.button.disabled.image.color",
303 theme
->titlebut_disabled_unfocused_color
,
304 RrColorNew(inst
, 0, 0, 0));
306 READ_COLOR("window.active.button.hover.image.color",
307 theme
->titlebut_hover_focused_color
,
308 RrColorCopy(theme
->titlebut_focused_unpressed_color
));
310 READ_COLOR("window.inactive.button.hover.image.color",
311 theme
->titlebut_hover_unfocused_color
,
312 RrColorCopy(theme
->titlebut_unfocused_unpressed_color
));
314 READ_COLOR_("window.active.button.toggled.unpressed.image.color",
315 "window.active.button.toggled.image.color",
316 theme
->titlebut_toggled_focused_unpressed_color
,
317 RrColorCopy(theme
->titlebut_focused_pressed_color
));
319 READ_COLOR_("window.inactive.button.toggled.unpressed.image.color",
320 "window.inactive.button.toggled.image.color",
321 theme
->titlebut_toggled_unfocused_unpressed_color
,
322 RrColorCopy(theme
->titlebut_unfocused_pressed_color
));
324 READ_COLOR("window.active.button.toggled.hover.image.color",
325 theme
->titlebut_toggled_hover_focused_color
,
326 RrColorCopy(theme
->titlebut_toggled_focused_unpressed_color
));
328 READ_COLOR("window.inactive.button.toggled.hover.image.color",
329 theme
->titlebut_toggled_hover_unfocused_color
,
330 RrColorCopy(theme
->titlebut_toggled_unfocused_unpressed_color
));
332 READ_COLOR("window.active.button.toggled.pressed.image.color",
333 theme
->titlebut_toggled_focused_pressed_color
,
334 RrColorCopy(theme
->titlebut_focused_pressed_color
));
336 READ_COLOR("window.inactive.button.toggled.pressed.image.color",
337 theme
->titlebut_toggled_unfocused_pressed_color
,
338 RrColorCopy(theme
->titlebut_unfocused_pressed_color
));
340 READ_COLOR("menu.title.text.color", theme
->menu_title_color
,
341 RrColorNew(inst
, 0, 0, 0));
343 READ_COLOR("menu.items.text.color", theme
->menu_color
,
344 RrColorNew(inst
, 0xff, 0xff, 0xff));
346 READ_COLOR("menu.items.disabled.text.color", theme
->menu_disabled_color
,
347 RrColorNew(inst
, 0, 0, 0));
349 READ_COLOR("menu.items.active.disabled.text.color",
350 theme
->menu_disabled_selected_color
,
351 RrColorCopy(theme
->menu_disabled_color
));
353 READ_COLOR("menu.items.active.text.color", theme
->menu_selected_color
,
354 RrColorNew(inst
, 0, 0, 0));
356 READ_COLOR("menu.separator.color", theme
->menu_sep_color
,
357 RrColorCopy(theme
->menu_color
));
359 /* load the image masks */
361 /* maximize button masks */
363 if (!read_mask(inst
, path
, theme
, "max.xbm", &theme
->max_mask
)) {
364 guchar data
[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
365 theme
->max_mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
368 if (!read_mask(inst
, path
, theme
, "max_toggled.xbm",
369 &theme
->max_toggled_mask
))
372 theme
->max_toggled_mask
= RrPixmapMaskCopy(theme
->max_mask
);
374 guchar data
[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
375 theme
->max_toggled_mask
= RrPixmapMaskNew(inst
, 6, 6,(gchar
*)data
);
378 READ_MASK_COPY("max_pressed.xbm", theme
->max_pressed_mask
,
380 READ_MASK_COPY("max_disabled.xbm", theme
->max_disabled_mask
,
382 READ_MASK_COPY("max_hover.xbm", theme
->max_hover_mask
, theme
->max_mask
);
383 READ_MASK_COPY("max_toggled_pressed.xbm", theme
->max_toggled_pressed_mask
,
384 theme
->max_toggled_mask
);
385 READ_MASK_COPY("max_toggled_hover.xbm", theme
->max_toggled_hover_mask
,
386 theme
->max_toggled_mask
);
388 /* iconify button masks */
389 if (!read_mask(inst
, path
, theme
, "iconify.xbm", &theme
->iconify_mask
)) {
390 guchar data
[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
391 theme
->iconify_mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
393 READ_MASK_COPY("iconify_pressed.xbm", theme
->iconify_pressed_mask
,
394 theme
->iconify_mask
);
395 READ_MASK_COPY("iconify_disabled.xbm", theme
->iconify_disabled_mask
,
396 theme
->iconify_mask
);
397 READ_MASK_COPY("iconify_hover.xbm", theme
->iconify_hover_mask
,
398 theme
->iconify_mask
);
400 /* all desktops button masks */
402 if (!read_mask(inst
, path
, theme
, "desk.xbm", &theme
->desk_mask
)) {
403 guchar data
[] = { 0x33, 0x33, 0x00, 0x00, 0x33, 0x33 };
404 theme
->desk_mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
407 if (!read_mask(inst
, path
, theme
, "desk_toggled.xbm",
408 &theme
->desk_toggled_mask
)) {
410 theme
->desk_toggled_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
412 guchar data
[] = { 0x00, 0x1e, 0x1a, 0x16, 0x1e, 0x00 };
413 theme
->desk_toggled_mask
=
414 RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
417 READ_MASK_COPY("desk_pressed.xbm", theme
->desk_pressed_mask
,
419 READ_MASK_COPY("desk_disabled.xbm", theme
->desk_disabled_mask
,
421 READ_MASK_COPY("desk_hover.xbm", theme
->desk_hover_mask
, theme
->desk_mask
);
422 READ_MASK_COPY("desk_toggled_pressed.xbm",
423 theme
->desk_toggled_pressed_mask
, theme
->desk_toggled_mask
);
424 READ_MASK_COPY("desk_toggled_hover.xbm", theme
->desk_toggled_hover_mask
,
425 theme
->desk_toggled_mask
);
427 /* shade button masks */
428 if (!read_mask(inst
, path
, theme
, "shade.xbm", &theme
->shade_mask
)) {
429 guchar data
[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
430 theme
->shade_mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
432 READ_MASK_COPY("shade_toggled.xbm", theme
->shade_toggled_mask
,
434 READ_MASK_COPY("shade_pressed.xbm", theme
->shade_pressed_mask
,
436 READ_MASK_COPY("shade_disabled.xbm", theme
->shade_disabled_mask
,
438 READ_MASK_COPY("shade_hover.xbm", theme
->shade_hover_mask
,
440 READ_MASK_COPY("shade_toggled_pressed.xbm",
441 theme
->shade_toggled_pressed_mask
,
442 theme
->shade_toggled_mask
);
443 READ_MASK_COPY("shade_toggled_hover.xbm",
444 theme
->shade_toggled_hover_mask
, theme
->shade_toggled_mask
);
446 /* close button masks */
447 if (!read_mask(inst
, path
, theme
, "close.xbm", &theme
->close_mask
)) {
448 guchar data
[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
449 theme
->close_mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
451 READ_MASK_COPY("close_pressed.xbm", theme
->close_pressed_mask
,
453 READ_MASK_COPY("close_disabled.xbm", theme
->close_disabled_mask
,
455 READ_MASK_COPY("close_hover.xbm", theme
->close_hover_mask
,
458 /* submenu bullet mask */
459 if (!read_mask(inst
, path
, theme
, "bullet.xbm", &theme
->menu_bullet_mask
))
461 guchar data
[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
462 theme
->menu_bullet_mask
= RrPixmapMaskNew(inst
, 4, 7, (gchar
*)data
);
465 /* up and down arrows */
467 guchar data
[] = { 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00 };
468 theme
->down_arrow_mask
= RrPixmapMaskNew(inst
, 9, 4, (gchar
*)data
);
471 guchar data
[] = { 0x10, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xfe, 0x00 };
472 theme
->up_arrow_mask
= RrPixmapMaskNew(inst
, 9, 4, (gchar
*)data
);
475 /* setup the default window icon */
476 theme
->def_win_icon
= read_c_image(OB_DEFAULT_ICON_WIDTH
,
477 OB_DEFAULT_ICON_HEIGHT
,
478 OB_DEFAULT_ICON_pixel_data
);
479 theme
->def_win_icon_w
= OB_DEFAULT_ICON_WIDTH
;
480 theme
->def_win_icon_h
= OB_DEFAULT_ICON_HEIGHT
;
482 /* read the decoration textures */
483 READ_APPEARANCE("window.active.title.bg", theme
->a_focused_title
, FALSE
);
484 READ_APPEARANCE("window.inactive.title.bg", theme
->a_unfocused_title
,
486 READ_APPEARANCE("window.active.label.bg", theme
->a_focused_label
, TRUE
);
487 READ_APPEARANCE("window.inactive.label.bg", theme
->a_unfocused_label
,
489 READ_APPEARANCE("window.active.handle.bg", theme
->a_focused_handle
, FALSE
);
490 READ_APPEARANCE("window.inactive.handle.bg",theme
->a_unfocused_handle
,
492 READ_APPEARANCE("window.active.grip.bg", theme
->a_focused_grip
, TRUE
);
493 READ_APPEARANCE("window.inactive.grip.bg", theme
->a_unfocused_grip
, TRUE
);
494 READ_APPEARANCE("menu.items.bg", theme
->a_menu
, FALSE
);
495 READ_APPEARANCE("menu.title.bg", theme
->a_menu_title
, TRUE
);
496 READ_APPEARANCE("menu.items.active.bg", theme
->a_menu_selected
, TRUE
);
498 theme
->a_menu_disabled_selected
=
499 RrAppearanceCopy(theme
->a_menu_selected
);
501 /* read appearances for non-decorations (on-screen-display) */
502 if (!read_appearance(db
, inst
, "osd.bg", theme
->osd_bg
, FALSE
)) {
503 RrAppearanceFree(theme
->osd_bg
);
504 theme
->osd_bg
= RrAppearanceCopy(theme
->a_focused_title
);
506 if (!read_appearance(db
, inst
, "osd.active.label.bg",
507 theme
->osd_hilite_label
, TRUE
) &&
508 !read_appearance(db
, inst
, "osd.label.bg",
509 theme
->osd_hilite_label
, TRUE
)) {
510 RrAppearanceFree(theme
->osd_hilite_label
);
511 theme
->osd_hilite_label
= RrAppearanceCopy(theme
->a_focused_label
);
513 if (!read_appearance(db
, inst
, "osd.inactive.label.bg",
514 theme
->osd_unhilite_label
, TRUE
)) {
515 RrAppearanceFree(theme
->osd_unhilite_label
);
516 theme
->osd_unhilite_label
= RrAppearanceCopy(theme
->a_unfocused_label
);
518 /* osd_hilite_fg can't be parentrel */
519 if (!read_appearance(db
, inst
, "osd.hilight.bg",
520 theme
->osd_hilite_bg
, FALSE
)) {
521 RrAppearanceFree(theme
->osd_hilite_bg
);
522 if (theme
->a_focused_label
->surface
.grad
!= RR_SURFACE_PARENTREL
)
523 theme
->osd_hilite_bg
= RrAppearanceCopy(theme
->a_focused_label
);
525 theme
->osd_hilite_bg
= RrAppearanceCopy(theme
->a_focused_title
);
527 /* osd_unhilite_fg can't be parentrel either */
528 if (!read_appearance(db
, inst
, "osd.unhilight.bg",
529 theme
->osd_unhilite_bg
, FALSE
)) {
530 RrAppearanceFree(theme
->osd_unhilite_bg
);
531 if (theme
->a_unfocused_label
->surface
.grad
!= RR_SURFACE_PARENTREL
)
532 theme
->osd_unhilite_bg
=RrAppearanceCopy(theme
->a_unfocused_label
);
534 theme
->osd_unhilite_bg
=RrAppearanceCopy(theme
->a_unfocused_title
);
537 /* read buttons textures */
538 READ_APPEARANCE("window.active.button.disabled.bg",
539 theme
->a_disabled_focused_max
, TRUE
);
540 READ_APPEARANCE("window.inactive.button.disabled.bg",
541 theme
->a_disabled_unfocused_max
, TRUE
);
542 READ_APPEARANCE("window.active.button.pressed.bg",
543 theme
->a_focused_pressed_max
, TRUE
);
544 READ_APPEARANCE("window.inactive.button.pressed.bg",
545 theme
->a_unfocused_pressed_max
, TRUE
);
547 READ_APPEARANCE_("window.active.button.toggled.unpressed.bg",
548 "window.active.button.toggled.bg",
549 theme
->a_toggled_focused_unpressed_max
, TRUE
,
550 theme
->a_focused_pressed_max
);
551 READ_APPEARANCE_("window.inactive.button.toggled.unpressed.bg",
552 "window.inactive.button.toggled.bg",
553 theme
->a_toggled_unfocused_unpressed_max
, TRUE
,
554 theme
->a_unfocused_pressed_max
);
556 READ_APPEARANCE_COPY("window.active.button.toggled.hover.bg",
557 theme
->a_toggled_hover_focused_max
, TRUE
,
558 theme
->a_toggled_focused_unpressed_max
);
559 READ_APPEARANCE_COPY("window.inactive.button.toggled.hover.bg",
560 theme
->a_toggled_hover_unfocused_max
, TRUE
,
561 theme
->a_toggled_unfocused_unpressed_max
);
563 READ_APPEARANCE_COPY("window.active.button.toggled.pressed.bg",
564 theme
->a_toggled_focused_pressed_max
, TRUE
,
565 theme
->a_focused_pressed_max
);
566 READ_APPEARANCE_COPY("window.inactive.button.toggled.pressed.bg",
567 theme
->a_toggled_unfocused_pressed_max
, TRUE
,
568 theme
->a_unfocused_pressed_max
);
570 READ_APPEARANCE("window.active.button.unpressed.bg",
571 theme
->a_focused_unpressed_max
, TRUE
);
572 READ_APPEARANCE("window.inactive.button.unpressed.bg",
573 theme
->a_unfocused_unpressed_max
, TRUE
);
575 READ_APPEARANCE_COPY("window.active.button.hover.bg",
576 theme
->a_hover_focused_max
, TRUE
,
577 theme
->a_focused_unpressed_max
);
578 READ_APPEARANCE_COPY("window.inactive.button.hover.bg",
579 theme
->a_hover_unfocused_max
, TRUE
,
580 theme
->a_unfocused_unpressed_max
);
582 theme
->a_disabled_focused_close
=
583 RrAppearanceCopy(theme
->a_disabled_focused_max
);
584 theme
->a_disabled_unfocused_close
=
585 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
586 theme
->a_hover_focused_close
=
587 RrAppearanceCopy(theme
->a_hover_focused_max
);
588 theme
->a_hover_unfocused_close
=
589 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
590 theme
->a_unfocused_unpressed_close
=
591 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
592 theme
->a_unfocused_pressed_close
=
593 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
594 theme
->a_focused_unpressed_close
=
595 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
596 theme
->a_focused_pressed_close
=
597 RrAppearanceCopy(theme
->a_focused_pressed_max
);
598 theme
->a_disabled_focused_desk
=
599 RrAppearanceCopy(theme
->a_disabled_focused_max
);
600 theme
->a_disabled_unfocused_desk
=
601 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
602 theme
->a_hover_focused_desk
=
603 RrAppearanceCopy(theme
->a_hover_focused_max
);
604 theme
->a_hover_unfocused_desk
=
605 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
606 theme
->a_toggled_hover_focused_desk
=
607 RrAppearanceCopy(theme
->a_toggled_hover_focused_max
);
608 theme
->a_toggled_hover_unfocused_desk
=
609 RrAppearanceCopy(theme
->a_toggled_hover_unfocused_max
);
610 theme
->a_toggled_focused_unpressed_desk
=
611 RrAppearanceCopy(theme
->a_toggled_focused_unpressed_max
);
612 theme
->a_toggled_unfocused_unpressed_desk
=
613 RrAppearanceCopy(theme
->a_toggled_unfocused_unpressed_max
);
614 theme
->a_toggled_focused_pressed_desk
=
615 RrAppearanceCopy(theme
->a_toggled_focused_pressed_max
);
616 theme
->a_toggled_unfocused_pressed_desk
=
617 RrAppearanceCopy(theme
->a_toggled_unfocused_pressed_max
);
618 theme
->a_unfocused_unpressed_desk
=
619 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
620 theme
->a_unfocused_pressed_desk
=
621 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
622 theme
->a_focused_unpressed_desk
=
623 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
624 theme
->a_focused_pressed_desk
=
625 RrAppearanceCopy(theme
->a_focused_pressed_max
);
626 theme
->a_disabled_focused_shade
=
627 RrAppearanceCopy(theme
->a_disabled_focused_max
);
628 theme
->a_disabled_unfocused_shade
=
629 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
630 theme
->a_hover_focused_shade
=
631 RrAppearanceCopy(theme
->a_hover_focused_max
);
632 theme
->a_hover_unfocused_shade
=
633 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
634 theme
->a_toggled_hover_focused_shade
=
635 RrAppearanceCopy(theme
->a_toggled_hover_focused_max
);
636 theme
->a_toggled_hover_unfocused_shade
=
637 RrAppearanceCopy(theme
->a_toggled_hover_unfocused_max
);
638 theme
->a_toggled_focused_unpressed_shade
=
639 RrAppearanceCopy(theme
->a_toggled_focused_unpressed_max
);
640 theme
->a_toggled_unfocused_unpressed_shade
=
641 RrAppearanceCopy(theme
->a_toggled_unfocused_unpressed_max
);
642 theme
->a_toggled_focused_pressed_shade
=
643 RrAppearanceCopy(theme
->a_toggled_focused_pressed_max
);
644 theme
->a_toggled_unfocused_pressed_shade
=
645 RrAppearanceCopy(theme
->a_toggled_unfocused_pressed_max
);
646 theme
->a_unfocused_unpressed_shade
=
647 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
648 theme
->a_unfocused_pressed_shade
=
649 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
650 theme
->a_focused_unpressed_shade
=
651 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
652 theme
->a_focused_pressed_shade
=
653 RrAppearanceCopy(theme
->a_focused_pressed_max
);
654 theme
->a_disabled_focused_iconify
=
655 RrAppearanceCopy(theme
->a_disabled_focused_max
);
656 theme
->a_disabled_unfocused_iconify
=
657 RrAppearanceCopy(theme
->a_disabled_focused_max
);
658 theme
->a_hover_focused_iconify
=
659 RrAppearanceCopy(theme
->a_hover_focused_max
);
660 theme
->a_hover_unfocused_iconify
=
661 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
662 theme
->a_unfocused_unpressed_iconify
=
663 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
664 theme
->a_unfocused_pressed_iconify
=
665 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
666 theme
->a_focused_unpressed_iconify
=
667 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
668 theme
->a_focused_pressed_iconify
=
669 RrAppearanceCopy(theme
->a_focused_pressed_max
);
671 theme
->a_icon
->surface
.grad
=
672 theme
->a_clear
->surface
.grad
=
673 theme
->a_clear_tex
->surface
.grad
=
674 theme
->a_menu_text_title
->surface
.grad
=
675 theme
->a_menu_normal
->surface
.grad
=
676 theme
->a_menu_disabled
->surface
.grad
=
677 theme
->a_menu_text_normal
->surface
.grad
=
678 theme
->a_menu_text_selected
->surface
.grad
=
679 theme
->a_menu_text_disabled
->surface
.grad
=
680 theme
->a_menu_text_disabled_selected
->surface
.grad
=
681 theme
->a_menu_bullet_normal
->surface
.grad
=
682 theme
->a_menu_bullet_selected
->surface
.grad
= RR_SURFACE_PARENTREL
;
684 /* set up the textures */
685 theme
->a_focused_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
686 theme
->a_focused_label
->texture
[0].data
.text
.justify
= winjust
;
687 theme
->a_focused_label
->texture
[0].data
.text
.font
=theme
->win_font_focused
;
688 theme
->a_focused_label
->texture
[0].data
.text
.color
=
689 theme
->title_focused_color
;
691 if (read_string(db
, "window.active.label.text.font", &str
)) {
695 if (strstr(str
, "shadow=y")) {
696 if ((p
= strstr(str
, "shadowoffset=")))
697 i
= parse_inline_number(p
+ strlen("shadowoffset="));
700 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_x
= i
;
701 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_y
= i
;
703 if ((p
= strstr(str
, "shadowtint=")))
705 i
= parse_inline_number(p
+ strlen("shadowtint="));
706 j
= (i
> 0 ? 0 : 255);
709 theme
->title_focused_shadow_color
= RrColorNew(inst
, j
, j
, j
);
710 theme
->title_focused_shadow_alpha
= i
;
712 theme
->title_focused_shadow_color
= RrColorNew(inst
, 0, 0, 0);
713 theme
->title_focused_shadow_alpha
= 50;
717 theme
->a_focused_label
->texture
[0].data
.text
.shadow_color
=
718 theme
->title_focused_shadow_color
;
719 theme
->a_focused_label
->texture
[0].data
.text
.shadow_alpha
=
720 theme
->title_focused_shadow_alpha
;
722 theme
->osd_hilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
723 theme
->osd_hilite_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
724 theme
->osd_hilite_label
->texture
[0].data
.text
.font
=
725 theme
->osd_font_hilite
;
726 theme
->osd_hilite_label
->texture
[0].data
.text
.color
=
727 theme
->osd_text_active_color
;
729 if (read_string(db
, "osd.active.label.text.font", &str
) ||
730 read_string(db
, "osd.label.text.font", &str
))
735 if (strstr(str
, "shadow=y")) {
736 if ((p
= strstr(str
, "shadowoffset=")))
737 i
= parse_inline_number(p
+ strlen("shadowoffset="));
740 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_offset_x
= i
;
741 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_offset_y
= i
;
743 if ((p
= strstr(str
, "shadowtint=")))
745 i
= parse_inline_number(p
+ strlen("shadowtint="));
746 j
= (i
> 0 ? 0 : 255);
749 theme
->osd_text_active_shadow_color
= RrColorNew(inst
, j
, j
, j
);
750 theme
->osd_text_active_shadow_alpha
= i
;
752 theme
->osd_text_active_shadow_color
= RrColorNew(inst
, 0, 0, 0);
753 theme
->osd_text_active_shadow_alpha
= 50;
756 /* inherit the font settings from the focused label */
757 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_offset_x
=
758 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_x
;
759 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_offset_y
=
760 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_y
;
761 if (theme
->title_focused_shadow_color
)
762 theme
->osd_text_active_shadow_color
=
764 theme
->title_focused_shadow_color
->r
,
765 theme
->title_focused_shadow_color
->g
,
766 theme
->title_focused_shadow_color
->b
);
768 theme
->osd_text_active_shadow_color
= RrColorNew(inst
, 0, 0, 0);
769 theme
->osd_text_active_shadow_alpha
=
770 theme
->title_focused_shadow_alpha
;
773 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_color
=
774 theme
->osd_text_active_shadow_color
;
775 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_alpha
=
776 theme
->osd_text_active_shadow_alpha
;
778 theme
->a_unfocused_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
779 theme
->a_unfocused_label
->texture
[0].data
.text
.justify
= winjust
;
780 theme
->a_unfocused_label
->texture
[0].data
.text
.font
=
781 theme
->win_font_unfocused
;
782 theme
->a_unfocused_label
->texture
[0].data
.text
.color
=
783 theme
->title_unfocused_color
;
785 if (read_string(db
, "window.inactive.label.text.font", &str
)) {
789 if (strstr(str
, "shadow=y")) {
790 if ((p
= strstr(str
, "shadowoffset=")))
791 i
= parse_inline_number(p
+ strlen("shadowoffset="));
794 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_x
= i
;
795 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_y
= i
;
797 if ((p
= strstr(str
, "shadowtint=")))
799 i
= parse_inline_number(p
+ strlen("shadowtint="));
800 j
= (i
> 0 ? 0 : 255);
803 theme
->title_unfocused_shadow_color
= RrColorNew(inst
, j
, j
, j
);
804 theme
->title_unfocused_shadow_alpha
= i
;
806 theme
->title_unfocused_shadow_color
= RrColorNew(inst
, 0, 0, 0);
807 theme
->title_unfocused_shadow_alpha
= 50;
811 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_color
=
812 theme
->title_unfocused_shadow_color
;
813 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_alpha
=
814 theme
->title_unfocused_shadow_alpha
;
816 theme
->osd_unhilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
817 theme
->osd_unhilite_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
818 theme
->osd_unhilite_label
->texture
[0].data
.text
.font
=
819 theme
->osd_font_unhilite
;
820 theme
->osd_unhilite_label
->texture
[0].data
.text
.color
=
821 theme
->osd_text_inactive_color
;
823 if (read_string(db
, "osd.inactive.label.text.font", &str
))
828 if (strstr(str
, "shadow=y")) {
829 if ((p
= strstr(str
, "shadowoffset=")))
830 i
= parse_inline_number(p
+ strlen("shadowoffset="));
833 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_offset_x
=i
;
834 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_offset_y
=i
;
836 if ((p
= strstr(str
, "shadowtint=")))
838 i
= parse_inline_number(p
+ strlen("shadowtint="));
839 j
= (i
> 0 ? 0 : 255);
842 theme
->osd_text_inactive_shadow_color
= RrColorNew(inst
, j
, j
, j
);
843 theme
->osd_text_inactive_shadow_alpha
= i
;
845 theme
->osd_text_inactive_shadow_color
= RrColorNew(inst
, 0, 0, 0);
846 theme
->osd_text_inactive_shadow_alpha
= 50;
849 /* inherit the font settings from the unfocused label */
850 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_offset_x
=
851 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_x
;
852 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_offset_y
=
853 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_y
;
854 if (theme
->title_unfocused_shadow_color
)
855 theme
->osd_text_inactive_shadow_color
=
857 theme
->title_unfocused_shadow_color
->r
,
858 theme
->title_unfocused_shadow_color
->g
,
859 theme
->title_unfocused_shadow_color
->b
);
861 theme
->osd_text_inactive_shadow_color
= RrColorNew(inst
, 0, 0, 0);
862 theme
->osd_text_inactive_shadow_alpha
=
863 theme
->title_unfocused_shadow_alpha
;
866 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_color
=
867 theme
->osd_text_inactive_shadow_color
;
868 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_alpha
=
869 theme
->osd_text_inactive_shadow_alpha
;
871 theme
->a_menu_text_title
->texture
[0].type
= RR_TEXTURE_TEXT
;
872 theme
->a_menu_text_title
->texture
[0].data
.text
.justify
= mtitlejust
;
873 theme
->a_menu_text_title
->texture
[0].data
.text
.font
=
874 theme
->menu_title_font
;
875 theme
->a_menu_text_title
->texture
[0].data
.text
.color
=
876 theme
->menu_title_color
;
878 if (read_string(db
, "menu.title.text.font", &str
)) {
882 if (strstr(str
, "shadow=y")) {
883 if ((p
= strstr(str
, "shadowoffset=")))
884 i
= parse_inline_number(p
+ strlen("shadowoffset="));
887 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_offset_x
= i
;
888 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_offset_y
= i
;
890 if ((p
= strstr(str
, "shadowtint=")))
892 i
= parse_inline_number(p
+ strlen("shadowtint="));
893 j
= (i
> 0 ? 0 : 255);
896 theme
->menu_title_shadow_color
= RrColorNew(inst
, j
, j
, j
);
897 theme
->menu_title_shadow_alpha
= i
;
899 theme
->menu_title_shadow_color
= RrColorNew(inst
, 0, 0, 0);
900 theme
->menu_title_shadow_alpha
= 50;
904 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_color
=
905 theme
->menu_title_shadow_color
;
906 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_alpha
=
907 theme
->menu_title_shadow_alpha
;
909 theme
->a_menu_text_normal
->texture
[0].type
=
910 theme
->a_menu_text_selected
->texture
[0].type
=
911 theme
->a_menu_text_disabled
->texture
[0].type
=
912 theme
->a_menu_text_disabled_selected
->texture
[0].type
=
914 theme
->a_menu_text_normal
->texture
[0].data
.text
.justify
=
915 theme
->a_menu_text_selected
->texture
[0].data
.text
.justify
=
916 theme
->a_menu_text_disabled
->texture
[0].data
.text
.justify
=
917 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.justify
=
919 theme
->a_menu_text_normal
->texture
[0].data
.text
.font
=
920 theme
->a_menu_text_selected
->texture
[0].data
.text
.font
=
921 theme
->a_menu_text_disabled
->texture
[0].data
.text
.font
=
922 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.font
=
924 theme
->a_menu_text_normal
->texture
[0].data
.text
.color
= theme
->menu_color
;
925 theme
->a_menu_text_selected
->texture
[0].data
.text
.color
=
926 theme
->menu_selected_color
;
927 theme
->a_menu_text_disabled
->texture
[0].data
.text
.color
=
928 theme
->menu_disabled_color
;
929 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.color
=
930 theme
->menu_disabled_selected_color
;
932 if (read_string(db
, "menu.items.font", &str
)) {
936 if (strstr(str
, "shadow=y")) {
937 if ((p
= strstr(str
, "shadowoffset=")))
938 i
= parse_inline_number(p
+ strlen("shadowoffset="));
941 theme
->a_menu_text_normal
->
942 texture
[0].data
.text
.shadow_offset_x
= i
;
943 theme
->a_menu_text_normal
->
944 texture
[0].data
.text
.shadow_offset_y
= i
;
945 theme
->a_menu_text_selected
->
946 texture
[0].data
.text
.shadow_offset_x
= i
;
947 theme
->a_menu_text_selected
->
948 texture
[0].data
.text
.shadow_offset_y
= i
;
949 theme
->a_menu_text_disabled
->
950 texture
[0].data
.text
.shadow_offset_x
= i
;
951 theme
->a_menu_text_disabled
->
952 texture
[0].data
.text
.shadow_offset_y
= i
;
953 theme
->a_menu_text_disabled_selected
->
954 texture
[0].data
.text
.shadow_offset_x
= i
;
955 theme
->a_menu_text_disabled_selected
->
956 texture
[0].data
.text
.shadow_offset_y
= i
;
958 if ((p
= strstr(str
, "shadowtint=")))
960 i
= parse_inline_number(p
+ strlen("shadowtint="));
961 j
= (i
> 0 ? 0 : 255);
964 theme
->menu_text_normal_shadow_color
= RrColorNew(inst
, j
, j
, j
);
965 theme
->menu_text_selected_shadow_color
= RrColorNew(inst
, j
, j
, j
);
966 theme
->menu_text_disabled_shadow_color
= RrColorNew(inst
, j
, j
, j
);
967 theme
->menu_text_normal_shadow_alpha
= i
;
968 theme
->menu_text_selected_shadow_alpha
= i
;
969 theme
->menu_text_disabled_shadow_alpha
= i
;
970 theme
->menu_text_disabled_selected_shadow_alpha
= i
;
972 theme
->menu_text_normal_shadow_color
= RrColorNew(inst
, 0, 0, 0);
973 theme
->menu_text_selected_shadow_color
= RrColorNew(inst
, 0, 0, 0);
974 theme
->menu_text_disabled_shadow_color
= RrColorNew(inst
, 0, 0, 0);
975 theme
->menu_text_normal_shadow_alpha
= 50;
976 theme
->menu_text_selected_shadow_alpha
= 50;
977 theme
->menu_text_disabled_selected_shadow_alpha
= 50;
981 theme
->a_menu_text_normal
->texture
[0].data
.text
.shadow_color
=
982 theme
->menu_text_normal_shadow_color
;
983 theme
->a_menu_text_normal
->texture
[0].data
.text
.shadow_alpha
=
984 theme
->menu_text_normal_shadow_alpha
;
985 theme
->a_menu_text_selected
->texture
[0].data
.text
.shadow_color
=
986 theme
->menu_text_selected_shadow_color
;
987 theme
->a_menu_text_selected
->texture
[0].data
.text
.shadow_alpha
=
988 theme
->menu_text_selected_shadow_alpha
;
989 theme
->a_menu_text_disabled
->texture
[0].data
.text
.shadow_color
=
990 theme
->menu_text_disabled_shadow_color
;
991 theme
->a_menu_text_disabled
->texture
[0].data
.text
.shadow_alpha
=
992 theme
->menu_text_disabled_shadow_alpha
;
993 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.shadow_color
=
994 theme
->menu_text_disabled_shadow_color
;
995 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.shadow_alpha
=
996 theme
->menu_text_disabled_shadow_alpha
;
998 theme
->a_disabled_focused_max
->texture
[0].type
=
999 theme
->a_disabled_unfocused_max
->texture
[0].type
=
1000 theme
->a_hover_focused_max
->texture
[0].type
=
1001 theme
->a_hover_unfocused_max
->texture
[0].type
=
1002 theme
->a_toggled_hover_focused_max
->texture
[0].type
=
1003 theme
->a_toggled_hover_unfocused_max
->texture
[0].type
=
1004 theme
->a_toggled_focused_unpressed_max
->texture
[0].type
=
1005 theme
->a_toggled_unfocused_unpressed_max
->texture
[0].type
=
1006 theme
->a_toggled_focused_pressed_max
->texture
[0].type
=
1007 theme
->a_toggled_unfocused_pressed_max
->texture
[0].type
=
1008 theme
->a_focused_unpressed_max
->texture
[0].type
=
1009 theme
->a_focused_pressed_max
->texture
[0].type
=
1010 theme
->a_unfocused_unpressed_max
->texture
[0].type
=
1011 theme
->a_unfocused_pressed_max
->texture
[0].type
=
1012 theme
->a_disabled_focused_close
->texture
[0].type
=
1013 theme
->a_disabled_unfocused_close
->texture
[0].type
=
1014 theme
->a_hover_focused_close
->texture
[0].type
=
1015 theme
->a_hover_unfocused_close
->texture
[0].type
=
1016 theme
->a_focused_unpressed_close
->texture
[0].type
=
1017 theme
->a_focused_pressed_close
->texture
[0].type
=
1018 theme
->a_unfocused_unpressed_close
->texture
[0].type
=
1019 theme
->a_unfocused_pressed_close
->texture
[0].type
=
1020 theme
->a_disabled_focused_desk
->texture
[0].type
=
1021 theme
->a_disabled_unfocused_desk
->texture
[0].type
=
1022 theme
->a_hover_focused_desk
->texture
[0].type
=
1023 theme
->a_hover_unfocused_desk
->texture
[0].type
=
1024 theme
->a_toggled_hover_focused_desk
->texture
[0].type
=
1025 theme
->a_toggled_hover_unfocused_desk
->texture
[0].type
=
1026 theme
->a_toggled_focused_unpressed_desk
->texture
[0].type
=
1027 theme
->a_toggled_unfocused_unpressed_desk
->texture
[0].type
=
1028 theme
->a_toggled_focused_pressed_desk
->texture
[0].type
=
1029 theme
->a_toggled_unfocused_pressed_desk
->texture
[0].type
=
1030 theme
->a_focused_unpressed_desk
->texture
[0].type
=
1031 theme
->a_focused_pressed_desk
->texture
[0].type
=
1032 theme
->a_unfocused_unpressed_desk
->texture
[0].type
=
1033 theme
->a_unfocused_pressed_desk
->texture
[0].type
=
1034 theme
->a_disabled_focused_shade
->texture
[0].type
=
1035 theme
->a_disabled_unfocused_shade
->texture
[0].type
=
1036 theme
->a_hover_focused_shade
->texture
[0].type
=
1037 theme
->a_hover_unfocused_shade
->texture
[0].type
=
1038 theme
->a_toggled_hover_focused_shade
->texture
[0].type
=
1039 theme
->a_toggled_hover_unfocused_shade
->texture
[0].type
=
1040 theme
->a_toggled_focused_unpressed_shade
->texture
[0].type
=
1041 theme
->a_toggled_unfocused_unpressed_shade
->texture
[0].type
=
1042 theme
->a_toggled_focused_pressed_shade
->texture
[0].type
=
1043 theme
->a_toggled_unfocused_pressed_shade
->texture
[0].type
=
1044 theme
->a_focused_unpressed_shade
->texture
[0].type
=
1045 theme
->a_focused_pressed_shade
->texture
[0].type
=
1046 theme
->a_unfocused_unpressed_shade
->texture
[0].type
=
1047 theme
->a_unfocused_pressed_shade
->texture
[0].type
=
1048 theme
->a_disabled_focused_iconify
->texture
[0].type
=
1049 theme
->a_disabled_unfocused_iconify
->texture
[0].type
=
1050 theme
->a_hover_focused_iconify
->texture
[0].type
=
1051 theme
->a_hover_unfocused_iconify
->texture
[0].type
=
1052 theme
->a_focused_unpressed_iconify
->texture
[0].type
=
1053 theme
->a_focused_pressed_iconify
->texture
[0].type
=
1054 theme
->a_unfocused_unpressed_iconify
->texture
[0].type
=
1055 theme
->a_unfocused_pressed_iconify
->texture
[0].type
=
1056 theme
->a_menu_bullet_normal
->texture
[0].type
=
1057 theme
->a_menu_bullet_selected
->texture
[0].type
= RR_TEXTURE_MASK
;
1059 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.mask
=
1060 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.mask
=
1061 theme
->max_disabled_mask
;
1062 theme
->a_hover_focused_max
->texture
[0].data
.mask
.mask
=
1063 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.mask
=
1064 theme
->max_hover_mask
;
1065 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.mask
=
1066 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.mask
=
1067 theme
->max_pressed_mask
;
1068 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.mask
=
1069 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.mask
=
1071 theme
->a_toggled_hover_focused_max
->texture
[0].data
.mask
.mask
=
1072 theme
->a_toggled_hover_unfocused_max
->texture
[0].data
.mask
.mask
=
1073 theme
->max_toggled_hover_mask
;
1074 theme
->a_toggled_focused_unpressed_max
->texture
[0].data
.mask
.mask
=
1075 theme
->a_toggled_unfocused_unpressed_max
->texture
[0].data
.mask
.mask
=
1076 theme
->max_toggled_mask
;
1077 theme
->a_toggled_focused_pressed_max
->texture
[0].data
.mask
.mask
=
1078 theme
->a_toggled_unfocused_pressed_max
->texture
[0].data
.mask
.mask
=
1079 theme
->max_toggled_pressed_mask
;
1080 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.mask
=
1081 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.mask
=
1082 theme
->close_disabled_mask
;
1083 theme
->a_hover_focused_close
->texture
[0].data
.mask
.mask
=
1084 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.mask
=
1085 theme
->close_hover_mask
;
1086 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.mask
=
1087 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.mask
=
1088 theme
->close_pressed_mask
;
1089 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.mask
=
1090 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.mask
=
1092 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.mask
=
1093 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.mask
=
1094 theme
->desk_disabled_mask
;
1095 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.mask
=
1096 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.mask
=
1097 theme
->desk_hover_mask
;
1098 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.mask
=
1099 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.mask
=
1100 theme
->desk_pressed_mask
;
1101 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.mask
=
1102 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.mask
=
1104 theme
->a_toggled_hover_focused_desk
->texture
[0].data
.mask
.mask
=
1105 theme
->a_toggled_hover_unfocused_desk
->texture
[0].data
.mask
.mask
=
1106 theme
->desk_toggled_hover_mask
;
1107 theme
->a_toggled_focused_unpressed_desk
->texture
[0].data
.mask
.mask
=
1108 theme
->a_toggled_unfocused_unpressed_desk
->texture
[0].data
.mask
.mask
=
1109 theme
->desk_toggled_mask
;
1110 theme
->a_toggled_focused_pressed_desk
->texture
[0].data
.mask
.mask
=
1111 theme
->a_toggled_unfocused_pressed_desk
->texture
[0].data
.mask
.mask
=
1112 theme
->desk_toggled_pressed_mask
;
1113 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.mask
=
1114 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.mask
=
1115 theme
->shade_disabled_mask
;
1116 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.mask
=
1117 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.mask
=
1118 theme
->shade_hover_mask
;
1119 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.mask
=
1120 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.mask
=
1121 theme
->shade_pressed_mask
;
1122 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.mask
=
1123 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.mask
=
1125 theme
->a_toggled_hover_focused_shade
->texture
[0].data
.mask
.mask
=
1126 theme
->a_toggled_hover_unfocused_shade
->texture
[0].data
.mask
.mask
=
1127 theme
->shade_toggled_hover_mask
;
1128 theme
->a_toggled_focused_unpressed_shade
->texture
[0].data
.mask
.mask
=
1129 theme
->a_toggled_unfocused_unpressed_shade
->texture
[0].data
.mask
.mask
=
1130 theme
->shade_toggled_mask
;
1131 theme
->a_toggled_focused_pressed_shade
->texture
[0].data
.mask
.mask
=
1132 theme
->a_toggled_unfocused_pressed_shade
->texture
[0].data
.mask
.mask
=
1133 theme
->shade_toggled_pressed_mask
;
1134 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.mask
=
1135 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.mask
=
1136 theme
->iconify_disabled_mask
;
1137 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.mask
=
1138 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.mask
=
1139 theme
->iconify_hover_mask
;
1140 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.mask
=
1141 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.mask
=
1142 theme
->iconify_pressed_mask
;
1143 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
1144 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
1145 theme
->iconify_mask
;
1146 theme
->a_menu_bullet_normal
->texture
[0].data
.mask
.mask
=
1147 theme
->a_menu_bullet_selected
->texture
[0].data
.mask
.mask
=
1148 theme
->menu_bullet_mask
;
1149 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.color
=
1150 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.color
=
1151 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.color
=
1152 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.color
=
1153 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.color
=
1154 theme
->titlebut_disabled_focused_color
;
1155 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.color
=
1156 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.color
=
1157 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.color
=
1158 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.color
=
1159 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.color
=
1160 theme
->titlebut_disabled_unfocused_color
;
1161 theme
->a_hover_focused_max
->texture
[0].data
.mask
.color
=
1162 theme
->a_hover_focused_close
->texture
[0].data
.mask
.color
=
1163 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.color
=
1164 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.color
=
1165 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.color
=
1166 theme
->titlebut_hover_focused_color
;
1167 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.color
=
1168 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.color
=
1169 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.color
=
1170 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.color
=
1171 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.color
=
1172 theme
->titlebut_hover_unfocused_color
;
1173 theme
->a_toggled_hover_focused_max
->texture
[0].data
.mask
.color
=
1174 theme
->a_toggled_hover_focused_desk
->texture
[0].data
.mask
.color
=
1175 theme
->a_toggled_hover_focused_shade
->texture
[0].data
.mask
.color
=
1176 theme
->titlebut_toggled_hover_focused_color
;
1177 theme
->a_toggled_hover_unfocused_max
->texture
[0].data
.mask
.color
=
1178 theme
->a_toggled_hover_unfocused_desk
->texture
[0].data
.mask
.color
=
1179 theme
->a_toggled_hover_unfocused_shade
->texture
[0].data
.mask
.color
=
1180 theme
->titlebut_toggled_hover_unfocused_color
;
1181 theme
->a_toggled_focused_unpressed_max
->texture
[0].data
.mask
.color
=
1182 theme
->a_toggled_focused_unpressed_desk
->texture
[0].data
.mask
.color
=
1183 theme
->a_toggled_focused_unpressed_shade
->texture
[0].data
.mask
.color
=
1184 theme
->titlebut_toggled_focused_unpressed_color
;
1185 theme
->a_toggled_unfocused_unpressed_max
->texture
[0].data
.mask
.color
=
1186 theme
->a_toggled_unfocused_unpressed_desk
->texture
[0].data
.mask
.color
=
1187 theme
->a_toggled_unfocused_unpressed_shade
->texture
[0].data
.mask
.color
=
1188 theme
->titlebut_toggled_unfocused_unpressed_color
;
1189 theme
->a_toggled_focused_pressed_max
->texture
[0].data
.mask
.color
=
1190 theme
->a_toggled_focused_pressed_desk
->texture
[0].data
.mask
.color
=
1191 theme
->a_toggled_focused_pressed_shade
->texture
[0].data
.mask
.color
=
1192 theme
->titlebut_toggled_focused_pressed_color
;
1193 theme
->a_toggled_unfocused_pressed_max
->texture
[0].data
.mask
.color
=
1194 theme
->a_toggled_unfocused_pressed_desk
->texture
[0].data
.mask
.color
=
1195 theme
->a_toggled_unfocused_pressed_shade
->texture
[0].data
.mask
.color
=
1196 theme
->titlebut_toggled_unfocused_pressed_color
;
1197 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.color
=
1198 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.color
=
1199 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.color
=
1200 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.color
=
1201 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.color
=
1202 theme
->titlebut_focused_unpressed_color
;
1203 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.color
=
1204 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.color
=
1205 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.color
=
1206 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.color
=
1207 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.color
=
1208 theme
->titlebut_focused_pressed_color
;
1209 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.color
=
1210 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.color
=
1211 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.color
=
1212 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.color
=
1213 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.color
=
1214 theme
->titlebut_unfocused_unpressed_color
;
1215 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.color
=
1216 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.color
=
1217 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.color
=
1218 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.color
=
1219 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.color
=
1220 theme
->titlebut_unfocused_pressed_color
;
1221 theme
->a_menu_bullet_normal
->texture
[0].data
.mask
.color
=
1223 theme
->a_menu_bullet_selected
->texture
[0].data
.mask
.color
=
1224 theme
->menu_selected_color
;
1227 XrmDestroyDatabase(db
);
1229 /* set the font heights */
1230 theme
->win_font_height
= RrFontHeight
1231 (theme
->win_font_focused
,
1232 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_y
);
1233 theme
->win_font_height
=
1234 MAX(theme
->win_font_height
,
1236 (theme
->win_font_focused
,
1237 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_y
));
1238 theme
->menu_title_font_height
= RrFontHeight
1239 (theme
->menu_title_font
,
1240 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_offset_y
);
1241 theme
->menu_font_height
= RrFontHeight
1243 theme
->a_menu_text_normal
->texture
[0].data
.text
.shadow_offset_y
);
1245 /* calculate some last extents */
1247 gint ft
, fb
, fl
, fr
, ut
, ub
, ul
, ur
;
1249 RrMargins(theme
->a_focused_label
, &fl
, &ft
, &fr
, &fb
);
1250 RrMargins(theme
->a_unfocused_label
, &ul
, &ut
, &ur
, &ub
);
1251 theme
->label_height
= theme
->win_font_height
+ MAX(ft
+ fb
, ut
+ ub
);
1252 theme
->label_height
+= theme
->label_height
% 2;
1254 /* this would be nice I think, since padding.width can now be 0,
1255 but it breaks frame.c horribly and I don't feel like fixing that
1256 right now, so if anyone complains, here is how to keep text from
1257 going over the title's bevel/border with a padding.width of 0 and a
1258 bevelless/borderless label
1259 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1260 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1261 theme->title_height = theme->label_height +
1262 MAX(MAX(theme->padding * 2, ft + fb),
1263 MAX(theme->padding * 2, ut + ub));
1265 theme
->title_height
= theme
->label_height
+ theme
->paddingy
* 2;
1267 RrMargins(theme
->a_menu_title
, &ul
, &ut
, &ur
, &ub
);
1268 theme
->menu_title_label_height
= theme
->menu_title_font_height
+ut
+ub
;
1269 theme
->menu_title_height
= theme
->menu_title_label_height
+
1270 theme
->paddingy
* 2;
1272 theme
->button_size
= theme
->label_height
- 2;
1273 theme
->grip_width
= 25;
1278 void RrThemeFree(RrTheme
*theme
)
1281 g_free(theme
->name
);
1283 RrColorFree(theme
->menu_border_color
);
1284 RrColorFree(theme
->osd_border_color
);
1285 RrColorFree(theme
->frame_focused_border_color
);
1286 RrColorFree(theme
->frame_unfocused_border_color
);
1287 RrColorFree(theme
->title_separator_focused_color
);
1288 RrColorFree(theme
->title_separator_unfocused_color
);
1289 RrColorFree(theme
->cb_unfocused_color
);
1290 RrColorFree(theme
->cb_focused_color
);
1291 RrColorFree(theme
->title_focused_color
);
1292 RrColorFree(theme
->title_unfocused_color
);
1293 RrColorFree(theme
->titlebut_disabled_focused_color
);
1294 RrColorFree(theme
->titlebut_disabled_unfocused_color
);
1295 RrColorFree(theme
->titlebut_hover_focused_color
);
1296 RrColorFree(theme
->titlebut_hover_unfocused_color
);
1297 RrColorFree(theme
->titlebut_toggled_hover_focused_color
);
1298 RrColorFree(theme
->titlebut_toggled_hover_unfocused_color
);
1299 RrColorFree(theme
->titlebut_toggled_focused_pressed_color
);
1300 RrColorFree(theme
->titlebut_toggled_unfocused_pressed_color
);
1301 RrColorFree(theme
->titlebut_toggled_focused_unpressed_color
);
1302 RrColorFree(theme
->titlebut_toggled_unfocused_unpressed_color
);
1303 RrColorFree(theme
->titlebut_focused_pressed_color
);
1304 RrColorFree(theme
->titlebut_unfocused_pressed_color
);
1305 RrColorFree(theme
->titlebut_focused_unpressed_color
);
1306 RrColorFree(theme
->titlebut_unfocused_unpressed_color
);
1307 RrColorFree(theme
->menu_title_color
);
1308 RrColorFree(theme
->menu_sep_color
);
1309 RrColorFree(theme
->menu_color
);
1310 RrColorFree(theme
->menu_selected_color
);
1311 RrColorFree(theme
->menu_disabled_color
);
1312 RrColorFree(theme
->menu_disabled_selected_color
);
1313 RrColorFree(theme
->title_focused_shadow_color
);
1314 RrColorFree(theme
->title_unfocused_shadow_color
);
1315 RrColorFree(theme
->osd_text_active_color
);
1316 RrColorFree(theme
->osd_text_inactive_color
);
1317 RrColorFree(theme
->osd_text_active_shadow_color
);
1318 RrColorFree(theme
->osd_text_inactive_shadow_color
);
1319 RrColorFree(theme
->menu_title_shadow_color
);
1320 RrColorFree(theme
->menu_text_normal_shadow_color
);
1321 RrColorFree(theme
->menu_text_selected_shadow_color
);
1322 RrColorFree(theme
->menu_text_disabled_shadow_color
);
1323 RrColorFree(theme
->menu_text_disabled_selected_shadow_color
);
1325 g_free(theme
->def_win_icon
);
1327 RrPixmapMaskFree(theme
->max_mask
);
1328 RrPixmapMaskFree(theme
->max_toggled_mask
);
1329 RrPixmapMaskFree(theme
->max_toggled_hover_mask
);
1330 RrPixmapMaskFree(theme
->max_toggled_pressed_mask
);
1331 RrPixmapMaskFree(theme
->max_disabled_mask
);
1332 RrPixmapMaskFree(theme
->max_hover_mask
);
1333 RrPixmapMaskFree(theme
->max_pressed_mask
);
1334 RrPixmapMaskFree(theme
->desk_mask
);
1335 RrPixmapMaskFree(theme
->desk_toggled_mask
);
1336 RrPixmapMaskFree(theme
->desk_toggled_hover_mask
);
1337 RrPixmapMaskFree(theme
->desk_toggled_pressed_mask
);
1338 RrPixmapMaskFree(theme
->desk_disabled_mask
);
1339 RrPixmapMaskFree(theme
->desk_hover_mask
);
1340 RrPixmapMaskFree(theme
->desk_pressed_mask
);
1341 RrPixmapMaskFree(theme
->shade_mask
);
1342 RrPixmapMaskFree(theme
->shade_toggled_mask
);
1343 RrPixmapMaskFree(theme
->shade_toggled_hover_mask
);
1344 RrPixmapMaskFree(theme
->shade_toggled_pressed_mask
);
1345 RrPixmapMaskFree(theme
->shade_disabled_mask
);
1346 RrPixmapMaskFree(theme
->shade_hover_mask
);
1347 RrPixmapMaskFree(theme
->shade_pressed_mask
);
1348 RrPixmapMaskFree(theme
->iconify_mask
);
1349 RrPixmapMaskFree(theme
->iconify_disabled_mask
);
1350 RrPixmapMaskFree(theme
->iconify_hover_mask
);
1351 RrPixmapMaskFree(theme
->iconify_pressed_mask
);
1352 RrPixmapMaskFree(theme
->close_mask
);
1353 RrPixmapMaskFree(theme
->close_disabled_mask
);
1354 RrPixmapMaskFree(theme
->close_hover_mask
);
1355 RrPixmapMaskFree(theme
->close_pressed_mask
);
1356 RrPixmapMaskFree(theme
->menu_bullet_mask
);
1357 RrPixmapMaskFree(theme
->down_arrow_mask
);
1358 RrPixmapMaskFree(theme
->up_arrow_mask
);
1360 RrFontClose(theme
->win_font_focused
);
1361 RrFontClose(theme
->win_font_unfocused
);
1362 RrFontClose(theme
->menu_title_font
);
1363 RrFontClose(theme
->menu_font
);
1364 RrFontClose(theme
->osd_font_hilite
);
1365 RrFontClose(theme
->osd_font_unhilite
);
1367 RrAppearanceFree(theme
->a_disabled_focused_max
);
1368 RrAppearanceFree(theme
->a_disabled_unfocused_max
);
1369 RrAppearanceFree(theme
->a_hover_focused_max
);
1370 RrAppearanceFree(theme
->a_hover_unfocused_max
);
1371 RrAppearanceFree(theme
->a_toggled_hover_focused_max
);
1372 RrAppearanceFree(theme
->a_toggled_hover_unfocused_max
);
1373 RrAppearanceFree(theme
->a_toggled_focused_unpressed_max
);
1374 RrAppearanceFree(theme
->a_toggled_focused_pressed_max
);
1375 RrAppearanceFree(theme
->a_toggled_unfocused_unpressed_max
);
1376 RrAppearanceFree(theme
->a_toggled_unfocused_pressed_max
);
1377 RrAppearanceFree(theme
->a_focused_unpressed_max
);
1378 RrAppearanceFree(theme
->a_focused_pressed_max
);
1379 RrAppearanceFree(theme
->a_unfocused_unpressed_max
);
1380 RrAppearanceFree(theme
->a_unfocused_pressed_max
);
1381 RrAppearanceFree(theme
->a_disabled_focused_close
);
1382 RrAppearanceFree(theme
->a_disabled_unfocused_close
);
1383 RrAppearanceFree(theme
->a_hover_focused_close
);
1384 RrAppearanceFree(theme
->a_hover_unfocused_close
);
1385 RrAppearanceFree(theme
->a_focused_unpressed_close
);
1386 RrAppearanceFree(theme
->a_focused_pressed_close
);
1387 RrAppearanceFree(theme
->a_unfocused_unpressed_close
);
1388 RrAppearanceFree(theme
->a_unfocused_pressed_close
);
1389 RrAppearanceFree(theme
->a_disabled_focused_desk
);
1390 RrAppearanceFree(theme
->a_disabled_unfocused_desk
);
1391 RrAppearanceFree(theme
->a_hover_focused_desk
);
1392 RrAppearanceFree(theme
->a_hover_unfocused_desk
);
1393 RrAppearanceFree(theme
->a_toggled_hover_focused_desk
);
1394 RrAppearanceFree(theme
->a_toggled_hover_unfocused_desk
);
1395 RrAppearanceFree(theme
->a_toggled_focused_unpressed_desk
);
1396 RrAppearanceFree(theme
->a_toggled_focused_pressed_desk
);
1397 RrAppearanceFree(theme
->a_toggled_unfocused_unpressed_desk
);
1398 RrAppearanceFree(theme
->a_toggled_unfocused_pressed_desk
);
1399 RrAppearanceFree(theme
->a_focused_unpressed_desk
);
1400 RrAppearanceFree(theme
->a_focused_pressed_desk
);
1401 RrAppearanceFree(theme
->a_unfocused_unpressed_desk
);
1402 RrAppearanceFree(theme
->a_unfocused_pressed_desk
);
1403 RrAppearanceFree(theme
->a_disabled_focused_shade
);
1404 RrAppearanceFree(theme
->a_disabled_unfocused_shade
);
1405 RrAppearanceFree(theme
->a_hover_focused_shade
);
1406 RrAppearanceFree(theme
->a_hover_unfocused_shade
);
1407 RrAppearanceFree(theme
->a_toggled_hover_focused_shade
);
1408 RrAppearanceFree(theme
->a_toggled_hover_unfocused_shade
);
1409 RrAppearanceFree(theme
->a_toggled_focused_unpressed_shade
);
1410 RrAppearanceFree(theme
->a_toggled_focused_pressed_shade
);
1411 RrAppearanceFree(theme
->a_toggled_unfocused_unpressed_shade
);
1412 RrAppearanceFree(theme
->a_toggled_unfocused_pressed_shade
);
1413 RrAppearanceFree(theme
->a_focused_unpressed_shade
);
1414 RrAppearanceFree(theme
->a_focused_pressed_shade
);
1415 RrAppearanceFree(theme
->a_unfocused_unpressed_shade
);
1416 RrAppearanceFree(theme
->a_unfocused_pressed_shade
);
1417 RrAppearanceFree(theme
->a_disabled_focused_iconify
);
1418 RrAppearanceFree(theme
->a_disabled_unfocused_iconify
);
1419 RrAppearanceFree(theme
->a_hover_focused_iconify
);
1420 RrAppearanceFree(theme
->a_hover_unfocused_iconify
);
1421 RrAppearanceFree(theme
->a_focused_unpressed_iconify
);
1422 RrAppearanceFree(theme
->a_focused_pressed_iconify
);
1423 RrAppearanceFree(theme
->a_unfocused_unpressed_iconify
);
1424 RrAppearanceFree(theme
->a_unfocused_pressed_iconify
);
1425 RrAppearanceFree(theme
->a_focused_grip
);
1426 RrAppearanceFree(theme
->a_unfocused_grip
);
1427 RrAppearanceFree(theme
->a_focused_title
);
1428 RrAppearanceFree(theme
->a_unfocused_title
);
1429 RrAppearanceFree(theme
->a_focused_label
);
1430 RrAppearanceFree(theme
->a_unfocused_label
);
1431 RrAppearanceFree(theme
->a_icon
);
1432 RrAppearanceFree(theme
->a_focused_handle
);
1433 RrAppearanceFree(theme
->a_unfocused_handle
);
1434 RrAppearanceFree(theme
->a_menu
);
1435 RrAppearanceFree(theme
->a_menu_title
);
1436 RrAppearanceFree(theme
->a_menu_text_title
);
1437 RrAppearanceFree(theme
->a_menu_normal
);
1438 RrAppearanceFree(theme
->a_menu_selected
);
1439 RrAppearanceFree(theme
->a_menu_disabled
);
1440 RrAppearanceFree(theme
->a_menu_disabled_selected
);
1441 RrAppearanceFree(theme
->a_menu_text_normal
);
1442 RrAppearanceFree(theme
->a_menu_text_selected
);
1443 RrAppearanceFree(theme
->a_menu_text_disabled
);
1444 RrAppearanceFree(theme
->a_menu_text_disabled_selected
);
1445 RrAppearanceFree(theme
->a_menu_bullet_normal
);
1446 RrAppearanceFree(theme
->a_menu_bullet_selected
);
1447 RrAppearanceFree(theme
->a_clear
);
1448 RrAppearanceFree(theme
->a_clear_tex
);
1449 RrAppearanceFree(theme
->osd_bg
);
1450 RrAppearanceFree(theme
->osd_hilite_bg
);
1451 RrAppearanceFree(theme
->osd_hilite_label
);
1452 RrAppearanceFree(theme
->osd_unhilite_bg
);
1453 RrAppearanceFree(theme
->osd_unhilite_label
);
1455 g_slice_free(RrTheme
, theme
);
1459 static XrmDatabase
loaddb(const gchar
*name
, gchar
**path
)
1462 XrmDatabase db
= NULL
;
1465 if (name
[0] == '/') {
1466 s
= g_build_filename(name
, "openbox-3", "themerc", NULL
);
1467 if ((db
= XrmGetFileDatabase(s
)))
1468 *path
= g_path_get_dirname(s
);
1473 p
= obt_paths_new();
1475 /* XXX backwards compatibility, remove me sometime later */
1476 s
= g_build_filename(g_get_home_dir(), ".themes", name
,
1477 "openbox-3", "themerc", NULL
);
1478 if ((db
= XrmGetFileDatabase(s
)))
1479 *path
= g_path_get_dirname(s
);
1482 for (it
= obt_paths_data_dirs(p
); !db
&& it
; it
= g_slist_next(it
))
1484 s
= g_build_filename(it
->data
, "themes", name
,
1485 "openbox-3", "themerc", NULL
);
1486 if ((db
= XrmGetFileDatabase(s
)))
1487 *path
= g_path_get_dirname(s
);
1495 s
= g_build_filename(name
, "themerc", NULL
);
1496 if ((db
= XrmGetFileDatabase(s
)))
1497 *path
= g_path_get_dirname(s
);
1504 static gchar
*create_class_name(const gchar
*rname
)
1506 gchar
*rclass
= g_strdup(rname
);
1511 p
= strchr(p
+1, '.');
1512 if (p
== NULL
) break;
1514 if (*p
== '\0') break;
1519 static gboolean
read_int(XrmDatabase db
, const gchar
*rname
, gint
*value
)
1521 gboolean ret
= FALSE
;
1522 gchar
*rclass
= create_class_name(rname
);
1523 gchar
*rettype
, *end
;
1526 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1527 retvalue
.addr
!= NULL
) {
1528 *value
= (gint
)strtol(retvalue
.addr
, &end
, 10);
1529 if (end
!= retvalue
.addr
)
1537 static gboolean
read_string(XrmDatabase db
, const gchar
*rname
, gchar
**value
)
1539 gboolean ret
= FALSE
;
1540 gchar
*rclass
= create_class_name(rname
);
1544 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1545 retvalue
.addr
!= NULL
) {
1546 *value
= retvalue
.addr
;
1554 static gboolean
read_color(XrmDatabase db
, const RrInstance
*inst
,
1555 const gchar
*rname
, RrColor
**value
)
1557 gboolean ret
= FALSE
;
1558 gchar
*rclass
= create_class_name(rname
);
1562 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1563 retvalue
.addr
!= NULL
) {
1564 RrColor
*c
= RrColorParse(inst
, retvalue
.addr
);
1575 static gboolean
read_mask(const RrInstance
*inst
, const gchar
*path
,
1576 RrTheme
*theme
, const gchar
*maskname
,
1577 RrPixmapMask
**value
)
1579 gboolean ret
= FALSE
;
1581 gint hx
, hy
; /* ignored */
1585 s
= g_build_filename(path
, maskname
, NULL
);
1586 if (XReadBitmapFileData(s
, &w
, &h
, &b
, &hx
, &hy
) == BitmapSuccess
) {
1588 *value
= RrPixmapMaskNew(inst
, w
, h
, (gchar
*)b
);
1596 static void parse_appearance(gchar
*tex
, RrSurfaceColorType
*grad
,
1597 RrReliefType
*relief
, RrBevelType
*bevel
,
1598 gboolean
*interlaced
, gboolean
*border
,
1599 gboolean allow_trans
)
1603 /* convert to all lowercase */
1604 for (t
= tex
; *t
!= '\0'; ++t
)
1605 *t
= g_ascii_tolower(*t
);
1607 if (allow_trans
&& strstr(tex
, "parentrelative") != NULL
) {
1608 *grad
= RR_SURFACE_PARENTREL
;
1610 if (strstr(tex
, "gradient") != NULL
) {
1611 if (strstr(tex
, "crossdiagonal") != NULL
)
1612 *grad
= RR_SURFACE_CROSS_DIAGONAL
;
1613 else if (strstr(tex
, "pyramid") != NULL
)
1614 *grad
= RR_SURFACE_PYRAMID
;
1615 else if (strstr(tex
, "mirrorhorizontal") != NULL
)
1616 *grad
= RR_SURFACE_MIRROR_HORIZONTAL
;
1617 else if (strstr(tex
, "horizontal") != NULL
)
1618 *grad
= RR_SURFACE_HORIZONTAL
;
1619 else if (strstr(tex
, "splitvertical") != NULL
)
1620 *grad
= RR_SURFACE_SPLIT_VERTICAL
;
1621 else if (strstr(tex
, "vertical") != NULL
)
1622 *grad
= RR_SURFACE_VERTICAL
;
1624 *grad
= RR_SURFACE_DIAGONAL
;
1626 *grad
= RR_SURFACE_SOLID
;
1630 if (strstr(tex
, "sunken") != NULL
)
1631 *relief
= RR_RELIEF_SUNKEN
;
1632 else if (strstr(tex
, "flat") != NULL
)
1633 *relief
= RR_RELIEF_FLAT
;
1634 else if (strstr(tex
, "raised") != NULL
)
1635 *relief
= RR_RELIEF_RAISED
;
1637 *relief
= (*grad
== RR_SURFACE_PARENTREL
) ?
1638 RR_RELIEF_FLAT
: RR_RELIEF_RAISED
;
1641 if (*relief
== RR_RELIEF_FLAT
) {
1642 if (strstr(tex
, "border") != NULL
)
1645 if (strstr(tex
, "bevel2") != NULL
)
1646 *bevel
= RR_BEVEL_2
;
1648 *bevel
= RR_BEVEL_1
;
1651 if (strstr(tex
, "interlaced") != NULL
)
1654 *interlaced
= FALSE
;
1657 static gboolean
read_appearance(XrmDatabase db
, const RrInstance
*inst
,
1658 const gchar
*rname
, RrAppearance
*value
,
1659 gboolean allow_trans
)
1661 gboolean ret
= FALSE
;
1662 gchar
*rclass
= create_class_name(rname
);
1663 gchar
*cname
, *ctoname
, *bcname
, *icname
, *hname
, *sname
;
1664 gchar
*csplitname
, *ctosplitname
;
1669 cname
= g_strconcat(rname
, ".color", NULL
);
1670 ctoname
= g_strconcat(rname
, ".colorTo", NULL
);
1671 bcname
= g_strconcat(rname
, ".border.color", NULL
);
1672 icname
= g_strconcat(rname
, ".interlace.color", NULL
);
1673 hname
= g_strconcat(rname
, ".highlight", NULL
);
1674 sname
= g_strconcat(rname
, ".shadow", NULL
);
1675 csplitname
= g_strconcat(rname
, ".color.splitTo", NULL
);
1676 ctosplitname
= g_strconcat(rname
, ".colorTo.splitTo", NULL
);
1678 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1679 retvalue
.addr
!= NULL
) {
1680 parse_appearance(retvalue
.addr
,
1681 &value
->surface
.grad
,
1682 &value
->surface
.relief
,
1683 &value
->surface
.bevel
,
1684 &value
->surface
.interlaced
,
1685 &value
->surface
.border
,
1687 if (!read_color(db
, inst
, cname
, &value
->surface
.primary
))
1688 value
->surface
.primary
= RrColorNew(inst
, 0, 0, 0);
1689 if (!read_color(db
, inst
, ctoname
, &value
->surface
.secondary
))
1690 value
->surface
.secondary
= RrColorNew(inst
, 0, 0, 0);
1691 if (value
->surface
.border
)
1692 if (!read_color(db
, inst
, bcname
,
1693 &value
->surface
.border_color
))
1694 value
->surface
.border_color
= RrColorNew(inst
, 0, 0, 0);
1695 if (value
->surface
.interlaced
)
1696 if (!read_color(db
, inst
, icname
,
1697 &value
->surface
.interlace_color
))
1698 value
->surface
.interlace_color
= RrColorNew(inst
, 0, 0, 0);
1699 if (read_int(db
, hname
, &i
) && i
>= 0)
1700 value
->surface
.bevel_light_adjust
= i
;
1701 if (read_int(db
, sname
, &i
) && i
>= 0 && i
<= 256)
1702 value
->surface
.bevel_dark_adjust
= i
;
1704 if (value
->surface
.grad
== RR_SURFACE_SPLIT_VERTICAL
) {
1707 if (!read_color(db
, inst
, csplitname
,
1708 &value
->surface
.split_primary
))
1710 r
= value
->surface
.primary
->r
;
1712 g
= value
->surface
.primary
->g
;
1714 b
= value
->surface
.primary
->b
;
1716 if (r
> 0xFF) r
= 0xFF;
1717 if (g
> 0xFF) g
= 0xFF;
1718 if (b
> 0xFF) b
= 0xFF;
1719 value
->surface
.split_primary
= RrColorNew(inst
, r
, g
, b
);
1722 if (!read_color(db
, inst
, ctosplitname
,
1723 &value
->surface
.split_secondary
))
1725 r
= value
->surface
.secondary
->r
;
1727 g
= value
->surface
.secondary
->g
;
1729 b
= value
->surface
.secondary
->b
;
1731 if (r
> 0xFF) r
= 0xFF;
1732 if (g
> 0xFF) g
= 0xFF;
1733 if (b
> 0xFF) b
= 0xFF;
1734 value
->surface
.split_secondary
= RrColorNew(inst
, r
, g
, b
);
1741 g_free(ctosplitname
);
1753 static int parse_inline_number(const char *p
)
1761 for (; isdigit(*p
); ++p
)
1762 res
= res
* 10 + *p
- '0';
1767 static void set_default_appearance(RrAppearance
*a
)
1769 a
->surface
.grad
= RR_SURFACE_SOLID
;
1770 a
->surface
.relief
= RR_RELIEF_FLAT
;
1771 a
->surface
.bevel
= RR_BEVEL_1
;
1772 a
->surface
.interlaced
= FALSE
;
1773 a
->surface
.border
= FALSE
;
1774 a
->surface
.primary
= RrColorNew(a
->inst
, 0, 0, 0);
1775 a
->surface
.secondary
= RrColorNew(a
->inst
, 0, 0, 0);
1778 /* Reads the output from gimp's C-Source file format into valid RGBA data for
1779 an RrTextureRGBA. */
1780 static RrPixel32
* read_c_image(gint width
, gint height
, const guint8
*data
)
1785 p
= im
= g_memdup(data
, width
* height
* sizeof(RrPixel32
));
1787 for (i
= 0; i
< width
* height
; ++i
) {
1788 guchar a
= ((*p
>> 24) & 0xff);
1789 guchar b
= ((*p
>> 16) & 0xff);
1790 guchar g
= ((*p
>> 8) & 0xff);
1791 guchar r
= ((*p
>> 0) & 0xff);
1793 *p
= ((r
<< RrDefaultRedOffset
) +
1794 (g
<< RrDefaultGreenOffset
) +
1795 (b
<< RrDefaultBlueOffset
) +
1796 (a
<< RrDefaultAlphaOffset
));