--- rxvt-unicode/src/init.C 2006/01/31 16:57:35 1.163 +++ rxvt-unicode/src/init.C 2006/02/01 21:15:33 1.168 @@ -299,6 +299,7 @@ if (!(display = displays.get (rs[Rs_display_name]))) rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); + // using a local pointer decreases code size a lot xa = display->xa; #if XFT @@ -312,6 +313,10 @@ free (r_argv); + for (int i = NUM_RESOURCES; i--; ) + if (rs [i] == resval_undef) + rs [i] = 0; + #if ENABLE_PERL if (!rs[Rs_perl_ext_1]) rs[Rs_perl_ext_1] = "default"; @@ -423,6 +428,7 @@ { if (!rs[Rs_color + Color_fg]) rs[Rs_color + Color_fg] = def_colorName[Color_bg]; + if (!rs[Rs_color + Color_bg]) rs[Rs_color + Color_bg] = def_colorName[Color_fg]; } @@ -657,66 +663,58 @@ for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) { - rxvt_color xcol; + const char *name = rs[Rs_color + i]; - if (!rs[Rs_color + i]) + if (!name) continue; - if (!set_color (xcol, rs[Rs_color + i])) + rxvt_color xcol; + + if (!set_color (xcol, name)) { #ifndef XTERM_REVERSE_VIDEO if (i < 2 && OPTION (Opt_reverseVideo)) - rs[Rs_color + i] = def_colorName[!i]; + name = def_colorName [1 - i]; else #endif - rs[Rs_color + i] = def_colorName[i]; + name = def_colorName [i]; - if (!rs[Rs_color + i]) + if (!name) continue; - if (!set_color (xcol, rs[Rs_color + i])) + if (!set_color (xcol, name)) { switch (i) { case Color_fg: case Color_bg: - /* fatal: need bg/fg color */ rxvt_warn ("unable to get foreground/background colour, continuing.\n"); + name = ""; break; #ifndef NO_CURSORCOLOR case Color_cursor2: - xcol = pix_colors[Color_fg]; - break; -#endif /* ! NO_CURSORCOLOR */ +#endif case Color_pointer_fg: - xcol = pix_colors[Color_fg]; + name = rs[Rs_color + Color_fg]; + xcol.set (this, name); break; default: - xcol = pix_colors[Color_bg]; /* None */ + name = rs[Rs_color + Color_bg]; + xcol.set (this, name); break; } } } pix_colors[i] = xcol; - SET_PIXCOLOR (i); + rs[Rs_color + i] = name; } -#ifdef OFF_FOCUS_FADING - if (rs[Rs_fade]) - for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) - { - rxvt_rgba c; - pix_colors[Color_fade].get (this, c); - pix_colors_focused[i].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused[i],c); - } -#endif - if (depth <= 2) { - if (!rs[Rs_color + Color_pointer_fg]) pix_colors[Color_pointer_fg] = pix_colors[Color_fg]; - if (!rs[Rs_color + Color_pointer_bg]) pix_colors[Color_pointer_bg] = pix_colors[Color_bg]; - if (!rs[Rs_color + Color_border] ) pix_colors[Color_border] = pix_colors[Color_fg]; + if (!rs[Rs_color + Color_pointer_fg]) alias_color (Color_pointer_fg, Color_fg); + if (!rs[Rs_color + Color_pointer_bg]) alias_color (Color_pointer_bg, Color_bg); + if (!rs[Rs_color + Color_border] ) alias_color (Color_border, Color_fg); } /* @@ -726,44 +724,41 @@ * from the fvwm window manager. */ #ifdef KEEP_SCROLLCOLOR - if (depth <= 2) { /* Monochrome */ - pix_colors[Color_scroll] = pix_colors[Color_fg]; - pix_colors[Color_topShadow] = pix_colors[Color_bg]; - pix_colors[Color_bottomShadow] = pix_colors[Color_bg]; + alias_color (Color_scroll, Color_fg); + alias_color (Color_topShadow, Color_bg); + alias_color (Color_bottomShadow, Color_bg); } else { - rxvt_color xcol[2]; - /* xcol[0] == white - * xcol[1] == top shadow - * xcol[2] == bot shadow */ - - xcol[1] = pix_colors[Color_scroll]; - xcol[0].set (this, rxvt_rgba (rxvt_rgba::MAX_CC, rxvt_rgba::MAX_CC, rxvt_rgba::MAX_CC)); - - rxvt_rgba c0, c1; + pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]); - xcol[0].get (this, c0); - xcol[1].get (this, c1); - - xcol[1].fade (this, 50, pix_colors[Color_bottomShadow]); + rgba cscroll; + pix_colors [Color_scroll].get (cscroll); /* topShadowColor */ - if (!xcol[1].set (this, - rxvt_rgba ( - min (c0.r, max (c1.r / 5, c1.r) * 7 / 5), - min (c0.g, max (c1.g / 5, c1.g) * 7 / 5), - min (c0.b, max (c1.b / 5, c1.b) * 7 / 5), - c1.a) // pa1 vs. pa0: arbitrary - )); - xcol[1] = pix_colors[Color_White]; - - pix_colors[Color_topShadow] = xcol[1]; + if (!pix_colors[Color_topShadow].set (this, + rgba ( + min ((int)rgba::MAX_CC, max (cscroll.r / 5, cscroll.r) * 7 / 5), + min ((int)rgba::MAX_CC, max (cscroll.g / 5, cscroll.g) * 7 / 5), + min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5), + cscroll.a) + )) + alias_color (Color_topShadow, Color_White); } #endif /* KEEP_SCROLLCOLOR */ + +#ifdef OFF_FOCUS_FADING + if (rs[Rs_fade]) + for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) + { + rgba c; + pix_colors [Color_fade].get (c); + pix_colors_focused [i].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused[i],c); + } +#endif } /*----------------------------------------------------------------------*/