--- rxvt-unicode/src/init.C 2006/01/31 19:11:43 1.165 +++ rxvt-unicode/src/init.C 2007/07/24 14:32:47 1.191 @@ -1,4 +1,4 @@ -/*--------------------------------*-C-*---------------------------------* + /*----------------------------------------------------------------------* * File: init.C *----------------------------------------------------------------------* * @@ -48,7 +48,7 @@ "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:cd/cd/00", // 3: yellow (Yellow3) "rgb:00/00/cd", // 4: blue (Blue3) "rgb:cd/00/cd", // 5: magenta (Magenta3) "rgb:00/cd/cd", // 6: cyan (Cyan3) @@ -185,13 +185,12 @@ pix_colors_unfocused = new rxvt_color [TOTAL_COLORS]; #endif -#if defined(XPM_BACKGROUND) || defined(TRANSPARENT) +#if defined(XPM_BACKGROUND) || defined(ENABLE_TRANSPARENCY) pixmap = None; #endif MEvent.time = CurrentTime; MEvent.button = AnyButton; - options = DEFAULT_OPTIONS; want_refresh = 1; priv_modes = SavedModes = PrivMode_Default; ncol = 80; @@ -202,18 +201,27 @@ saveLines = SAVELINES; numpix_colors = TOTAL_COLORS; - refresh_limit = 1; refresh_type = SLOW_REFRESH; oldcursor.row = oldcursor.col = -1; #ifdef XPM_BACKGROUND /* bgPixmap.w = bgPixmap.h = 0; */ - bgPixmap.x = bgPixmap.y = 50; + bgPixmap.x = bgPixmap.y = 0; bgPixmap.pixmap = None; #endif last_bot = last_state = -1; + set_option (Opt_scrollBar); + set_option (Opt_scrollTtyOutput); + set_option (Opt_jumpScroll); + set_option (Opt_skipScroll); + set_option (Opt_secondaryScreen); + set_option (Opt_secondaryScroll); + set_option (Opt_pastableTabs); + set_option (Opt_intensityStyles); + set_option (Opt_iso14755_52); + return true; } @@ -260,10 +268,10 @@ const char **cmd_argv, **r_argv; /* - * Look for -exec option. Find => split and make cmd_argv[] of command args + * Look for -e option. Find => split and make cmd_argv[] of command args */ for (r_argc = 0; r_argc < argc; r_argc++) - if (!strcmp (argv[r_argc], "-e") || !strcmp (argv[r_argc], "-exec")) + if (!strcmp (argv[r_argc], "-e")) break; r_argv = (const char **)rxvt_malloc (sizeof (char *) * (r_argc + 1)); @@ -299,19 +307,27 @@ 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; + set (display); + extract_resources (); + #if XFT if (rs[Rs_depth]) - set (display, strtol (rs[Rs_depth], 0, 0)); - else + select_visual (strtol (rs[Rs_depth], 0, 0)); #endif - set (display); - - extract_resources (); +#ifdef HAVE_AFTERIMAGE + ::dpy = NULL ; /* init global var from libAfter... */ + asv = AFTERIMAGE_DPY_OP (create_asvisual_for_id (dpy, display->screen, depth, XVisualIDFromVisual (visual), cmap, NULL)); +#endif 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"; @@ -419,7 +435,7 @@ #ifdef XTERM_REVERSE_VIDEO /* this is how xterm implements reverseVideo */ - if (OPTION (Opt_reverseVideo)) + if (option (Opt_reverseVideo)) { if (!rs[Rs_color + Color_fg]) rs[Rs_color + Color_fg] = def_colorName[Color_bg]; @@ -435,7 +451,7 @@ #ifndef XTERM_REVERSE_VIDEO /* this is how we implement reverseVideo */ - if (OPTION (Opt_reverseVideo)) + if (option (Opt_reverseVideo)) ::swap (rs[Rs_color + Color_fg], rs[Rs_color + Color_bg]); #endif @@ -485,7 +501,7 @@ if (val == NULL) #endif /* DISPLAY_IS_IP */ - val = XDisplayString (xdisp); + val = XDisplayString (dpy); if (rs[Rs_display_name] == NULL) rs[Rs_display_name] = val; /* use broken `:0' value */ @@ -619,16 +635,16 @@ */ #ifdef META8_OPTION - meta_char = OPTION (Opt_meta8) ? 0x80 : C0_ESC; + meta_char = option (Opt_meta8) ? 0x80 : C0_ESC; #endif get_ourmods (); - if (!OPTION (Opt_scrollTtyOutput)) + if (!option (Opt_scrollTtyOutput)) priv_modes |= PrivMode_TtyOutputInh; - if (OPTION (Opt_scrollTtyKeypress)) + if (option (Opt_scrollTtyKeypress)) priv_modes |= PrivMode_Keypress; - if (!OPTION (Opt_jumpScroll)) + if (!option (Opt_jumpScroll)) priv_modes |= PrivMode_smoothScroll; #ifndef NO_BACKSPACE_KEY @@ -668,7 +684,7 @@ if (!set_color (xcol, name)) { #ifndef XTERM_REVERSE_VIDEO - if (i < 2 && OPTION (Opt_reverseVideo)) + if (i < 2 && option (Opt_reverseVideo)) name = def_colorName [1 - i]; else #endif @@ -691,11 +707,11 @@ #endif case Color_pointer_fg: name = rs[Rs_color + Color_fg]; - xcol = pix_colors[Color_fg]; + xcol.set (this, name); break; default: name = rs[Rs_color + Color_bg]; - xcol = pix_colors[Color_bg]; + xcol.set (this, name); break; } } @@ -705,21 +721,11 @@ rs[Rs_color + i] = name; } -#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 (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); } /* @@ -729,44 +735,36 @@ * 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, rgba (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC)); + pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]); - rgba c0, c1; - - 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, - 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 + for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) + update_fade_color (i); +#endif } /*----------------------------------------------------------------------*/ @@ -815,7 +813,7 @@ && strcasecmp (rsmod, "mod1") >= 0 && strcasecmp (rsmod, "mod5") <= 0) requestedmeta = rsmod[3] - '0'; - map = XGetModifierMapping (xdisp); + map = XGetModifierMapping (dpy); kc = map->modifiermap; for (i = 1; i < 6; i++) @@ -827,7 +825,7 @@ if (kc[k] == 0) break; - switch (XKeycodeToKeysym (xdisp, kc[k], 0)) + switch (XKeycodeToKeysym (dpy, kc[k], 0)) { case XK_Num_Lock: ModNumLockMask = modmasks[i - 1]; @@ -893,7 +891,7 @@ XSetWindowAttributes attributes; Window top, parent; - dLocal (Display *, xdisp); + dLocal (Display *, dpy); /* grab colors before netscape does */ Get_Colours (); @@ -903,12 +901,12 @@ parent = display->root; - attributes.override_redirect = !!OPTION (Opt_override_redirect); + attributes.override_redirect = !!option (Opt_override_redirect); #if ENABLE_FRILLS - if (OPTION (Opt_borderLess)) + if (option (Opt_borderLess)) { - if (XInternAtom (xdisp, "_MOTIF_WM_INFO", True) == None) + if (XInternAtom (dpy, "_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; @@ -931,7 +929,7 @@ parent = strtol (rs[Rs_embed], 0, 0); - if (!XGetWindowAttributes (xdisp, parent, &wattr)) + if (!XGetWindowAttributes (dpy, parent, &wattr)) rxvt_fatal ("invalid window-id specified with -embed, aborting.\n"); window_calc (wattr.width, wattr.height); @@ -945,7 +943,7 @@ attributes.border_pixel = pix_colors_focused [Color_border]; attributes.colormap = cmap; - top = XCreateWindow (xdisp, parent, + top = XCreateWindow (dpy, parent, szHint.x, szHint.y, szHint.width, szHint.height, ext_bwidth, @@ -966,15 +964,15 @@ wmHint.flags = InputHint | StateHint | WindowGroupHint; wmHint.input = True; - wmHint.initial_state = OPTION (Opt_iconic) ? IconicState : NormalState; + wmHint.initial_state = option (Opt_iconic) ? IconicState : NormalState; wmHint.window_group = top; - XmbSetWMProperties (xdisp, top, NULL, NULL, (char **)argv, argc, + XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, &szHint, &wmHint, &classHint); #if ENABLE_FRILLS if (mwmhints.flags) - XChangeProperty (xdisp, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, + XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, PropModeReplace, (unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS); #endif @@ -985,24 +983,24 @@ #endif }; - XSetWMProtocols (xdisp, top, protocols, sizeof (protocols) / sizeof (protocols[0])); + XSetWMProtocols (dpy, top, protocols, sizeof (protocols) / sizeof (protocols[0])); #if ENABLE_FRILLS if (rs[Rs_transient_for]) - XSetTransientForHint (xdisp, top, (Window)strtol (rs[Rs_transient_for], 0, 0)); + XSetTransientForHint (dpy, top, (Window)strtol (rs[Rs_transient_for], 0, 0)); #endif #if ENABLE_EWMH long pid = getpid (); - XChangeProperty (xdisp, top, + XChangeProperty (dpy, 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 (xdisp, top, + XSelectInput (dpy, top, KeyPressMask #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ENABLE_FRILLS || ISO_14755 | KeyReleaseMask @@ -1013,15 +1011,15 @@ termwin_ev.start (display, top); /* vt cursor: Black-on-White is standard, but this is more popular */ - TermWin_cursor = XCreateFontCursor (xdisp, XC_xterm); + TermWin_cursor = XCreateFontCursor (dpy, XC_xterm); #ifdef HAVE_SCROLLBARS /* cursor scrollBar: Black-on-White */ - leftptr_cursor = XCreateFontCursor (xdisp, XC_left_ptr); + leftptr_cursor = XCreateFontCursor (dpy, XC_left_ptr); #endif /* the vt window */ - vt = XCreateSimpleWindow (xdisp, top, + vt = XCreateSimpleWindow (dpy, top, window_vt_x, window_vt_y, width, height, 0, @@ -1029,11 +1027,11 @@ pix_colors_focused[Color_bg]); attributes.bit_gravity = NorthWestGravity; - XChangeWindowAttributes (xdisp, vt, CWBitGravity, &attributes); + XChangeWindowAttributes (dpy, vt, CWBitGravity, &attributes); vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; - if (OPTION (Opt_pointerBlank)) + if (option (Opt_pointerBlank)) vt_emask |= PointerMotionMask; else vt_emask |= Button1MotionMask | Button3MotionMask; @@ -1044,7 +1042,10 @@ #ifdef XPM_BACKGROUND if (rs[Rs_backgroundPixmap] != NULL - && !OPTION (Opt_transparent)) +#ifndef HAVE_AFTERIMAGE + && !option (Opt_transparent) +#endif + ) { const char *p = rs[Rs_backgroundPixmap]; @@ -1062,9 +1063,9 @@ /* graphics context for the vt window */ gcvalue.foreground = pix_colors[Color_fg]; gcvalue.background = pix_colors[Color_bg]; - gcvalue.graphics_exposures = 1; + gcvalue.graphics_exposures = 0; - gc = XCreateGC (xdisp, vt, + gc = XCreateGC (dpy, vt, GCForeground | GCBackground | GCGraphicsExposures, &gcvalue); @@ -1072,11 +1073,11 @@ #ifdef RXVT_SCROLLBAR gcvalue.foreground = pix_colors[Color_topShadow]; - topShadowGC = XCreateGC (xdisp, vt, GCForeground, &gcvalue); + topShadowGC = XCreateGC (dpy, vt, GCForeground, &gcvalue); gcvalue.foreground = pix_colors[Color_bottomShadow]; - botShadowGC = XCreateGC (xdisp, vt, GCForeground, &gcvalue); + botShadowGC = XCreateGC (dpy, vt, GCForeground, &gcvalue); gcvalue.foreground = pix_colors[ (depth <= 2 ? Color_fg : Color_scroll)]; - scrollbarGC = XCreateGC (xdisp, vt, GCForeground, &gcvalue); + scrollbarGC = XCreateGC (dpy, vt, GCForeground, &gcvalue); #endif #ifdef OFF_FOCUS_FADING @@ -1095,7 +1096,6 @@ void rxvt_get_ttymode (ttymode_t *tio, int erase) { -#ifdef HAVE_TERMIOS_H /* * standard System V termios interface */ @@ -1172,53 +1172,6 @@ | ECHOCTL | ECHOKE # endif | ECHOE | ECHOK); -# else /* HAVE_TERMIOS_H */ - - /* - * sgtty interface - */ - - /* get parameters -- gtty */ - if (ioctl (STDIN_FILENO, TIOCGETP, & (tio->sg)) < 0) - { - tio->sg.sg_erase = CERASE; /* ^H */ - tio->sg.sg_kill = CKILL; /* ^U */ - } - - if (erase != -1) - tio->sg.sg_erase = (char)erase; - - tio->sg.sg_flags = (CRMOD | ECHO | EVENP | ODDP); - - /* get special characters */ - if (ioctl (STDIN_FILENO, TIOCGETC, & (tio->tc)) < 0) - { - tio->tc.t_intrc = CINTR; /* ^C */ - tio->tc.t_quitc = CQUIT; /* ^\ */ - tio->tc.t_startc = CSTART; /* ^Q */ - tio->tc.t_stopc = CSTOP; /* ^S */ - tio->tc.t_eofc = CEOF; /* ^D */ - tio->tc.t_brkc = -1; - } - - /* get local special chars */ - if (ioctl (STDIN_FILENO, TIOCGLTC, & (tio->lc)) < 0) - { - tio->lc.t_suspc = CSUSP; /* ^Z */ - tio->lc.t_dsuspc = CDSUSP; /* ^Y */ - tio->lc.t_rprntc = CRPRNT; /* ^R */ - tio->lc.t_flushc = CFLUSH; /* ^O */ - tio->lc.t_werasc = CWERASE; /* ^W */ - tio->lc.t_lnextc = CLNEXT; /* ^V */ - } - /* get line discipline */ - ioctl (STDIN_FILENO, TIOCGETD, & (tio->line)); -# ifdef NTTYDISC - tio->line = NTTYDISC; -# endif /* NTTYDISC */ - - tio->local = (LCRTBS | LCRTERA | LCTLECH | LPASS8 | LCRTKIL); -#endif /* HAVE_TERMIOS_H */ /* * Debugging @@ -1329,11 +1282,6 @@ if (!pty->get ()) rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); - pty->set_utf8_mode (enc_utf8); - - /* set initial window size */ - tt_winch (); - int er; #ifndef NO_BACKSPACE_KEY @@ -1346,6 +1294,11 @@ er = -1; rxvt_get_ttymode (&tio, er); + SET_TERMIOS (pty->tty, &tio); /* init terminal attributes */ + pty->set_utf8_mode (enc_utf8); + + /* set initial window size */ + tt_winch (); #if ENABLE_FRILLS if (rs[Rs_pty_fd]) @@ -1386,8 +1339,8 @@ _exit (EXIT_FAILURE); default: - if (!OPTION (Opt_utmpInhibit)) - pty->login (cmd_pid, OPTION (Opt_loginShell), rs[Rs_display_name]); + if (!option (Opt_utmpInhibit)) + pty->login (cmd_pid, option (Opt_loginShell), rs[Rs_display_name]); pty->close_tty (); @@ -1410,9 +1363,7 @@ { char *login; - SET_TTYMODE (STDIN_FILENO, &tio); /* init terminal attributes */ - - if (OPTION (Opt_console)) + if (option (Opt_console)) { /* be virtual console, fail silently */ #ifdef TIOCCONS unsigned int on = 1; @@ -1471,7 +1422,7 @@ argv0 = (const char *)rxvt_r_basename (shell); - if (OPTION (Opt_loginShell)) + if (option (Opt_loginShell)) { login = (char *)rxvt_malloc ((strlen (argv0) + 2) * sizeof (char));