diff options
author | hobbs <hobbs> | 2002-04-23 00:20:35 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2002-04-23 00:20:35 (GMT) |
commit | e299f884f26f88cb6551312a56335687b396e472 (patch) | |
tree | a856643118d026c2171547c749e53a064fe45f1a | |
parent | 47fe3ad632f682b3d520e04b85fe7b5adc7cc018 (diff) | |
download | tk-e299f884f26f88cb6551312a56335687b396e472.zip tk-e299f884f26f88cb6551312a56335687b396e472.tar.gz tk-e299f884f26f88cb6551312a56335687b396e472.tar.bz2 |
* generic/tkTextDisp.c (DisplayLineBackground):
* unix/tkUnix3d.c (Tk_3DHorizontalBevel):
* unix/tkUnixFont.c (Tk_DrawChars): applied fixes to not overrun
the X window 16-bit size limit. [Patch #541999] (bonfield)
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | generic/tkTextDisp.c | 21 | ||||
-rw-r--r-- | unix/tkUnix3d.c | 11 | ||||
-rw-r--r-- | unix/tkUnixFont.c | 72 |
4 files changed, 72 insertions, 39 deletions
@@ -1,3 +1,10 @@ +2002-04-22 Jeff Hobbs <jeffh@ActiveState.com> + + * generic/tkTextDisp.c (DisplayLineBackground): + * unix/tkUnix3d.c (Tk_3DHorizontalBevel): + * unix/tkUnixFont.c (Tk_DrawChars): applied fixes to not overrun + the X window 16-bit size limit. [Patch #541999] (bonfield) + 2002-04-22 Donal K. Fellows <fellowsd@cs.man.ac.uk> * generic/tkTextDisp.c (GetXView,GetYView): Comparison with diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 2a3cf44..ac1d8d2 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkTextDisp.c,v 1.10 2002/04/22 12:45:49 dkf Exp $ + * RCS: @(#) $Id: tkTextDisp.c,v 1.11 2002/04/23 00:20:35 hobbs Exp $ */ #include "tkPort.h" @@ -1890,6 +1890,25 @@ DisplayLineBackground(textPtr, dlPtr, prevPtr, pixmap) rightX = maxX; } if (chunkPtr->stylePtr->bgGC != None) { + /* Not visible - bail out now */ + if (rightX + xOffset <= 0) { + leftX = rightX; + continue; + } + + /* + * Trim the start position for drawing to be no further away than + * -borderWidth. The reason is that on many X servers drawing from + * -32768 (or less) to +something simply does not display + * correctly. [Patch #541999] + */ + if ((leftX + xOffset) < -(sValuePtr->borderWidth)) { + leftX = -sValuePtr->borderWidth - xOffset; + } + if ((rightX - leftX) > 32767) { + rightX = leftX + 32767; + } + XFillRectangle(display, pixmap, chunkPtr->stylePtr->bgGC, leftX + xOffset, 0, (unsigned int) (rightX - leftX), (unsigned int) dlPtr->height); diff --git a/unix/tkUnix3d.c b/unix/tkUnix3d.c index 28331c5..838a14b 100644 --- a/unix/tkUnix3d.c +++ b/unix/tkUnix3d.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnix3d.c,v 1.5 2000/04/14 01:36:35 ericm Exp $ + * RCS: @(#) $Id: tkUnix3d.c,v 1.6 2002/04/23 00:20:35 hobbs Exp $ */ #include <tk3d.h> @@ -294,6 +294,15 @@ Tk_3DHorizontalBevel(tkwin, drawable, border, x, y, width, height, for ( ; y < bottom; y++) { /* + * X Dimensions are 16-bit, so avoid wraparound or display errors + * by limiting these here. + */ + if (x1 < -32767) + x1 = -32767; + if (x2 > 32767) + x2 = 32767; + + /* * In some weird cases (such as large border widths for skinny * rectangles) x1 can be >= x2. Don't draw the lines * in these cases. diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index 444eebb..6301b30 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixFont.c,v 1.11 2002/04/12 07:35:42 hobbs Exp $ + * RCS: @(#) $Id: tkUnixFont.c,v 1.12 2002/04/23 00:20:35 hobbs Exp $ */ #include "tkUnixInt.h" @@ -1155,21 +1155,40 @@ Tk_DrawChars(display, drawable, gc, tkfont, source, numBytes, x, y) SubFont *thisSubFontPtr, *lastSubFontPtr; Tcl_DString runString; CONST char *p, *end, *next; - int xStart, needWidth; + int xStart, needWidth, window_width; Tcl_UniChar ch; FontFamily *familyPtr; + int rx, ry, width, height, border_width, depth; + Drawable root; fontPtr = (UnixFont *) tkfont; lastSubFontPtr = &fontPtr->subFontArray[0]; xStart = x; + /* + * Get the window width so we can abort drawing outside of the window + */ + if (XGetGeometry(display, drawable, &root, &rx, &ry, &width, &height, + &border_width, &depth) == False) { + window_width = INT_MAX; + } else { + window_width = width; + } + end = source + numBytes; + needWidth = fontPtr->font.fa.underline + fontPtr->font.fa.overstrike; for (p = source; p < end; ) { next = p + Tcl_UtfToUniChar(p, &ch); thisSubFontPtr = FindSubFontForChar(fontPtr, ch); - if (thisSubFontPtr != lastSubFontPtr) { + if ((thisSubFontPtr != lastSubFontPtr) + || (p == end-1) || (p-source > 200)) { + if (p == end-1) { + p++; + } if (p > source) { + int do_width = (needWidth || (p != end-1)) ? 1 : 0; + familyPtr = lastSubFontPtr->familyPtr; Tcl_UtfToExternalDString(familyPtr->encoding, source, p - source, &runString); @@ -1177,52 +1196,31 @@ Tk_DrawChars(display, drawable, gc, tkfont, source, numBytes, x, y) XDrawString16(display, drawable, gc, x, y, (XChar2b *) Tcl_DStringValue(&runString), Tcl_DStringLength(&runString) / 2); - - x += XTextWidth16(lastSubFontPtr->fontStructPtr, - (XChar2b *) Tcl_DStringValue(&runString), - Tcl_DStringLength(&runString) / 2); + if (do_width) { + x += XTextWidth16(lastSubFontPtr->fontStructPtr, + (XChar2b *) Tcl_DStringValue(&runString), + Tcl_DStringLength(&runString) / 2); + } } else { XDrawString(display, drawable, gc, x, y, Tcl_DStringValue(&runString), Tcl_DStringLength(&runString)); - x += XTextWidth(lastSubFontPtr->fontStructPtr, - Tcl_DStringValue(&runString), - Tcl_DStringLength(&runString)); + if (do_width) { + x += XTextWidth(lastSubFontPtr->fontStructPtr, + Tcl_DStringValue(&runString), + Tcl_DStringLength(&runString)); + } } Tcl_DStringFree(&runString); } lastSubFontPtr = thisSubFontPtr; source = p; XSetFont(display, gc, lastSubFontPtr->fontStructPtr->fid); - } - p = next; - } - - needWidth = fontPtr->font.fa.underline + fontPtr->font.fa.overstrike; - if (p > source) { - familyPtr = lastSubFontPtr->familyPtr; - Tcl_UtfToExternalDString(familyPtr->encoding, source, p - source, - &runString); - if (familyPtr->isTwoByteFont) { - XDrawString16(display, drawable, gc, x, y, - (XChar2b *) Tcl_DStringValue(&runString), - Tcl_DStringLength(&runString) >> 1); - if (needWidth) { - x += XTextWidth16(lastSubFontPtr->fontStructPtr, - (XChar2b *) Tcl_DStringValue(&runString), - Tcl_DStringLength(&runString) >> 1); - } - } else { - XDrawString(display, drawable, gc, x, y, - Tcl_DStringValue(&runString), - Tcl_DStringLength(&runString)); - if (needWidth) { - x += XTextWidth(lastSubFontPtr->fontStructPtr, - Tcl_DStringValue(&runString), - Tcl_DStringLength(&runString)); + if (x > window_width) { + break; } } - Tcl_DStringFree(&runString); + p = next; } if (lastSubFontPtr != &fontPtr->subFontArray[0]) { |