--- rxvt-unicode/src/init.C 2005/02/14 18:47:54 1.109 +++ rxvt-unicode/src/init.C 2005/02/19 04:16:49 1.113 @@ -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); @@ -993,11 +998,11 @@ refresh_type = FAST_REFRESH; XClearWindow (disp, top); // TODO: make XMapNotify-event-code a function and call it - // TODO: how can I detetc visibility without unmpa/map? + // TODO: how can I detect visibility without unmap/map? // TODO: focusin etc. } #else - // it'S easiets just to unmap/map to get all state correctly set-up + // it's easiest just to unmap/map to get all state correctly set-up XUnmapWindow (disp, top); #endif } @@ -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 @@ -1100,8 +1105,6 @@ vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; - pointer_unblank (); - #ifdef POINTER_BLANK if (options & Opt_pointerBlank) vt_emask |= PointerMotionMask; @@ -1180,7 +1183,13 @@ pix_colors = pix_colors_unfocused; #endif + pointer_unblank (); scr_recolour (); + +#if ENABLE_XEMBED + // why this is necessary, I don't know, race condition?? + XMoveWindow (disp, TermWin.vt, window_vt_x, window_vt_y); +#endif } /* ------------------------------------------------------------------------- * @@ -1419,8 +1428,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 +1457,11 @@ rxvt_get_ttymode (&tio, er); +#if ENABLE_FRILLS + if (rs[Rs_pty_fd]) + return; +#endif + sw_chld.start (SIGCHLD); #ifndef __QNX__ @@ -1447,7 +1469,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 ();