--- rxvt-unicode/src/init.C 2005/02/04 11:41:23 1.108 +++ 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; @@ -928,6 +931,7 @@ long vt_emask; XSetWindowAttributes attributes; XWindowAttributes gattr; + Window top; dDisp; #ifdef USING_W11LIB @@ -975,31 +979,64 @@ if (!set_fonts ()) rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); - window_calc (0, 0); - old_width = szHint.width; - old_height = szHint.height; +#if ENABLE_XEMBED + if (rs[Rs_embed]) + { + XWindowAttributes wattr; + + top = strtol (rs[Rs_embed], 0, 0); + + if (!XGetWindowAttributes (disp, top, &wattr)) + rxvt_fatal ("invalid window-id specified with -embed, aborting.\n"); + + window_calc (wattr.width, wattr.height); - /* sub-window placement & size in rxvt_resize_subwindows () */ +#if 0 + if (wattr.map_state == IsViewable) + { + TermWin.mapped = 1; + 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: focusin etc. + } +#else + // it'S easiets just to unmap/map to get all state correctly set-up + XUnmapWindow (disp, top); +#endif + } + else +#endif + { + 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; - TermWin.parent[0] = XCreateWindow (disp, DefaultRootWindow (disp), - szHint.x, szHint.y, - szHint.width, szHint.height, - TermWin.ext_bwidth, - display->depth, InputOutput, - display->visual, - CWColormap | CWBackPixel | CWBorderPixel, &attributes); + attributes.background_pixel = pix_colors_focused[Color_border]; + 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); #else - TermWin.parent[0] = 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]); + 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]); #endif + } + + TermWin.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_iconName, rs[Rs_iconName], CHAR_ST); @@ -1010,36 +1047,35 @@ wmHint.flags = InputHint | StateHint | WindowGroupHint; wmHint.input = True; wmHint.initial_state = options & Opt_iconic ? IconicState : NormalState; - wmHint.window_group = TermWin.parent[0]; + wmHint.window_group = top; - XSetWMProperties (disp, TermWin.parent[0], NULL, NULL, + XSetWMProperties (disp, top, NULL, NULL, (char **)argv, argc, &szHint, &wmHint, &classHint); /* Enable delete window protocol */ - XSetWMProtocols (disp, TermWin.parent[0], - &xa[XA_WMDELETEWINDOW], 1); + XSetWMProtocols (disp, top, &xa[XA_WM_DELETE_WINDOW], 1); #if ENABLE_FRILLS long pid = getpid (); - XChangeProperty (disp, TermWin.parent[0], + XChangeProperty (disp, top, xa[XA_NET_WM_PID], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1); #endif - XSelectInput (disp, TermWin.parent[0], + XSelectInput (disp, top, KeyPressMask #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ENABLE_FRILLS || ISO_14755 | KeyReleaseMask #endif | FocusChangeMask | VisibilityChangeMask - | ExposureMask - | StructureNotifyMask); - termwin_ev.start (display, TermWin.parent[0]); + | ExposureMask | StructureNotifyMask); + + termwin_ev.start (display, top); #if ENABLE_FRILLS if (mwmhints.flags) - XChangeProperty (disp, TermWin.parent[0], xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, + XChangeProperty (disp, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, PropModeReplace, (unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS); #endif @@ -1052,7 +1088,7 @@ #endif /* the vt window */ - TermWin.vt = XCreateSimpleWindow (disp, TermWin.parent[0], + TermWin.vt = XCreateSimpleWindow (disp, top, window_vt_x, window_vt_y, TermWin_TotalWidth (), @@ -1084,7 +1120,7 @@ #if defined(MENUBAR) && (MENUBAR_MAX > 1) if (menuBar_height ()) { - menuBar.win = XCreateSimpleWindow (disp, TermWin.parent[0], + menuBar.win = XCreateSimpleWindow (disp, top, window_vt_x, 0, TermWin_TotalWidth (), menuBar_TotalHeight (), @@ -1388,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); @@ -1409,6 +1453,11 @@ rxvt_get_ttymode (&tio, er); +#if ENABLE_FRILLS + if (rs[Rs_pty_fd]) + return; +#endif + sw_chld.start (SIGCHLD); #ifndef __QNX__ @@ -1416,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 ();