summaryrefslogtreecommitdiffstats
path: root/xlib
diff options
context:
space:
mode:
authordas <das>2007-11-09 06:26:53 (GMT)
committerdas <das>2007-11-09 06:26:53 (GMT)
commit9db63c3a0deba262eaef8b87ee78bf606837c0ae (patch)
tree40938979466c8caac1c03c907753bc43175304bd /xlib
parent8bad7de3c453b5b3ca2b95c6ba54e27f9e923eb6 (diff)
downloadtk-9db63c3a0deba262eaef8b87ee78bf606837c0ae.zip
tk-9db63c3a0deba262eaef8b87ee78bf606837c0ae.tar.gz
tk-9db63c3a0deba262eaef8b87ee78bf606837c0ae.tar.bz2
Backport from HEAD of Aqua changes from 2007-10-12 to 2007-11-09
Diffstat (limited to 'xlib')
-rw-r--r--xlib/xgc.c121
1 files changed, 83 insertions, 38 deletions
diff --git a/xlib/xgc.c b/xlib/xgc.c
index 57c1110..570d510 100644
--- a/xlib/xgc.c
+++ b/xlib/xgc.c
@@ -5,11 +5,12 @@
* contexts.
*
* Copyright (c) 1995-1996 Sun Microsystems, Inc.
+ * Copyright (c) 2002-2007 Daniel A. Steffen <das@users.sourceforge.net>
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: xgc.c,v 1.6.2.5 2007/07/02 13:27:04 das Exp $
+ * RCS: @(#) $Id: xgc.c,v 1.6.2.6 2007/11/09 06:26:57 das Exp $
*/
#include <tkInt.h>
@@ -24,6 +25,7 @@
# define Region XRegion
#endif
#ifdef MAC_OSX_TK
+# include <tkMacOSXInt.h>
# include <X11/Xlib.h>
# include <X11/X.h>
# define Cursor XCursor
@@ -34,6 +36,64 @@
/*
*----------------------------------------------------------------------
*
+ * AllocClipMask --
+ *
+ * Static helper proc to allocate new or clear existing TkpClipMask.
+ *
+ * Results:
+ * Returns ptr to the new/cleared TkpClipMask.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static TkpClipMask *AllocClipMask(GC gc) {
+ TkpClipMask *clip_mask = (TkpClipMask*) gc->clip_mask;
+
+ if (clip_mask == None) {
+ clip_mask = (TkpClipMask*) ckalloc(sizeof(TkpClipMask));
+ gc->clip_mask = (Pixmap) clip_mask;
+#ifdef MAC_OSX_TK
+ } else if (clip_mask->type == TKP_CLIP_REGION) {
+ TkpReleaseRegion(clip_mask->value.region);
+#endif
+ }
+ return clip_mask;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FreeClipMask --
+ *
+ * Static helper proc to free TkpClipMask.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void FreeClipMask(GC gc) {
+ if (gc->clip_mask != None) {
+#ifdef MAC_OSX_TK
+ if (((TkpClipMask*) gc->clip_mask)->type == TKP_CLIP_REGION) {
+ TkpReleaseRegion(((TkpClipMask*) gc->clip_mask)->value.region);
+ }
+#endif
+ ckfree((char*) gc->clip_mask);
+ gc->clip_mask = None;
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* XCreateGC --
*
* Allocate a new GC, and initialize the specified fields.
@@ -95,12 +155,12 @@ XCreateGC(display, d, mask, values)
gp->dashes = (mask & GCDashList) ?values->dashes :4;
(&(gp->dashes))[1] = 0;
+ gp->clip_mask = None;
if (mask & GCClipMask) {
- gp->clip_mask = (Pixmap)ckalloc(sizeof(TkpClipMask));
- ((TkpClipMask*)gp->clip_mask)->type = TKP_CLIP_PIXMAP;
- ((TkpClipMask*)gp->clip_mask)->value.pixmap = values->clip_mask;
- } else {
- gp->clip_mask = None;
+ TkpClipMask *clip_mask = AllocClipMask(gp);
+
+ clip_mask->type = TKP_CLIP_PIXMAP;
+ clip_mask->value.pixmap = values->clip_mask;
}
return gp;
@@ -176,9 +236,7 @@ void XFreeGC(d, gc)
GC gc;
{
if (gc != None) {
- if (gc->clip_mask != None) {
- ckfree((char*) gc->clip_mask);
- }
+ FreeClipMask(gc);
ckfree((char *) gc);
}
}
@@ -341,9 +399,9 @@ XSetClipOrigin(display, gc, clip_x_origin, clip_y_origin)
* Sets the clipping region/pixmap for a GC.
*
* Note that unlike the Xlib equivalent, it is not safe to delete the
- * region after setting it into the GC. The only uses of TkSetRegion
- * are currently in DisplayFrame and in ImgPhotoDisplay, which use the
- * GC immediately.
+ * region after setting it into the GC (except on Mac OS X). The only
+ * uses of TkSetRegion are currently in DisplayFrame and in
+ * ImgPhotoDisplay, which use the GC immediately.
*
* Results:
* None.
@@ -360,22 +418,17 @@ TkSetRegion(display, gc, r)
GC gc;
TkRegion r;
{
- TkpClipMask *clip_mask;
-
if (r == None) {
- if (gc->clip_mask) {
- ckfree((char*) gc->clip_mask);
- gc->clip_mask = None;
- }
- return;
- }
+ FreeClipMask(gc);
+ } else {
+ TkpClipMask *clip_mask = AllocClipMask(gc);
- if (gc->clip_mask == None) {
- gc->clip_mask = (Pixmap)ckalloc(sizeof(TkpClipMask));
+ clip_mask->type = TKP_CLIP_REGION;
+ clip_mask->value.region = r;
+#ifdef MAC_OSX_TK
+ TkpRetainRegion(r);
+#endif
}
- clip_mask = (TkpClipMask*) gc->clip_mask;
- clip_mask->type = TKP_CLIP_REGION;
- clip_mask->value.region = r;
}
void
@@ -384,22 +437,14 @@ XSetClipMask(display, gc, pixmap)
GC gc;
Pixmap pixmap;
{
- TkpClipMask *clip_mask;
-
if (pixmap == None) {
- if (gc->clip_mask) {
- ckfree((char*) gc->clip_mask);
- gc->clip_mask = None;
- }
- return;
- }
+ FreeClipMask(gc);
+ } else {
+ TkpClipMask *clip_mask = AllocClipMask(gc);
- if (gc->clip_mask == None) {
- gc->clip_mask = (Pixmap)ckalloc(sizeof(TkpClipMask));
+ clip_mask->type = TKP_CLIP_PIXMAP;
+ clip_mask->value.pixmap = pixmap;
}
- clip_mask = (TkpClipMask*) gc->clip_mask;
- clip_mask->type = TKP_CLIP_PIXMAP;
- clip_mask->value.pixmap = pixmap;
}
/*