Merge branch 'backport' into work
[dana/openbox.git] / render / theme.c
index 0edc81d..399bd2c 100644 (file)
@@ -23,7 +23,7 @@
 #include "mask.h"
 #include "theme.h"
 #include "icon.h"
-#include "parser/parse.h"
+#include "obt/paths.h"
 
 #include <X11/Xlib.h>
 #include <X11/Xresource.h>
@@ -46,6 +46,23 @@ static int parse_inline_number(const char *p);
 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data);
 static void set_default_appearance(RrAppearance *a);
 
+static RrFont *get_font(RrFont *target, RrFont **default_font,
+                        const RrInstance *inst)
+{
+    if (target) {
+        RrFontRef(target);
+        return target;
+    } else {
+        /* Only load the default font once */
+        if (*default_font) {
+            RrFontRef(*default_font);
+        } else {
+            *default_font = RrFontOpenDefault(inst);
+        }
+        return *default_font;
+    }
+}
+
 RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
                     gboolean allow_fallback,
                     RrFont *active_window_font, RrFont *inactive_window_font,
@@ -56,6 +73,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
     RrJustify winjust, mtitlejust;
     gchar *str;
     RrTheme *theme;
+    RrFont *default_font = NULL;
     gchar *path;
     gboolean userdef;
 
@@ -115,7 +133,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
     theme->a_menu_normal = RrAppearanceNew(inst, 0);
     theme->a_menu_selected = RrAppearanceNew(inst, 0);
     theme->a_menu_disabled = RrAppearanceNew(inst, 0);
-    theme->a_menu_disabled_selected = RrAppearanceNew(inst, 0);
+    /* a_menu_disabled_selected is copied from a_menu_selected */
     theme->a_menu_text_normal = RrAppearanceNew(inst, 1);
     theme->a_menu_text_selected = RrAppearanceNew(inst, 1);
     theme->a_menu_text_disabled = RrAppearanceNew(inst, 1);
@@ -130,17 +148,10 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
     theme->osd_unhilite_fg = RrAppearanceNew(inst, 0);
 
     /* load the font stuff */
-    if (active_window_font) {
-        theme->win_font_focused = active_window_font;
-        RrFontRef(active_window_font);
-    } else
-        theme->win_font_focused = RrFontOpenDefault(inst);
-
-    if (inactive_window_font) {
-        theme->win_font_unfocused = inactive_window_font;
-        RrFontRef(inactive_window_font);
-    } else
-        theme->win_font_unfocused = RrFontOpenDefault(inst);
+    theme->win_font_focused = get_font(active_window_font,
+                                       &default_font, inst);
+    theme->win_font_unfocused = get_font(inactive_window_font,
+                                         &default_font, inst);
 
     winjust = RR_JUSTIFY_LEFT;
     if (read_string(db, "window.label.text.justify", &str)) {
@@ -150,11 +161,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
             winjust = RR_JUSTIFY_CENTER;
     }
 
-    if (menu_title_font) {
-        theme->menu_title_font = menu_title_font;
-        RrFontRef(menu_title_font);
-    } else
-        theme->menu_title_font = RrFontOpenDefault(inst);
+    theme->menu_title_font = get_font(menu_title_font, &default_font, inst);
 
     mtitlejust = RR_JUSTIFY_LEFT;
     if (read_string(db, "menu.title.text.justify", &str)) {
@@ -164,29 +171,28 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
             mtitlejust = RR_JUSTIFY_CENTER;
     }
 
-    if (menu_item_font) {
-        theme->menu_font = menu_item_font;
-        RrFontRef(menu_item_font);
-    } else
-        theme->menu_font = RrFontOpenDefault(inst);
+    theme->menu_font = get_font(menu_item_font, &default_font, inst);
 
-    if (osd_font) {
-        theme->osd_font = osd_font;
-        RrFontRef(osd_font);
-    } else
-        theme->osd_font = RrFontOpenDefault(inst);
+    theme->osd_font = get_font(osd_font, &default_font, inst);
 
     /* load direct dimensions */
-    if (!read_int(db, "menu.overlap", &theme->menu_overlap) ||
-        theme->menu_overlap < -100 || theme->menu_overlap > 100)
-        theme->menu_overlap = 0;
+    if ((!read_int(db, "menu.overlap.x", &theme->menu_overlap_x) &&
+         !read_int(db, "menu.overlap", &theme->menu_overlap_x)) ||
+        theme->menu_overlap_x < -100 || theme->menu_overlap_x > 100)
+        theme->menu_overlap_x = 0;
+    if ((!read_int(db, "menu.overlap.y", &theme->menu_overlap_y) &&
+         !read_int(db, "menu.overlap", &theme->menu_overlap_y)) ||
+        theme->menu_overlap_y < -100 || theme->menu_overlap_y > 100)
+        theme->menu_overlap_y = 0;
     if (!read_int(db, "window.handle.width", &theme->handle_height) ||
         theme->handle_height < 0 || theme->handle_height > 100)
         theme->handle_height = 6;
     if (!read_int(db, "padding.width", &theme->paddingx) ||
         theme->paddingx < 0 || theme->paddingx > 100)
         theme->paddingx = 3;
-    theme->paddingy = theme->paddingx;
+    if (!read_int(db, "padding.height", &theme->paddingy) ||
+        theme->paddingy < 0 || theme->paddingy > 100)
+        theme->paddingy = theme->paddingx;
     if (!read_int(db, "border.width", &theme->fbwidth) ||
         theme->fbwidth < 0 || theme->fbwidth > 100)
         theme->fbwidth = 1;
@@ -204,6 +210,17 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
     if (!read_int(db, "window.client.padding.height", &theme->cbwidthy) ||
         theme->cbwidthy < 0 || theme->cbwidthy > 100)
         theme->cbwidthy = theme->cbwidthx;
+    if (!read_int(db, "menu.separator.width", &theme->menu_sep_width) ||
+        theme->menu_sep_width < 1 || theme->menu_sep_width > 100)
+        theme->menu_sep_width = 1;
+    if (!read_int(db, "menu.separator.padding.width",
+                  &theme->menu_sep_paddingx) ||
+        theme->menu_sep_paddingx < 0 || theme->menu_sep_paddingx > 100)
+        theme->menu_sep_paddingx = 6;
+    if (!read_int(db, "menu.separator.padding.height",
+                  &theme->menu_sep_paddingy) ||
+        theme->menu_sep_paddingy < 0 || theme->menu_sep_paddingy > 100)
+        theme->menu_sep_paddingy = 3;
 
     /* load colors */
     if (!read_color(db, inst,
@@ -213,7 +230,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
                     "border.color",
                     &theme->frame_focused_border_color))
         theme->frame_focused_border_color = RrColorNew(inst, 0, 0, 0);
-    /* title separator focused color inherits from focused boder color */
+    /* title separator focused color inherits from focused border color */
     if (!read_color(db, inst,
                     "window.active.title.separator.color",
                     &theme->title_separator_focused_color))
@@ -230,7 +247,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
             RrColorNew(inst, theme->frame_focused_border_color->r,
                        theme->frame_focused_border_color->g,
                        theme->frame_focused_border_color->b);
-    /* title separator unfocused color inherits from unfocused boder color */
+    /* title separator unfocused color inherits from unfocused border color */
     if (!read_color(db, inst,
                     "window.inactive.title.separator.color",
                     &theme->title_separator_unfocused_color))
@@ -401,7 +418,13 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
                     "menu.items.active.text.color",
                     &theme->menu_selected_color))
         theme->menu_selected_color = RrColorNew(inst, 0, 0, 0);
-    
+    if (!read_color(db, inst,
+                    "menu.separator.color", &theme->menu_sep_color))
+        theme->menu_sep_color = RrColorNew(inst,
+                                           theme->menu_color->r,
+                                           theme->menu_color->g,
+                                           theme->menu_color->b);
+
     /* load the image masks */
 
     /* maximize button masks */
@@ -536,25 +559,22 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
         theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data);
     }
 
+    /* up and down arrows */
+    {
+        guchar data[] = { 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00 };
+        theme->down_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data);
+    }
+    {
+        guchar data[] = { 0x10, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xfe, 0x00 };
+        theme->up_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data);
+    }
+
     /* setup the default window icon */
     theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
                                        OB_DEFAULT_ICON_HEIGHT,
                                        OB_DEFAULT_ICON_pixel_data);
-
-    /* the toggled hover mask = the toggled unpressed mask (i.e. no change) */
-    theme->max_toggled_hover_mask =
-        RrPixmapMaskCopy(theme->max_toggled_mask);
-    theme->desk_toggled_hover_mask =
-        RrPixmapMaskCopy(theme->desk_toggled_mask);
-    theme->shade_toggled_hover_mask =
-        RrPixmapMaskCopy(theme->shade_toggled_mask);
-    /* the toggled pressed mask = the toggled unpressed mask (i.e. no change)*/
-    theme->max_toggled_pressed_mask =
-        RrPixmapMaskCopy(theme->max_toggled_mask);
-    theme->desk_toggled_pressed_mask =
-        RrPixmapMaskCopy(theme->desk_toggled_mask);
-    theme->shade_toggled_pressed_mask =
-        RrPixmapMaskCopy(theme->shade_toggled_mask);
+    theme->def_win_icon_w = OB_DEFAULT_ICON_WIDTH;
+    theme->def_win_icon_h = OB_DEFAULT_ICON_HEIGHT;
 
     /* read the decoration textures */
     if (!read_appearance(db, inst,
@@ -768,7 +788,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
     theme->a_hover_focused_desk =
         RrAppearanceCopy(theme->a_hover_focused_max);
     theme->a_hover_unfocused_desk =
-        RrAppearanceCopy(theme->a_hover_unfocused_max); 
+        RrAppearanceCopy(theme->a_hover_unfocused_max);
     theme->a_toggled_hover_focused_desk =
         RrAppearanceCopy(theme->a_toggled_hover_focused_max);
     theme->a_toggled_hover_unfocused_desk =
@@ -910,13 +930,9 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
             j = (i > 0 ? 0 : 255);
             i = ABS(i*255/100);
 
-            theme->title_focused_shadow_color = RrColorNew(inst, j, j, j);
-            theme->title_focused_shadow_alpha = i;
             theme->osd_shadow_color = RrColorNew(inst, j, j, j);
             theme->osd_shadow_alpha = i;
         } else {
-            theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
-            theme->title_focused_shadow_alpha = 50;
             theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0);
             theme->osd_shadow_alpha = 50;
         }
@@ -1020,13 +1036,13 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
 
     theme->a_menu_text_normal->texture[0].type =
         theme->a_menu_text_selected->texture[0].type =
-        theme->a_menu_text_disabled->texture[0].type = 
-        theme->a_menu_text_disabled_selected->texture[0].type = 
+        theme->a_menu_text_disabled->texture[0].type =
+        theme->a_menu_text_disabled_selected->texture[0].type =
         RR_TEXTURE_TEXT;
-    theme->a_menu_text_normal->texture[0].data.text.justify = 
+    theme->a_menu_text_normal->texture[0].data.text.justify =
         theme->a_menu_text_selected->texture[0].data.text.justify =
-        theme->a_menu_text_disabled->texture[0].data.text.justify = 
-        theme->a_menu_text_disabled_selected->texture[0].data.text.justify = 
+        theme->a_menu_text_disabled->texture[0].data.text.justify =
+        theme->a_menu_text_disabled_selected->texture[0].data.text.justify =
         RR_JUSTIFY_LEFT;
     theme->a_menu_text_normal->texture[0].data.text.font =
         theme->a_menu_text_selected->texture[0].data.text.font =
@@ -1072,7 +1088,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
             i = parse_inline_number(p + strlen("shadowtint="));
             j = (i > 0 ? 0 : 255);
             i = ABS(i*255/100);
-            
+
             theme->menu_text_normal_shadow_color = RrColorNew(inst, j, j, j);
             theme->menu_text_selected_shadow_color = RrColorNew(inst, j, j, j);
             theme->menu_text_disabled_shadow_color = RrColorNew(inst, j, j, j);
@@ -1107,180 +1123,180 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
     theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_alpha =
         theme->menu_text_disabled_shadow_alpha;
 
-    theme->a_disabled_focused_max->texture[0].type = 
-        theme->a_disabled_unfocused_max->texture[0].type = 
-        theme->a_hover_focused_max->texture[0].type = 
-        theme->a_hover_unfocused_max->texture[0].type = 
-        theme->a_toggled_hover_focused_max->texture[0].type = 
-        theme->a_toggled_hover_unfocused_max->texture[0].type = 
-        theme->a_toggled_focused_unpressed_max->texture[0].type = 
-        theme->a_toggled_unfocused_unpressed_max->texture[0].type = 
-        theme->a_toggled_focused_pressed_max->texture[0].type = 
-        theme->a_toggled_unfocused_pressed_max->texture[0].type = 
-        theme->a_focused_unpressed_max->texture[0].type = 
-        theme->a_focused_pressed_max->texture[0].type = 
-        theme->a_unfocused_unpressed_max->texture[0].type = 
-        theme->a_unfocused_pressed_max->texture[0].type = 
-        theme->a_disabled_focused_close->texture[0].type = 
-        theme->a_disabled_unfocused_close->texture[0].type = 
-        theme->a_hover_focused_close->texture[0].type = 
-        theme->a_hover_unfocused_close->texture[0].type = 
-        theme->a_focused_unpressed_close->texture[0].type = 
-        theme->a_focused_pressed_close->texture[0].type = 
-        theme->a_unfocused_unpressed_close->texture[0].type = 
-        theme->a_unfocused_pressed_close->texture[0].type = 
-        theme->a_disabled_focused_desk->texture[0].type = 
-        theme->a_disabled_unfocused_desk->texture[0].type = 
-        theme->a_hover_focused_desk->texture[0].type = 
-        theme->a_hover_unfocused_desk->texture[0].type = 
-        theme->a_toggled_hover_focused_desk->texture[0].type = 
-        theme->a_toggled_hover_unfocused_desk->texture[0].type = 
-        theme->a_toggled_focused_unpressed_desk->texture[0].type = 
-        theme->a_toggled_unfocused_unpressed_desk->texture[0].type = 
-        theme->a_toggled_focused_pressed_desk->texture[0].type = 
-        theme->a_toggled_unfocused_pressed_desk->texture[0].type = 
-        theme->a_focused_unpressed_desk->texture[0].type = 
-        theme->a_focused_pressed_desk->texture[0].type = 
-        theme->a_unfocused_unpressed_desk->texture[0].type = 
-        theme->a_unfocused_pressed_desk->texture[0].type = 
-        theme->a_disabled_focused_shade->texture[0].type = 
-        theme->a_disabled_unfocused_shade->texture[0].type = 
-        theme->a_hover_focused_shade->texture[0].type = 
-        theme->a_hover_unfocused_shade->texture[0].type = 
-        theme->a_toggled_hover_focused_shade->texture[0].type = 
-        theme->a_toggled_hover_unfocused_shade->texture[0].type = 
-        theme->a_toggled_focused_unpressed_shade->texture[0].type = 
-        theme->a_toggled_unfocused_unpressed_shade->texture[0].type = 
-        theme->a_toggled_focused_pressed_shade->texture[0].type = 
-        theme->a_toggled_unfocused_pressed_shade->texture[0].type = 
-        theme->a_focused_unpressed_shade->texture[0].type = 
-        theme->a_focused_pressed_shade->texture[0].type = 
-        theme->a_unfocused_unpressed_shade->texture[0].type = 
-        theme->a_unfocused_pressed_shade->texture[0].type = 
-        theme->a_disabled_focused_iconify->texture[0].type = 
-        theme->a_disabled_unfocused_iconify->texture[0].type = 
-        theme->a_hover_focused_iconify->texture[0].type = 
-        theme->a_hover_unfocused_iconify->texture[0].type = 
-        theme->a_focused_unpressed_iconify->texture[0].type = 
-        theme->a_focused_pressed_iconify->texture[0].type = 
-        theme->a_unfocused_unpressed_iconify->texture[0].type = 
+    theme->a_disabled_focused_max->texture[0].type =
+        theme->a_disabled_unfocused_max->texture[0].type =
+        theme->a_hover_focused_max->texture[0].type =
+        theme->a_hover_unfocused_max->texture[0].type =
+        theme->a_toggled_hover_focused_max->texture[0].type =
+        theme->a_toggled_hover_unfocused_max->texture[0].type =
+        theme->a_toggled_focused_unpressed_max->texture[0].type =
+        theme->a_toggled_unfocused_unpressed_max->texture[0].type =
+        theme->a_toggled_focused_pressed_max->texture[0].type =
+        theme->a_toggled_unfocused_pressed_max->texture[0].type =
+        theme->a_focused_unpressed_max->texture[0].type =
+        theme->a_focused_pressed_max->texture[0].type =
+        theme->a_unfocused_unpressed_max->texture[0].type =
+        theme->a_unfocused_pressed_max->texture[0].type =
+        theme->a_disabled_focused_close->texture[0].type =
+        theme->a_disabled_unfocused_close->texture[0].type =
+        theme->a_hover_focused_close->texture[0].type =
+        theme->a_hover_unfocused_close->texture[0].type =
+        theme->a_focused_unpressed_close->texture[0].type =
+        theme->a_focused_pressed_close->texture[0].type =
+        theme->a_unfocused_unpressed_close->texture[0].type =
+        theme->a_unfocused_pressed_close->texture[0].type =
+        theme->a_disabled_focused_desk->texture[0].type =
+        theme->a_disabled_unfocused_desk->texture[0].type =
+        theme->a_hover_focused_desk->texture[0].type =
+        theme->a_hover_unfocused_desk->texture[0].type =
+        theme->a_toggled_hover_focused_desk->texture[0].type =
+        theme->a_toggled_hover_unfocused_desk->texture[0].type =
+        theme->a_toggled_focused_unpressed_desk->texture[0].type =
+        theme->a_toggled_unfocused_unpressed_desk->texture[0].type =
+        theme->a_toggled_focused_pressed_desk->texture[0].type =
+        theme->a_toggled_unfocused_pressed_desk->texture[0].type =
+        theme->a_focused_unpressed_desk->texture[0].type =
+        theme->a_focused_pressed_desk->texture[0].type =
+        theme->a_unfocused_unpressed_desk->texture[0].type =
+        theme->a_unfocused_pressed_desk->texture[0].type =
+        theme->a_disabled_focused_shade->texture[0].type =
+        theme->a_disabled_unfocused_shade->texture[0].type =
+        theme->a_hover_focused_shade->texture[0].type =
+        theme->a_hover_unfocused_shade->texture[0].type =
+        theme->a_toggled_hover_focused_shade->texture[0].type =
+        theme->a_toggled_hover_unfocused_shade->texture[0].type =
+        theme->a_toggled_focused_unpressed_shade->texture[0].type =
+        theme->a_toggled_unfocused_unpressed_shade->texture[0].type =
+        theme->a_toggled_focused_pressed_shade->texture[0].type =
+        theme->a_toggled_unfocused_pressed_shade->texture[0].type =
+        theme->a_focused_unpressed_shade->texture[0].type =
+        theme->a_focused_pressed_shade->texture[0].type =
+        theme->a_unfocused_unpressed_shade->texture[0].type =
+        theme->a_unfocused_pressed_shade->texture[0].type =
+        theme->a_disabled_focused_iconify->texture[0].type =
+        theme->a_disabled_unfocused_iconify->texture[0].type =
+        theme->a_hover_focused_iconify->texture[0].type =
+        theme->a_hover_unfocused_iconify->texture[0].type =
+        theme->a_focused_unpressed_iconify->texture[0].type =
+        theme->a_focused_pressed_iconify->texture[0].type =
+        theme->a_unfocused_unpressed_iconify->texture[0].type =
         theme->a_unfocused_pressed_iconify->texture[0].type =
         theme->a_menu_bullet_normal->texture[0].type =
         theme->a_menu_bullet_selected->texture[0].type = RR_TEXTURE_MASK;
-    
-    theme->a_disabled_focused_max->texture[0].data.mask.mask = 
-        theme->a_disabled_unfocused_max->texture[0].data.mask.mask = 
+
+    theme->a_disabled_focused_max->texture[0].data.mask.mask =
+        theme->a_disabled_unfocused_max->texture[0].data.mask.mask =
         theme->max_disabled_mask;
-    theme->a_hover_focused_max->texture[0].data.mask.mask = 
-        theme->a_hover_unfocused_max->texture[0].data.mask.mask = 
+    theme->a_hover_focused_max->texture[0].data.mask.mask =
+        theme->a_hover_unfocused_max->texture[0].data.mask.mask =
         theme->max_hover_mask;
-    theme->a_focused_pressed_max->texture[0].data.mask.mask = 
+    theme->a_focused_pressed_max->texture[0].data.mask.mask =
         theme->a_unfocused_pressed_max->texture[0].data.mask.mask =
         theme->max_pressed_mask;
-    theme->a_focused_unpressed_max->texture[0].data.mask.mask = 
-        theme->a_unfocused_unpressed_max->texture[0].data.mask.mask = 
+    theme->a_focused_unpressed_max->texture[0].data.mask.mask =
+        theme->a_unfocused_unpressed_max->texture[0].data.mask.mask =
         theme->max_mask;
-    theme->a_toggled_hover_focused_max->texture[0].data.mask.mask = 
+    theme->a_toggled_hover_focused_max->texture[0].data.mask.mask =
         theme->a_toggled_hover_unfocused_max->texture[0].data.mask.mask =
         theme->max_toggled_hover_mask;
-    theme->a_toggled_focused_unpressed_max->texture[0].data.mask.mask = 
+    theme->a_toggled_focused_unpressed_max->texture[0].data.mask.mask =
         theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.mask =
         theme->max_toggled_mask;
-    theme->a_toggled_focused_pressed_max->texture[0].data.mask.mask = 
+    theme->a_toggled_focused_pressed_max->texture[0].data.mask.mask =
         theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.mask =
         theme->max_toggled_pressed_mask;
-    theme->a_disabled_focused_close->texture[0].data.mask.mask = 
-        theme->a_disabled_unfocused_close->texture[0].data.mask.mask = 
+    theme->a_disabled_focused_close->texture[0].data.mask.mask =
+        theme->a_disabled_unfocused_close->texture[0].data.mask.mask =
         theme->close_disabled_mask;
-    theme->a_hover_focused_close->texture[0].data.mask.mask = 
-        theme->a_hover_unfocused_close->texture[0].data.mask.mask = 
+    theme->a_hover_focused_close->texture[0].data.mask.mask =
+        theme->a_hover_unfocused_close->texture[0].data.mask.mask =
         theme->close_hover_mask;
-    theme->a_focused_pressed_close->texture[0].data.mask.mask = 
+    theme->a_focused_pressed_close->texture[0].data.mask.mask =
         theme->a_unfocused_pressed_close->texture[0].data.mask.mask =
         theme->close_pressed_mask;
-    theme->a_focused_unpressed_close->texture[0].data.mask.mask = 
+    theme->a_focused_unpressed_close->texture[0].data.mask.mask =
         theme->a_unfocused_unpressed_close->texture[0].data.mask.mask =
         theme->close_mask;
-    theme->a_disabled_focused_desk->texture[0].data.mask.mask = 
-        theme->a_disabled_unfocused_desk->texture[0].data.mask.mask = 
+    theme->a_disabled_focused_desk->texture[0].data.mask.mask =
+        theme->a_disabled_unfocused_desk->texture[0].data.mask.mask =
         theme->desk_disabled_mask;
-    theme->a_hover_focused_desk->texture[0].data.mask.mask = 
-        theme->a_hover_unfocused_desk->texture[0].data.mask.mask = 
+    theme->a_hover_focused_desk->texture[0].data.mask.mask =
+        theme->a_hover_unfocused_desk->texture[0].data.mask.mask =
         theme->desk_hover_mask;
-    theme->a_focused_pressed_desk->texture[0].data.mask.mask = 
+    theme->a_focused_pressed_desk->texture[0].data.mask.mask =
         theme->a_unfocused_pressed_desk->texture[0].data.mask.mask =
         theme->desk_pressed_mask;
-    theme->a_focused_unpressed_desk->texture[0].data.mask.mask = 
-        theme->a_unfocused_unpressed_desk->texture[0].data.mask.mask = 
+    theme->a_focused_unpressed_desk->texture[0].data.mask.mask =
+        theme->a_unfocused_unpressed_desk->texture[0].data.mask.mask =
         theme->desk_mask;
-    theme->a_toggled_hover_focused_desk->texture[0].data.mask.mask = 
+    theme->a_toggled_hover_focused_desk->texture[0].data.mask.mask =
         theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.mask =
         theme->desk_toggled_hover_mask;
-    theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.mask = 
+    theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.mask =
         theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.mask =
         theme->desk_toggled_mask;
-    theme->a_toggled_focused_pressed_desk->texture[0].data.mask.mask = 
+    theme->a_toggled_focused_pressed_desk->texture[0].data.mask.mask =
         theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.mask =
         theme->desk_toggled_pressed_mask;
-    theme->a_disabled_focused_shade->texture[0].data.mask.mask = 
-        theme->a_disabled_unfocused_shade->texture[0].data.mask.mask = 
+    theme->a_disabled_focused_shade->texture[0].data.mask.mask =
+        theme->a_disabled_unfocused_shade->texture[0].data.mask.mask =
         theme->shade_disabled_mask;
-    theme->a_hover_focused_shade->texture[0].data.mask.mask = 
-        theme->a_hover_unfocused_shade->texture[0].data.mask.mask = 
+    theme->a_hover_focused_shade->texture[0].data.mask.mask =
+        theme->a_hover_unfocused_shade->texture[0].data.mask.mask =
         theme->shade_hover_mask;
-    theme->a_focused_pressed_shade->texture[0].data.mask.mask = 
+    theme->a_focused_pressed_shade->texture[0].data.mask.mask =
         theme->a_unfocused_pressed_shade->texture[0].data.mask.mask =
         theme->shade_pressed_mask;
-    theme->a_focused_unpressed_shade->texture[0].data.mask.mask = 
-        theme->a_unfocused_unpressed_shade->texture[0].data.mask.mask = 
+    theme->a_focused_unpressed_shade->texture[0].data.mask.mask =
+        theme->a_unfocused_unpressed_shade->texture[0].data.mask.mask =
         theme->shade_mask;
-    theme->a_toggled_hover_focused_shade->texture[0].data.mask.mask = 
+    theme->a_toggled_hover_focused_shade->texture[0].data.mask.mask =
         theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.mask =
         theme->shade_toggled_hover_mask;
-    theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.mask = 
+    theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.mask =
         theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.mask =
         theme->shade_toggled_mask;
-    theme->a_toggled_focused_pressed_shade->texture[0].data.mask.mask = 
+    theme->a_toggled_focused_pressed_shade->texture[0].data.mask.mask =
         theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.mask =
         theme->shade_toggled_pressed_mask;
-    theme->a_disabled_focused_iconify->texture[0].data.mask.mask = 
-        theme->a_disabled_unfocused_iconify->texture[0].data.mask.mask = 
+    theme->a_disabled_focused_iconify->texture[0].data.mask.mask =
+        theme->a_disabled_unfocused_iconify->texture[0].data.mask.mask =
         theme->iconify_disabled_mask;
-    theme->a_hover_focused_iconify->texture[0].data.mask.mask = 
-        theme->a_hover_unfocused_iconify->texture[0].data.mask.mask = 
+    theme->a_hover_focused_iconify->texture[0].data.mask.mask =
+        theme->a_hover_unfocused_iconify->texture[0].data.mask.mask =
         theme->iconify_hover_mask;
-    theme->a_focused_pressed_iconify->texture[0].data.mask.mask = 
+    theme->a_focused_pressed_iconify->texture[0].data.mask.mask =
         theme->a_unfocused_pressed_iconify->texture[0].data.mask.mask =
         theme->iconify_pressed_mask;
-    theme->a_focused_unpressed_iconify->texture[0].data.mask.mask = 
-        theme->a_unfocused_unpressed_iconify->texture[0].data.mask.mask = 
+    theme->a_focused_unpressed_iconify->texture[0].data.mask.mask =
+        theme->a_unfocused_unpressed_iconify->texture[0].data.mask.mask =
         theme->iconify_mask;
-    theme->a_menu_bullet_normal->texture[0].data.mask.mask = 
-    theme->a_menu_bullet_selected->texture[0].data.mask.mask = 
+    theme->a_menu_bullet_normal->texture[0].data.mask.mask =
+    theme->a_menu_bullet_selected->texture[0].data.mask.mask =
         theme->menu_bullet_mask;
-    theme->a_disabled_focused_max->texture[0].data.mask.color = 
-        theme->a_disabled_focused_close->texture[0].data.mask.color = 
-        theme->a_disabled_focused_desk->texture[0].data.mask.color = 
-        theme->a_disabled_focused_shade->texture[0].data.mask.color = 
-        theme->a_disabled_focused_iconify->texture[0].data.mask.color = 
+    theme->a_disabled_focused_max->texture[0].data.mask.color =
+        theme->a_disabled_focused_close->texture[0].data.mask.color =
+        theme->a_disabled_focused_desk->texture[0].data.mask.color =
+        theme->a_disabled_focused_shade->texture[0].data.mask.color =
+        theme->a_disabled_focused_iconify->texture[0].data.mask.color =
         theme->titlebut_disabled_focused_color;
-    theme->a_disabled_unfocused_max->texture[0].data.mask.color = 
-        theme->a_disabled_unfocused_close->texture[0].data.mask.color = 
-        theme->a_disabled_unfocused_desk->texture[0].data.mask.color = 
-        theme->a_disabled_unfocused_shade->texture[0].data.mask.color = 
-        theme->a_disabled_unfocused_iconify->texture[0].data.mask.color = 
+    theme->a_disabled_unfocused_max->texture[0].data.mask.color =
+        theme->a_disabled_unfocused_close->texture[0].data.mask.color =
+        theme->a_disabled_unfocused_desk->texture[0].data.mask.color =
+        theme->a_disabled_unfocused_shade->texture[0].data.mask.color =
+        theme->a_disabled_unfocused_iconify->texture[0].data.mask.color =
         theme->titlebut_disabled_unfocused_color;
-    theme->a_hover_focused_max->texture[0].data.mask.color = 
-        theme->a_hover_focused_close->texture[0].data.mask.color = 
-        theme->a_hover_focused_desk->texture[0].data.mask.color = 
-        theme->a_hover_focused_shade->texture[0].data.mask.color = 
-        theme->a_hover_focused_iconify->texture[0].data.mask.color = 
+    theme->a_hover_focused_max->texture[0].data.mask.color =
+        theme->a_hover_focused_close->texture[0].data.mask.color =
+        theme->a_hover_focused_desk->texture[0].data.mask.color =
+        theme->a_hover_focused_shade->texture[0].data.mask.color =
+        theme->a_hover_focused_iconify->texture[0].data.mask.color =
         theme->titlebut_hover_focused_color;
-    theme->a_hover_unfocused_max->texture[0].data.mask.color = 
-        theme->a_hover_unfocused_close->texture[0].data.mask.color = 
-        theme->a_hover_unfocused_desk->texture[0].data.mask.color = 
-        theme->a_hover_unfocused_shade->texture[0].data.mask.color = 
-        theme->a_hover_unfocused_iconify->texture[0].data.mask.color = 
+    theme->a_hover_unfocused_max->texture[0].data.mask.color =
+        theme->a_hover_unfocused_close->texture[0].data.mask.color =
+        theme->a_hover_unfocused_desk->texture[0].data.mask.color =
+        theme->a_hover_unfocused_shade->texture[0].data.mask.color =
+        theme->a_hover_unfocused_iconify->texture[0].data.mask.color =
         theme->titlebut_hover_unfocused_color;
     theme->a_toggled_hover_focused_max->texture[0].data.mask.color =
         theme->a_toggled_hover_focused_desk->texture[0].data.mask.color =
@@ -1306,33 +1322,33 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
         theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.color =
         theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.color =
         theme->titlebut_toggled_unfocused_pressed_color;
-    theme->a_focused_unpressed_max->texture[0].data.mask.color = 
-        theme->a_focused_unpressed_close->texture[0].data.mask.color = 
-        theme->a_focused_unpressed_desk->texture[0].data.mask.color = 
-        theme->a_focused_unpressed_shade->texture[0].data.mask.color = 
-        theme->a_focused_unpressed_iconify->texture[0].data.mask.color = 
+    theme->a_focused_unpressed_max->texture[0].data.mask.color =
+        theme->a_focused_unpressed_close->texture[0].data.mask.color =
+        theme->a_focused_unpressed_desk->texture[0].data.mask.color =
+        theme->a_focused_unpressed_shade->texture[0].data.mask.color =
+        theme->a_focused_unpressed_iconify->texture[0].data.mask.color =
         theme->titlebut_focused_unpressed_color;
-    theme->a_focused_pressed_max->texture[0].data.mask.color = 
-        theme->a_focused_pressed_close->texture[0].data.mask.color = 
-        theme->a_focused_pressed_desk->texture[0].data.mask.color = 
-        theme->a_focused_pressed_shade->texture[0].data.mask.color = 
+    theme->a_focused_pressed_max->texture[0].data.mask.color =
+        theme->a_focused_pressed_close->texture[0].data.mask.color =
+        theme->a_focused_pressed_desk->texture[0].data.mask.color =
+        theme->a_focused_pressed_shade->texture[0].data.mask.color =
         theme->a_focused_pressed_iconify->texture[0].data.mask.color =
         theme->titlebut_focused_pressed_color;
-    theme->a_unfocused_unpressed_max->texture[0].data.mask.color = 
-        theme->a_unfocused_unpressed_close->texture[0].data.mask.color = 
-        theme->a_unfocused_unpressed_desk->texture[0].data.mask.color = 
-        theme->a_unfocused_unpressed_shade->texture[0].data.mask.color = 
-        theme->a_unfocused_unpressed_iconify->texture[0].data.mask.color = 
+    theme->a_unfocused_unpressed_max->texture[0].data.mask.color =
+        theme->a_unfocused_unpressed_close->texture[0].data.mask.color =
+        theme->a_unfocused_unpressed_desk->texture[0].data.mask.color =
+        theme->a_unfocused_unpressed_shade->texture[0].data.mask.color =
+        theme->a_unfocused_unpressed_iconify->texture[0].data.mask.color =
         theme->titlebut_unfocused_unpressed_color;
-    theme->a_unfocused_pressed_max->texture[0].data.mask.color = 
-        theme->a_unfocused_pressed_close->texture[0].data.mask.color = 
-        theme->a_unfocused_pressed_desk->texture[0].data.mask.color = 
-        theme->a_unfocused_pressed_shade->texture[0].data.mask.color = 
+    theme->a_unfocused_pressed_max->texture[0].data.mask.color =
+        theme->a_unfocused_pressed_close->texture[0].data.mask.color =
+        theme->a_unfocused_pressed_desk->texture[0].data.mask.color =
+        theme->a_unfocused_pressed_shade->texture[0].data.mask.color =
         theme->a_unfocused_pressed_iconify->texture[0].data.mask.color =
         theme->titlebut_unfocused_pressed_color;
-    theme->a_menu_bullet_normal->texture[0].data.mask.color = 
+    theme->a_menu_bullet_normal->texture[0].data.mask.color =
         theme->menu_color;
-    theme->a_menu_bullet_selected->texture[0].data.mask.color = 
+    theme->a_menu_bullet_selected->texture[0].data.mask.color =
         theme->menu_selected_color;
 
     g_free(path);
@@ -1417,6 +1433,7 @@ void RrThemeFree(RrTheme *theme)
         RrColorFree(theme->titlebut_focused_unpressed_color);
         RrColorFree(theme->titlebut_unfocused_unpressed_color);
         RrColorFree(theme->menu_title_color);
+        RrColorFree(theme->menu_sep_color);
         RrColorFree(theme->menu_color);
         RrColorFree(theme->menu_selected_color);
         RrColorFree(theme->menu_disabled_color);
@@ -1463,11 +1480,14 @@ void RrThemeFree(RrTheme *theme)
         RrPixmapMaskFree(theme->close_hover_mask);
         RrPixmapMaskFree(theme->close_pressed_mask);
         RrPixmapMaskFree(theme->menu_bullet_mask);
+        RrPixmapMaskFree(theme->down_arrow_mask);
+        RrPixmapMaskFree(theme->up_arrow_mask);
 
-        RrFontClose(theme->win_font_focused); 
+        RrFontClose(theme->win_font_focused);
         RrFontClose(theme->win_font_unfocused);
         RrFontClose(theme->menu_title_font);
         RrFontClose(theme->menu_font);
+        RrFontClose(theme->osd_font);
 
         RrAppearanceFree(theme->a_disabled_focused_max);
         RrAppearanceFree(theme->a_disabled_unfocused_max);
@@ -1572,6 +1592,10 @@ static XrmDatabase loaddb(const gchar *name, gchar **path)
             *path = g_path_get_dirname(s);
         g_free(s);
     } else {
+        ObtPaths *p;
+
+        p = obt_paths_new();
+
         /* XXX backwards compatibility, remove me sometime later */
         s = g_build_filename(g_get_home_dir(), ".themes", name,
                              "openbox-3", "themerc", NULL);
@@ -1579,8 +1603,7 @@ static XrmDatabase loaddb(const gchar *name, gchar **path)
             *path = g_path_get_dirname(s);
         g_free(s);
 
-        for (it = parse_xdg_data_dir_paths(); !db && it;
-             it = g_slist_next(it))
+        for (it = obt_paths_data_dirs(p); !db && it; it = g_slist_next(it))
         {
             s = g_build_filename(it->data, "themes", name,
                                  "openbox-3", "themerc", NULL);
@@ -1588,6 +1611,8 @@ static XrmDatabase loaddb(const gchar *name, gchar **path)
                 *path = g_path_get_dirname(s);
             g_free(s);
         }
+
+        obt_paths_unref(p);
     }
 
     if (db == NULL) {
@@ -1621,7 +1646,7 @@ static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value)
     gchar *rclass = create_class_name(rname);
     gchar *rettype, *end;
     XrmValue retvalue;
-  
+
     if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
         retvalue.addr != NULL) {
         *value = (gint)strtol(retvalue.addr, &end, 10);
@@ -1639,7 +1664,7 @@ static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value)
     gchar *rclass = create_class_name(rname);
     gchar *rettype;
     XrmValue retvalue;
-  
+
     if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
         retvalue.addr != NULL) {
         *value = retvalue.addr;
@@ -1657,7 +1682,7 @@ static gboolean read_color(XrmDatabase db, const RrInstance *inst,
     gchar *rclass = create_class_name(rname);
     gchar *rettype;
     XrmValue retvalue;
-  
+
     if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
         retvalue.addr != NULL) {
         RrColor *c = RrColorParse(inst, retvalue.addr);
@@ -1753,7 +1778,6 @@ static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
         *interlaced = FALSE;
 }
 
-
 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
                                 const gchar *rname, RrAppearance *value,
                                 gboolean allow_trans)
@@ -1761,6 +1785,7 @@ static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
     gboolean ret = FALSE;
     gchar *rclass = create_class_name(rname);
     gchar *cname, *ctoname, *bcname, *icname, *hname, *sname;
+    gchar *csplitname, *ctosplitname;
     gchar *rettype;
     XrmValue retvalue;
     gint i;
@@ -1771,6 +1796,8 @@ static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
     icname = g_strconcat(rname, ".interlace.color", NULL);
     hname = g_strconcat(rname, ".highlight", NULL);
     sname = g_strconcat(rname, ".shadow", NULL);
+    csplitname = g_strconcat(rname, ".color.splitTo", NULL);
+    ctosplitname = g_strconcat(rname, ".colorTo.splitTo", NULL);
 
     if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
         retvalue.addr != NULL) {
@@ -1801,32 +1828,42 @@ static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
         if (value->surface.grad == RR_SURFACE_SPLIT_VERTICAL) {
             gint r, g, b;
 
-            r = value->surface.primary->r;
-            r += r >> 2;
-            g = value->surface.primary->g;
-            g += g >> 2;
-            b = value->surface.primary->b;
-            b += b >> 2;
-            if (r > 0xFF) r = 0xFF;
-            if (g > 0xFF) g = 0xFF;
-            if (b > 0xFF) b = 0xFF;
-            value->surface.split_primary = RrColorNew(inst, r, g, b);
-
-            r = value->surface.secondary->r;
-            r += r >> 4;
-            g = value->surface.secondary->g;
-            g += g >> 4;
-            b = value->surface.secondary->b;
-            b += b >> 4;
-            if (r > 0xFF) r = 0xFF;
-            if (g > 0xFF) g = 0xFF;
-            if (b > 0xFF) b = 0xFF;
-            value->surface.split_secondary = RrColorNew(inst, r, g, b);
+            if (!read_color(db, inst, csplitname,
+                            &value->surface.split_primary))
+            {
+                r = value->surface.primary->r;
+                r += r >> 2;
+                g = value->surface.primary->g;
+                g += g >> 2;
+                b = value->surface.primary->b;
+                b += b >> 2;
+                if (r > 0xFF) r = 0xFF;
+                if (g > 0xFF) g = 0xFF;
+                if (b > 0xFF) b = 0xFF;
+                value->surface.split_primary = RrColorNew(inst, r, g, b);
+            }
+
+            if (!read_color(db, inst, ctosplitname,
+                            &value->surface.split_secondary))
+            {
+                r = value->surface.secondary->r;
+                r += r >> 4;
+                g = value->surface.secondary->g;
+                g += g >> 4;
+                b = value->surface.secondary->b;
+                b += b >> 4;
+                if (r > 0xFF) r = 0xFF;
+                if (g > 0xFF) g = 0xFF;
+                if (b > 0xFF) b = 0xFF;
+                value->surface.split_secondary = RrColorNew(inst, r, g, b);
+            }
         }
 
         ret = TRUE;
     }
 
+    g_free(ctosplitname);
+    g_free(csplitname);
     g_free(sname);
     g_free(hname);
     g_free(icname);