--- rxvt-unicode/src/init.C 2006/01/17 11:02:10 1.144 +++ rxvt-unicode/src/init.C 2006/01/25 02:42:06 1.153 @@ -176,45 +176,6 @@ #endif }; -const char *const xa_names[] = - { - "TEXT", - "COMPOUND_TEXT", - "UTF8_STRING", - "MULTIPLE", - "TARGETS", - "TIMESTAMP", - "VT_SELECTION", - "INCR", - "WM_PROTOCOLS", - "WM_DELETE_WINDOW", - "CLIPBOARD", -#if ENABLE_FRILLS - "_MOTIF_WM_HINTS", -#endif -#if ENABLE_EWMH - "_NET_WM_PID", - "_NET_WM_NAME", - "_NET_WM_ICON_NAME", - "_NET_WM_PING", -#endif -#if USE_XIM - "WM_LOCALE_NAME", -#endif -#ifdef TRANSPARENT - "_XROOTPMAP_ID", - "ESETROOT_PMAP_ID", -#endif -#ifdef OFFIX_DND - "DndProtocol", - "DndSelection", -#endif -#if ENABLE_XEMBED - "_XEMBED", - "_XEMBED_INFO", -#endif - }; - bool rxvt_term::init_vars () { @@ -347,6 +308,19 @@ free (r_argv); +#if ENABLE_PERL + if (!rs[Rs_perl_ext_1]) + rs[Rs_perl_ext_1] = "default"; + + if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) + || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2]) + || (rs[Rs_perl_eval] && *rs[Rs_perl_eval])) + { + rxvt_perl.init (this); + HOOK_INVOKE ((this, HOOK_INIT, DT_END)); + } +#endif + /* * set any defaults not already set */ @@ -907,40 +881,32 @@ XClassHint classHint; XWMHints wmHint; #if ENABLE_FRILLS - Atom prop = None; MWMHints mwmhints; #endif XGCValues gcvalue; XSetWindowAttributes attributes; - XWindowAttributes gattr; Window top, parent; dDisp; -#ifdef USING_W11LIB - /* enable W11 callbacks */ - W11AddEventHandler (disp, rxvt_W11_process_x_event); -#endif + xa = display->xa; - assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); - XInternAtoms (disp, (char **)xa_names, NUM_XA, False, xa); + /* grab colors before netscape does */ + Get_Colours (); - if (OPTION (Opt_transparent)) - { - XGetWindowAttributes (disp, RootWindow (disp, display->screen), &gattr); - display->depth = gattr.depth; // doh //TODO, per-term not per-display? - } + if (!set_fonts ()) + rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); + + parent = display->root; + + attributes.override_redirect = !!OPTION (Opt_override_redirect); #if ENABLE_FRILLS if (OPTION (Opt_borderLess)) { - prop = XInternAtom(disp, "_MOTIF_WM_INFO", True); - - if (prop == None) + if (XInternAtom (disp, "_MOTIF_WM_INFO", True) == None) { /* print_warning("Window Manager does not support MWM hints. Bypassing window manager control for borderless window.\n");*/ -#ifdef PREFER_24BIT attributes.override_redirect = TRUE; -#endif mwmhints.flags = 0; } else @@ -953,14 +919,6 @@ mwmhints.flags = 0; #endif - /* grab colors before netscape does */ - Get_Colours (); - - if (!set_fonts ()) - rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); - - parent = DefaultRootWindow (disp); - #if ENABLE_XEMBED if (rs[Rs_embed]) { @@ -978,45 +936,44 @@ window_calc (0, 0); /* sub-window placement & size in rxvt_resize_subwindows () */ -#ifdef PREFER_24BIT attributes.background_pixel = pix_colors_focused[Color_border]; - attributes.border_pixel = pix_colors_focused[Color_border]; - attributes.colormap = display->cmap; + attributes.border_pixel = pix_colors_focused[Color_border]; + attributes.colormap = display->cmap; + top = XCreateWindow (disp, parent, szHint.x, szHint.y, szHint.width, szHint.height, ext_bwidth, display->depth, InputOutput, display->visual, - CWColormap | CWBackPixel | CWBorderPixel, &attributes); -#else - top = XCreateSimpleWindow (disp, parent, - szHint.x, szHint.y, - szHint.width, szHint.height, - ext_bwidth, - pix_colors_focused[Color_border], - pix_colors_focused[Color_border]); -#endif + CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect, + &attributes); this->parent[0] = top; old_width = szHint.width; old_height = szHint.height; - process_xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST); + process_xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST); process_xterm_seq (XTerm_iconName, rs[Rs_iconName], CHAR_ST); - classHint.res_name = (char *)rs[Rs_name]; + classHint.res_name = (char *)rs[Rs_name]; classHint.res_class = (char *)RESCLASS; - wmHint.flags = InputHint | StateHint | WindowGroupHint; - wmHint.input = True; + wmHint.flags = InputHint | StateHint | WindowGroupHint; + wmHint.input = True; wmHint.initial_state = OPTION (Opt_iconic) ? IconicState : NormalState; - wmHint.window_group = top; + wmHint.window_group = top; XmbSetWMProperties (disp, 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, + PropModeReplace, (unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS); +#endif + Atom protocols[] = { xa[XA_WM_DELETE_WINDOW], #if ENABLE_EWMH @@ -1051,12 +1008,6 @@ termwin_ev.start (display, top); -#if ENABLE_FRILLS - if (mwmhints.flags) - XChangeProperty (disp, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, - PropModeReplace, (unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS); -#endif - /* vt cursor: Black-on-White is standard, but this is more popular */ TermWin_cursor = XCreateFontCursor (disp, XC_xterm); @@ -1067,16 +1018,11 @@ /* the vt window */ vt = XCreateSimpleWindow (disp, top, - window_vt_x, - window_vt_y, - width, - height, - 0, - pix_colors_focused[Color_fg], - pix_colors_focused[Color_bg]); -#ifdef DEBUG_X - XStoreName (disp, vt, "vt window"); -#endif + window_vt_x, window_vt_y, + width, height, + 0, + pix_colors_focused[Color_fg], + pix_colors_focused[Color_bg]); attributes.bit_gravity = NorthWestGravity; XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes); @@ -1110,12 +1056,13 @@ #endif /* graphics context for the vt window */ - gcvalue.foreground = pix_colors[Color_fg]; - gcvalue.background = pix_colors[Color_bg]; + gcvalue.foreground = pix_colors[Color_fg]; + gcvalue.background = pix_colors[Color_bg]; gcvalue.graphics_exposures = 1; + gc = XCreateGC (disp, vt, - GCForeground | GCBackground | GCGraphicsExposures, - &gcvalue); + GCForeground | GCBackground | GCGraphicsExposures, + &gcvalue); drawable = new rxvt_drawable (display, vt); @@ -1136,16 +1083,6 @@ pointer_unblank (); scr_recolour (); - -#if ENABLE_XEMBED - if (rs[Rs_embed]) - { - long info[2] = { 0, XEMBED_MAPPED }; - - XChangeProperty (disp, parent, xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO], - 32, PropModeReplace, (unsigned char *)&info, 2); - } -#endif } /* ------------------------------------------------------------------------- * @@ -1372,23 +1309,23 @@ #if ENABLE_FRILLS if (rs[Rs_pty_fd]) { - pty.pty = atoi (rs[Rs_pty_fd]); + pty->pty = atoi (rs[Rs_pty_fd]); - if (pty.pty >= 0) + if (pty->pty >= 0) { if (getfd_hook) - pty.pty = (*getfd_hook) (pty.pty); + pty->pty = (*getfd_hook) (pty->pty); - if (pty.pty < 0 || fcntl (pty.pty, F_SETFL, O_NONBLOCK)) + if (pty->pty < 0 || fcntl (pty->pty, F_SETFL, O_NONBLOCK)) rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); } } else #endif - if (!pty.get ()) + if (!pty->get ()) rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); - pty.set_utf8_mode (enc_utf8); + pty->set_utf8_mode (enc_utf8); /* set initial window size */ tt_winch (); @@ -1422,20 +1359,20 @@ case 0: init_env (); - if (!pty.make_controlling_tty ()) + if (!pty->make_controlling_tty ()) fprintf (stderr, "%s: could not obtain control of tty.", RESNAME); else { /* Reopen stdin, stdout and stderr over the tty file descriptor */ - dup2 (pty.tty, STDIN_FILENO); - dup2 (pty.tty, STDOUT_FILENO); - dup2 (pty.tty, STDERR_FILENO); + dup2 (pty->tty, STDIN_FILENO); + dup2 (pty->tty, STDOUT_FILENO); + dup2 (pty->tty, STDERR_FILENO); // close all our file handles that we do no longer need for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) { - if ((*t)->pty.pty > 2) close ((*t)->pty.pty); - if ((*t)->pty.tty > 2) close ((*t)->pty.tty); + if ((*t)->pty->pty > 2) close ((*t)->pty->pty); + if ((*t)->pty->tty > 2) close ((*t)->pty->tty); } run_child (argv); @@ -1445,26 +1382,14 @@ _exit (EXIT_FAILURE); default: - { -#if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) - int fdstdin; - - fdstdin = dup (STDIN_FILENO); - dup2 (pty.tty, STDIN_FILENO); -#endif + if (!OPTION (Opt_utmpInhibit)) + pty->login (cmd_pid, OPTION (Opt_loginShell), rs[Rs_display_name]); -#ifdef UTMP_SUPPORT - privileged_utmp (SAVE); -#endif + pty->close_tty (); -#if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) - - dup2 (fdstdin, STDIN_FILENO); - close (fdstdin); -#endif - } + child_ev.start (cmd_pid); - pty.close_tty (); /* keep STDERR_FILENO, pty.pty, display->fd () open */ + HOOK_INVOKE ((this, HOOK_CHILD_START, DT_INT, cmd_pid, DT_END)); break; } }