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 Ben 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
, gchar
*name
);
35 static gboolean
read_bool(XrmDatabase db
, gchar
*rname
, gboolean
*value
);
36 static gboolean
read_int(XrmDatabase db
, gchar
*rname
, gint
*value
);
37 static gboolean
read_string(XrmDatabase db
, gchar
*rname
, gchar
**value
);
38 static gboolean
read_color(XrmDatabase db
, const RrInstance
*inst
,
39 gchar
*rname
, RrColor
**value
);
40 static gboolean
read_mask(const RrInstance
*inst
,
41 gchar
*maskname
, RrTheme
*theme
,
42 RrPixmapMask
**value
);
43 static gboolean
read_appearance(XrmDatabase db
, const RrInstance
*inst
,
44 gchar
*rname
, RrAppearance
*value
,
45 gboolean allow_trans
);
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
)
53 XrmDatabase db
= NULL
;
54 RrJustify winjust
, mtitlejust
;
61 theme
= g_new0(RrTheme
, 1);
65 theme
->show_handle
= TRUE
;
67 theme
->a_disabled_focused_max
= RrAppearanceNew(inst
, 1);
68 theme
->a_disabled_unfocused_max
= RrAppearanceNew(inst
, 1);
69 theme
->a_hover_focused_max
= RrAppearanceNew(inst
, 1);
70 theme
->a_hover_unfocused_max
= RrAppearanceNew(inst
, 1);
71 theme
->a_toggled_focused_max
= RrAppearanceNew(inst
, 1);
72 theme
->a_toggled_unfocused_max
= RrAppearanceNew(inst
, 1);
73 theme
->a_focused_unpressed_max
= RrAppearanceNew(inst
, 1);
74 theme
->a_focused_pressed_max
= RrAppearanceNew(inst
, 1);
75 theme
->a_unfocused_unpressed_max
= RrAppearanceNew(inst
, 1);
76 theme
->a_unfocused_pressed_max
= RrAppearanceNew(inst
, 1);
77 theme
->a_focused_grip
= RrAppearanceNew(inst
, 0);
78 theme
->a_unfocused_grip
= RrAppearanceNew(inst
, 0);
79 theme
->a_focused_title
= RrAppearanceNew(inst
, 0);
80 theme
->a_unfocused_title
= RrAppearanceNew(inst
, 0);
81 theme
->a_focused_label
= RrAppearanceNew(inst
, 1);
82 theme
->a_unfocused_label
= RrAppearanceNew(inst
, 1);
83 theme
->a_icon
= RrAppearanceNew(inst
, 1);
84 theme
->a_focused_handle
= RrAppearanceNew(inst
, 0);
85 theme
->a_unfocused_handle
= RrAppearanceNew(inst
, 0);
86 theme
->a_menu
= RrAppearanceNew(inst
, 0);
87 theme
->a_menu_title
= RrAppearanceNew(inst
, 1);
88 theme
->a_menu_normal
= RrAppearanceNew(inst
, 0);
89 theme
->a_menu_disabled
= RrAppearanceNew(inst
, 0);
90 theme
->a_menu_selected
= RrAppearanceNew(inst
, 0);
91 theme
->a_menu_text_normal
= RrAppearanceNew(inst
, 1);
92 theme
->a_menu_text_disabled
= RrAppearanceNew(inst
, 1);
93 theme
->a_menu_text_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
);
102 g_warning("Failed to load the theme '%s'\n"
103 "Falling back to the default: '%s'",
104 name
, DEFAULT_THEME
);
106 theme
->name
= g_path_get_basename(name
);
109 db
= loaddb(theme
, DEFAULT_THEME
);
111 g_warning("Failed to load the theme '%s'.", DEFAULT_THEME
);
114 theme
->name
= g_path_get_basename(DEFAULT_THEME
);
117 /* load the font stuff */
118 if (active_window_font
) {
119 theme
->win_font_focused
= active_window_font
;
120 RrFontRef(active_window_font
);
122 theme
->win_font_focused
= RrFontOpenDefault(inst
);
124 if (inactive_window_font
) {
125 theme
->win_font_unfocused
= inactive_window_font
;
126 RrFontRef(inactive_window_font
);
128 theme
->win_font_unfocused
= RrFontOpenDefault(inst
);
130 winjust
= RR_JUSTIFY_LEFT
;
131 if (read_string(db
, "window.label.text.justify", &str
)) {
132 if (!g_ascii_strcasecmp(str
, "right"))
133 winjust
= RR_JUSTIFY_RIGHT
;
134 else if (!g_ascii_strcasecmp(str
, "center"))
135 winjust
= RR_JUSTIFY_CENTER
;
138 if (menu_title_font
) {
139 theme
->menu_title_font
= menu_title_font
;
140 RrFontRef(menu_title_font
);
142 theme
->menu_title_font
= RrFontOpenDefault(inst
);
144 mtitlejust
= RR_JUSTIFY_LEFT
;
145 if (read_string(db
, "menu.title.text.justify", &str
)) {
146 if (!g_ascii_strcasecmp(str
, "right"))
147 mtitlejust
= RR_JUSTIFY_RIGHT
;
148 else if (!g_ascii_strcasecmp(str
, "center"))
149 mtitlejust
= RR_JUSTIFY_CENTER
;
152 if (menu_item_font
) {
153 theme
->menu_font
= menu_item_font
;
154 RrFontRef(menu_item_font
);
156 theme
->menu_font
= RrFontOpenDefault(inst
);
158 /* load direct dimensions */
159 if (!read_int(db
, "menu.overlap", &theme
->menu_overlap
) ||
160 theme
->menu_overlap
< 0 || theme
->menu_overlap
> 20)
161 theme
->menu_overlap
= 0;
162 if (!read_int(db
, "window.handle.width", &theme
->handle_height
))
163 theme
->handle_height
= 6;
164 if (!theme
->handle_height
)
165 theme
->show_handle
= FALSE
;
166 if (theme
->handle_height
<= 0 || theme
->handle_height
> 100)
167 theme
->handle_height
= 6;
168 if (!read_int(db
, "padding.width", &theme
->padding
) ||
169 theme
->padding
< 0 || theme
->padding
> 100)
171 if (!read_int(db
, "border.width", &theme
->bwidth
) ||
172 theme
->bwidth
< 0 || theme
->bwidth
> 100)
174 if (!read_int(db
, "window.client.padding.width", &theme
->cbwidth
) ||
175 theme
->cbwidth
< 0 || theme
->cbwidth
> 100)
176 theme
->cbwidth
= theme
->padding
;
179 if (!read_color(db
, inst
,
180 "border.color", &theme
->b_color
))
181 theme
->b_color
= RrColorNew(inst
, 0, 0, 0);
182 if (!read_color(db
, inst
,
183 "window.active.client.color",
184 &theme
->cb_focused_color
))
185 theme
->cb_focused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
186 if (!read_color(db
, inst
,
187 "window.inactive.client.color",
188 &theme
->cb_unfocused_color
))
189 theme
->cb_unfocused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
190 if (!read_color(db
, inst
,
191 "window.active.label.text.color",
192 &theme
->title_focused_color
))
193 theme
->title_focused_color
= RrColorNew(inst
, 0x0, 0x0, 0x0);
194 if (!read_color(db
, inst
,
195 "window.inactive.label.text.color",
196 &theme
->title_unfocused_color
))
197 theme
->title_unfocused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
198 if (!read_color(db
, inst
,
199 "window.active.button.unpressed.image.color",
200 &theme
->titlebut_focused_unpressed_color
))
201 theme
->titlebut_focused_unpressed_color
= RrColorNew(inst
, 0, 0, 0);
202 if (!read_color(db
, inst
,
203 "window.inactive.button.unpressed.image.color",
204 &theme
->titlebut_unfocused_unpressed_color
))
205 theme
->titlebut_unfocused_unpressed_color
=
206 RrColorNew(inst
, 0xff, 0xff, 0xff);
207 if (!read_color(db
, inst
,
208 "window.active.button.pressed.image.color",
209 &theme
->titlebut_focused_pressed_color
))
210 theme
->titlebut_focused_pressed_color
=
212 theme
->titlebut_focused_unpressed_color
->r
,
213 theme
->titlebut_focused_unpressed_color
->g
,
214 theme
->titlebut_focused_unpressed_color
->b
);
215 if (!read_color(db
, inst
,
216 "window.inactive.button.pressed.image.color",
217 &theme
->titlebut_unfocused_pressed_color
))
218 theme
->titlebut_unfocused_pressed_color
=
220 theme
->titlebut_unfocused_unpressed_color
->r
,
221 theme
->titlebut_unfocused_unpressed_color
->g
,
222 theme
->titlebut_unfocused_unpressed_color
->b
);
223 if (!read_color(db
, inst
,
224 "window.active.button.disabled.image.color",
225 &theme
->titlebut_disabled_focused_color
))
226 theme
->titlebut_disabled_focused_color
=
227 RrColorNew(inst
, 0xff, 0xff, 0xff);
228 if (!read_color(db
, inst
,
229 "window.inactive.button.disabled.image.color",
230 &theme
->titlebut_disabled_unfocused_color
))
231 theme
->titlebut_disabled_unfocused_color
= RrColorNew(inst
, 0, 0, 0);
232 if (!read_color(db
, inst
,
233 "window.active.button.hover.image.color",
234 &theme
->titlebut_hover_focused_color
))
235 theme
->titlebut_hover_focused_color
=
237 theme
->titlebut_focused_unpressed_color
->r
,
238 theme
->titlebut_focused_unpressed_color
->g
,
239 theme
->titlebut_focused_unpressed_color
->b
);
240 if (!read_color(db
, inst
,
241 "window.inactive.button.hover.image.color",
242 &theme
->titlebut_hover_unfocused_color
))
243 theme
->titlebut_hover_unfocused_color
=
245 theme
->titlebut_unfocused_unpressed_color
->r
,
246 theme
->titlebut_unfocused_unpressed_color
->g
,
247 theme
->titlebut_unfocused_unpressed_color
->b
);
248 if (!read_color(db
, inst
,
249 "window.active.button.toggled.image.color",
250 &theme
->titlebut_toggled_focused_color
))
251 theme
->titlebut_toggled_focused_color
=
253 theme
->titlebut_focused_pressed_color
->r
,
254 theme
->titlebut_focused_pressed_color
->g
,
255 theme
->titlebut_focused_pressed_color
->b
);
256 if (!read_color(db
, inst
,
257 "window.inactive.button.toggled.image.color",
258 &theme
->titlebut_toggled_unfocused_color
))
259 theme
->titlebut_toggled_unfocused_color
=
261 theme
->titlebut_unfocused_pressed_color
->r
,
262 theme
->titlebut_unfocused_pressed_color
->g
,
263 theme
->titlebut_unfocused_pressed_color
->b
);
264 if (!read_color(db
, inst
,
265 "menu.title.text.color", &theme
->menu_title_color
))
266 theme
->menu_title_color
= RrColorNew(inst
, 0, 0, 0);
267 if (!read_color(db
, inst
,
268 "menu.items.text.color", &theme
->menu_color
))
269 theme
->menu_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
270 if (!read_color(db
, inst
,
271 "menu.items.disabled.text.color",
272 &theme
->menu_disabled_color
))
273 theme
->menu_disabled_color
= RrColorNew(inst
, 0, 0, 0);
274 if (!read_color(db
, inst
,
275 "menu.items.active.text.color",
276 &theme
->menu_selected_color
))
277 theme
->menu_selected_color
= RrColorNew(inst
, 0, 0, 0);
279 if (read_mask(inst
, "max.xbm", theme
, &theme
->max_mask
)) {
280 if (!read_mask(inst
, "max_pressed.xbm", theme
,
281 &theme
->max_pressed_mask
)) {
282 theme
->max_pressed_mask
= RrPixmapMaskCopy(theme
->max_mask
);
284 if (!read_mask(inst
, "max_toggled.xbm", theme
,
285 &theme
->max_toggled_mask
)) {
286 theme
->max_toggled_mask
=
287 RrPixmapMaskCopy(theme
->max_pressed_mask
);
289 if (!read_mask(inst
, "max_disabled.xbm", theme
,
290 &theme
->max_disabled_mask
)) {
291 theme
->max_disabled_mask
= RrPixmapMaskCopy(theme
->max_mask
);
293 if (!read_mask(inst
, "max_hover.xbm", theme
, &theme
->max_hover_mask
)) {
294 theme
->max_hover_mask
= RrPixmapMaskCopy(theme
->max_mask
);
298 guchar data
[] = { 0x7f, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f };
299 theme
->max_mask
= RrPixmapMaskNew(inst
, 7, 7, (gchar
*)data
);
302 guchar data
[] = { 0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
303 theme
->max_toggled_mask
= RrPixmapMaskNew(inst
, 7, 7, (gchar
*)data
);
305 theme
->max_pressed_mask
= RrPixmapMaskCopy(theme
->max_mask
);
306 theme
->max_disabled_mask
= RrPixmapMaskCopy(theme
->max_mask
);
307 theme
->max_hover_mask
= RrPixmapMaskCopy(theme
->max_mask
);
310 if (read_mask(inst
, "iconify.xbm", theme
, &theme
->iconify_mask
)) {
311 if (!read_mask(inst
, "iconify_pressed.xbm", theme
,
312 &theme
->iconify_pressed_mask
)) {
313 theme
->iconify_pressed_mask
=
314 RrPixmapMaskCopy(theme
->iconify_mask
);
316 if (!read_mask(inst
, "iconify_disabled.xbm", theme
,
317 &theme
->iconify_disabled_mask
)) {
318 theme
->iconify_disabled_mask
=
319 RrPixmapMaskCopy(theme
->iconify_mask
);
321 if (!read_mask(inst
, "iconify_hover.xbm", theme
,
322 &theme
->iconify_hover_mask
)) {
323 theme
->iconify_hover_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
327 guchar data
[] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x7f };
328 theme
->iconify_mask
= RrPixmapMaskNew(inst
, 7, 7, (gchar
*)data
);
330 theme
->iconify_pressed_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
331 theme
->iconify_disabled_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
332 theme
->iconify_hover_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
335 theme
->def_win_icon
= read_c_image(OB_DEFAULT_ICON_WIDTH
,
336 OB_DEFAULT_ICON_HEIGHT
,
337 OB_DEFAULT_ICON_pixel_data
);
339 if (read_mask(inst
, "desk.xbm", theme
, &theme
->desk_mask
)) {
340 if (!read_mask(inst
, "desk_pressed.xbm", theme
,
341 &theme
->desk_pressed_mask
)) {
342 theme
->desk_pressed_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
344 if (!read_mask(inst
, "desk_toggled.xbm", theme
,
345 &theme
->desk_toggled_mask
)) {
346 theme
->desk_toggled_mask
=
347 RrPixmapMaskCopy(theme
->desk_pressed_mask
);
349 if (!read_mask(inst
, "desk_disabled.xbm", theme
,
350 &theme
->desk_disabled_mask
)) {
351 theme
->desk_disabled_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
353 if (!read_mask(inst
, "desk_hover.xbm", theme
,
354 &theme
->desk_hover_mask
)) {
355 theme
->desk_hover_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
359 guchar data
[] = { 0x63, 0x63, 0x00, 0x00, 0x00, 0x63, 0x63 };
360 theme
->desk_mask
= RrPixmapMaskNew(inst
, 7, 7, (gchar
*)data
);
363 guchar data
[] = { 0x00, 0x36, 0x36, 0x08, 0x36, 0x36, 0x00 };
364 theme
->desk_toggled_mask
= RrPixmapMaskNew(inst
, 7, 7,
367 theme
->desk_pressed_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
368 theme
->desk_disabled_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
369 theme
->desk_hover_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
372 if (read_mask(inst
, "shade.xbm", theme
, &theme
->shade_mask
)) {
373 if (!read_mask(inst
, "shade_pressed.xbm", theme
,
374 &theme
->shade_pressed_mask
)) {
375 theme
->shade_pressed_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
377 if (!read_mask(inst
, "shade_toggled.xbm", theme
,
378 &theme
->shade_toggled_mask
)) {
379 theme
->shade_toggled_mask
=
380 RrPixmapMaskCopy(theme
->shade_pressed_mask
);
382 if (!read_mask(inst
, "shade_disabled.xbm", theme
,
383 &theme
->shade_disabled_mask
)) {
384 theme
->shade_disabled_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
386 if (!read_mask(inst
, "shade_hover.xbm", theme
,
387 &theme
->shade_hover_mask
)) {
388 theme
->shade_hover_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
392 guchar data
[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00 };
393 theme
->shade_mask
= RrPixmapMaskNew(inst
, 7, 7, (gchar
*)data
);
396 guchar data
[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x7f };
397 theme
->shade_toggled_mask
= RrPixmapMaskNew(inst
, 7, 7,
400 theme
->shade_pressed_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
401 theme
->shade_disabled_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
402 theme
->shade_hover_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
405 if (read_mask(inst
, "close.xbm", theme
, &theme
->close_mask
)) {
406 if (!read_mask(inst
, "close_pressed.xbm", theme
,
407 &theme
->close_pressed_mask
)) {
408 theme
->close_pressed_mask
= RrPixmapMaskCopy(theme
->close_mask
);
410 if (!read_mask(inst
, "close_disabled.xbm", theme
,
411 &theme
->close_disabled_mask
)) {
412 theme
->close_disabled_mask
= RrPixmapMaskCopy(theme
->close_mask
);
414 if (!read_mask(inst
, "close_hover.xbm", theme
,
415 &theme
->close_hover_mask
)) {
416 theme
->close_hover_mask
= RrPixmapMaskCopy(theme
->close_mask
);
420 guchar data
[] = { 0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63 };
421 theme
->close_mask
= RrPixmapMaskNew(inst
, 7, 7, (gchar
*)data
);
423 theme
->close_pressed_mask
= RrPixmapMaskCopy(theme
->close_mask
);
424 theme
->close_disabled_mask
= RrPixmapMaskCopy(theme
->close_mask
);
425 theme
->close_hover_mask
= RrPixmapMaskCopy(theme
->close_mask
);
428 if (!read_mask(inst
, "bullet.xbm", theme
, &theme
->menu_bullet_mask
)) {
429 guchar data
[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
430 theme
->menu_bullet_mask
= RrPixmapMaskNew(inst
, 4, 7, (gchar
*)data
);
433 /* read the decoration textures */
434 if (!read_appearance(db
, inst
,
435 "window.active.title.bg", theme
->a_focused_title
,
437 set_default_appearance(theme
->a_focused_title
);
438 if (!read_appearance(db
, inst
,
439 "window.inactive.title.bg", theme
->a_unfocused_title
,
441 set_default_appearance(theme
->a_unfocused_title
);
442 if (!read_appearance(db
, inst
,
443 "window.active.label.bg", theme
->a_focused_label
,
445 set_default_appearance(theme
->a_focused_label
);
446 if (!read_appearance(db
, inst
,
447 "window.inactive.label.bg", theme
->a_unfocused_label
,
449 set_default_appearance(theme
->a_unfocused_label
);
450 if (!read_appearance(db
, inst
,
451 "window.active.handle.bg", theme
->a_focused_handle
,
453 set_default_appearance(theme
->a_focused_handle
);
454 if (!read_appearance(db
, inst
,
455 "window.inactive.handle.bg",theme
->a_unfocused_handle
,
457 set_default_appearance(theme
->a_unfocused_handle
);
458 if (!read_appearance(db
, inst
,
459 "window.active.grip.bg", theme
->a_focused_grip
,
461 set_default_appearance(theme
->a_focused_grip
);
462 if (!read_appearance(db
, inst
,
463 "window.inactive.grip.bg", theme
->a_unfocused_grip
,
465 set_default_appearance(theme
->a_unfocused_grip
);
466 if (!read_appearance(db
, inst
,
467 "menu.items.bg", theme
->a_menu
,
469 set_default_appearance(theme
->a_menu
);
470 if (!read_appearance(db
, inst
,
471 "menu.title.bg", theme
->a_menu_title
,
473 set_default_appearance(theme
->a_menu_title
);
474 if (!read_appearance(db
, inst
,
475 "menu.items.active.bg", theme
->a_menu_selected
,
477 set_default_appearance(theme
->a_menu_selected
);
479 /* read the appearances for rendering non-decorations */
480 theme
->app_hilite_bg
= RrAppearanceCopy(theme
->a_focused_title
);
481 theme
->app_hilite_label
= RrAppearanceCopy(theme
->a_focused_label
);
482 if (theme
->a_focused_label
->surface
.grad
!= RR_SURFACE_PARENTREL
)
483 theme
->app_hilite_fg
= RrAppearanceCopy(theme
->a_focused_label
);
485 theme
->app_hilite_fg
= RrAppearanceCopy(theme
->a_focused_title
);
486 theme
->app_unhilite_bg
= RrAppearanceCopy(theme
->a_unfocused_title
);
487 theme
->app_unhilite_label
= RrAppearanceCopy(theme
->a_unfocused_label
);
488 if (theme
->a_unfocused_label
->surface
.grad
!= RR_SURFACE_PARENTREL
)
489 theme
->app_unhilite_fg
= RrAppearanceCopy(theme
->a_unfocused_label
);
491 theme
->app_unhilite_fg
= RrAppearanceCopy(theme
->a_unfocused_title
);
493 /* read buttons textures */
494 if (!read_appearance(db
, inst
,
495 "window.active.button.disabled.bg",
496 theme
->a_disabled_focused_max
,
498 set_default_appearance(theme
->a_disabled_focused_max
);
499 if (!read_appearance(db
, inst
,
500 "window.inactive.button.disabled.bg",
501 theme
->a_disabled_unfocused_max
,
503 set_default_appearance(theme
->a_disabled_unfocused_max
);
504 if (!read_appearance(db
, inst
,
505 "window.active.button.pressed.bg",
506 theme
->a_focused_pressed_max
,
508 set_default_appearance(theme
->a_focused_pressed_max
);
509 if (!read_appearance(db
, inst
,
510 "window.inactive.button.pressed.bg",
511 theme
->a_unfocused_pressed_max
,
513 set_default_appearance(theme
->a_unfocused_pressed_max
);
514 if (!read_appearance(db
, inst
,
515 "window.active.button.toggled.bg",
516 theme
->a_toggled_focused_max
,
519 RrAppearanceFree(theme
->a_toggled_focused_max
);
520 theme
->a_toggled_focused_max
=
521 RrAppearanceCopy(theme
->a_focused_pressed_max
);
523 if (!read_appearance(db
, inst
,
524 "window.inactive.button.toggled.bg",
525 theme
->a_toggled_unfocused_max
,
528 RrAppearanceFree(theme
->a_toggled_unfocused_max
);
529 theme
->a_toggled_unfocused_max
=
530 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
532 if (!read_appearance(db
, inst
,
533 "window.active.button.unpressed.bg",
534 theme
->a_focused_unpressed_max
,
536 set_default_appearance(theme
->a_focused_unpressed_max
);
537 if (!read_appearance(db
, inst
,
538 "window.inactive.button.unpressed.bg",
539 theme
->a_unfocused_unpressed_max
,
541 set_default_appearance(theme
->a_unfocused_unpressed_max
);
542 if (!read_appearance(db
, inst
,
543 "window.active.button.hover.bg",
544 theme
->a_hover_focused_max
,
547 RrAppearanceFree(theme
->a_hover_focused_max
);
548 theme
->a_hover_focused_max
=
549 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
551 if (!read_appearance(db
, inst
,
552 "window.inactive.button.hover.bg",
553 theme
->a_hover_unfocused_max
,
556 RrAppearanceFree(theme
->a_hover_unfocused_max
);
557 theme
->a_hover_unfocused_max
=
558 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
561 theme
->a_disabled_focused_close
=
562 RrAppearanceCopy(theme
->a_disabled_focused_max
);
563 theme
->a_disabled_unfocused_close
=
564 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
565 theme
->a_hover_focused_close
=
566 RrAppearanceCopy(theme
->a_hover_focused_max
);
567 theme
->a_hover_unfocused_close
=
568 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
569 theme
->a_unfocused_unpressed_close
=
570 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
571 theme
->a_unfocused_pressed_close
=
572 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
573 theme
->a_focused_unpressed_close
=
574 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
575 theme
->a_focused_pressed_close
=
576 RrAppearanceCopy(theme
->a_focused_pressed_max
);
577 theme
->a_disabled_focused_desk
=
578 RrAppearanceCopy(theme
->a_disabled_focused_max
);
579 theme
->a_disabled_unfocused_desk
=
580 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
581 theme
->a_hover_focused_desk
=
582 RrAppearanceCopy(theme
->a_hover_focused_max
);
583 theme
->a_hover_unfocused_desk
=
584 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
585 theme
->a_toggled_focused_desk
=
586 RrAppearanceCopy(theme
->a_toggled_focused_max
);
587 theme
->a_toggled_unfocused_desk
=
588 RrAppearanceCopy(theme
->a_toggled_unfocused_max
);
589 theme
->a_unfocused_unpressed_desk
=
590 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
591 theme
->a_unfocused_pressed_desk
=
592 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
593 theme
->a_focused_unpressed_desk
=
594 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
595 theme
->a_focused_pressed_desk
=
596 RrAppearanceCopy(theme
->a_focused_pressed_max
);
597 theme
->a_disabled_focused_shade
=
598 RrAppearanceCopy(theme
->a_disabled_focused_max
);
599 theme
->a_disabled_unfocused_shade
=
600 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
601 theme
->a_hover_focused_shade
=
602 RrAppearanceCopy(theme
->a_hover_focused_max
);
603 theme
->a_hover_unfocused_shade
=
604 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
605 theme
->a_toggled_focused_shade
=
606 RrAppearanceCopy(theme
->a_toggled_focused_max
);
607 theme
->a_toggled_unfocused_shade
=
608 RrAppearanceCopy(theme
->a_toggled_unfocused_max
);
609 theme
->a_unfocused_unpressed_shade
=
610 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
611 theme
->a_unfocused_pressed_shade
=
612 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
613 theme
->a_focused_unpressed_shade
=
614 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
615 theme
->a_focused_pressed_shade
=
616 RrAppearanceCopy(theme
->a_focused_pressed_max
);
617 theme
->a_disabled_focused_iconify
=
618 RrAppearanceCopy(theme
->a_disabled_focused_max
);
619 theme
->a_disabled_unfocused_iconify
=
620 RrAppearanceCopy(theme
->a_disabled_focused_max
);
621 theme
->a_hover_focused_iconify
=
622 RrAppearanceCopy(theme
->a_hover_focused_max
);
623 theme
->a_hover_unfocused_iconify
=
624 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
625 theme
->a_unfocused_unpressed_iconify
=
626 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
627 theme
->a_unfocused_pressed_iconify
=
628 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
629 theme
->a_focused_unpressed_iconify
=
630 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
631 theme
->a_focused_pressed_iconify
=
632 RrAppearanceCopy(theme
->a_focused_pressed_max
);
634 theme
->a_icon
->surface
.grad
=
635 theme
->a_clear
->surface
.grad
=
636 theme
->a_clear_tex
->surface
.grad
=
637 theme
->a_menu_normal
->surface
.grad
=
638 theme
->a_menu_disabled
->surface
.grad
=
639 theme
->a_menu_text_normal
->surface
.grad
=
640 theme
->a_menu_text_disabled
->surface
.grad
=
641 theme
->a_menu_text_selected
->surface
.grad
=
642 theme
->a_menu_bullet_normal
->surface
.grad
=
643 theme
->a_menu_bullet_selected
->surface
.grad
= RR_SURFACE_PARENTREL
;
645 /* set up the textures */
646 theme
->a_focused_label
->texture
[0].type
=
647 theme
->app_hilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
648 theme
->a_focused_label
->texture
[0].data
.text
.justify
= winjust
;
649 theme
->app_hilite_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
650 theme
->a_focused_label
->texture
[0].data
.text
.font
=
651 theme
->app_hilite_label
->texture
[0].data
.text
.font
=
652 theme
->win_font_focused
;
653 theme
->a_focused_label
->texture
[0].data
.text
.color
=
654 theme
->app_hilite_label
->texture
[0].data
.text
.color
=
655 theme
->title_focused_color
;
657 if (read_bool(db
, "window.active.label.text.shadow", &b
) && b
) {
658 if (!read_int(db
, "window.active.label.text.shadow.offset", &offset
))
661 if (!read_int(db
, "window.active.label.text.shadow.tint", &tint
))
663 tint
= (tint
> 100 ? 100 : (tint
< -100 ? -100 : tint
));
668 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset
=
669 theme
->app_hilite_label
->texture
[0].data
.text
.shadow_offset
= offset
;
670 theme
->a_focused_label
->texture
[0].data
.text
.shadow_tint
=
671 theme
->app_hilite_label
->texture
[0].data
.text
.shadow_tint
= tint
;
673 theme
->a_unfocused_label
->texture
[0].type
=
674 theme
->app_unhilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
675 theme
->a_unfocused_label
->texture
[0].data
.text
.justify
= winjust
;
676 theme
->app_unhilite_label
->texture
[0].data
.text
.justify
=
678 theme
->a_unfocused_label
->texture
[0].data
.text
.font
=
679 theme
->app_unhilite_label
->texture
[0].data
.text
.font
=
680 theme
->win_font_unfocused
;
681 theme
->a_unfocused_label
->texture
[0].data
.text
.color
=
682 theme
->app_unhilite_label
->texture
[0].data
.text
.color
=
683 theme
->title_unfocused_color
;
685 if (read_bool(db
, "window.inactive.label.text.shadow", &b
) && b
) {
686 if (!read_int(db
, "window.inactive.label.text.shadow.offset", &offset
))
689 if (!read_int(db
, "window.inactive.label.text.shadow.tint", &tint
))
691 tint
= (tint
> 100 ? 100 : (tint
< -100 ? -100 : tint
));
696 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset
=
697 theme
->app_unhilite_label
->texture
[0].data
.text
.shadow_offset
=
699 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_tint
=
700 theme
->app_unhilite_label
->texture
[0].data
.text
.shadow_tint
= tint
;
702 theme
->a_menu_title
->texture
[0].type
= RR_TEXTURE_TEXT
;
703 theme
->a_menu_title
->texture
[0].data
.text
.justify
= mtitlejust
;
704 theme
->a_menu_title
->texture
[0].data
.text
.font
= theme
->menu_title_font
;
705 theme
->a_menu_title
->texture
[0].data
.text
.color
= theme
->menu_title_color
;
707 if (read_bool(db
, "menu.title.text.shadow", &b
) && b
) {
708 if (!read_int(db
, "menu.title.text.shadow.offset", &offset
))
711 if (!read_int(db
, "menu.title.text.shadow.tint", &tint
))
713 tint
= (tint
> 100 ? 100 : (tint
< -100 ? -100 : tint
));
718 theme
->a_menu_title
->texture
[0].data
.text
.shadow_offset
= offset
;
719 theme
->a_menu_title
->texture
[0].data
.text
.shadow_tint
= tint
;
721 theme
->a_menu_text_normal
->texture
[0].type
=
722 theme
->a_menu_text_disabled
->texture
[0].type
=
723 theme
->a_menu_text_selected
->texture
[0].type
= RR_TEXTURE_TEXT
;
724 theme
->a_menu_text_normal
->texture
[0].data
.text
.justify
=
725 theme
->a_menu_text_disabled
->texture
[0].data
.text
.justify
=
726 theme
->a_menu_text_selected
->texture
[0].data
.text
.justify
=
728 theme
->a_menu_text_normal
->texture
[0].data
.text
.font
=
729 theme
->a_menu_text_disabled
->texture
[0].data
.text
.font
=
730 theme
->a_menu_text_selected
->texture
[0].data
.text
.font
=
732 theme
->a_menu_text_normal
->texture
[0].data
.text
.color
= theme
->menu_color
;
733 theme
->a_menu_text_disabled
->texture
[0].data
.text
.color
=
734 theme
->menu_disabled_color
;
735 theme
->a_menu_text_selected
->texture
[0].data
.text
.color
=
736 theme
->menu_selected_color
;
738 if (read_bool(db
, "menu.items.text.shadow", &b
) && b
) {
739 if (!read_int(db
, "menu.items.text.shadow.offset", &offset
))
742 if (!read_int(db
, "menu.items.text.shadow.tint", &tint
))
744 tint
= (tint
> 100 ? 100 : (tint
< -100 ? -100 : tint
));
749 theme
->a_menu_text_normal
->texture
[0].data
.text
.shadow_offset
=
750 theme
->a_menu_text_disabled
->texture
[0].data
.text
.shadow_offset
=
751 theme
->a_menu_text_selected
->texture
[0].data
.text
.shadow_offset
=
753 theme
->a_menu_text_normal
->texture
[0].data
.text
.shadow_tint
=
754 theme
->a_menu_text_disabled
->texture
[0].data
.text
.shadow_tint
=
755 theme
->a_menu_text_selected
->texture
[0].data
.text
.shadow_tint
= tint
;
757 theme
->a_disabled_focused_max
->texture
[0].type
=
758 theme
->a_disabled_unfocused_max
->texture
[0].type
=
759 theme
->a_hover_focused_max
->texture
[0].type
=
760 theme
->a_hover_unfocused_max
->texture
[0].type
=
761 theme
->a_toggled_focused_max
->texture
[0].type
=
762 theme
->a_toggled_unfocused_max
->texture
[0].type
=
763 theme
->a_focused_unpressed_max
->texture
[0].type
=
764 theme
->a_focused_pressed_max
->texture
[0].type
=
765 theme
->a_unfocused_unpressed_max
->texture
[0].type
=
766 theme
->a_unfocused_pressed_max
->texture
[0].type
=
767 theme
->a_disabled_focused_close
->texture
[0].type
=
768 theme
->a_disabled_unfocused_close
->texture
[0].type
=
769 theme
->a_hover_focused_close
->texture
[0].type
=
770 theme
->a_hover_unfocused_close
->texture
[0].type
=
771 theme
->a_focused_unpressed_close
->texture
[0].type
=
772 theme
->a_focused_pressed_close
->texture
[0].type
=
773 theme
->a_unfocused_unpressed_close
->texture
[0].type
=
774 theme
->a_unfocused_pressed_close
->texture
[0].type
=
775 theme
->a_disabled_focused_desk
->texture
[0].type
=
776 theme
->a_disabled_unfocused_desk
->texture
[0].type
=
777 theme
->a_hover_focused_desk
->texture
[0].type
=
778 theme
->a_hover_unfocused_desk
->texture
[0].type
=
779 theme
->a_toggled_focused_desk
->texture
[0].type
=
780 theme
->a_toggled_unfocused_desk
->texture
[0].type
=
781 theme
->a_focused_unpressed_desk
->texture
[0].type
=
782 theme
->a_focused_pressed_desk
->texture
[0].type
=
783 theme
->a_unfocused_unpressed_desk
->texture
[0].type
=
784 theme
->a_unfocused_pressed_desk
->texture
[0].type
=
785 theme
->a_disabled_focused_shade
->texture
[0].type
=
786 theme
->a_disabled_unfocused_shade
->texture
[0].type
=
787 theme
->a_hover_focused_shade
->texture
[0].type
=
788 theme
->a_hover_unfocused_shade
->texture
[0].type
=
789 theme
->a_toggled_focused_shade
->texture
[0].type
=
790 theme
->a_toggled_unfocused_shade
->texture
[0].type
=
791 theme
->a_focused_unpressed_shade
->texture
[0].type
=
792 theme
->a_focused_pressed_shade
->texture
[0].type
=
793 theme
->a_unfocused_unpressed_shade
->texture
[0].type
=
794 theme
->a_unfocused_pressed_shade
->texture
[0].type
=
795 theme
->a_disabled_focused_iconify
->texture
[0].type
=
796 theme
->a_disabled_unfocused_iconify
->texture
[0].type
=
797 theme
->a_hover_focused_iconify
->texture
[0].type
=
798 theme
->a_hover_unfocused_iconify
->texture
[0].type
=
799 theme
->a_focused_unpressed_iconify
->texture
[0].type
=
800 theme
->a_focused_pressed_iconify
->texture
[0].type
=
801 theme
->a_unfocused_unpressed_iconify
->texture
[0].type
=
802 theme
->a_unfocused_pressed_iconify
->texture
[0].type
=
803 theme
->a_menu_bullet_normal
->texture
[0].type
=
804 theme
->a_menu_bullet_selected
->texture
[0].type
= RR_TEXTURE_MASK
;
806 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.mask
=
807 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.mask
=
808 theme
->max_disabled_mask
;
809 theme
->a_hover_focused_max
->texture
[0].data
.mask
.mask
=
810 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.mask
=
811 theme
->max_hover_mask
;
812 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.mask
=
813 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.mask
=
814 theme
->max_pressed_mask
;
815 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.mask
=
816 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.mask
=
818 theme
->a_toggled_focused_max
->texture
[0].data
.mask
.mask
=
819 theme
->a_toggled_unfocused_max
->texture
[0].data
.mask
.mask
=
820 theme
->max_toggled_mask
;
821 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.mask
=
822 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.mask
=
823 theme
->close_disabled_mask
;
824 theme
->a_hover_focused_close
->texture
[0].data
.mask
.mask
=
825 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.mask
=
826 theme
->close_hover_mask
;
827 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.mask
=
828 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.mask
=
829 theme
->close_pressed_mask
;
830 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.mask
=
831 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.mask
=
833 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.mask
=
834 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.mask
=
835 theme
->desk_disabled_mask
;
836 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.mask
=
837 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.mask
=
838 theme
->desk_hover_mask
;
839 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.mask
=
840 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.mask
=
841 theme
->desk_pressed_mask
;
842 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.mask
=
843 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.mask
=
845 theme
->a_toggled_focused_desk
->texture
[0].data
.mask
.mask
=
846 theme
->a_toggled_unfocused_desk
->texture
[0].data
.mask
.mask
=
847 theme
->desk_toggled_mask
;
848 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.mask
=
849 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.mask
=
850 theme
->shade_disabled_mask
;
851 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.mask
=
852 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.mask
=
853 theme
->shade_hover_mask
;
854 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.mask
=
855 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.mask
=
856 theme
->shade_pressed_mask
;
857 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.mask
=
858 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.mask
=
860 theme
->a_toggled_focused_shade
->texture
[0].data
.mask
.mask
=
861 theme
->a_toggled_unfocused_shade
->texture
[0].data
.mask
.mask
=
862 theme
->shade_toggled_mask
;
863 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.mask
=
864 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.mask
=
865 theme
->iconify_disabled_mask
;
866 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.mask
=
867 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.mask
=
868 theme
->iconify_hover_mask
;
869 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.mask
=
870 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.mask
=
871 theme
->iconify_pressed_mask
;
872 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
873 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
875 theme
->a_menu_bullet_normal
->texture
[0].data
.mask
.mask
=
876 theme
->a_menu_bullet_selected
->texture
[0].data
.mask
.mask
=
877 theme
->menu_bullet_mask
;
878 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.color
=
879 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.color
=
880 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.color
=
881 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.color
=
882 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.color
=
883 theme
->titlebut_disabled_focused_color
;
884 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.color
=
885 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.color
=
886 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.color
=
887 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.color
=
888 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.color
=
889 theme
->titlebut_disabled_unfocused_color
;
890 theme
->a_hover_focused_max
->texture
[0].data
.mask
.color
=
891 theme
->a_hover_focused_close
->texture
[0].data
.mask
.color
=
892 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.color
=
893 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.color
=
894 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.color
=
895 theme
->titlebut_hover_focused_color
;
896 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.color
=
897 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.color
=
898 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.color
=
899 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.color
=
900 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.color
=
901 theme
->titlebut_hover_unfocused_color
;
902 theme
->a_toggled_focused_max
->texture
[0].data
.mask
.color
=
903 theme
->a_toggled_focused_desk
->texture
[0].data
.mask
.color
=
904 theme
->a_toggled_focused_shade
->texture
[0].data
.mask
.color
=
905 theme
->titlebut_toggled_focused_color
;
906 theme
->a_toggled_unfocused_max
->texture
[0].data
.mask
.color
=
907 theme
->a_toggled_unfocused_desk
->texture
[0].data
.mask
.color
=
908 theme
->a_toggled_unfocused_shade
->texture
[0].data
.mask
.color
=
909 theme
->titlebut_toggled_unfocused_color
;
910 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.color
=
911 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.color
=
912 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.color
=
913 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.color
=
914 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.color
=
915 theme
->titlebut_focused_unpressed_color
;
916 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.color
=
917 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.color
=
918 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.color
=
919 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.color
=
920 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.color
=
921 theme
->titlebut_focused_pressed_color
;
922 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.color
=
923 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.color
=
924 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.color
=
925 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.color
=
926 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.color
=
927 theme
->titlebut_unfocused_unpressed_color
;
928 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.color
=
929 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.color
=
930 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.color
=
931 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.color
=
932 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.color
=
933 theme
->titlebut_unfocused_pressed_color
;
934 theme
->a_menu_bullet_normal
->texture
[0].data
.mask
.color
=
936 theme
->a_menu_bullet_selected
->texture
[0].data
.mask
.color
=
937 theme
->menu_selected_color
;
939 XrmDestroyDatabase(db
);
941 /* set the font heights */
942 theme
->win_font_height
= RrFontHeight
943 (theme
->win_font_focused
,
944 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset
);
945 theme
->win_font_height
=
946 MAX(theme
->win_font_height
,
948 (theme
->win_font_focused
,
949 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset
));
950 theme
->menu_title_font_height
= RrFontHeight
951 (theme
->menu_title_font
,
952 theme
->a_menu_title
->texture
[0].data
.text
.shadow_offset
);
953 theme
->menu_font_height
= RrFontHeight
955 theme
->a_menu_text_normal
->texture
[0].data
.text
.shadow_offset
);
957 /* calculate some last extents */
959 gint ft
, fb
, fl
, fr
, ut
, ub
, ul
, ur
;
961 RrMargins(theme
->a_focused_label
, &fl
, &ft
, &fr
, &fb
);
962 RrMargins(theme
->a_unfocused_label
, &ul
, &ut
, &ur
, &ub
);
963 theme
->label_height
= theme
->win_font_height
+ MAX(ft
+ fb
, ut
+ ub
);
965 /* this would be nice I think, since padding.width can now be 0,
966 but it breaks frame.c horribly and I don't feel like fixing that
967 right now, so if anyone complains, here is how to keep text from
968 going over the title's bevel/border with a padding.width of 0 and a
969 bevelless/borderless label
970 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
971 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
972 theme->title_height = theme->label_height +
973 MAX(MAX(theme->padding * 2, ft + fb),
974 MAX(theme->padding * 2, ut + ub));
976 theme
->title_height
= theme
->label_height
+ theme
->padding
* 2;
977 /* this should match the above title_height given the same font size
979 theme
->menu_title_height
= theme
->menu_title_font_height
+
982 theme
->button_size
= theme
->label_height
- 2;
983 theme
->grip_width
= 25;
988 void RrThemeFree(RrTheme
*theme
)
994 RrColorFree(theme
->b_color
);
995 RrColorFree(theme
->cb_unfocused_color
);
996 RrColorFree(theme
->cb_focused_color
);
997 RrColorFree(theme
->title_unfocused_color
);
998 RrColorFree(theme
->title_focused_color
);
999 RrColorFree(theme
->titlebut_disabled_focused_color
);
1000 RrColorFree(theme
->titlebut_disabled_unfocused_color
);
1001 RrColorFree(theme
->titlebut_hover_focused_color
);
1002 RrColorFree(theme
->titlebut_hover_unfocused_color
);
1003 RrColorFree(theme
->titlebut_toggled_focused_color
);
1004 RrColorFree(theme
->titlebut_toggled_unfocused_color
);
1005 RrColorFree(theme
->titlebut_unfocused_pressed_color
);
1006 RrColorFree(theme
->titlebut_focused_pressed_color
);
1007 RrColorFree(theme
->titlebut_unfocused_unpressed_color
);
1008 RrColorFree(theme
->titlebut_focused_unpressed_color
);
1009 RrColorFree(theme
->menu_color
);
1010 RrColorFree(theme
->menu_title_color
);
1011 RrColorFree(theme
->menu_disabled_color
);
1012 RrColorFree(theme
->menu_selected_color
);
1014 g_free(theme
->def_win_icon
);
1016 RrPixmapMaskFree(theme
->max_mask
);
1017 RrPixmapMaskFree(theme
->max_toggled_mask
);
1018 RrPixmapMaskFree(theme
->max_disabled_mask
);
1019 RrPixmapMaskFree(theme
->max_hover_mask
);
1020 RrPixmapMaskFree(theme
->max_pressed_mask
);
1021 RrPixmapMaskFree(theme
->desk_mask
);
1022 RrPixmapMaskFree(theme
->desk_toggled_mask
);
1023 RrPixmapMaskFree(theme
->desk_disabled_mask
);
1024 RrPixmapMaskFree(theme
->desk_hover_mask
);
1025 RrPixmapMaskFree(theme
->desk_pressed_mask
);
1026 RrPixmapMaskFree(theme
->shade_mask
);
1027 RrPixmapMaskFree(theme
->shade_toggled_mask
);
1028 RrPixmapMaskFree(theme
->shade_disabled_mask
);
1029 RrPixmapMaskFree(theme
->shade_hover_mask
);
1030 RrPixmapMaskFree(theme
->shade_pressed_mask
);
1031 RrPixmapMaskFree(theme
->iconify_mask
);
1032 RrPixmapMaskFree(theme
->iconify_disabled_mask
);
1033 RrPixmapMaskFree(theme
->iconify_hover_mask
);
1034 RrPixmapMaskFree(theme
->iconify_pressed_mask
);
1035 RrPixmapMaskFree(theme
->close_mask
);
1036 RrPixmapMaskFree(theme
->close_disabled_mask
);
1037 RrPixmapMaskFree(theme
->close_hover_mask
);
1038 RrPixmapMaskFree(theme
->close_pressed_mask
);
1039 RrPixmapMaskFree(theme
->menu_bullet_mask
);
1041 RrFontClose(theme
->win_font_focused
);
1042 RrFontClose(theme
->win_font_unfocused
);
1043 RrFontClose(theme
->menu_title_font
);
1044 RrFontClose(theme
->menu_font
);
1046 RrAppearanceFree(theme
->a_disabled_focused_max
);
1047 RrAppearanceFree(theme
->a_disabled_unfocused_max
);
1048 RrAppearanceFree(theme
->a_hover_focused_max
);
1049 RrAppearanceFree(theme
->a_hover_unfocused_max
);
1050 RrAppearanceFree(theme
->a_toggled_focused_max
);
1051 RrAppearanceFree(theme
->a_toggled_unfocused_max
);
1052 RrAppearanceFree(theme
->a_focused_unpressed_max
);
1053 RrAppearanceFree(theme
->a_focused_pressed_max
);
1054 RrAppearanceFree(theme
->a_unfocused_unpressed_max
);
1055 RrAppearanceFree(theme
->a_unfocused_pressed_max
);
1056 RrAppearanceFree(theme
->a_disabled_focused_close
);
1057 RrAppearanceFree(theme
->a_disabled_unfocused_close
);
1058 RrAppearanceFree(theme
->a_hover_focused_close
);
1059 RrAppearanceFree(theme
->a_hover_unfocused_close
);
1060 RrAppearanceFree(theme
->a_focused_unpressed_close
);
1061 RrAppearanceFree(theme
->a_focused_pressed_close
);
1062 RrAppearanceFree(theme
->a_unfocused_unpressed_close
);
1063 RrAppearanceFree(theme
->a_unfocused_pressed_close
);
1064 RrAppearanceFree(theme
->a_disabled_focused_desk
);
1065 RrAppearanceFree(theme
->a_disabled_unfocused_desk
);
1066 RrAppearanceFree(theme
->a_hover_focused_desk
);
1067 RrAppearanceFree(theme
->a_hover_unfocused_desk
);
1068 RrAppearanceFree(theme
->a_toggled_focused_desk
);
1069 RrAppearanceFree(theme
->a_toggled_unfocused_desk
);
1070 RrAppearanceFree(theme
->a_focused_unpressed_desk
);
1071 RrAppearanceFree(theme
->a_focused_pressed_desk
);
1072 RrAppearanceFree(theme
->a_unfocused_unpressed_desk
);
1073 RrAppearanceFree(theme
->a_unfocused_pressed_desk
);
1074 RrAppearanceFree(theme
->a_disabled_focused_shade
);
1075 RrAppearanceFree(theme
->a_disabled_unfocused_shade
);
1076 RrAppearanceFree(theme
->a_hover_focused_shade
);
1077 RrAppearanceFree(theme
->a_hover_unfocused_shade
);
1078 RrAppearanceFree(theme
->a_toggled_focused_shade
);
1079 RrAppearanceFree(theme
->a_toggled_unfocused_shade
);
1080 RrAppearanceFree(theme
->a_focused_unpressed_shade
);
1081 RrAppearanceFree(theme
->a_focused_pressed_shade
);
1082 RrAppearanceFree(theme
->a_unfocused_unpressed_shade
);
1083 RrAppearanceFree(theme
->a_unfocused_pressed_shade
);
1084 RrAppearanceFree(theme
->a_disabled_focused_iconify
);
1085 RrAppearanceFree(theme
->a_disabled_unfocused_iconify
);
1086 RrAppearanceFree(theme
->a_hover_focused_iconify
);
1087 RrAppearanceFree(theme
->a_hover_unfocused_iconify
);
1088 RrAppearanceFree(theme
->a_focused_unpressed_iconify
);
1089 RrAppearanceFree(theme
->a_focused_pressed_iconify
);
1090 RrAppearanceFree(theme
->a_unfocused_unpressed_iconify
);
1091 RrAppearanceFree(theme
->a_unfocused_pressed_iconify
);
1092 RrAppearanceFree(theme
->a_focused_grip
);
1093 RrAppearanceFree(theme
->a_unfocused_grip
);
1094 RrAppearanceFree(theme
->a_focused_title
);
1095 RrAppearanceFree(theme
->a_unfocused_title
);
1096 RrAppearanceFree(theme
->a_focused_label
);
1097 RrAppearanceFree(theme
->a_unfocused_label
);
1098 RrAppearanceFree(theme
->a_icon
);
1099 RrAppearanceFree(theme
->a_focused_handle
);
1100 RrAppearanceFree(theme
->a_unfocused_handle
);
1101 RrAppearanceFree(theme
->a_menu
);
1102 RrAppearanceFree(theme
->a_menu_title
);
1103 RrAppearanceFree(theme
->a_menu_normal
);
1104 RrAppearanceFree(theme
->a_menu_disabled
);
1105 RrAppearanceFree(theme
->a_menu_selected
);
1106 RrAppearanceFree(theme
->a_menu_text_normal
);
1107 RrAppearanceFree(theme
->a_menu_text_disabled
);
1108 RrAppearanceFree(theme
->a_menu_text_selected
);
1109 RrAppearanceFree(theme
->a_menu_bullet_normal
);
1110 RrAppearanceFree(theme
->a_menu_bullet_selected
);
1111 RrAppearanceFree(theme
->a_clear
);
1112 RrAppearanceFree(theme
->a_clear_tex
);
1113 RrAppearanceFree(theme
->app_hilite_bg
);
1114 RrAppearanceFree(theme
->app_unhilite_bg
);
1115 RrAppearanceFree(theme
->app_hilite_fg
);
1116 RrAppearanceFree(theme
->app_unhilite_fg
);
1117 RrAppearanceFree(theme
->app_hilite_label
);
1118 RrAppearanceFree(theme
->app_unhilite_label
);
1124 static XrmDatabase
loaddb(RrTheme
*theme
, gchar
*name
)
1127 XrmDatabase db
= NULL
;
1130 if (name
[0] == '/') {
1131 s
= g_build_filename(name
, "openbox-3", "themerc", NULL
);
1132 if ((db
= XrmGetFileDatabase(s
)))
1133 theme
->path
= g_path_get_dirname(s
);
1136 /* XXX backwards compatibility, remove me sometime later */
1137 s
= g_build_filename(g_get_home_dir(), ".themes", name
,
1138 "openbox-3", "themerc", NULL
);
1139 if ((db
= XrmGetFileDatabase(s
)))
1140 theme
->path
= g_path_get_dirname(s
);
1143 for (it
= parse_xdg_data_dir_paths(); !db
&& it
;
1144 it
= g_slist_next(it
))
1146 s
= g_build_filename(it
->data
, "themes", name
,
1147 "openbox-3", "themerc", NULL
);
1148 if ((db
= XrmGetFileDatabase(s
)))
1149 theme
->path
= g_path_get_dirname(s
);
1155 s
= g_build_filename(name
, "themerc", NULL
);
1156 if ((db
= XrmGetFileDatabase(s
)))
1157 theme
->path
= g_path_get_dirname(s
);
1164 static gchar
*create_class_name(gchar
*rname
)
1166 gchar
*rclass
= g_strdup(rname
);
1171 p
= strchr(p
+1, '.');
1172 if (p
== NULL
) break;
1174 if (*p
== '\0') break;
1179 static gboolean
read_bool(XrmDatabase db
, gchar
*rname
, gint
*value
)
1181 gboolean ret
= FALSE
;
1182 gchar
*rclass
= create_class_name(rname
);
1186 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1187 retvalue
.addr
!= NULL
) {
1188 if (!g_ascii_strcasecmp(retvalue
.addr
, "true")) {
1191 } else if (!g_ascii_strcasecmp(retvalue
.addr
, "false")) {
1201 static gboolean
read_int(XrmDatabase db
, gchar
*rname
, gint
*value
)
1203 gboolean ret
= FALSE
;
1204 gchar
*rclass
= create_class_name(rname
);
1205 gchar
*rettype
, *end
;
1208 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1209 retvalue
.addr
!= NULL
) {
1210 *value
= (gint
)strtol(retvalue
.addr
, &end
, 10);
1211 if (end
!= retvalue
.addr
)
1219 static gboolean
read_string(XrmDatabase db
, gchar
*rname
, gchar
**value
)
1221 gboolean ret
= FALSE
;
1222 gchar
*rclass
= create_class_name(rname
);
1226 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1227 retvalue
.addr
!= NULL
) {
1228 *value
= retvalue
.addr
;
1236 static gboolean
read_color(XrmDatabase db
, const RrInstance
*inst
,
1237 gchar
*rname
, RrColor
**value
)
1239 gboolean ret
= FALSE
;
1240 gchar
*rclass
= create_class_name(rname
);
1244 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1245 retvalue
.addr
!= NULL
) {
1246 RrColor
*c
= RrColorParse(inst
, retvalue
.addr
);
1257 static gboolean
read_mask(const RrInstance
*inst
,
1258 gchar
*maskname
, RrTheme
*theme
,
1259 RrPixmapMask
**value
)
1261 gboolean ret
= FALSE
;
1263 gint hx
, hy
; /* ignored */
1267 s
= g_build_filename(theme
->path
, maskname
, NULL
);
1268 if (XReadBitmapFileData(s
, &w
, &h
, &b
, &hx
, &hy
) == BitmapSuccess
) {
1270 *value
= RrPixmapMaskNew(inst
, w
, h
, (gchar
*)b
);
1278 static void parse_appearance(gchar
*tex
, RrSurfaceColorType
*grad
,
1279 RrReliefType
*relief
, RrBevelType
*bevel
,
1280 gboolean
*interlaced
, gboolean
*border
,
1281 gboolean allow_trans
)
1285 /* convert to all lowercase */
1286 for (t
= tex
; *t
!= '\0'; ++t
)
1287 *t
= g_ascii_tolower(*t
);
1289 if (allow_trans
&& strstr(tex
, "parentrelative") != NULL
) {
1290 *grad
= RR_SURFACE_PARENTREL
;
1292 if (strstr(tex
, "gradient") != NULL
) {
1293 if (strstr(tex
, "crossdiagonal") != NULL
)
1294 *grad
= RR_SURFACE_CROSS_DIAGONAL
;
1295 else if (strstr(tex
, "pyramid") != NULL
)
1296 *grad
= RR_SURFACE_PYRAMID
;
1297 else if (strstr(tex
, "mirrorhorizontal") != NULL
)
1298 *grad
= RR_SURFACE_MIRROR_HORIZONTAL
;
1299 else if (strstr(tex
, "horizontal") != NULL
)
1300 *grad
= RR_SURFACE_HORIZONTAL
;
1301 else if (strstr(tex
, "splitvertical") != NULL
)
1302 *grad
= RR_SURFACE_SPLIT_VERTICAL
;
1303 else if (strstr(tex
, "vertical") != NULL
)
1304 *grad
= RR_SURFACE_VERTICAL
;
1306 *grad
= RR_SURFACE_DIAGONAL
;
1308 *grad
= RR_SURFACE_SOLID
;
1311 if (strstr(tex
, "sunken") != NULL
)
1312 *relief
= RR_RELIEF_SUNKEN
;
1313 else if (strstr(tex
, "flat") != NULL
)
1314 *relief
= RR_RELIEF_FLAT
;
1316 *relief
= RR_RELIEF_RAISED
;
1319 if (*relief
== RR_RELIEF_FLAT
) {
1320 if (strstr(tex
, "border") != NULL
)
1323 if (strstr(tex
, "bevel2") != NULL
)
1324 *bevel
= RR_BEVEL_2
;
1326 *bevel
= RR_BEVEL_1
;
1329 if (strstr(tex
, "interlaced") != NULL
)
1332 *interlaced
= FALSE
;
1337 static gboolean
read_appearance(XrmDatabase db
, const RrInstance
*inst
,
1338 gchar
*rname
, RrAppearance
*value
,
1339 gboolean allow_trans
)
1341 gboolean ret
= FALSE
;
1342 gchar
*rclass
= create_class_name(rname
);
1343 gchar
*cname
, *ctoname
, *bcname
, *icname
;
1347 cname
= g_strconcat(rname
, ".color", NULL
);
1348 ctoname
= g_strconcat(rname
, ".colorTo", NULL
);
1349 bcname
= g_strconcat(rname
, ".border.color", NULL
);
1350 icname
= g_strconcat(rname
, ".interlace.color", NULL
);
1352 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1353 retvalue
.addr
!= NULL
) {
1354 parse_appearance(retvalue
.addr
,
1355 &value
->surface
.grad
,
1356 &value
->surface
.relief
,
1357 &value
->surface
.bevel
,
1358 &value
->surface
.interlaced
,
1359 &value
->surface
.border
,
1361 if (!read_color(db
, inst
, cname
, &value
->surface
.primary
))
1362 value
->surface
.primary
= RrColorNew(inst
, 0, 0, 0);
1363 if (!read_color(db
, inst
, ctoname
, &value
->surface
.secondary
))
1364 value
->surface
.secondary
= RrColorNew(inst
, 0, 0, 0);
1365 if (value
->surface
.border
)
1366 if (!read_color(db
, inst
, bcname
,
1367 &value
->surface
.border_color
))
1368 value
->surface
.border_color
= RrColorNew(inst
, 0, 0, 0);
1369 if (value
->surface
.interlaced
)
1370 if (!read_color(db
, inst
, icname
,
1371 &value
->surface
.interlace_color
))
1372 value
->surface
.interlace_color
= RrColorNew(inst
, 0, 0, 0);
1384 static void set_default_appearance(RrAppearance
*a
)
1386 a
->surface
.grad
= RR_SURFACE_SOLID
;
1387 a
->surface
.relief
= RR_RELIEF_FLAT
;
1388 a
->surface
.bevel
= RR_BEVEL_1
;
1389 a
->surface
.interlaced
= FALSE
;
1390 a
->surface
.border
= FALSE
;
1391 a
->surface
.primary
= RrColorNew(a
->inst
, 0, 0, 0);
1392 a
->surface
.secondary
= RrColorNew(a
->inst
, 0, 0, 0);
1395 /* Reads the output from gimp's C-Source file format into valid RGBA data for
1396 an RrTextureRGBA. */
1397 static RrPixel32
* read_c_image(gint width
, gint height
, const guint8
*data
)
1402 p
= im
= g_memdup(data
, width
* height
* sizeof(RrPixel32
));
1404 for (i
= 0; i
< width
* height
; ++i
) {
1405 guchar a
= ((*p
>> 24) & 0xff);
1406 guchar b
= ((*p
>> 16) & 0xff);
1407 guchar g
= ((*p
>> 8) & 0xff);
1408 guchar r
= ((*p
>> 0) & 0xff);
1410 *p
= ((r
<< RrDefaultRedOffset
) +
1411 (g
<< RrDefaultGreenOffset
) +
1412 (b
<< RrDefaultBlueOffset
) +
1413 (a
<< RrDefaultAlphaOffset
));