--- rxvt-unicode/src/init.C 2005/02/04 11:41:23 1.108 +++ rxvt-unicode/src/init.C 2005/02/20 19:45:30 1.116 @@ -183,13 +183,17 @@ "TIMESTAMP", "VT_SELECTION", "INCR", + "WM_PROTOCOLS", "WM_DELETE_WINDOW", "CLIPBOARD", #if ENABLE_FRILLS - "_NET_WM_PID", "_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", @@ -202,6 +206,10 @@ "DndProtocol", "DndSelection", #endif +#if ENABLE_XEMBED + "_XEMBED", + "_XEMBED_INFO", +#endif }; bool @@ -227,8 +235,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 +681,7 @@ priv_modes |= PrivMode_scrollBar; SavedModes |= PrivMode_scrollBar; } + if (menubar_visible ()) { priv_modes |= PrivMode_menuBar; @@ -928,6 +935,7 @@ long vt_emask; XSetWindowAttributes attributes; XWindowAttributes gattr; + Window top, parent; dDisp; #ifdef USING_W11LIB @@ -964,9 +972,7 @@ } } else - { - mwmhints.flags = 0; - } + mwmhints.flags = 0; #endif /* grab colors before netscape does */ @@ -975,32 +981,50 @@ 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]) + { + XWindowAttributes wattr; + + parent = strtol (rs[Rs_embed], 0, 0); + + if (!XGetWindowAttributes (disp, parent, &wattr)) + rxvt_fatal ("invalid window-id specified with -embed, aborting.\n"); + + window_calc (wattr.width, wattr.height); + } + +#endif window_calc (0, 0); - old_width = szHint.width; - old_height = szHint.height; /* 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); + top = XCreateWindow (disp, parent, + 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, parent, + 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 +1034,43 @@ 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; + + XmbSetWMProperties (disp, top, NULL, NULL, (char **)argv, argc, + &szHint, &wmHint, &classHint); - XSetWMProperties (disp, TermWin.parent[0], NULL, NULL, - (char **)argv, argc, &szHint, &wmHint, &classHint); + Atom protocols[] = { + xa[XA_WM_DELETE_WINDOW], +#if ENABLE_EWMH + xa[XA_NET_WM_PING], +#endif + }; - /* Enable delete window protocol */ - XSetWMProtocols (disp, TermWin.parent[0], - &xa[XA_WMDELETEWINDOW], 1); + XSetWMProtocols (disp, top, protocols, sizeof (protocols) / sizeof (protocols[0])); -#if ENABLE_FRILLS +#if ENABLE_EWMH long pid = getpid (); - XChangeProperty (disp, TermWin.parent[0], + XChangeProperty (disp, top, xa[XA_NET_WM_PID], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1); + + // _NET_WM_WINDOW_TYPE is NORMAL, which is the default #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 +1083,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 (), @@ -1069,8 +1100,6 @@ vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; - pointer_unblank (); - #ifdef POINTER_BLANK if (options & Opt_pointerBlank) vt_emask |= PointerMotionMask; @@ -1084,7 +1113,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 (), @@ -1149,7 +1178,18 @@ pix_colors = pix_colors_unfocused; #endif + 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 } /* ------------------------------------------------------------------------- * @@ -1388,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); @@ -1409,6 +1457,11 @@ rxvt_get_ttymode (&tio, er); +#if ENABLE_FRILLS + if (rs[Rs_pty_fd]) + return; +#endif + sw_chld.start (SIGCHLD); #ifndef __QNX__ @@ -1416,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 ();