--- rxvt-unicode/src/main.C 2011/07/09 13:40:13 1.358 +++ rxvt-unicode/src/main.C 2012/06/05 11:00:40 1.377 @@ -38,9 +38,9 @@ #include -#include -#include -#include +#include +#include +#include #include @@ -48,9 +48,7 @@ # define X_LOCALE # include #else -# ifdef HAVE_SETLOCALE -# include -# endif +# include #endif struct termios rxvt_term::def_tio; @@ -107,7 +105,7 @@ } // check to see whether this combination already exists otherwise - for (cc = v.end (); cc-- > v.begin (); ) + for (cc = v.begin (); cc < v.end (); cc++) if (cc->c1 == c1 && cc->c2 == c2) return COMPOSE_LO + (cc - v.begin ()); @@ -176,7 +174,7 @@ rootwin_ev.set (this), #endif scrollbar_ev.set (this), -#ifdef USE_XIM +#if USE_XIM im_ev.set (this), #endif #ifdef POINTER_BLANK @@ -235,7 +233,7 @@ selection_clear (); selection_clear (true); -#ifdef USE_XIM +#if USE_XIM im_destroy (); #endif scrollBar.destroy (); @@ -269,9 +267,6 @@ free (selection.text); free (selection.clip_text); - // TODO: manage env vars in child only(!) - free (env_display); - free (env_term); free (locale); free (v_buffer); @@ -355,7 +350,7 @@ } void -rxvt_term::set_option (uint8_t opt, bool set) +rxvt_term::set_option (uint8_t opt, bool set) NOTHROW { if (!opt) return; @@ -381,7 +376,7 @@ } #if !ENABLE_MINIMAL -static void +static void ecb_cold print_x_error (Display *dpy, XErrorEvent *event) { char buffer[BUFSIZ]; @@ -429,7 +424,7 @@ } #endif -int +int ecb_cold rxvt_xerror_handler (Display *display, XErrorEvent *event) { if (GET_R->allowedxerror == -1) @@ -448,7 +443,7 @@ return 0; } -int +int ecb_cold rxvt_xioerror_handler (Display *display) { rxvt_warn ("X connection to '%s' broken, unable to recover, exiting.\n", @@ -578,6 +573,10 @@ XSetIOErrorHandler (rxvt_xioerror_handler); XrmInitialize (); + +#if HAVE_PIXBUF + g_type_init (); +#endif } /*----------------------------------------------------------------------*/ @@ -708,6 +707,15 @@ ncol = width / fwidth; nrow = height / fheight; + + // When the size of the vt window is not a multiple of the cell + // size, i.e., when the wm does not honour our size hints, there are + // extra areas not covered by the terminal screen. Such gaps, when a + // bg pixmap is set, would have to be cleared manually to properly + // refresh the background. We take the simpler route and shrink the + // vt window so as to avoid creating gaps. + vt_width = ncol * fwidth; + vt_height = nrow * fheight; } /*----------------------------------------------------------------------*/ @@ -725,8 +733,8 @@ ws.ws_col = ncol; ws.ws_row = nrow; - ws.ws_xpixel = width; - ws.ws_ypixel = height; + ws.ws_xpixel = vt_width; + ws.ws_ypixel = vt_height; ioctl (pty->pty, TIOCSWINSZ, &ws); #if 0 @@ -762,13 +770,12 @@ fontset[0] = fs; prop = (*fs)[rxvt_fontset::firstFont]->properties (); - prop.height += lineSpace; prop.width += letterSpace; fs->set_prop (prop, false); fwidth = prop.width; - fheight = prop.height; + fheight = prop.height + lineSpace; fbase = prop.ascent; for (int style = 1; style < 4; style++) @@ -940,13 +947,14 @@ /* * find if fg/bg matches any of the normal (low-intensity) colors */ -void -rxvt_term::set_colorfgbg () +char * +rxvt_term::get_colorfgbg () { unsigned int i; const char *xpmb = ""; char fstr[] = "default"; char bstr[] = "default"; + char *env_colorfgbg; for (i = Color_Black; i <= Color_White; i++) if (pix_colors[Color_fg] == pix_colors[i]) @@ -959,13 +967,15 @@ if (pix_colors[Color_bg] == pix_colors[i]) { sprintf (bstr, "%d", i - Color_Black); -#ifdef BG_IMAGE_FROM_FILE +#if BG_IMAGE_FROM_FILE xpmb = "default;"; #endif break; } + env_colorfgbg = (char *)rxvt_malloc (sizeof ("COLORFGBG=default;default;bg")); sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); + return env_colorfgbg; } /*----------------------------------------------------------------------*/ @@ -1068,7 +1078,9 @@ XMoveResizeWindow (dpy, vt, window_vt_x, window_vt_y, - width, height); + vt_width, vt_height); + + HOOK_INVOKE ((this, HOOK_SIZE_CHANGE, DT_INT, newwidth, DT_INT, newheight, DT_END)); #ifdef HAVE_BG_PIXMAP if (bg_window_size_sensitive ()) @@ -1079,7 +1091,7 @@ if (fix_screen || old_height == 0) scr_reset (); -#ifdef USE_XIM +#if USE_XIM im_set_position (); #endif } @@ -1103,7 +1115,7 @@ newheight = wattr.height - szHint.base_height; } - if (newwidth != width || newheight != height) + if (newwidth != vt_width || newheight != vt_height) { newwidth += szHint.base_width; newheight += szHint.base_height; @@ -1114,7 +1126,7 @@ /* -------------------------------------------------------------------- * * - X INPUT METHOD ROUTINES - * * -------------------------------------------------------------------- */ -#ifdef USE_XIM +#if USE_XIM void rxvt_term::im_set_color (unsigned long &fg, unsigned long &bg) @@ -1521,10 +1533,8 @@ if (Input_Context) return; -#if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) if (rs[Rs_imLocale]) SET_LOCALE (rs[Rs_imLocale]); -#endif p = rs[Rs_inputMethod]; if (p && *p) @@ -1562,10 +1572,8 @@ goto done; done: -#if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) if (rs[Rs_imLocale]) SET_LOCALE (locale); -#endif } void @@ -1620,28 +1628,6 @@ XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr); } -Pixmap -rxvt_term::get_pixmap_property (Atom property) -{ - Pixmap pixmap = None; - - int aformat; - unsigned long nitems, bytes_after; - Atom atype; - unsigned char *prop; - int result = XGetWindowProperty (dpy, display->root, property, - 0L, 1L, False, XA_PIXMAP, &atype, &aformat, - &nitems, &bytes_after, &prop); - if (result == Success) - { - if (atype == XA_PIXMAP) - pixmap = *(Pixmap *)prop; - XFree (prop); - } - - return pixmap; -} - #ifdef HAVE_BG_PIXMAP void @@ -1652,6 +1638,9 @@ bg_invalidate (); + if (!mapped) + return; + ev_tstamp to_wait = 0.5 - (ev::now () - bg_valid_since); if (to_wait <= 0.)