--- rxvt-unicode/src/init.C 2006/01/25 02:42:06 1.153 +++ rxvt-unicode/src/init.C 2006/01/31 16:57:35 1.163 @@ -45,31 +45,31 @@ COLOR_FOREGROUND, COLOR_BACKGROUND, /* low-intensity colors */ - "Black", /* 0: black (#000000) */ - "Red3", /* 1: red (#CD0000) */ - "Green3", /* 2: green (#00CD00) */ - "Yellow3", /* 3: yellow (#CDCD00) */ - "Blue3", /* 4: blue (#0000CD) */ - "Magenta3", /* 5: magenta (#CD00CD) */ - "Cyan3", /* 6: cyan (#00CDCD) */ -# ifdef XTERM_COLORS - "Grey90", /* 7: white (#E5E5E5) */ -# else - "AntiqueWhite", /* 7: white (#FAEBD7) */ + "rgb:00/00/00", // 0: black (Black) + "rgb:cd/00/00", // 1: red (Red3) + "rgb:00/cd/00", // 2: green (Green3) + "rgb:cd/cd/00", // 3: ywlloe (Yellow3) + "rgb:00/00/cd", // 4: blue (Blue3) + "rgb:cd/00/cd", // 5: magenta (Magenta3) + "rgb:00/cd/cd", // 6: cyan (Cyan3) +# ifdef XTERM_COLORS + "rgb:e5/e5/e5", // 7: white (Grey90) +# else + "rgb:fa/eb/d7", // 7: white (AntiqueWhite) # endif /* high-intensity colors */ # ifdef XTERM_COLORS - "Grey30", /* 8: bright black (#4D4D4D) */ + "rgb:4d/4d/4d", // 8: bright black (Grey30) # else - "Grey25", /* 8: bright black (#404040) */ + "rgb:40/40/40", // 8: bright black (Grey25) # endif - "Red", /* 1/9: bright red (#FF0000) */ - "Green", /* 2/10: bright green (#00FF00) */ - "Yellow", /* 3/11: bright yellow (#FFFF00) */ - "Blue", /* 4/12: bright blue (#0000FF) */ - "Magenta", /* 5/13: bright magenta (#FF00FF) */ - "Cyan", /* 6/14: bright cyan (#00FFFF) */ - "White", /* 7/15: bright white (#FFFFFF) */ + "rgb:ff/00/00", // 1/9: bright red (Reed) + "rgb:00/ff/00", // 2/10: bright green (Green) + "rgb:ff/ff/00", // 3/11: bright yellow (Yellow) + "rgb:00/00/ff", // 4/12: bright blue (Blue) + "rgb:ff/00/ff", // 5/13: bright magenta (Magenta) + "rgb:00/ff/ff", // 6/14: bright cyan (Cyan) + "rgb:ff/ff/ff", // 7/15: bright white (White) // 88 xterm colours "rgb:00/00/00", @@ -172,21 +172,18 @@ NULL, #endif #if OFF_FOCUS_FADING - "black", + "rgb:00/00/00", #endif }; bool rxvt_term::init_vars () { - pix_colors_focused = new rxvt_color [TOTAL_COLORS]; + pix_colors = // + pix_colors_focused = new rxvt_color [TOTAL_COLORS]; #ifdef OFF_FOCUS_FADING pix_colors_unfocused = new rxvt_color [TOTAL_COLORS]; #endif - pix_colors = pix_colors_focused; - - if (pix_colors == NULL) - return false; #if defined(XPM_BACKGROUND) || defined(TRANSPARENT) pixmap = None; @@ -197,7 +194,6 @@ options = DEFAULT_OPTIONS; want_refresh = 1; priv_modes = SavedModes = PrivMode_Default; - focus = 0; ncol = 80; nrow = 24; int_bwidth = INTERNALBORDERWIDTH; @@ -208,7 +204,6 @@ refresh_limit = 1; refresh_type = SLOW_REFRESH; - prev_nrow = prev_ncol = 0; oldcursor.row = oldcursor.col = -1; #ifdef XPM_BACKGROUND @@ -304,6 +299,15 @@ if (!(display = displays.get (rs[Rs_display_name]))) rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); + xa = display->xa; + +#if XFT + if (rs[Rs_depth]) + set (display, strtol (rs[Rs_depth], 0, 0)); + else +#endif + set (display); + extract_resources (); free (r_argv); @@ -480,7 +484,7 @@ if (val == NULL) #endif /* DISPLAY_IS_IP */ - val = XDisplayString (display->display); + val = XDisplayString (xdisp); if (rs[Rs_display_name] == NULL) rs[Rs_display_name] = val; /* use broken `:0' value */ @@ -490,15 +494,7 @@ sprintf (env_display, "DISPLAY=%s", val); - /* avoiding the math library: - * i = (int) (ceil (log10 ((unsigned int)parent[0]))) */ - for (i = 0, u = (unsigned int)parent[0]; u; u /= 10, i++) - ; - max_it (i, 1); - env_windowid = (char *)rxvt_malloc ((i + 10) * sizeof (char)); - - sprintf (env_windowid, "WINDOWID=%u", - (unsigned int)parent[0]); + sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent[0]); /* add entries to the environment: * @ DISPLAY: in case we started with -display @@ -510,6 +506,7 @@ */ putenv (env_display); putenv (env_windowid); + if (env_colorfgbg) putenv (env_colorfgbg); @@ -517,7 +514,7 @@ putenv ("TERMINFO=" RXVT_TERMINFO); #endif - if (display->depth <= 2) + if (depth <= 2) putenv ("COLORTERM=" COLORTERMENV "-mono"); else putenv ("COLORTERM=" COLORTERMENVFULL); @@ -658,14 +655,14 @@ pix_colors = pix_colors_focused; #endif - for (i = 0; i < (display->depth <= 2 ? 2 : NRS_COLORS); i++) + for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) { rxvt_color xcol; if (!rs[Rs_color + i]) continue; - if (!rXParseAllocColor (&xcol, rs[Rs_color + i])) + if (!set_color (xcol, rs[Rs_color + i])) { #ifndef XTERM_REVERSE_VIDEO if (i < 2 && OPTION (Opt_reverseVideo)) @@ -677,15 +674,14 @@ if (!rs[Rs_color + i]) continue; - if (!rXParseAllocColor (&xcol, rs[Rs_color + i])) + if (!set_color (xcol, rs[Rs_color + i])) { switch (i) { case Color_fg: case Color_bg: /* fatal: need bg/fg color */ - rxvt_fatal ("unable to get foreground/background colour, aborting.\n"); - /* NOTREACHED */ + rxvt_warn ("unable to get foreground/background colour, continuing.\n"); break; #ifndef NO_CURSORCOLOR case Color_cursor2: @@ -708,11 +704,15 @@ #ifdef OFF_FOCUS_FADING if (rs[Rs_fade]) - for (i = 0; i < (display->depth <= 2 ? 2 : NRS_COLORS); i++) - pix_colors_unfocused[i] = pix_colors_focused[i].fade (display, atoi (rs[Rs_fade]), pix_colors[Color_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 (display->depth <= 2) + 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]; @@ -727,7 +727,7 @@ */ #ifdef KEEP_SCROLLCOLOR - if (display->depth <= 2) + if (depth <= 2) { /* Monochrome */ pix_colors[Color_scroll] = pix_colors[Color_fg]; @@ -742,20 +742,23 @@ * xcol[2] == bot shadow */ xcol[1] = pix_colors[Color_scroll]; - xcol[0].set (display, 65535, 65535, 65535); + xcol[0].set (this, rxvt_rgba (rxvt_rgba::MAX_CC, rxvt_rgba::MAX_CC, rxvt_rgba::MAX_CC)); - unsigned short pr1, pg1, pb1, pr0, pg0, pb0; + rxvt_rgba c0, c1; - xcol[0].get (display, pr0, pg0, pb0); - xcol[1].get (display, pr1, pg1, pb1); + xcol[0].get (this, c0); + xcol[1].get (this, c1); - pix_colors[Color_bottomShadow] = xcol[1].fade (display, 50); + xcol[1].fade (this, 50, pix_colors[Color_bottomShadow]); /* topShadowColor */ - if (!xcol[1].set (display, - min (pr0, max (pr0 / 5, pr1) * 7 / 5), - min (pg0, max (pg0 / 5, pg1) * 7 / 5), - min (pb0, max (pb0 / 5, pb1) * 7 / 5))) + 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]; @@ -809,7 +812,7 @@ && strcasecmp (rsmod, "mod1") >= 0 && strcasecmp (rsmod, "mod5") <= 0) requestedmeta = rsmod[3] - '0'; - map = XGetModifierMapping (display->display); + map = XGetModifierMapping (xdisp); kc = map->modifiermap; for (i = 1; i < 6; i++) @@ -821,7 +824,7 @@ if (kc[k] == 0) break; - switch (XKeycodeToKeysym (display->display, kc[k], 0)) + switch (XKeycodeToKeysym (xdisp, kc[k], 0)) { case XK_Num_Lock: ModNumLockMask = modmasks[i - 1]; @@ -886,9 +889,8 @@ XGCValues gcvalue; XSetWindowAttributes attributes; Window top, parent; - dDisp; - xa = display->xa; + dLocal (Display *, xdisp); /* grab colors before netscape does */ Get_Colours (); @@ -903,10 +905,10 @@ #if ENABLE_FRILLS if (OPTION (Opt_borderLess)) { - if (XInternAtom (disp, "_MOTIF_WM_INFO", True) == None) + if (XInternAtom (xdisp, "_MOTIF_WM_INFO", True) == None) { /* print_warning("Window Manager does not support MWM hints. Bypassing window manager control for borderless window.\n");*/ - attributes.override_redirect = TRUE; + attributes.override_redirect = true; mwmhints.flags = 0; } else @@ -926,7 +928,7 @@ parent = strtol (rs[Rs_embed], 0, 0); - if (!XGetWindowAttributes (disp, parent, &wattr)) + if (!XGetWindowAttributes (xdisp, parent, &wattr)) rxvt_fatal ("invalid window-id specified with -embed, aborting.\n"); window_calc (wattr.width, wattr.height); @@ -936,16 +938,15 @@ window_calc (0, 0); /* sub-window placement & size in rxvt_resize_subwindows () */ - attributes.background_pixel = pix_colors_focused[Color_border]; - attributes.border_pixel = pix_colors_focused[Color_border]; - attributes.colormap = display->cmap; + attributes.background_pixel = pix_colors_focused [Color_border]; + attributes.border_pixel = pix_colors_focused [Color_border]; + attributes.colormap = cmap; - top = XCreateWindow (disp, parent, + top = XCreateWindow (xdisp, parent, szHint.x, szHint.y, szHint.width, szHint.height, ext_bwidth, - display->depth, InputOutput, - display->visual, + depth, InputOutput, visual, CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect, &attributes); @@ -965,12 +966,12 @@ wmHint.initial_state = OPTION (Opt_iconic) ? IconicState : NormalState; wmHint.window_group = top; - XmbSetWMProperties (disp, top, NULL, NULL, (char **)argv, argc, + XmbSetWMProperties (xdisp, top, NULL, NULL, (char **)argv, argc, &szHint, &wmHint, &classHint); #if ENABLE_FRILLS if (mwmhints.flags) - XChangeProperty (disp, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, + XChangeProperty (xdisp, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, PropModeReplace, (unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS); #endif @@ -981,24 +982,24 @@ #endif }; - XSetWMProtocols (disp, top, protocols, sizeof (protocols) / sizeof (protocols[0])); + XSetWMProtocols (xdisp, top, protocols, sizeof (protocols) / sizeof (protocols[0])); #if ENABLE_FRILLS if (rs[Rs_transient_for]) - XSetTransientForHint (disp, top, (Window)strtol (rs[Rs_transient_for], 0, 0)); + XSetTransientForHint (xdisp, top, (Window)strtol (rs[Rs_transient_for], 0, 0)); #endif #if ENABLE_EWMH long pid = getpid (); - XChangeProperty (disp, top, + XChangeProperty (xdisp, top, xa[XA_NET_WM_PID], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1); // _NET_WM_WINDOW_TYPE is NORMAL, which is the default #endif - XSelectInput (disp, top, + XSelectInput (xdisp, top, KeyPressMask #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ENABLE_FRILLS || ISO_14755 | KeyReleaseMask @@ -1009,15 +1010,15 @@ termwin_ev.start (display, top); /* vt cursor: Black-on-White is standard, but this is more popular */ - TermWin_cursor = XCreateFontCursor (disp, XC_xterm); + TermWin_cursor = XCreateFontCursor (xdisp, XC_xterm); #ifdef HAVE_SCROLLBARS /* cursor scrollBar: Black-on-White */ - leftptr_cursor = XCreateFontCursor (disp, XC_left_ptr); + leftptr_cursor = XCreateFontCursor (xdisp, XC_left_ptr); #endif /* the vt window */ - vt = XCreateSimpleWindow (disp, top, + vt = XCreateSimpleWindow (xdisp, top, window_vt_x, window_vt_y, width, height, 0, @@ -1025,7 +1026,7 @@ pix_colors_focused[Color_bg]); attributes.bit_gravity = NorthWestGravity; - XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes); + XChangeWindowAttributes (xdisp, vt, CWBitGravity, &attributes); vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; @@ -1040,7 +1041,7 @@ #ifdef XPM_BACKGROUND if (rs[Rs_backgroundPixmap] != NULL - && ! OPTION (Opt_transparent)) + && !OPTION (Opt_transparent)) { const char *p = rs[Rs_backgroundPixmap]; @@ -1060,19 +1061,19 @@ gcvalue.background = pix_colors[Color_bg]; gcvalue.graphics_exposures = 1; - gc = XCreateGC (disp, vt, + gc = XCreateGC (xdisp, vt, GCForeground | GCBackground | GCGraphicsExposures, &gcvalue); - drawable = new rxvt_drawable (display, vt); + drawable = new rxvt_drawable (this, vt); #ifdef RXVT_SCROLLBAR gcvalue.foreground = pix_colors[Color_topShadow]; - topShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); + topShadowGC = XCreateGC (xdisp, vt, GCForeground, &gcvalue); gcvalue.foreground = pix_colors[Color_bottomShadow]; - botShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); - gcvalue.foreground = pix_colors[ (display->depth <= 2 ? Color_fg : Color_scroll)]; - scrollbarGC = XCreateGC (disp, vt, GCForeground, &gcvalue); + botShadowGC = XCreateGC (xdisp, vt, GCForeground, &gcvalue); + gcvalue.foreground = pix_colors[ (depth <= 2 ? Color_fg : Color_scroll)]; + scrollbarGC = XCreateGC (xdisp, vt, GCForeground, &gcvalue); #endif #ifdef OFF_FOCUS_FADING