--- rxvt-unicode/src/init.C 2005/02/14 18:47:54 1.109 +++ rxvt-unicode/src/init.C 2005/02/19 01:07:58 1.112 @@ -183,6 +183,7 @@ "TIMESTAMP", "VT_SELECTION", "INCR", + "WM_PROTOCOLS", "WM_DELETE_WINDOW", "CLIPBOARD", #if ENABLE_FRILLS @@ -202,6 +203,9 @@ "DndProtocol", "DndSelection", #endif +#if ENABLE_XEMBED + "_XEMBED", +#endif }; bool @@ -227,8 +231,6 @@ MEvent.button = AnyButton; options = DEFAULT_OPTIONS; want_refresh = 1; - cmd_pid = -1; - pty.pty = pty.tty = -1; priv_modes = SavedModes = PrivMode_Default; TermWin.focus = 0; TermWin.ncol = 80; @@ -675,6 +677,7 @@ priv_modes |= PrivMode_scrollBar; SavedModes |= PrivMode_scrollBar; } + if (menubar_visible ()) { priv_modes |= PrivMode_menuBar; @@ -976,13 +979,15 @@ if (!set_fonts ()) rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); -#if ENABLE_FRILLS +#if ENABLE_XEMBED if (rs[Rs_embed]) { + XWindowAttributes wattr; + top = strtol (rs[Rs_embed], 0, 0); - XWindowAttributes wattr; - XGetWindowAttributes (disp, top, &wattr); + if (!XGetWindowAttributes (disp, top, &wattr)) + rxvt_fatal ("invalid window-id specified with -embed, aborting.\n"); window_calc (wattr.width, wattr.height); @@ -1012,19 +1017,19 @@ attributes.border_pixel = pix_colors_focused[Color_border]; attributes.colormap = display->cmap; top = XCreateWindow (disp, DefaultRootWindow (disp), - szHint.x, szHint.y, - szHint.width, szHint.height, - TermWin.ext_bwidth, - display->depth, InputOutput, - display->visual, - CWColormap | CWBackPixel | CWBorderPixel, &attributes); + szHint.x, szHint.y, + szHint.width, szHint.height, + TermWin.ext_bwidth, + display->depth, InputOutput, + display->visual, + CWColormap | CWBackPixel | CWBorderPixel, &attributes); #else top = XCreateSimpleWindow (disp, DefaultRootWindow (disp), - szHint.x, szHint.y, - szHint.width, szHint.height, - TermWin.ext_bwidth, - pix_colors_focused[Color_border], - pix_colors_focused[Color_border]); + szHint.x, szHint.y, + szHint.width, szHint.height, + TermWin.ext_bwidth, + pix_colors_focused[Color_border], + pix_colors_focused[Color_border]); #endif } @@ -1048,7 +1053,7 @@ (char **)argv, argc, &szHint, &wmHint, &classHint); /* Enable delete window protocol */ - XSetWMProtocols (disp, top, &xa[XA_WMDELETEWINDOW], 1); + XSetWMProtocols (disp, top, &xa[XA_WM_DELETE_WINDOW], 1); #if ENABLE_FRILLS long pid = getpid (); @@ -1064,8 +1069,8 @@ | KeyReleaseMask #endif | FocusChangeMask | VisibilityChangeMask - | ExposureMask - | StructureNotifyMask); + | ExposureMask | StructureNotifyMask); + termwin_ev.start (display, top); #if ENABLE_FRILLS @@ -1419,8 +1424,16 @@ void rxvt_term::run_command (const char *const *argv) { - if (!pty.get ()) - rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); +#if ENABLE_FRILLS + if (rs[Rs_pty_fd]) + { + pty.pty = atoi (rs[Rs_pty_fd]); + fcntl (pty.pty, F_SETFL, O_NONBLOCK); + } + else +#endif + if (!pty.get ()) + rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); pty.set_utf8_mode (enc_utf8); @@ -1440,6 +1453,11 @@ rxvt_get_ttymode (&tio, er); +#if ENABLE_FRILLS + if (rs[Rs_pty_fd]) + return; +#endif + sw_chld.start (SIGCHLD); #ifndef __QNX__ @@ -1447,7 +1465,10 @@ switch (cmd_pid = fork ()) { case -1: - rxvt_fatal ("can't fork, aborting.\n"); + { + cmd_pid = 0; + rxvt_fatal ("can't fork, aborting.\n"); + } case 0: init_env ();