summaryrefslogtreecommitdiffstats
path: root/generic/ttk
diff options
context:
space:
mode:
authordkf <dkf@noemail.net>2012-06-12 08:34:40 (GMT)
committerdkf <dkf@noemail.net>2012-06-12 08:34:40 (GMT)
commitf2cd61121e59243e107ee8d950b5c7a47b65fa75 (patch)
treea423d46e9f550b20ab44f59a5e28af4ced782956 /generic/ttk
parentae7141b620269c8c4e0bdc69fbbee397a9ecaa64 (diff)
parentdd5cb2fbc6412565a5b77c0a837c28104dd21940 (diff)
downloadtk-f2cd61121e59243e107ee8d950b5c7a47b65fa75.zip
tk-f2cd61121e59243e107ee8d950b5c7a47b65fa75.tar.gz
tk-f2cd61121e59243e107ee8d950b5c7a47b65fa75.tar.bz2
Fix text clipping when working with the Xft-based renderer.
FossilOrigin-Name: 66c1f59a8931ff176bcbbe14870fb6279fc86139
Diffstat (limited to 'generic/ttk')
-rw-r--r--generic/ttk/ttkEntry.c13
-rw-r--r--generic/ttk/ttkLabel.c13
2 files changed, 24 insertions, 2 deletions
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c
index 98c8079..6eccf51 100644
--- a/generic/ttk/ttkEntry.c
+++ b/generic/ttk/ttkEntry.c
@@ -1221,7 +1221,8 @@ static void EntryDisplay(void *clientData, Drawable d)
}
}
- /* Initialize the clip region:
+ /* Initialize the clip region. Note that Xft does _not_ derive its
+ * clipping area from the GC, so we have to supply that by other means.
*/
rect.x = entryPtr->entry.layoutX;
@@ -1230,6 +1231,9 @@ static void EntryDisplay(void *clientData, Drawable d)
rect.height = entryPtr->entry.layoutHeight;
clipRegion = TkCreateRegion();
TkUnionRectWithRegion(&rect, clipRegion, clipRegion);
+#ifdef HAVE_XFT
+ TkUnixSetXftClipRegion(clipRegion);
+#endif
/* Draw cursor:
*/
@@ -1272,6 +1276,13 @@ static void EntryDisplay(void *clientData, Drawable d)
selFirst, selLast);
Tk_FreeGC(Tk_Display(tkwin), gc);
}
+
+ /* Drop the region. Note that we have to manually remove the reference to
+ * it from the Xft guts (if they're being used).
+ */
+#ifdef HAVE_XFT
+ TkUnixSetXftClipRegion(None);
+#endif
TkDestroyRegion(clipRegion);
}
diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c
index 6abc847..17433dc 100644
--- a/generic/ttk/ttkLabel.c
+++ b/generic/ttk/ttkLabel.c
@@ -131,6 +131,7 @@ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b)
XGCValues gcValues;
GC gc1, gc2;
Tk_Anchor anchor = TK_ANCHOR_CENTER;
+ TkRegion clipRegion = NULL;
gcValues.font = Tk_FontId(text->tkfont);
gcValues.foreground = color->pixel;
@@ -148,9 +149,9 @@ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b)
* Clip text if it's too wide:
*/
if (b.width < text->width) {
- TkRegion clipRegion = TkCreateRegion();
XRectangle rect;
+ clipRegion = TkCreateRegion();
rect.x = b.x;
rect.y = b.y;
rect.width = b.width + (text->embossed ? 1 : 0);
@@ -158,7 +159,11 @@ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b)
TkUnionRectWithRegion(&rect, clipRegion, clipRegion);
TkSetRegion(Tk_Display(tkwin), gc1, clipRegion);
TkSetRegion(Tk_Display(tkwin), gc2, clipRegion);
+#ifdef HAVE_XFT
+ TkUnixSetXftClipRegion(clipRegion);
+#else
TkDestroyRegion(clipRegion);
+#endif
}
if (text->embossed) {
@@ -180,6 +185,12 @@ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b)
Tk_FreeGC(Tk_Display(tkwin), gc1);
Tk_FreeGC(Tk_Display(tkwin), gc2);
+#ifdef HAVE_XFT
+ if (clipRegion != NULL) {
+ TkUnixSetXftClipRegion(None);
+ TkDestroyRegion(clipRegion);
+ }
+#endif
}
static void TextElementSize(