From cfdbe23e0d9b72b4c220a10ddf60a4e981967b63 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 21 Dec 2009 10:35:06 -0500 Subject: [PATCH] Add themeing options for inactive osd labels, osd.inactive.label.* (rename the current osd label options from osd.label to osd.active.label, similar to the window.(in)?active.label options. --- openbox/dock.c | 4 +- openbox/focus_cycle_popup.c | 14 +-- openbox/popup.c | 6 +- openbox/prompt.c | 2 +- render/theme.c | 152 +++++++++++++++++++++------- render/theme.h | 14 ++- themes/Clearlooks/openbox-3/themerc | 11 +- 7 files changed, 145 insertions(+), 58 deletions(-) diff --git a/openbox/dock.c b/openbox/dock.c index ee1202c7..ce2dafb8 100644 --- a/openbox/dock.c +++ b/openbox/dock.c @@ -65,7 +65,7 @@ void dock_startup(gboolean reconfig) XSetWindowBorderWidth(obt_display, dock->frame, ob_rr_theme->obwidth); RrAppearanceFree(dock->a_frame); - dock->a_frame = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg); + dock->a_frame = RrAppearanceCopy(ob_rr_theme->osd_bg); stacking_add(DOCK_AS_WINDOW(dock)); @@ -98,7 +98,7 @@ void dock_startup(gboolean reconfig) CWOverrideRedirect | CWEventMask | CWDontPropagate, &attrib); - dock->a_frame = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg); + dock->a_frame = RrAppearanceCopy(ob_rr_theme->osd_bg); XSetWindowBorder(obt_display, dock->frame, RrColorPixel(ob_rr_theme->osd_border_color)); XSetWindowBorderWidth(obt_display, dock->frame, ob_rr_theme->obwidth); diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index cc2b3b36..0f9bd752 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -124,9 +124,9 @@ void focus_cycle_popup_startup(gboolean reconfig) single_popup = icon_popup_new(); popup.obwin.type = OB_WINDOW_CLASS_INTERNAL; - popup.a_bg = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg); + popup.a_bg = RrAppearanceCopy(ob_rr_theme->osd_bg); popup.a_hilite_text = RrAppearanceCopy(ob_rr_theme->osd_hilite_label); - popup.a_text = RrAppearanceCopy(ob_rr_theme->a_unfocused_label); + popup.a_text = RrAppearanceCopy(ob_rr_theme->osd_unhilite_label); popup.a_icon = RrAppearanceCopy(ob_rr_theme->a_clear); popup.a_arrow = RrAppearanceCopy(ob_rr_theme->a_clear_tex); @@ -147,7 +147,7 @@ void focus_cycle_popup_startup(gboolean reconfig) RrAppearanceClearTextures(popup.a_arrow); popup.a_arrow->texture[0].type = RR_TEXTURE_MASK; popup.a_arrow->texture[0].data.mask.color = - ob_rr_theme->osd_color; + ob_rr_theme->osd_text_active_color; attrib.override_redirect = True; attrib.border_pixel=RrColorPixel(ob_rr_theme->osd_border_color); @@ -175,11 +175,13 @@ void focus_cycle_popup_startup(gboolean reconfig) /* create the hilite under the target icon */ { RrPixel32 color; + RrColor *tc; gint x, y, o; - color = ((ob_rr_theme->osd_color->r & 0xff) << RrDefaultRedOffset) + - ((ob_rr_theme->osd_color->g & 0xff) << RrDefaultGreenOffset) + - ((ob_rr_theme->osd_color->b & 0xff) << RrDefaultBlueOffset); + tc = ob_rr_theme->osd_text_active_color; + color = ((tc->r & 0xff) << RrDefaultRedOffset) + + ((tc->g & 0xff) << RrDefaultGreenOffset) + + ((tc->b & 0xff) << RrDefaultBlueOffset); o = 0; for (x = 0; x < HILITE_SIZE; x++) diff --git a/openbox/popup.c b/openbox/popup.c index 47d0d0fb..a4192819 100644 --- a/openbox/popup.c +++ b/openbox/popup.c @@ -36,7 +36,7 @@ ObPopup *popup_new(void) self->obwin.type = OB_WINDOW_CLASS_INTERNAL; self->gravity = NorthWestGravity; self->x = self->y = self->textw = self->h = 0; - self->a_bg = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg); + self->a_bg = RrAppearanceCopy(ob_rr_theme->osd_bg); self->a_text = RrAppearanceCopy(ob_rr_theme->osd_hilite_label); self->iconwm = self->iconhm = 1; @@ -506,8 +506,8 @@ ObPagerPopup *pager_popup_new(void) self->desks = 0; self->wins = g_new(Window, self->desks); - self->hilight = RrAppearanceCopy(ob_rr_theme->osd_hilite_fg); - self->unhilight = RrAppearanceCopy(ob_rr_theme->osd_unhilite_fg); + self->hilight = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg); + self->unhilight = RrAppearanceCopy(ob_rr_theme->osd_unhilite_bg); self->popup->hasicon = TRUE; self->popup->draw_icon = pager_popup_draw_icon; diff --git a/openbox/prompt.c b/openbox/prompt.c index 785a864d..829c57f4 100644 --- a/openbox/prompt.c +++ b/openbox/prompt.c @@ -57,7 +57,7 @@ void prompt_startup(gboolean reconfig) RrColor *c_button, *c_focus, *c_press, *c_pfocus; /* note: this is not a copy, don't free it */ - prompt_a_bg = ob_rr_theme->osd_hilite_bg; + prompt_a_bg = ob_rr_theme->osd_bg; prompt_a_button = RrAppearanceCopy(ob_rr_theme->a_focused_unpressed_close); prompt_a_focus = RrAppearanceCopy(ob_rr_theme->a_hover_focused_close); diff --git a/render/theme.c b/render/theme.c index 399bd2c5..29d81c0d 100644 --- a/render/theme.c +++ b/render/theme.c @@ -142,10 +142,11 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name, theme->a_menu_bullet_selected = RrAppearanceNew(inst, 1); theme->a_clear = RrAppearanceNew(inst, 0); theme->a_clear_tex = RrAppearanceNew(inst, 1); - theme->osd_hilite_bg = RrAppearanceNew(inst, 0); + theme->osd_bg = RrAppearanceNew(inst, 0); theme->osd_hilite_label = RrAppearanceNew(inst, 1); - theme->osd_hilite_fg = RrAppearanceNew(inst, 0); - theme->osd_unhilite_fg = RrAppearanceNew(inst, 0); + theme->osd_hilite_bg = RrAppearanceNew(inst, 0); + theme->osd_unhilite_label = RrAppearanceNew(inst, 1); + theme->osd_unhilite_bg = RrAppearanceNew(inst, 0); /* load the font stuff */ theme->win_font_focused = get_font(active_window_font, @@ -283,15 +284,26 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name, "window.active.label.text.color", &theme->title_focused_color)) theme->title_focused_color = RrColorNew(inst, 0x0, 0x0, 0x0); - if (!read_color(db, inst, "osd.label.text.color", &theme->osd_color)) - theme->osd_color = RrColorNew(inst, - theme->title_focused_color->r, - theme->title_focused_color->g, - theme->title_focused_color->b); + if (!read_color(db, inst, "osd.active.label.text.color", + &theme->osd_text_active_color) && + !read_color(db, inst, "osd.label.text.color", + &theme->osd_text_active_color)) + theme->osd_text_active_color = + RrColorNew(inst, + theme->title_focused_color->r, + theme->title_focused_color->g, + theme->title_focused_color->b); if (!read_color(db, inst, "window.inactive.label.text.color", &theme->title_unfocused_color)) theme->title_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff); + if (!read_color(db, inst, "osd.inactive.label.text.color", + &theme->osd_text_inactive_color)) + theme->osd_text_inactive_color = + RrColorNew(inst, + theme->title_unfocused_color->r, + theme->title_unfocused_color->g, + theme->title_unfocused_color->b); if (!read_color(db, inst, "window.active.button.unpressed.image.color", &theme->titlebut_focused_unpressed_color)) @@ -625,32 +637,39 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name, RrAppearanceCopy(theme->a_menu_selected); /* read appearances for non-decorations (on-screen-display) */ - if (!read_appearance(db, inst, "osd.bg", theme->osd_hilite_bg, FALSE)) { - RrAppearanceFree(theme->osd_hilite_bg); - theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_title); + if (!read_appearance(db, inst, "osd.bg", theme->osd_bg, FALSE)) { + RrAppearanceFree(theme->osd_bg); + theme->osd_bg = RrAppearanceCopy(theme->a_focused_title); } - if (!read_appearance(db, inst, "osd.label.bg", + if (!read_appearance(db, inst, "osd.active.label.bg", + theme->osd_hilite_label, TRUE) && + !read_appearance(db, inst, "osd.label.bg", theme->osd_hilite_label, TRUE)) { RrAppearanceFree(theme->osd_hilite_label); theme->osd_hilite_label = RrAppearanceCopy(theme->a_focused_label); } + if (!read_appearance(db, inst, "osd.inactive.label.bg", + theme->osd_unhilite_label, TRUE)) { + RrAppearanceFree(theme->osd_unhilite_label); + theme->osd_unhilite_label = RrAppearanceCopy(theme->a_unfocused_label); + } /* osd_hilite_fg can't be parentrel */ if (!read_appearance(db, inst, "osd.hilight.bg", - theme->osd_hilite_fg, FALSE)) { - RrAppearanceFree(theme->osd_hilite_fg); + theme->osd_hilite_bg, FALSE)) { + RrAppearanceFree(theme->osd_hilite_bg); if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL) - theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_label); + theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_label); else - theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_title); + theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_title); } /* osd_unhilite_fg can't be parentrel either */ if (!read_appearance(db, inst, "osd.unhilight.bg", - theme->osd_unhilite_fg, FALSE)) { - RrAppearanceFree(theme->osd_unhilite_fg); + theme->osd_unhilite_bg, FALSE)) { + RrAppearanceFree(theme->osd_unhilite_bg); if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL) - theme->osd_unhilite_fg=RrAppearanceCopy(theme->a_unfocused_label); + theme->osd_unhilite_bg=RrAppearanceCopy(theme->a_unfocused_label); else - theme->osd_unhilite_fg=RrAppearanceCopy(theme->a_unfocused_title); + theme->osd_unhilite_bg=RrAppearanceCopy(theme->a_unfocused_title); } /* read buttons textures */ @@ -908,9 +927,18 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name, theme->osd_hilite_label->texture[0].type = RR_TEXTURE_TEXT; theme->osd_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT; theme->osd_hilite_label->texture[0].data.text.font = theme->osd_font; - theme->osd_hilite_label->texture[0].data.text.color = theme->osd_color; + theme->osd_hilite_label->texture[0].data.text.color = + theme->osd_text_active_color; - if (read_string(db, "osd.label.text.font", &str)) { + theme->osd_unhilite_label->texture[0].type = RR_TEXTURE_TEXT; + theme->osd_unhilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT; + theme->osd_unhilite_label->texture[0].data.text.font = theme->osd_font; + theme->osd_unhilite_label->texture[0].data.text.color = + theme->osd_text_inactive_color; + + if (read_string(db, "osd.active.label.text.font", &str) || + read_string(db, "osd.label.text.font", &str)) + { char *p; gint i = 0; gint j; @@ -919,8 +947,6 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name, i = parse_inline_number(p + strlen("shadowoffset=")); else i = 1; - theme->a_focused_label->texture[0].data.text.shadow_offset_x = i; - theme->a_focused_label->texture[0].data.text.shadow_offset_y = i; theme->osd_hilite_label->texture[0].data.text.shadow_offset_x = i; theme->osd_hilite_label->texture[0].data.text.shadow_offset_y = i; } @@ -930,11 +956,11 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name, j = (i > 0 ? 0 : 255); i = ABS(i*255/100); - theme->osd_shadow_color = RrColorNew(inst, j, j, j); - theme->osd_shadow_alpha = i; + theme->osd_text_active_shadow_color = RrColorNew(inst, j, j, j); + theme->osd_text_active_shadow_alpha = i; } else { - theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0); - theme->osd_shadow_alpha = 50; + theme->osd_text_active_shadow_color = RrColorNew(inst, 0, 0, 0); + theme->osd_text_active_shadow_alpha = 50; } } else { /* inherit the font settings from the focused label */ @@ -943,20 +969,69 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name, theme->osd_hilite_label->texture[0].data.text.shadow_offset_y = theme->a_focused_label->texture[0].data.text.shadow_offset_y; if (theme->title_focused_shadow_color) - theme->osd_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); else - theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0); - theme->osd_shadow_alpha = theme->title_focused_shadow_alpha; + theme->osd_text_active_shadow_color = RrColorNew(inst, 0, 0, 0); + theme->osd_text_active_shadow_alpha = + theme->title_focused_shadow_alpha; } theme->osd_hilite_label->texture[0].data.text.shadow_color = - theme->osd_shadow_color; + theme->osd_text_active_shadow_color; theme->osd_hilite_label->texture[0].data.text.shadow_alpha = - theme->osd_shadow_alpha; + theme->osd_text_active_shadow_alpha; + + if (read_string(db, "osd.inactive.label.text.font", &str)) + { + char *p; + gint i = 0; + gint j; + if (strstr(str, "shadow=y")) { + if ((p = strstr(str, "shadowoffset="))) + i = parse_inline_number(p + strlen("shadowoffset=")); + else + i = 1; + theme->osd_unhilite_label->texture[0].data.text.shadow_offset_x=i; + theme->osd_unhilite_label->texture[0].data.text.shadow_offset_y=i; + } + if ((p = strstr(str, "shadowtint="))) + { + i = parse_inline_number(p + strlen("shadowtint=")); + j = (i > 0 ? 0 : 255); + i = ABS(i*255/100); + + theme->osd_text_inactive_shadow_color = RrColorNew(inst, j, j, j); + theme->osd_text_inactive_shadow_alpha = i; + } else { + theme->osd_text_inactive_shadow_color = RrColorNew(inst, 0, 0, 0); + theme->osd_text_inactive_shadow_alpha = 50; + } + } else { + /* inherit the font settings from the focused label */ + theme->osd_unhilite_label->texture[0].data.text.shadow_offset_x = + theme->a_unfocused_label->texture[0].data.text.shadow_offset_x; + theme->osd_unhilite_label->texture[0].data.text.shadow_offset_y = + 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); + else + theme->osd_text_inactive_shadow_color = RrColorNew(inst, 0, 0, 0); + theme->osd_text_inactive_shadow_alpha = + theme->title_unfocused_shadow_alpha; + } + + theme->osd_unhilite_label->texture[0].data.text.shadow_color = + theme->osd_text_inactive_shadow_color; + theme->osd_unhilite_label->texture[0].data.text.shadow_alpha = + theme->osd_text_inactive_shadow_alpha; theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT; theme->a_unfocused_label->texture[0].data.text.justify = winjust; @@ -1440,8 +1515,10 @@ void RrThemeFree(RrTheme *theme) RrColorFree(theme->menu_disabled_selected_color); RrColorFree(theme->title_focused_shadow_color); RrColorFree(theme->title_unfocused_shadow_color); - RrColorFree(theme->osd_color); - RrColorFree(theme->osd_shadow_color); + RrColorFree(theme->osd_text_active_color); + RrColorFree(theme->osd_text_inactive_color); + RrColorFree(theme->osd_text_active_shadow_color); + RrColorFree(theme->osd_text_inactive_shadow_color); RrColorFree(theme->menu_title_shadow_color); RrColorFree(theme->menu_text_normal_shadow_color); RrColorFree(theme->menu_text_selected_shadow_color); @@ -1571,10 +1648,11 @@ void RrThemeFree(RrTheme *theme) RrAppearanceFree(theme->a_menu_bullet_selected); RrAppearanceFree(theme->a_clear); RrAppearanceFree(theme->a_clear_tex); + RrAppearanceFree(theme->osd_bg); RrAppearanceFree(theme->osd_hilite_bg); - RrAppearanceFree(theme->osd_hilite_fg); RrAppearanceFree(theme->osd_hilite_label); - RrAppearanceFree(theme->osd_unhilite_fg); + RrAppearanceFree(theme->osd_unhilite_bg); + RrAppearanceFree(theme->osd_unhilite_label); g_free(theme); } diff --git a/render/theme.h b/render/theme.h index da8e80d3..06014cbb 100644 --- a/render/theme.h +++ b/render/theme.h @@ -96,9 +96,12 @@ struct _RrTheme { gchar title_focused_shadow_alpha; RrColor *title_unfocused_shadow_color; gchar title_unfocused_shadow_alpha; - RrColor *osd_color; - RrColor *osd_shadow_color; - gchar osd_shadow_alpha; + RrColor *osd_text_active_color; + RrColor *osd_text_inactive_color; + RrColor *osd_text_active_shadow_color; + RrColor *osd_text_inactive_shadow_color; + gchar osd_text_active_shadow_alpha; + gchar osd_text_inactive_shadow_alpha; RrColor *menu_title_shadow_color; gchar menu_title_shadow_alpha; RrColor *menu_text_normal_shadow_color; @@ -239,10 +242,11 @@ struct _RrTheme { RrAppearance *a_clear; /* clear with no texture */ RrAppearance *a_clear_tex; /* clear with a texture */ + RrAppearance *osd_bg; /* can never be parent relative */ RrAppearance *osd_hilite_bg; /* can never be parent relative */ - RrAppearance *osd_hilite_fg; /* can never be parent relative */ RrAppearance *osd_hilite_label; /* can be parent relative */ - RrAppearance *osd_unhilite_fg; /* can never be parent relative */ + RrAppearance *osd_unhilite_bg; /* can never be parent relative */ + RrAppearance *osd_unhilite_label; /* can be parent relative */ gchar *name; }; diff --git a/themes/Clearlooks/openbox-3/themerc b/themes/Clearlooks/openbox-3/themerc index 1dde5fba..67d5f260 100644 --- a/themes/Clearlooks/openbox-3/themerc +++ b/themes/Clearlooks/openbox-3/themerc @@ -145,11 +145,14 @@ osd.bg.colorTo.splitto: #E7E5E4 osd.bg.border.color: #ffffff -osd.label.bg: parentrelative -osd.label.bg.color: #efefef -osd.label.bg.border.color: #9c9e9c +osd.active.label.bg: parentrelative +osd.active.label.bg.color: #efefef +osd.active.label.bg.border.color: #9c9e9c +osd.active.label.text.color: #444 + +osd.inactive.label.bg: parentrelative +osd.inactive.label.text.color: #70747d -osd.label.text.color: #444 !# yeah whatever, this is fine anyhoo? osd.hilight.bg: flat vertical gradient osd.hilight.bg.color: #9ebde5 -- 2.45.2