--- rxvt-unicode/src/init.C 2005/02/17 20:52:48 1.111 +++ rxvt-unicode/src/init.C 2005/12/21 19:50:16 1.125 @@ -36,6 +36,8 @@ #include "rxvtutil.h" #include "init.h" +#include + #include const char *const def_colorName[] = @@ -171,6 +173,9 @@ #if TINTING NULL, #endif +#if OFF_FOCUS_FADING + "black", +#endif }; const char *const xa_names[] = @@ -183,13 +188,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,14 +211,15 @@ "DndProtocol", "DndSelection", #endif +#if ENABLE_XEMBED + "_XEMBED", + "_XEMBED_INFO", +#endif }; bool rxvt_term::init_vars () { - sw_term.start (SIGTERM); - sw_int.start (SIGINT); - pix_colors_focused = new rxvt_color [TOTAL_COLORS]; #ifdef OFF_FOCUS_FADING pix_colors_unfocused = new rxvt_color [TOTAL_COLORS]; @@ -220,7 +230,7 @@ return false; #if defined(XPM_BACKGROUND) || defined(TRANSPARENT) - TermWin.pixmap = None; + pixmap = None; #endif MEvent.time = CurrentTime; @@ -228,13 +238,13 @@ options = DEFAULT_OPTIONS; want_refresh = 1; priv_modes = SavedModes = PrivMode_Default; - TermWin.focus = 0; - TermWin.ncol = 80; - TermWin.nrow = 24; - TermWin.int_bwidth = INTERNALBORDERWIDTH; - TermWin.ext_bwidth = EXTERNALBORDERWIDTH; - TermWin.lineSpace = LINESPACE; - TermWin.saveLines = SAVELINES; + focus = 0; + ncol = 80; + nrow = 24; + int_bwidth = INTERNALBORDERWIDTH; + ext_bwidth = EXTERNALBORDERWIDTH; + lineSpace = LINESPACE; + saveLines = SAVELINES; numpix_colors = TOTAL_COLORS; refresh_limit = 1; @@ -338,19 +348,7 @@ get_options (r_argc, r_argv); -#ifdef LOCAL_X_IS_UNIX - if (rs[Rs_display_name][0] == ':') - { - val = rxvt_malloc (5 + strlen (rs[Rs_display_name])); - strcpy (val, "unix"); - strcat (val, rs[Rs_display_name]); - display = displays.get (val); - free (val); - } -#endif - - if (!display - && ! (display = displays.get (rs[Rs_display_name]))) + if (!(display = displays.get (rs[Rs_display_name]))) rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); extract_resources (); @@ -375,15 +373,17 @@ } if (rs[Rs_saveLines] && (i = atoi (rs[Rs_saveLines])) >= 0) - TermWin.saveLines = BOUND_POSITIVE_INT16 (i); + saveLines = min (i, std::numeric_limits::max ()); #if ENABLE_FRILLS if (rs[Rs_int_bwidth] && (i = atoi (rs[Rs_int_bwidth])) >= 0) - TermWin.int_bwidth = min (i, 100); /* arbitrary limit */ + int_bwidth = min (i, std::numeric_limits::max ()); + if (rs[Rs_ext_bwidth] && (i = atoi (rs[Rs_ext_bwidth])) >= 0) - TermWin.ext_bwidth = min (i, 100); /* arbitrary limit */ + ext_bwidth = min (i, std::numeric_limits::max ()); + if (rs[Rs_lineSpace] && (i = atoi (rs[Rs_lineSpace])) >= 0) - TermWin.lineSpace = min (i, 100); /* arbitrary limit */ + lineSpace = min (i, std::numeric_limits::max ()); #endif #ifdef POINTER_BLANK @@ -394,7 +394,7 @@ #endif /* no point having a scrollbar without having any scrollback! */ - if (!TermWin.saveLines) + if (!saveLines) options &= ~Opt_scrollBar; #ifdef PRINTPIPE @@ -464,7 +464,7 @@ #ifndef XTERM_REVERSE_VIDEO /* this is how we implement reverseVideo */ if (options & Opt_reverseVideo) - SWAP_IT (rs[Rs_color + Color_fg], rs[Rs_color + Color_bg], const char *); + ::swap (rs[Rs_color + Color_fg], rs[Rs_color + Color_bg]); #endif /* convenient aliases for setting fg/bg to colors */ @@ -524,14 +524,14 @@ sprintf (env_display, "DISPLAY=%s", val); /* avoiding the math library: - * i = (int) (ceil (log10 ((unsigned int)TermWin.parent[0]))) */ - for (i = 0, u = (unsigned int)TermWin.parent[0]; u; u /= 10, i++) + * i = (int) (ceil (log10 ((unsigned int)parent[0]))) */ + for (i = 0, u = (unsigned int)parent[0]; u; u /= 10, i++) ; - MAX_IT (i, 1); + max_it (i, 1); env_windowid = (char *)rxvt_malloc ((i + 10) * sizeof (char)); sprintf (env_windowid, "WINDOWID=%u", - (unsigned int)TermWin.parent[0]); + (unsigned int)parent[0]); /* add entries to the environment: * @ DISPLAY: in case we started with -display @@ -743,13 +743,15 @@ } pix_colors[i] = xcol; -#ifdef OFF_FOCUS_FADING - if (rs[Rs_fade]) - pix_colors_unfocused[i] = xcol.fade (display, atoi (rs[Rs_fade])); -#endif SET_PIXCOLOR (i); } +#ifdef OFF_FOCUS_FADING + if (rs[Rs_fade]) + for (i = 0; i < (display->depth <= 2 ? 2 : NRS_COLORS); i++) + pix_colors_unfocused[i] = pix_colors_focused[i].fade (display, atoi (rs[Rs_fade]), pix_colors[Color_fade]); +#endif + if (display->depth <= 2) { if (!rs[Rs_color + Color_pointer_fg]) pix_colors[Color_pointer_fg] = pix_colors[Color_fg]; @@ -766,7 +768,8 @@ #ifdef KEEP_SCROLLCOLOR if (display->depth <= 2) - { /* Monochrome */ + { + /* Monochrome */ pix_colors[Color_scroll] = pix_colors[Color_fg]; pix_colors[Color_topShadow] = pix_colors[Color_bg]; pix_colors[Color_bottomShadow] = pix_colors[Color_bg]; @@ -927,7 +930,7 @@ long vt_emask; XSetWindowAttributes attributes; XWindowAttributes gattr; - Window top; + Window top, parent; dDisp; #ifdef USING_W11LIB @@ -964,9 +967,7 @@ } } else - { - mwmhints.flags = 0; - } + mwmhints.flags = 0; #endif /* grab colors before netscape does */ @@ -975,61 +976,46 @@ if (!set_fonts ()) rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); -#if ENABLE_FRILLS + parent = DefaultRootWindow (disp); + +#if ENABLE_XEMBED if (rs[Rs_embed]) { XWindowAttributes wattr; - top = strtol (rs[Rs_embed], 0, 0); + parent = strtol (rs[Rs_embed], 0, 0); - if (!XGetWindowAttributes (disp, top, &wattr)) + if (!XGetWindowAttributes (disp, parent, &wattr)) rxvt_fatal ("invalid window-id specified with -embed, aborting.\n"); window_calc (wattr.width, wattr.height); - -#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 () */ + 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; - 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); + attributes.background_pixel = pix_colors_focused[Color_border]; + 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, 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, + ext_bwidth, + pix_colors_focused[Color_border], + pix_colors_focused[Color_border]); #endif - } - TermWin.parent[0] = top; + this->parent[0] = top; old_width = szHint.width; old_height = szHint.height; @@ -1045,18 +1031,26 @@ wmHint.initial_state = options & Opt_iconic ? IconicState : NormalState; wmHint.window_group = top; - XSetWMProperties (disp, top, NULL, NULL, - (char **)argv, argc, &szHint, &wmHint, &classHint); + XmbSetWMProperties (disp, top, NULL, NULL, (char **)argv, argc, + &szHint, &wmHint, &classHint); - /* Enable delete window protocol */ - XSetWMProtocols (disp, top, &xa[XA_WMDELETEWINDOW], 1); + Atom protocols[] = { + xa[XA_WM_DELETE_WINDOW], +#if ENABLE_EWMH + xa[XA_NET_WM_PING], +#endif + }; -#if ENABLE_FRILLS + XSetWMProtocols (disp, top, protocols, sizeof (protocols) / sizeof (protocols[0])); + +#if ENABLE_EWMH long pid = getpid (); 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, top, @@ -1065,8 +1059,8 @@ | KeyReleaseMask #endif | FocusChangeMask | VisibilityChangeMask - | ExposureMask - | StructureNotifyMask); + | ExposureMask | StructureNotifyMask); + termwin_ev.start (display, top); #if ENABLE_FRILLS @@ -1084,7 +1078,7 @@ #endif /* the vt window */ - TermWin.vt = XCreateSimpleWindow (disp, top, + vt = XCreateSimpleWindow (disp, top, window_vt_x, window_vt_y, TermWin_TotalWidth (), @@ -1093,16 +1087,14 @@ pix_colors_focused[Color_fg], pix_colors_focused[Color_bg]); #ifdef DEBUG_X - XStoreName (disp, TermWin.vt, "vt window"); + XStoreName (disp, vt, "vt window"); #endif attributes.bit_gravity = NorthWestGravity; - XChangeWindowAttributes (disp, TermWin.vt, CWBitGravity, &attributes); + XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes); vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; - pointer_unblank (); - #ifdef POINTER_BLANK if (options & Opt_pointerBlank) vt_emask |= PointerMotionMask; @@ -1110,8 +1102,8 @@ #endif vt_emask |= Button1MotionMask | Button3MotionMask; - XSelectInput (disp, TermWin.vt, vt_emask); - vt_ev.start (display, TermWin.vt); + XSelectInput (disp, vt, vt_emask); + vt_ev.start (display, vt); #if defined(MENUBAR) && (MENUBAR_MAX > 1) if (menuBar_height ()) @@ -1160,19 +1152,19 @@ gcvalue.foreground = pix_colors[Color_fg]; gcvalue.background = pix_colors[Color_bg]; gcvalue.graphics_exposures = 1; - TermWin.gc = XCreateGC (disp, TermWin.vt, + gc = XCreateGC (disp, vt, GCForeground | GCBackground | GCGraphicsExposures, &gcvalue); - TermWin.drawable = new rxvt_drawable (display, TermWin.vt); + drawable = new rxvt_drawable (display, vt); #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) gcvalue.foreground = pix_colors[Color_topShadow]; - topShadowGC = XCreateGC (disp, TermWin.vt, GCForeground, &gcvalue); + topShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); gcvalue.foreground = pix_colors[Color_bottomShadow]; - botShadowGC = XCreateGC (disp, TermWin.vt, GCForeground, &gcvalue); + botShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); gcvalue.foreground = pix_colors[ (display->depth <= 2 ? Color_fg : Color_scroll)]; - scrollbarGC = XCreateGC (disp, TermWin.vt, GCForeground, &gcvalue); + scrollbarGC = XCreateGC (disp, vt, GCForeground, &gcvalue); #endif #ifdef OFF_FOCUS_FADING @@ -1181,7 +1173,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 } /* ------------------------------------------------------------------------- * @@ -1205,47 +1208,37 @@ tio->c_cc[VSTOP] = CSTOP; tio->c_cc[VSUSP] = CSUSP; # ifdef VDSUSP - tio->c_cc[VDSUSP] = CDSUSP; # endif # ifdef VREPRINT - tio->c_cc[VREPRINT] = CRPRNT; # endif # ifdef VDISCRD - tio->c_cc[VDISCRD] = CFLUSH; # endif # ifdef VWERSE - tio->c_cc[VWERSE] = CWERASE; # endif # ifdef VLNEXT - tio->c_cc[VLNEXT] = CLNEXT; # endif - } + tio->c_cc[VEOF] = CEOF; tio->c_cc[VEOL] = VDISABLE; # ifdef VEOL2 - tio->c_cc[VEOL2] = VDISABLE; # endif # ifdef VSWTC - tio->c_cc[VSWTC] = VDISABLE; # endif # ifdef VSWTCH - tio->c_cc[VSWTCH] = VDISABLE; # endif # if VMIN != VEOF - tio->c_cc[VMIN] = 1; # endif # if VTIME != VEOL - tio->c_cc[VTIME] = 0; # endif @@ -1283,6 +1276,7 @@ tio->sg.sg_erase = CERASE; /* ^H */ tio->sg.sg_kill = CKILL; /* ^U */ } + if (erase != -1) tio->sg.sg_erase = (char)erase; @@ -1298,6 +1292,7 @@ tio->tc.t_eofc = CEOF; /* ^D */ tio->tc.t_brkc = -1; } + /* get local special chars */ if (ioctl (STDIN_FILENO, TIOCGLTC, & (tio->lc)) < 0) { @@ -1311,7 +1306,6 @@ /* get line discipline */ ioctl (STDIN_FILENO, TIOCGETD, & (tio->line)); # ifdef NTTYDISC - tio->line = NTTYDISC; # endif /* NTTYDISC */ @@ -1344,15 +1338,12 @@ FOO (IXON, "IXON"); FOO (IXOFF, "IXOFF"); # ifdef IUCLC - FOO (IUCLC, "IUCLC"); # endif # ifdef IXANY - FOO (IXANY, "IXANY"); # endif # ifdef IMAXBEL - FOO (IMAXBEL, "IMAXBEL"); # endif @@ -1369,39 +1360,30 @@ FOO (VEOF, "VEOF"); FOO (VEOL, "VEOL"); # ifdef VEOL2 - FOO (VEOL2, "VEOL2"); # endif # ifdef VSWTC - FOO (VSWTC, "VSWTC"); # endif # ifdef VSWTCH - FOO (VSWTCH, "VSWTCH"); # endif - FOO (VSTART, "VSTART"); FOO (VSTOP, "VSTOP"); FOO (VSUSP, "VSUSP"); # ifdef VDSUSP - FOO (VDSUSP, "VDSUSP"); # endif # ifdef VREPRINT - FOO (VREPRINT, "VREPRINT"); # endif # ifdef VDISCRD - FOO (VDISCRD, "VDISCRD"); # endif # ifdef VWERSE - FOO (VWERSE, "VWERSE"); # endif # ifdef VLNEXT - FOO (VLNEXT, "VLNEXT"); # endif @@ -1454,8 +1436,6 @@ return; #endif - sw_chld.start (SIGCHLD); - #ifndef __QNX__ /* spin off the command interpreter */ switch (cmd_pid = fork ())