--- rxvt-unicode/src/main.C 2011/02/12 00:30:00 1.353 +++ rxvt-unicode/src/main.C 2011/08/21 20:13:58 1.361 @@ -13,7 +13,7 @@ * Copyright (c) 1997,1998 Oezguer Kesim * Copyright (c) 1998-2001 Geoff Wing * - extensive modifications - * Copyright (c) 2003-2010 Marc Lehmann + * Copyright (c) 2003-2010 Marc Lehmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -107,7 +107,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 ()); @@ -243,8 +243,8 @@ delete drawable; // destroy all windows - if (parent[0]) - XDestroyWindow (dpy, parent[0]); + if (parent) + XDestroyWindow (dpy, parent); for (int i = 0; i < TOTAL_COLORS; i++) if (ISSET_PIXCOLOR (i)) @@ -708,6 +708,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. + width = ncol * fwidth; + height = nrow * fheight; } /*----------------------------------------------------------------------*/ @@ -737,13 +746,7 @@ } /*----------------------------------------------------------------------*/ -/* set_fonts () - load and set the various fonts - * - * init = 1 - initialize - * - * fontname == FONT_UP - switch to bigger font - * fontname == FONT_DN - switch to smaller font - */ +/* load and set the various fonts */ bool rxvt_term::set_fonts () { @@ -810,7 +813,7 @@ #endif } - if (parent[0]) + if (parent) { resize_all_windows (0, 0, 0); scr_remap_chars (); @@ -823,7 +826,7 @@ void rxvt_term::set_string_property (Atom prop, const char *str, int len) { - XChangeProperty (dpy, parent[0], + XChangeProperty (dpy, parent, prop, XA_STRING, 8, PropModeReplace, (const unsigned char *)str, len >= 0 ? len : strlen (str)); } @@ -835,7 +838,7 @@ if (XmbTextListToTextProperty (dpy, (char **)&str, 1, XStdICCTextStyle, &ct) >= 0) { - XSetTextProperty (dpy, parent[0], &ct, prop); + XSetTextProperty (dpy, parent, &ct, prop); XFree (ct.value); } } @@ -846,7 +849,7 @@ wchar_t *ws = rxvt_mbstowcs (str, len); char *s = rxvt_wcstoutf8 (ws); - XChangeProperty (dpy, parent[0], + XChangeProperty (dpy, parent, prop, xa[XA_UTF8_STRING], 8, PropModeReplace, (const unsigned char *)s, strlen (s)); @@ -1010,7 +1013,7 @@ if (set_hint) { szHint.flags &= ~(PBaseSize | PResizeInc); - XSetWMNormalHints (dpy, parent[0], &szHint); + XSetWMNormalHints (dpy, parent, &szHint); szHint.flags |= PBaseSize | PResizeInc; } @@ -1026,9 +1029,9 @@ unsigned int unused_w1, unused_h1, unused_b1, unused_d1; Window unused_cr; - XTranslateCoordinates (dpy, parent[0], display->root, + XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &unused_cr); - XGetGeometry (dpy, parent[0], &unused_cr, &x1, &y1, + XGetGeometry (dpy, parent, &unused_cr, &x1, &y1, &unused_w1, &unused_h1, &unused_b1, &unused_d1); /* * if display->root isn't the parent window, a WM will probably have offset @@ -1055,15 +1058,15 @@ else if (y == y1) /* exact center */ dy /= 2; - XMoveResizeWindow (dpy, parent[0], x + dx, y + dy, + XMoveResizeWindow (dpy, parent, x + dx, y + dy, szHint.width, szHint.height); #else - XResizeWindow (dpy, parent[0], szHint.width, szHint.height); + XResizeWindow (dpy, parent, szHint.width, szHint.height); #endif } if (set_hint) - XSetWMNormalHints (dpy, parent[0], &szHint); + XSetWMNormalHints (dpy, parent, &szHint); fix_screen = ncol != prev_ncol || nrow != prev_nrow; @@ -1086,7 +1089,7 @@ scr_reset (); #ifdef USE_XIM - IMSetPosition (); + im_set_position (); #endif } @@ -1157,7 +1160,7 @@ /* Checking whether input method is running. */ bool -rxvt_term::IMisRunning () +rxvt_term::im_is_running () { Atom atom; Window win; @@ -1183,7 +1186,7 @@ } void -rxvt_term::IMSendSpot () +rxvt_term::im_send_spot () { XPoint nspot; XVaNestedList preedit_attr; @@ -1299,7 +1302,7 @@ * open a suitable preedit type */ bool -rxvt_term::IM_get_IC (const char *modifiers) +rxvt_term::im_get_ic (const char *modifiers) { int i, j, found; XIM xim; @@ -1309,9 +1312,6 @@ const char *p; char **s; XIMStyles *xim_styles; -#ifdef ENABLE_XIM_ONTHESPOT - XIMCallback xcb[4]; -#endif set_environ (envv); @@ -1461,6 +1461,8 @@ #if ENABLE_XIM_ONTHESPOT else if (input_style & XIMPreeditCallbacks) { + XIMCallback xcb[4]; + im_set_position (spot); xcb[0].client_data = (XPointer)this; xcb[0].callback = (XIMProc)xim_preedit_start; @@ -1485,7 +1487,7 @@ Input_Context = XCreateIC (xim, XNInputStyle, input_style, XNClientWindow, vt, - XNFocusWindow, parent[0], + XNFocusWindow, parent, preedit_attr ? XNPreeditAttributes : NULL, preedit_attr, status_attr ? XNStatusAttributes : NULL, @@ -1508,7 +1510,7 @@ vt_select_input (); #endif - IMSetPosition (); + im_set_position (); return true; } @@ -1546,7 +1548,7 @@ { strcpy (buf, "@im="); strncat (buf, s[i], IMBUFSIZ - 5); - if (IM_get_IC (buf)) + if (im_get_ic (buf)) { found = true; break; @@ -1561,11 +1563,11 @@ } /* try with XMODIFIERS env. var. */ - if (IM_get_IC ("")) + if (im_get_ic ("")) goto done; /* try with no modifiers base IF the user didn't specify an IM */ - if (IM_get_IC ("@im=none")) + if (im_get_ic ("@im=none")) goto done; done: @@ -1576,7 +1578,7 @@ } void -rxvt_term::IMSetPosition () +rxvt_term::im_set_position () { XRectangle preedit_rect, status_rect, *needed_rect; XVaNestedList preedit_attr, status_attr; @@ -1584,7 +1586,7 @@ if (!Input_Context || !focus || !(input_style & (XIMPreeditArea | XIMPreeditPosition)) - || !IMisRunning ()) + || !im_is_running ()) return; if (input_style & XIMPreeditPosition) @@ -1624,7 +1626,7 @@ rxvt_term::get_window_origin (int &x, int &y) { Window cr; - XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr); + XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr); } Pixmap @@ -1659,6 +1661,9 @@ bg_invalidate (); + if (!mapped) + return; + ev_tstamp to_wait = 0.5 - (ev::now () - bg_valid_since); if (to_wait <= 0.)