Make the inactive osd text color fall back to the old osd property, and lastly inheri...
[dana/openbox.git] / obrender / theme.c
index ea49abe..634fc51 100644 (file)
@@ -259,9 +259,13 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
     READ_INT("border.width", theme->fbwidth, 0, 100, 1);
     READ_INT("menu.border.width", theme->mbwidth, 0, 100, theme->fbwidth);
     READ_INT("osd.border.width", theme->obwidth, 0, 100, theme->fbwidth);
+    READ_INT("undecorated.border.width", theme->ubwidth, 0, 100,
+             theme->fbwidth);
     READ_INT("menu.separator.width", theme->menu_sep_width, 1, 100, 1);
-    READ_INT("menu.separator.padding.width", theme->menu_sep_paddingx, 0, 100, 6);
-    READ_INT("menu.separator.padding.height", theme->menu_sep_paddingy, 0, 100, 3);
+    READ_INT("menu.separator.padding.width", theme->menu_sep_paddingx,
+             0, 100, 6);
+    READ_INT("menu.separator.padding.height", theme->menu_sep_paddingy,
+             0, 100, 3);
     READ_INT("window.client.padding.width", theme->cbwidthx, 0, 100,
              theme->paddingx);
     READ_INT("window.client.padding.height", theme->cbwidthy, 0, 100,
@@ -270,7 +274,11 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
     /* load colors */
     READ_COLOR_("window.active.border.color", "border.color",
                 theme->frame_focused_border_color, RrColorNew(inst, 0, 0, 0));
-
+    /* undecorated focused border color inherits from frame focused border
+       color */
+    READ_COLOR("window.undecorated.active.border.color",
+               theme->frame_undecorated_focused_border_color,
+               RrColorCopy(theme->frame_focused_border_color));
     /* title separator focused color inherits from focused border color */
     READ_COLOR("window.active.title.separator.color",
                theme->title_separator_focused_color,
@@ -281,6 +289,12 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
                theme->frame_unfocused_border_color,
                RrColorCopy(theme->frame_focused_border_color));
 
+    /* undecorated unfocused border color inherits from frame unfocused border
+       color */
+    READ_COLOR("window.undecorated.inactive.border.color",
+               theme->frame_undecorated_unfocused_border_color,
+               RrColorCopy(theme->frame_unfocused_border_color));
+
     /* title separator unfocused color inherits from unfocused border color */
     READ_COLOR("window.inactive.title.separator.color",
                theme->title_separator_unfocused_color,
@@ -303,19 +317,16 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
     READ_COLOR("window.active.label.text.color", theme->title_focused_color,
                RrColorNew(inst, 0x0, 0x0, 0x0));
 
-    READ_COLOR_("osd.active.label.text.color",
-                "osd.label.text.color",
-                theme->osd_text_active_color, RrColorCopy(theme->title_focused_color));
-
     READ_COLOR("window.inactive.label.text.color", theme->title_unfocused_color,
                RrColorCopy(theme->title_unfocused_color));
 
-    READ_COLOR("osd.inactive.label.text.color", theme->osd_text_inactive_color,
-               RrColorNew(inst, 0xff, 0xff, 0xff));
+    READ_COLOR_("osd.active.label.text.color",
+                "osd.label.text.color",
+                theme->osd_text_active_color, RrColorCopy(theme->title_focused_color));
 
-    READ_COLOR("window.inactive.label.text.color",
-               theme->title_unfocused_color,
-               RrColorNew(inst, 0xff, 0xff, 0xff));
+    READ_COLOR_("osd.inactive.label.text.color",
+                "osd.label.text.color",
+                theme->osd_text_inactive_color, RrColorCopy(theme->title_unfocused_color));
 
     READ_COLOR("window.active.button.unpressed.image.color",
                theme->titlebut_focused_unpressed_color,
@@ -986,10 +997,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
             theme->a_focused_label->texture[0].data.text.shadow_offset_y;
         if (theme->title_focused_shadow_color)
             theme->osd_text_active_shadow_color =
-                RrColorNew(inst,
-                           theme->title_focused_shadow_color->r,
-                           theme->title_focused_shadow_color->g,
-                           theme->title_focused_shadow_color->b);
+                RrColorCopy(theme->title_focused_shadow_color);
         else
             theme->osd_text_active_shadow_color = RrColorNew(inst, 0, 0, 0);
         theme->osd_text_active_shadow_alpha =
@@ -1001,16 +1009,21 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
     theme->osd_hilite_label->texture[0].data.text.shadow_alpha =
         theme->osd_text_active_shadow_alpha;
 
-    theme->osd_unpressed_button->texture[0] =
-        theme->osd_pressed_button->texture[0] =
-        theme->osd_focused_button->texture[0] =
-        theme->osd_hilite_label->texture[0];
+    theme->osd_unpressed_button->texture[0].type =
+        theme->osd_pressed_button->texture[0].type =
+        theme->osd_focused_button->texture[0].type =
+        RR_TEXTURE_TEXT;
 
     theme->osd_unpressed_button->texture[0].data.text.justify =
         theme->osd_pressed_button->texture[0].data.text.justify =
         theme->osd_focused_button->texture[0].data.text.justify =
         RR_JUSTIFY_CENTER;
 
+    theme->osd_unpressed_button->texture[0].data.text.font =
+        theme->osd_pressed_button->texture[0].data.text.font =
+        theme->osd_focused_button->texture[0].data.text.font =
+        theme->osd_font_hilite;
+
     theme->osd_unpressed_button->texture[0].data.text.color =
         theme->osd_unpressed_color;
     theme->osd_pressed_button->texture[0].data.text.color =
@@ -1108,10 +1121,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
             theme->a_unfocused_label->texture[0].data.text.shadow_offset_y;
         if (theme->title_unfocused_shadow_color)
             theme->osd_text_inactive_shadow_color =
-                RrColorNew(inst,
-                           theme->title_unfocused_shadow_color->r,
-                           theme->title_unfocused_shadow_color->g,
-                           theme->title_unfocused_shadow_color->b);
+                RrColorCopy(theme->title_unfocused_shadow_color);
         else
             theme->osd_text_inactive_shadow_color = RrColorNew(inst, 0, 0, 0);
         theme->osd_text_inactive_shadow_alpha =
@@ -1603,7 +1613,9 @@ void RrThemeFree(RrTheme *theme)
         RrColorFree(theme->menu_border_color);
         RrColorFree(theme->osd_border_color);
         RrColorFree(theme->frame_focused_border_color);
+        RrColorFree(theme->frame_undecorated_focused_border_color);
         RrColorFree(theme->frame_unfocused_border_color);
+        RrColorFree(theme->frame_undecorated_unfocused_border_color);
         RrColorFree(theme->title_separator_focused_color);
         RrColorFree(theme->title_separator_unfocused_color);
         RrColorFree(theme->cb_unfocused_color);
@@ -1786,6 +1798,7 @@ static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value)
 
     if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
         retvalue.addr != NULL) {
+        g_strstrip(retvalue.addr);
         *value = retvalue.addr;
         ret = TRUE;
     }
@@ -1804,7 +1817,12 @@ static gboolean read_color(XrmDatabase db, const RrInstance *inst,
 
     if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
         retvalue.addr != NULL) {
-        RrColor *c = RrColorParse(inst, retvalue.addr);
+        RrColor *c;
+
+        /* retvalue.addr is inside the xrdb database so we can't destroy it
+           but we can edit it in place, as g_strstrip does. */
+        g_strstrip(retvalue.addr);
+        c = RrColorParse(inst, retvalue.addr);
         if (c != NULL) {
             *value = c;
             ret = TRUE;