--- rxvt-unicode/src/init.C 2007/12/12 09:33:48 1.227 +++ rxvt-unicode/src/init.C 2008/01/25 16:04:57 1.243 @@ -12,9 +12,7 @@ * Copyright (c) 1997,1998 Oezguer Kesim * Copyright (c) 1998-2001 Geoff Wing * - extensive modifications - * Copyright (c) 1999 D J Hawkey Jr - * - QNX support - * Copyright (c) 2003-2006 Marc Lehmann + * Copyright (c) 2003-2008 Marc Lehmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,6 +36,7 @@ #include "rxvt.h" /* NECESSARY */ #include "rxvtutil.h" #include "init.h" +#include "keyboard.h" #include @@ -285,12 +284,7 @@ void rxvt_term::init_vars () { - 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; MEvent.time = CurrentTime; MEvent.button = AnyButton; @@ -302,12 +296,10 @@ ext_bwidth = EXTERNALBORDERWIDTH; lineSpace = LINESPACE; saveLines = SAVELINES; - numpix_colors = TOTAL_COLORS; refresh_type = SLOW_REFRESH; oldcursor.row = oldcursor.col = -1; - last_bot = last_state = -1; set_option (Opt_scrollBar); set_option (Opt_scrollTtyOutput); @@ -320,18 +312,13 @@ set_option (Opt_iso14755_52); } -void -rxvt_term::init_secondary () +static void +init_secondary () { int i; - /* - * Close all unused file descriptors - * We don't want them, we don't need them. - */ if ((i = open ("/dev/null", O_RDONLY)) < 0) { - /* TODO: BOO HISS */ dup2 (STDERR_FILENO, STDIN_FILENO); } else if (i != STDIN_FILENO) @@ -341,17 +328,6 @@ } dup2 (STDERR_FILENO, STDOUT_FILENO); - -#if 0 // schmorp sayz closing filies is murder - for (i = STDERR_FILENO + 1; i < num_fds; i++) - { -#ifdef __sgi /* Alex Coventry says we need 4 & 7 too */ - if (i == 4 || i == 7) - continue; -#endif - close (i); - } -#endif } /*----------------------------------------------------------------------*/ @@ -418,6 +394,8 @@ #endif #ifdef HAVE_AFTERIMAGE + set_application_name ((char*)rs[Rs_name]); + set_output_threshold (OUTPUT_LEVEL_WARNING); asv = create_asvisual_for_id (dpy, display->screen, depth, XVisualIDFromVisual (visual), cmap, NULL); #endif free (r_argv); @@ -558,6 +536,125 @@ /*----------------------------------------------------------------------*/ void +rxvt_term::init (int argc, const char *const *argv, stringvec *envv) +{ + this->envv = envv; + + SET_R (this); + set_locale (""); + set_environ (envv); // few things in X do not call setlocale :( + + init_vars (); + + init_secondary (); + + const char **cmd_argv = init_resources (argc, argv); + +#ifdef KEYSYM_RESOURCE + keyboard->register_done (); +#endif + +#ifdef HAVE_SCROLLBARS + if (option (Opt_scrollBar)) + scrollBar.setIdle (); /* set existence for size calculations */ +#endif + + pty = ptytty::create (); + + create_windows (argc, argv); + + init_xlocale (); + + scr_reset (); // initialize screen + +#if 0 + XSynchronize (dpy, True); +#endif + +#ifdef HAVE_SCROLLBARS + if (option (Opt_scrollBar)) + resize_scrollbar (); /* create and map scrollbar */ +#endif +#ifdef HAVE_BG_PIXMAP + { + bgPixmap.set_target (this); + bgPixmap.invalidate (); + +#ifdef ENABLE_TRANSPARENCY + if (option (Opt_transparent)) + { + bgPixmap.set_transparent (); + +#ifdef HAVE_AFTERIMAGE + if (rs [Rs_blurradius]) + bgPixmap.set_blur_radius (rs [Rs_blurradius]); +#endif + if (ISSET_PIXCOLOR (Color_tint)) + bgPixmap.set_tint (pix_colors_focused [Color_tint]); + + if (rs [Rs_shade]) + bgPixmap.set_shade (rs [Rs_shade]); + + bgPixmap.set_root_pixmap (); + XSelectInput (dpy, display->root, PropertyChangeMask); + rootwin_ev.start (display, display->root); + } +#endif + +#ifdef BG_IMAGE_FROM_FILE + if (rs[Rs_backgroundPixmap]) + { + const char *p = rs[Rs_backgroundPixmap]; + + if ((p = strchr (p, ';')) != 0) + { + p++; + bgPixmap.set_geometry (p); + } + else + bgPixmap.set_defaultGeometry (); + + if (bgPixmap.set_file (rs[Rs_backgroundPixmap])) + if (!bgPixmap.window_position_sensitive ()) + update_background (); + } +#endif + } +#endif + +#if ENABLE_PERL + rootwin_ev.start (display, display->root); +#endif + + set_colorfgbg (); + + init_command (cmd_argv); + + free (cmd_argv); + + if (pty->pty >= 0) + pty_ev.start (pty->pty, ev::READ); + + HOOK_INVOKE ((this, HOOK_START, DT_END)); + +#if ENABLE_XEMBED + if (rs[Rs_embed]) + { + long info[2] = { 0, XEMBED_MAPPED }; + + XChangeProperty (dpy, parent[0], xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO], + 32, PropModeReplace, (unsigned char *)&info, 2); + } +#endif + + XMapWindow (dpy, vt); + XMapWindow (dpy, parent[0]); + + refresh_check (); +} + +/*----------------------------------------------------------------------*/ +void rxvt_term::init_env () { int i; @@ -1084,11 +1181,6 @@ /* vt cursor: Black-on-White is standard, but this is more popular */ TermWin_cursor = XCreateFontCursor (dpy, XC_xterm); -#ifdef HAVE_SCROLLBARS - /* cursor scrollBar: Black-on-White */ - leftptr_cursor = XCreateFontCursor (dpy, XC_left_ptr); -#endif - /* the vt window */ vt = XCreateSimpleWindow (dpy, top, window_vt_x, window_vt_y, @@ -1122,15 +1214,6 @@ drawable = new rxvt_drawable (this, vt); -#ifdef RXVT_SCROLLBAR - gcvalue.foreground = pix_colors[Color_topShadow]; - topShadowGC = XCreateGC (dpy, vt, GCForeground, &gcvalue); - gcvalue.foreground = pix_colors[Color_bottomShadow]; - botShadowGC = XCreateGC (dpy, vt, GCForeground, &gcvalue); - gcvalue.foreground = pix_colors[ (depth <= 2 ? Color_fg : Color_scroll)]; - scrollbarGC = XCreateGC (dpy, vt, GCForeground, &gcvalue); -#endif - #ifdef OFF_FOCUS_FADING // initially we are in unfocused state if (rs[Rs_fade]) @@ -1145,16 +1228,16 @@ * GET TTY CURRENT STATE * * ------------------------------------------------------------------------- */ void -rxvt_get_ttymode (ttymode_t *tio, int erase) +rxvt_get_ttymode (struct termios *tio, int erase) { /* * standard System V termios interface */ - if (GET_TERMIOS (STDIN_FILENO, tio) < 0) + if (tcgetattr (STDIN_FILENO, tio) < 0) { // return error - use system defaults, // where possible, and zero elsewhere - memset (tio, 0, sizeof (ttymode_t)); + memset (tio, 0, sizeof (struct termios)); tio->c_cc[VINTR] = CINTR; tio->c_cc[VQUIT] = CQUIT; @@ -1343,7 +1426,10 @@ er = -1; rxvt_get_ttymode (&tio, er); - SET_TERMIOS (pty->tty, &tio); /* init terminal attributes */ + /* init terminal attributes */ + cfsetospeed (&tio, BAUDRATE); + cfsetispeed (&tio, BAUDRATE); + tcsetattr (pty->tty, TCSANOW, &tio); pty->set_utf8_mode (enc_utf8); /* set initial window size */