summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2017-06-05 18:32:24 (GMT)
committerfvogel <fvogelnew1@free.fr>2017-06-05 18:32:24 (GMT)
commitfbac4859a673c9a5f0c8936ed8d18ea9e9145304 (patch)
tree4e184d638205d9ce2ef854ebea9393e5d8d91bd3
parent452ee6a6849e04a6a94bc7488e935129614041f8 (diff)
parentfd3fd3d844d9ff5f83c3fd26ee88f2c02892c180 (diff)
downloadtk-fbac4859a673c9a5f0c8936ed8d18ea9e9145304.zip
tk-fbac4859a673c9a5f0c8936ed8d18ea9e9145304.tar.gz
tk-fbac4859a673c9a5f0c8936ed8d18ea9e9145304.tar.bz2
merge trunk
-rw-r--r--doc/FindPhoto.337
-rw-r--r--generic/tk.decls14
-rw-r--r--generic/tkBind.c36
-rw-r--r--generic/tkCanvPs.c2
-rw-r--r--generic/tkDecls.h57
-rw-r--r--generic/tkFont.c44
-rw-r--r--generic/tkFont.h6
-rw-r--r--generic/tkImgPhInstance.c2
-rw-r--r--generic/tkImgPhoto.c169
-rw-r--r--generic/tkInt.h1
-rw-r--r--generic/tkPanedWindow.c24
-rw-r--r--generic/tkSelect.c4
-rw-r--r--generic/tkStubInit.c6
-rw-r--r--generic/tkWindow.c2
-rw-r--r--generic/ttk/ttkNotebook.c9
-rw-r--r--macosx/tkMacOSXDialog.c555
-rw-r--r--macosx/tkMacOSXFont.c2
-rw-r--r--macosx/tkMacOSXScrlbr.c81
-rw-r--r--macosx/tkMacOSXWm.c5
-rw-r--r--macosx/tkMacOSXWm.h4
-rw-r--r--macosx/tkMacOSXXStubs.c6
-rw-r--r--tests/imgBmap.test3
-rw-r--r--tests/imgPhoto.test76
-rw-r--r--tests/menu.test2
-rwxr-xr-xunix/configure155
-rw-r--r--unix/tcl.m4165
-rw-r--r--unix/tkUnixButton.c81
-rw-r--r--unix/tkUnixFont.c16
-rw-r--r--unix/tkUnixRFont.c23
-rw-r--r--win/tcl.m42
-rw-r--r--win/tkWinClipboard.c2
-rw-r--r--win/tkWinDialog.c54
-rw-r--r--win/tkWinFont.c6
-rw-r--r--win/tkWinInit.c7
-rw-r--r--win/tkWinSend.c43
-rw-r--r--win/tkWinSendCom.c25
-rw-r--r--win/tkWinTest.c5
-rw-r--r--win/tkWinX.c30
-rw-r--r--xlib/xcolors.c4
-rw-r--r--xlib/xgc.c2
40 files changed, 1044 insertions, 723 deletions
diff --git a/doc/FindPhoto.3 b/doc/FindPhoto.3
index 61a47de..dc218bf 100644
--- a/doc/FindPhoto.3
+++ b/doc/FindPhoto.3
@@ -130,14 +130,23 @@ The \fIpixelPtr\fR field points to the first pixel, that is, the
top-left pixel in the block.
The \fIwidth\fR and \fIheight\fR fields specify the dimensions of the
block of pixels. The \fIpixelSize\fR field specifies the address
-difference between two horizontally adjacent pixels. Often it is 3
-or 4, but it can have any value. The \fIpitch\fR field specifies the
+difference between two horizontally adjacent pixels. It should be 4 for
+RGB and 2 for grayscale image data. Other values are possible, if the
+offsets in the \fIoffset\fR array are adjusted accordingly (e.g. for
+red, green and blue data stored in different planes). Using such a
+layout is strongly discouraged, though. Due to a bug, it might not work
+correctly if an alpha channel is provided. (see the \fBBUGS\fR section
+below). The \fIpitch\fR field specifies the
address difference between two vertically adjacent pixels. The
\fIoffset\fR array contains the offsets from the address of a pixel
to the addresses of the bytes containing the red, green, blue and alpha
-(transparency) components. These are normally 0, 1, 2 and 3, but can
-have other values, e.g., for images that are stored as separate red,
-green and blue planes.
+(transparency) components. If the offsets for red, green and blue are
+equal, the image is interpreted as grayscale. If they differ, RGB data
+is assumed. Normally the offsets will be 0, 1, 2, 3 for RGB data
+and 0, 0, 0, 1 for grayscale. It is possible to provide image data
+without an alpha channel by setting the offset for alpha to a negative
+value and adjusting the \fIpixelSize\fR field accordingly. This use is
+discouraged, though (see the \fBBUGS\fR section below).
.PP
The \fIcompRule\fR parameter to \fBTk_PhotoPutBlock\fR specifies a
compositing rule that says what to do with transparent pixels. The
@@ -248,6 +257,24 @@ memory was available for an image, Tk would panic. This behaviour is
still supported if you compile your extension with the additional flag
-DUSE_PANIC_ON_PHOTO_ALLOC_FAILURE. Code linked using Stubs against
older versions of Tk will continue to work.
+.SH BUGS
+The \fBTk_PhotoImageBlock\fR structure used to provide image data to
+\fBTk_PhotoPutBlock\fR promises great flexibility in the layout of the
+data (e.g. separate planes for the red, green, blue and alpha
+channels). Unfortunately, the implementation fails to hold this
+promise. The problem is that the \fIpixelSize\fR field is
+(incorrectly) used to determine whether the image has an alpha channel.
+Currently, if the offset for the alpha channel is greater or equal than
+\fIpixelSize\fR, \fBtk_PhotoPutblock\fR assumes no alpha data is
+present and makes the image fully opaque. This means that for layouts
+where the channels are separate (or any other exotic layout where
+\fIpixelSize\fR has to be smaller than the alpha offset), the alpha
+channel will not be read correctly. In order to be on the safe side
+if this issue will be corrected in a future release, it is strongly
+recommended you always provide alpha data - even if the image has no
+transparency - and only use the "standard" layout with a
+\fIpixelSize\fR of 2 for grayscale and 4 for RGB data with
+\fIoffset\fRs of 0, 0, 0, 1 or 0, 1, 2, 3 respectively.
.SH CREDITS
.PP
The code for the photo image type was developed by Paul Mackerras,
diff --git a/generic/tk.decls b/generic/tk.decls
index eaaa063..a8d0c58 100644
--- a/generic/tk.decls
+++ b/generic/tk.decls
@@ -326,7 +326,7 @@ declare 75 {
declare 76 {
void Tk_FreeTextLayout(Tk_TextLayout textLayout)
}
-declare 77 deprecated {
+declare 77 {deprecated {function does nothing, call can be removed}} {
void Tk_FreeXId(Display *display, XID xid)
}
declare 78 {
@@ -564,12 +564,12 @@ declare 143 {
Tk_Window tkwin, int *argcPtr, CONST84 char **argv,
const Tk_ArgvInfo *argTable, int flags)
}
-declare 144 {
+declare 144 {deprecated {function signature changed}} {
void Tk_PhotoPutBlock_NoComposite(Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height)
}
-declare 145 {
+declare 145 {deprecated {function signature changed}} {
void Tk_PhotoPutZoomedBlock_NoComposite(Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int zoomX, int zoomY,
@@ -581,13 +581,13 @@ declare 146 {
declare 147 {
void Tk_PhotoBlank(Tk_PhotoHandle handle)
}
-declare 148 {
+declare 148 {deprecated {function signature changed}} {
void Tk_PhotoExpand_Panic(Tk_PhotoHandle handle, int width, int height )
}
declare 149 {
void Tk_PhotoGetSize(Tk_PhotoHandle handle, int *widthPtr, int *heightPtr)
}
-declare 150 {
+declare 150 {deprecated {function signature changed}} {
void Tk_PhotoSetSize_Panic(Tk_PhotoHandle handle, int width, int height)
}
declare 151 {
@@ -943,12 +943,12 @@ declare 244 {
declare 245 {
void Tk_SetCaretPos(Tk_Window tkwin, int x, int y, int height)
}
-declare 246 {
+declare 246 {deprecated {function signature changed}} {
void Tk_PhotoPutBlock_Panic(Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int compRule)
}
-declare 247 {
+declare 247 {deprecated {function signature changed}} {
void Tk_PhotoPutZoomedBlock_Panic(Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int zoomX, int zoomY,
diff --git a/generic/tkBind.c b/generic/tkBind.c
index aaa5386..e0cc1ca 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -1267,7 +1267,7 @@ Tk_BindEvent(
*/
if ((eventPtr->type >= TK_LASTEVENT) || !flagArray[eventPtr->type]) {
- return;
+ return;
}
dispPtr = ((TkWindow *) tkwin)->dispPtr;
@@ -3466,12 +3466,7 @@ HandleEventGenerate(
if ((warp != 0) && Tk_IsMapped(tkwin)) {
TkDisplay *dispPtr = TkGetDisplay(event.general.xmotion.display);
- /*
- * TODO: No protection is in place to handle dispPtr destruction
- * before DoWarp is called back.
- */
-
- Tk_Window warpWindow = Tk_IdToWindow(dispPtr->display,
+Tk_Window warpWindow = Tk_IdToWindow(dispPtr->display,
event.general.xmotion.window);
if (!(dispPtr->flags & TK_DISPLAY_IN_WARP)) {
@@ -4321,6 +4316,33 @@ TkpGetBindingXEvent(
}
/*
+ *----------------------------------------------------------------------
+ *
+ * TkpCancelWarp --
+ *
+ * This function cancels an outstanding pointer warp and
+ * is called during tear down of the display.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkpCancelWarp(
+ TkDisplay *dispPtr)
+{
+ if (dispPtr->flags & TK_DISPLAY_IN_WARP) {
+ Tcl_CancelIdleCall(DoWarp, dispPtr);
+ dispPtr->flags &= ~TK_DISPLAY_IN_WARP;
+ }
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4
diff --git a/generic/tkCanvPs.c b/generic/tkCanvPs.c
index c6470dd..2bfdcc5 100644
--- a/generic/tkCanvPs.c
+++ b/generic/tkCanvPs.c
@@ -825,7 +825,7 @@ Tk_PostscriptFont(
fontname = Tcl_DStringValue(&ds);
Tcl_AppendPrintfToObj(GetPostscriptBuffer(interp),
"/%s findfont %d scalefont%s setfont\n",
- fontname, TkFontGetPoints(psInfoPtr->tkwin, points),
+ fontname, (int)(TkFontGetPoints(psInfoPtr->tkwin, points) + 0.5),
strncasecmp(fontname, "Symbol", 7) ? " ISOEncode" : "");
Tcl_CreateHashEntry(&psInfoPtr->fontTable, Tcl_DStringValue(&ds), &i);
Tcl_DStringFree(&ds);
diff --git a/generic/tkDecls.h b/generic/tkDecls.h
index 3b72706..1aa087f 100644
--- a/generic/tkDecls.h
+++ b/generic/tkDecls.h
@@ -18,9 +18,9 @@
#endif
#if defined(TK_NO_DEPRECATED) && defined(BUILD_tk)
-# define TK_DEPRECATED MODULE_SCOPE
+# define TK_DEPRECATED(msg) MODULE_SCOPE
#else
-# define TK_DEPRECATED EXTERN
+# define TK_DEPRECATED(msg) EXTERN TCL_DEPRECATED_API(msg)
#endif
/*
@@ -287,7 +287,9 @@ EXTERN void Tk_FreePixmap(Display *display, Pixmap pixmap);
/* 76 */
EXTERN void Tk_FreeTextLayout(Tk_TextLayout textLayout);
/* 77 */
-TK_DEPRECATED void Tk_FreeXId(Display *display, XID xid);
+TK_DEPRECATED("function does nothing, call can be removed")
+void Tk_FreeXId(
+ Display *display, XID xid);
/* 78 */
EXTERN GC Tk_GCForColor(XColor *colorPtr, Drawable drawable);
/* 79 */
@@ -477,11 +479,14 @@ EXTERN int Tk_ParseArgv(Tcl_Interp *interp, Tk_Window tkwin,
int *argcPtr, CONST84 char **argv,
const Tk_ArgvInfo *argTable, int flags);
/* 144 */
-EXTERN void Tk_PhotoPutBlock_NoComposite(Tk_PhotoHandle handle,
+TK_DEPRECATED("function signature changed")
+void Tk_PhotoPutBlock_NoComposite(
+ Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height);
/* 145 */
-EXTERN void Tk_PhotoPutZoomedBlock_NoComposite(
+TK_DEPRECATED("function signature changed")
+void Tk_PhotoPutZoomedBlock_NoComposite(
Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int zoomX, int zoomY,
@@ -492,14 +497,16 @@ EXTERN int Tk_PhotoGetImage(Tk_PhotoHandle handle,
/* 147 */
EXTERN void Tk_PhotoBlank(Tk_PhotoHandle handle);
/* 148 */
-EXTERN void Tk_PhotoExpand_Panic(Tk_PhotoHandle handle,
- int width, int height);
+TK_DEPRECATED("function signature changed")
+void Tk_PhotoExpand_Panic(
+ Tk_PhotoHandle handle, int width, int height);
/* 149 */
EXTERN void Tk_PhotoGetSize(Tk_PhotoHandle handle, int *widthPtr,
int *heightPtr);
/* 150 */
-EXTERN void Tk_PhotoSetSize_Panic(Tk_PhotoHandle handle,
- int width, int height);
+TK_DEPRECATED("function signature changed")
+void Tk_PhotoSetSize_Panic(
+ Tk_PhotoHandle handle, int width, int height);
/* 151 */
EXTERN int Tk_PointToChar(Tk_TextLayout layout, int x, int y);
/* 152 */
@@ -782,11 +789,15 @@ EXTERN void Tk_SetMinimumRequestSize(Tk_Window tkwin,
EXTERN void Tk_SetCaretPos(Tk_Window tkwin, int x, int y,
int height);
/* 246 */
-EXTERN void Tk_PhotoPutBlock_Panic(Tk_PhotoHandle handle,
+TK_DEPRECATED("function signature changed")
+void Tk_PhotoPutBlock_Panic(
+ Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int compRule);
/* 247 */
-EXTERN void Tk_PhotoPutZoomedBlock_Panic(Tk_PhotoHandle handle,
+TK_DEPRECATED("function signature changed")
+void Tk_PhotoPutZoomedBlock_Panic(
+ Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int zoomX, int zoomY,
int subsampleX, int subsampleY, int compRule);
@@ -959,7 +970,7 @@ typedef struct TkStubs {
void (*tk_FreeOptions) (const Tk_ConfigSpec *specs, char *widgRec, Display *display, int needFlags); /* 74 */
void (*tk_FreePixmap) (Display *display, Pixmap pixmap); /* 75 */
void (*tk_FreeTextLayout) (Tk_TextLayout textLayout); /* 76 */
- void (*tk_FreeXId) (Display *display, XID xid); /* 77 */
+ TCL_DEPRECATED_API("function does nothing, call can be removed") void (*tk_FreeXId) (Display *display, XID xid); /* 77 */
GC (*tk_GCForColor) (XColor *colorPtr, Drawable drawable); /* 78 */
void (*tk_GeometryRequest) (Tk_Window tkwin, int reqWidth, int reqHeight); /* 79 */
Tk_3DBorder (*tk_Get3DBorder) (Tcl_Interp *interp, Tk_Window tkwin, Tk_Uid colorName); /* 80 */
@@ -1026,13 +1037,13 @@ typedef struct TkStubs {
Tk_Window (*tk_NameToWindow) (Tcl_Interp *interp, const char *pathName, Tk_Window tkwin); /* 141 */
void (*tk_OwnSelection) (Tk_Window tkwin, Atom selection, Tk_LostSelProc *proc, ClientData clientData); /* 142 */
int (*tk_ParseArgv) (Tcl_Interp *interp, Tk_Window tkwin, int *argcPtr, CONST84 char **argv, const Tk_ArgvInfo *argTable, int flags); /* 143 */
- void (*tk_PhotoPutBlock_NoComposite) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height); /* 144 */
- void (*tk_PhotoPutZoomedBlock_NoComposite) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY); /* 145 */
+ TCL_DEPRECATED_API("function signature changed") void (*tk_PhotoPutBlock_NoComposite) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height); /* 144 */
+ TCL_DEPRECATED_API("function signature changed") void (*tk_PhotoPutZoomedBlock_NoComposite) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY); /* 145 */
int (*tk_PhotoGetImage) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr); /* 146 */
void (*tk_PhotoBlank) (Tk_PhotoHandle handle); /* 147 */
- void (*tk_PhotoExpand_Panic) (Tk_PhotoHandle handle, int width, int height); /* 148 */
+ TCL_DEPRECATED_API("function signature changed") void (*tk_PhotoExpand_Panic) (Tk_PhotoHandle handle, int width, int height); /* 148 */
void (*tk_PhotoGetSize) (Tk_PhotoHandle handle, int *widthPtr, int *heightPtr); /* 149 */
- void (*tk_PhotoSetSize_Panic) (Tk_PhotoHandle handle, int width, int height); /* 150 */
+ TCL_DEPRECATED_API("function signature changed") void (*tk_PhotoSetSize_Panic) (Tk_PhotoHandle handle, int width, int height); /* 150 */
int (*tk_PointToChar) (Tk_TextLayout layout, int x, int y); /* 151 */
int (*tk_PostscriptFontName) (Tk_Font tkfont, Tcl_DString *dsPtr); /* 152 */
void (*tk_PreserveColormap) (Display *display, Colormap colormap); /* 153 */
@@ -1128,8 +1139,8 @@ typedef struct TkStubs {
void (*tk_SetInternalBorderEx) (Tk_Window tkwin, int left, int right, int top, int bottom); /* 243 */
void (*tk_SetMinimumRequestSize) (Tk_Window tkwin, int minWidth, int minHeight); /* 244 */
void (*tk_SetCaretPos) (Tk_Window tkwin, int x, int y, int height); /* 245 */
- void (*tk_PhotoPutBlock_Panic) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int compRule); /* 246 */
- void (*tk_PhotoPutZoomedBlock_Panic) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY, int compRule); /* 247 */
+ TCL_DEPRECATED_API("function signature changed") void (*tk_PhotoPutBlock_Panic) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int compRule); /* 246 */
+ TCL_DEPRECATED_API("function signature changed") void (*tk_PhotoPutZoomedBlock_Panic) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY, int compRule); /* 247 */
int (*tk_CollapseMotionEvents) (Display *display, int collapse); /* 248 */
Tk_StyleEngine (*tk_RegisterStyleEngine) (const char *name, Tk_StyleEngine parent); /* 249 */
Tk_StyleEngine (*tk_GetStyleEngine) (const char *name); /* 250 */
@@ -1736,6 +1747,16 @@ extern const TkStubs *tkStubsPtr;
Tcl_AppInitProc *appInitProc, Tcl_Interp *interp);
#endif
+
+#ifdef TK_NO_DEPRECATED
+#undef Tk_PhotoPutBlock_NoComposite
+#undef Tk_PhotoPutZoomedBlock_NoComposite
+#undef Tk_PhotoExpand_Panic
+#undef Tk_PhotoPutBlock_Panic
+#undef Tk_PhotoPutZoomedBlock_Panic
+#undef Tk_PhotoSetSize_Panic
+#endif /* TK_NO_DEPRECATED */
+
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT
diff --git a/generic/tkFont.c b/generic/tkFont.c
index a00c627..3c2b4f9 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.c
@@ -1228,7 +1228,7 @@ Tk_AllocFontFromObj(
descent = fontPtr->fm.descent;
fontPtr->underlinePos = descent / 2;
- fontPtr->underlineHeight = TkFontGetPixels(tkwin, fontPtr->fa.size) / 10;
+ fontPtr->underlineHeight = (int) (TkFontGetPixels(tkwin, fontPtr->fa.size) / 10 + 0.5);
if (fontPtr->underlineHeight == 0) {
fontPtr->underlineHeight = 1;
}
@@ -1795,7 +1795,7 @@ Tk_PostscriptFontName(
}
}
- return fontPtr->fa.size;
+ return (int)(fontPtr->fa.size + 0.5);
}
/*
@@ -3404,7 +3404,7 @@ ConfigAttributesObj(
if (Tcl_GetIntFromObj(interp, valuePtr, &n) != TCL_OK) {
return TCL_ERROR;
}
- faPtr->size = n;
+ faPtr->size = (double)n;
break;
case FONT_WEIGHT:
n = TkFindStateNumObj(interp, optionPtr, weightMap, valuePtr);
@@ -3495,7 +3495,11 @@ GetAttributeInfoObj(
break;
case FONT_SIZE:
- valuePtr = Tcl_NewIntObj(faPtr->size);
+ if (faPtr->size >= 0.0) {
+ valuePtr = Tcl_NewIntObj((int)(faPtr->size + 0.5));
+ } else {
+ valuePtr = Tcl_NewIntObj(-(int)(-faPtr->size + 0.5));
+ }
break;
case FONT_WEIGHT:
@@ -3644,7 +3648,7 @@ ParseFontNameObj(
if (Tcl_GetIntFromObj(interp, objv[1], &n) != TCL_OK) {
return TCL_ERROR;
}
- faPtr->size = n;
+ faPtr->size = (double)n;
}
i = 2;
@@ -3888,7 +3892,7 @@ TkFontParseXLFD(
* historical compatibility.
*/
- faPtr->size = 12;
+ faPtr->size = 12.0;
if (FieldSpecified(field[XLFD_POINT_SIZE])) {
if (field[XLFD_POINT_SIZE][0] == '[') {
@@ -3902,10 +3906,10 @@ TkFontParseXLFD(
* the purpose of, so I ignore them.
*/
- faPtr->size = atoi(field[XLFD_POINT_SIZE] + 1);
+ faPtr->size = atof(field[XLFD_POINT_SIZE] + 1);
} else if (Tcl_GetInt(NULL, field[XLFD_POINT_SIZE],
- &faPtr->size) == TCL_OK) {
- faPtr->size /= 10;
+ &i) == TCL_OK) {
+ faPtr->size = i/10.0;
} else {
return TCL_ERROR;
}
@@ -3927,9 +3931,11 @@ TkFontParseXLFD(
* ignore them.
*/
- faPtr->size = atoi(field[XLFD_PIXEL_SIZE] + 1);
+ faPtr->size = atof(field[XLFD_PIXEL_SIZE] + 1);
} else if (Tcl_GetInt(NULL, field[XLFD_PIXEL_SIZE],
- &faPtr->size) != TCL_OK) {
+ &i) == TCL_OK) {
+ faPtr->size = (double)i;
+ } else {
return TCL_ERROR;
}
}
@@ -4005,21 +4011,21 @@ FieldSpecified(
*---------------------------------------------------------------------------
*/
-int
+double
TkFontGetPixels(
Tk_Window tkwin, /* For point->pixel conversion factor. */
- int size) /* Font size. */
+ double size) /* Font size. */
{
double d;
- if (size < 0) {
+ if (size <= 0.0) {
return -size;
}
d = size * 25.4 / 72.0;
d *= WidthOfScreen(Tk_Screen(tkwin));
d /= WidthMMOfScreen(Tk_Screen(tkwin));
- return (int) (d + 0.5);
+ return d;
}
/*
@@ -4039,21 +4045,21 @@ TkFontGetPixels(
*---------------------------------------------------------------------------
*/
-int
+double
TkFontGetPoints(
Tk_Window tkwin, /* For pixel->point conversion factor. */
- int size) /* Font size. */
+ double size) /* Font size. */
{
double d;
- if (size >= 0) {
+ if (size >= 0.0) {
return size;
}
d = -size * 72.0 / 25.4;
d *= WidthMMOfScreen(Tk_Screen(tkwin));
d /= WidthOfScreen(Tk_Screen(tkwin));
- return (int) (d + 0.5);
+ return d;
}
/*
diff --git a/generic/tkFont.h b/generic/tkFont.h
index b8de885..de479bf 100644
--- a/generic/tkFont.h
+++ b/generic/tkFont.h
@@ -23,7 +23,7 @@
struct TkFontAttributes {
Tk_Uid family; /* Font family, or NULL to represent plaform-
* specific default system font. */
- int size; /* Pointsize of font, 0 for default size, or
+ double size; /* Pointsize of font, 0.0 for default size, or
* negative number meaning pixel size. */
int weight; /* Weight flag; see below for def'n. */
int slant; /* Slant flag; see below for def'n. */
@@ -198,8 +198,8 @@ MODULE_SCOPE int TkFontParseXLFD(const char *string,
TkFontAttributes *faPtr, TkXLFDAttributes *xaPtr);
MODULE_SCOPE const char *const * TkFontGetAliasList(const char *faceName);
MODULE_SCOPE const char *const *const * TkFontGetFallbacks(void);
-MODULE_SCOPE int TkFontGetPixels(Tk_Window tkwin, int size);
-MODULE_SCOPE int TkFontGetPoints(Tk_Window tkwin, int size);
+MODULE_SCOPE double TkFontGetPixels(Tk_Window tkwin, double size);
+MODULE_SCOPE double TkFontGetPoints(Tk_Window tkwin, double size);
MODULE_SCOPE const char *const * TkFontGetGlobalClass(void);
MODULE_SCOPE const char *const * TkFontGetSymbolClass(void);
MODULE_SCOPE int TkCreateNamedFont(Tcl_Interp *interp, Tk_Window tkwin,
diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c
index 98aaeab..fd98c6e 100644
--- a/generic/tkImgPhInstance.c
+++ b/generic/tkImgPhInstance.c
@@ -1261,7 +1261,7 @@ AllocateColors(
}
} else {
/*
- * Monochrome display - allocate the shades of grey we want.
+ * Monochrome display - allocate the shades of gray we want.
*/
for (i = 0; i < numColors; ++i) {
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index bcf69a0..a1146b7 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -2713,7 +2713,7 @@ Tk_PhotoPutBlock(
* messages, or NULL. */
Tk_PhotoHandle handle, /* Opaque handle for the photo image to be
* updated. */
- register Tk_PhotoImageBlock *blockPtr,
+ Tk_PhotoImageBlock *blockPtr,
/* Pointer to a structure describing the pixel
* data to be copied into the image. */
int x, int y, /* Coordinates of the top-left pixel to be
@@ -2724,6 +2724,8 @@ Tk_PhotoPutBlock(
* transparent pixels. */
{
register PhotoMaster *masterPtr = (PhotoMaster *) handle;
+ Tk_PhotoImageBlock sourceBlock;
+ unsigned char *memToFree;
int xEnd, yEnd, greenOffset, blueOffset, alphaOffset;
int wLeft, hLeft, wCopy, hCopy, pitch;
unsigned char *srcPtr, *srcLinePtr, *destPtr, *destLinePtr;
@@ -2751,11 +2753,43 @@ Tk_PhotoPutBlock(
return TCL_OK;
}
+ /*
+ * Fix for bug e4336bef5d:
+ *
+ * Make a local copy of *blockPtr, as we might have to change some
+ * of its fields and don't want to interfere with the caller's data.
+ *
+ * If source and destination are the same image, create a copy of the
+ * source data in our local sourceBlock.
+ *
+ * To find out, just comparing the pointers is not enough - they might have
+ * different values and still point to the same block of memory. (e.g.
+ * if the -from option was passed to [imageName copy])
+ */
+ sourceBlock = *blockPtr;
+ memToFree = NULL;
+ if (sourceBlock.pixelPtr >= masterPtr->pix32
+ && sourceBlock.pixelPtr <= masterPtr->pix32 + masterPtr->width
+ * masterPtr->height * 4) {
+ sourceBlock.pixelPtr = attemptckalloc(sourceBlock.height
+ * sourceBlock.pitch);
+ if (sourceBlock.pixelPtr == NULL) {
+ if (interp != NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
+ Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
+ }
+ return TCL_ERROR;
+ }
+ memToFree = sourceBlock.pixelPtr;
+ memcpy(sourceBlock.pixelPtr, blockPtr->pixelPtr, sourceBlock.height
+ * sourceBlock.pitch);
+ }
+
+
xEnd = x + width;
yEnd = y + height;
if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) {
- int sameSrc = (blockPtr->pixelPtr == masterPtr->pix32);
-
if (ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width),
MAX(yEnd, masterPtr->height)) == TCL_ERROR) {
if (interp != NULL) {
@@ -2763,11 +2797,7 @@ Tk_PhotoPutBlock(
TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
}
- return TCL_ERROR;
- }
- if (sameSrc) {
- blockPtr->pixelPtr = masterPtr->pix32;
- blockPtr->pitch = masterPtr->width * 4;
+ goto errorExit;
}
}
@@ -2786,14 +2816,14 @@ Tk_PhotoPutBlock(
* components, mark it as a color image.
*/
- greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
- blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
- alphaOffset = blockPtr->offset[3];
- if ((alphaOffset >= blockPtr->pixelSize) || (alphaOffset < 0)) {
+ greenOffset = sourceBlock.offset[1] - sourceBlock.offset[0];
+ blueOffset = sourceBlock.offset[2] - sourceBlock.offset[0];
+ alphaOffset = sourceBlock.offset[3];
+ if ((alphaOffset >= sourceBlock.pixelSize) || (alphaOffset < 0)) {
alphaOffset = 0;
sourceIsSimplePhoto = 1;
} else {
- alphaOffset -= blockPtr->offset[0];
+ alphaOffset -= sourceBlock.offset[0];
}
if ((greenOffset != 0) || (blueOffset != 0)) {
masterPtr->flags |= COLOR_IMAGE;
@@ -2813,13 +2843,13 @@ Tk_PhotoPutBlock(
* pixelSize == 3 and alphaOffset == 0. Maybe other cases too.
*/
- if ((blockPtr->pixelSize == 4)
+ if ((sourceBlock.pixelSize == 4)
&& (greenOffset == 1) && (blueOffset == 2) && (alphaOffset == 3)
- && (width <= blockPtr->width) && (height <= blockPtr->height)
+ && (width <= sourceBlock.width) && (height <= sourceBlock.height)
&& ((height == 1) || ((x == 0) && (width == masterPtr->width)
- && (blockPtr->pitch == pitch)))
+ && (sourceBlock.pitch == pitch)))
&& (compRule == TK_PHOTO_COMPOSITE_SET)) {
- memmove(destLinePtr, blockPtr->pixelPtr + blockPtr->offset[0],
+ memmove(destLinePtr, sourceBlock.pixelPtr + sourceBlock.offset[0],
((size_t)height * width * 4));
/*
@@ -2835,11 +2865,11 @@ Tk_PhotoPutBlock(
*/
for (hLeft = height; hLeft > 0;) {
- int pixelSize = blockPtr->pixelSize;
+ int pixelSize = sourceBlock.pixelSize;
int compRuleSet = (compRule == TK_PHOTO_COMPOSITE_SET);
- srcLinePtr = blockPtr->pixelPtr + blockPtr->offset[0];
- hCopy = MIN(hLeft, blockPtr->height);
+ srcLinePtr = sourceBlock.pixelPtr + sourceBlock.offset[0];
+ hCopy = MIN(hLeft, sourceBlock.height);
hLeft -= hCopy;
for (; hCopy > 0; --hCopy) {
/*
@@ -2850,10 +2880,10 @@ Tk_PhotoPutBlock(
if ((pixelSize == 4) && (greenOffset == 1)
&& (blueOffset == 2) && (alphaOffset == 3)
- && (width <= blockPtr->width)
+ && (width <= sourceBlock.width)
&& compRuleSet) {
memcpy(destLinePtr, srcLinePtr, ((size_t)width * 4));
- srcLinePtr += blockPtr->pitch;
+ srcLinePtr += sourceBlock.pitch;
destLinePtr += pitch;
continue;
}
@@ -2864,7 +2894,7 @@ Tk_PhotoPutBlock(
destPtr = destLinePtr;
for (wLeft = width; wLeft > 0;) {
- wCopy = MIN(wLeft, blockPtr->width);
+ wCopy = MIN(wLeft, sourceBlock.width);
wLeft -= wCopy;
srcPtr = srcLinePtr;
@@ -2954,7 +2984,7 @@ Tk_PhotoPutBlock(
destPtr += 4;
}
}
- srcLinePtr += blockPtr->pitch;
+ srcLinePtr += sourceBlock.pitch;
destLinePtr += pitch;
}
}
@@ -3070,7 +3100,15 @@ Tk_PhotoPutBlock(
Tk_ImageChanged(masterPtr->tkMaster, x, y, width, height,
masterPtr->width, masterPtr->height);
+
+ if (memToFree) ckfree(memToFree);
+
return TCL_OK;
+
+ errorExit:
+ if (memToFree) ckfree(memToFree);
+
+ return TCL_ERROR;
}
/*
@@ -3097,7 +3135,7 @@ Tk_PhotoPutZoomedBlock(
* messages, or NULL. */
Tk_PhotoHandle handle, /* Opaque handle for the photo image to be
* updated. */
- register Tk_PhotoImageBlock *blockPtr,
+ Tk_PhotoImageBlock *blockPtr,
/* Pointer to a structure describing the pixel
* data to be copied into the image. */
int x, int y, /* Coordinates of the top-left pixel to be
@@ -3112,6 +3150,8 @@ Tk_PhotoPutZoomedBlock(
* transparent pixels. */
{
register PhotoMaster *masterPtr = (PhotoMaster *) handle;
+ register Tk_PhotoImageBlock sourceBlock;
+ unsigned char *memToFree;
int xEnd, yEnd, greenOffset, blueOffset, alphaOffset;
int wLeft, hLeft, wCopy, hCopy, blockWid, blockHt;
unsigned char *srcPtr, *srcLinePtr, *srcOrigPtr, *destPtr, *destLinePtr;
@@ -3148,11 +3188,41 @@ Tk_PhotoPutZoomedBlock(
return TCL_OK;
}
+ /*
+ * Fix for Bug e4336bef5d:
+ * Make a local copy of *blockPtr, as we might have to change some
+ * of its fields and don't want to interfere with the caller's data.
+ *
+ * If source and destination are the same image, create a copy of the
+ * source data in our local sourceBlock.
+ *
+ * To find out, just comparing the pointers is not enough - they might have
+ * different values and still point to the same block of memory. (e.g.
+ * if the -from option was passed to [imageName copy])
+ */
+ sourceBlock = *blockPtr;
+ memToFree = NULL;
+ if (sourceBlock.pixelPtr >= masterPtr->pix32
+ && sourceBlock.pixelPtr <= masterPtr->pix32 + masterPtr->width
+ * masterPtr->height * 4) {
+ sourceBlock.pixelPtr = attemptckalloc(sourceBlock.height
+ * sourceBlock.pitch);
+ if (sourceBlock.pixelPtr == NULL) {
+ if (interp != NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
+ Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
+ }
+ return TCL_ERROR;
+ }
+ memToFree = sourceBlock.pixelPtr;
+ memcpy(sourceBlock.pixelPtr, blockPtr->pixelPtr, sourceBlock.height
+ * sourceBlock.pitch);
+ }
+
xEnd = x + width;
yEnd = y + height;
if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) {
- int sameSrc = (blockPtr->pixelPtr == masterPtr->pix32);
-
if (ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width),
MAX(yEnd, masterPtr->height)) == TCL_ERROR) {
if (interp != NULL) {
@@ -3160,11 +3230,7 @@ Tk_PhotoPutZoomedBlock(
TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
}
- return TCL_ERROR;
- }
- if (sameSrc) {
- blockPtr->pixelPtr = masterPtr->pix32;
- blockPtr->pitch = masterPtr->width * 4;
+ goto errorExit;
}
}
@@ -3183,14 +3249,14 @@ Tk_PhotoPutZoomedBlock(
* components, mark it as a color image.
*/
- greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
- blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
- alphaOffset = blockPtr->offset[3];
- if ((alphaOffset >= blockPtr->pixelSize) || (alphaOffset < 0)) {
+ greenOffset = sourceBlock.offset[1] - sourceBlock.offset[0];
+ blueOffset = sourceBlock.offset[2] - sourceBlock.offset[0];
+ alphaOffset = sourceBlock.offset[3];
+ if ((alphaOffset >= sourceBlock.pixelSize) || (alphaOffset < 0)) {
alphaOffset = 0;
sourceIsSimplePhoto = 1;
} else {
- alphaOffset -= blockPtr->offset[0];
+ alphaOffset -= sourceBlock.offset[0];
}
if ((greenOffset != 0) || (blueOffset != 0)) {
masterPtr->flags |= COLOR_IMAGE;
@@ -3201,21 +3267,21 @@ Tk_PhotoPutZoomedBlock(
* subsampling and zooming.
*/
- blockXSkip = subsampleX * blockPtr->pixelSize;
- blockYSkip = subsampleY * blockPtr->pitch;
+ blockXSkip = subsampleX * sourceBlock.pixelSize;
+ blockYSkip = subsampleY * sourceBlock.pitch;
if (subsampleX > 0) {
- blockWid = ((blockPtr->width + subsampleX - 1) / subsampleX) * zoomX;
+ blockWid = ((sourceBlock.width + subsampleX - 1) / subsampleX) * zoomX;
} else if (subsampleX == 0) {
blockWid = width;
} else {
- blockWid = ((blockPtr->width - subsampleX - 1) / -subsampleX) * zoomX;
+ blockWid = ((sourceBlock.width - subsampleX - 1) / -subsampleX) * zoomX;
}
if (subsampleY > 0) {
- blockHt = ((blockPtr->height + subsampleY - 1) / subsampleY) * zoomY;
+ blockHt = ((sourceBlock.height + subsampleY - 1) / subsampleY) * zoomY;
} else if (subsampleY == 0) {
blockHt = height;
} else {
- blockHt = ((blockPtr->height - subsampleY - 1) / -subsampleY) * zoomY;
+ blockHt = ((sourceBlock.height - subsampleY - 1) / -subsampleY) * zoomY;
}
/*
@@ -3223,12 +3289,12 @@ Tk_PhotoPutZoomedBlock(
*/
destLinePtr = masterPtr->pix32 + (y * masterPtr->width + x) * 4;
- srcOrigPtr = blockPtr->pixelPtr + blockPtr->offset[0];
+ srcOrigPtr = sourceBlock.pixelPtr + sourceBlock.offset[0];
if (subsampleX < 0) {
- srcOrigPtr += (blockPtr->width - 1) * blockPtr->pixelSize;
+ srcOrigPtr += (sourceBlock.width - 1) * sourceBlock.pixelSize;
}
if (subsampleY < 0) {
- srcOrigPtr += (blockPtr->height - 1) * blockPtr->pitch;
+ srcOrigPtr += (sourceBlock.height - 1) * sourceBlock.pitch;
}
pitch = masterPtr->width * 4;
@@ -3378,7 +3444,15 @@ Tk_PhotoPutZoomedBlock(
Tk_ImageChanged(masterPtr->tkMaster, x, y, width, height, masterPtr->width,
masterPtr->height);
+
+ if (memToFree) ckfree(memToFree);
+
return TCL_OK;
+
+ errorExit:
+ if (memToFree) ckfree(memToFree);
+
+ return TCL_ERROR;
}
/*
@@ -3953,7 +4027,7 @@ ImgPhotoPostscript(
*
*----------------------------------------------------------------------
*/
-
+#ifndef TK_NO_DEPRECATED
void
Tk_PhotoPutBlock_NoComposite(
Tk_PhotoHandle handle,
@@ -4039,6 +4113,7 @@ Tk_PhotoSetSize_Panic(
Tcl_Panic(TK_PHOTO_ALLOC_FAILURE_MESSAGE);
}
}
+#endif /* TK_NO_DEPRECATED */
/*
* Local Variables:
diff --git a/generic/tkInt.h b/generic/tkInt.h
index a52339d..ed22fc3 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -1224,6 +1224,7 @@ MODULE_SCOPE int TkInitTkCmd(Tcl_Interp *interp,
MODULE_SCOPE int TkInitFontchooser(Tcl_Interp *interp,
ClientData clientData);
MODULE_SCOPE void TkpWarpPointer(TkDisplay *dispPtr);
+MODULE_SCOPE void TkpCancelWarp(TkDisplay *dispPtr);
MODULE_SCOPE int TkListCreateFrame(ClientData clientData,
Tcl_Interp *interp, Tcl_Obj *listObj,
int toplevel, Tcl_Obj *nameObj);
diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c
index 4bfc695..e1a7d97 100644
--- a/generic/tkPanedWindow.c
+++ b/generic/tkPanedWindow.c
@@ -1789,10 +1789,18 @@ ArrangePanes(
*/
if (horizontal) {
- paneSize = slavePtr->paneWidth;
+ if (slavePtr->width > 0) {
+ paneSize = slavePtr->width;
+ } else {
+ paneSize = slavePtr->paneWidth;
+ }
stretchReserve -= paneSize + (2 * slavePtr->padx);
} else {
- paneSize = slavePtr->paneHeight;
+ if (slavePtr->height > 0) {
+ paneSize = slavePtr->height;
+ } else {
+ paneSize = slavePtr->paneHeight;
+ }
stretchReserve -= paneSize + (2 * slavePtr->pady);
}
if (IsStretchable(slavePtr->stretch,i,first,last)
@@ -1842,10 +1850,18 @@ ArrangePanes(
*/
if (horizontal) {
- paneSize = slavePtr->paneWidth;
+ if (slavePtr->width > 0) {
+ paneSize = slavePtr->width;
+ } else {
+ paneSize = slavePtr->paneWidth;
+ }
pwSize = pwWidth;
} else {
- paneSize = slavePtr->paneHeight;
+ if (slavePtr->height > 0) {
+ paneSize = slavePtr->height;
+ } else {
+ paneSize = slavePtr->paneHeight;
+ }
pwSize = pwHeight;
}
if (IsStretchable(slavePtr->stretch, i, first, last)) {
diff --git a/generic/tkSelect.c b/generic/tkSelect.c
index 74b3964..4c3bbfd 100644
--- a/generic/tkSelect.c
+++ b/generic/tkSelect.c
@@ -190,8 +190,8 @@ Tk_CreateSelHandler(
* should make a copy for this selPtr.
*/
- unsigned cmdInfoLen = Tk_Offset(CommandInfo, command) +
- ((CommandInfo *)clientData)->cmdLength + 1;
+ unsigned cmdInfoLen = Tk_Offset(CommandInfo, command) + 1 +
+ ((CommandInfo *)clientData)->cmdLength;
selPtr->clientData = ckalloc(cmdInfoLen);
memcpy(selPtr->clientData, clientData, cmdInfoLen);
diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c
index f760677..a491622 100644
--- a/generic/tkStubInit.c
+++ b/generic/tkStubInit.c
@@ -43,6 +43,12 @@ MODULE_SCOPE const TkStubs tkStubs;
#ifdef TK_NO_DEPRECATED
#define Tk_FreeXId 0
+#define Tk_PhotoPutBlock_NoComposite 0
+#define Tk_PhotoPutZoomedBlock_NoComposite 0
+#define Tk_PhotoExpand_Panic 0
+#define Tk_PhotoPutBlock_Panic 0
+#define Tk_PhotoPutZoomedBlock_Panic 0
+#define Tk_PhotoSetSize_Panic 0
#else
static void
doNothing(void)
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index 81d4f0d..ef06a5b 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.c
@@ -239,6 +239,8 @@ TkCloseDisplay(
{
TkClipCleanup(dispPtr);
+ TkpCancelWarp(dispPtr);
+
if (dispPtr->name != NULL) {
ckfree(dispPtr->name);
}
diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c
index 06aa275..83d7db9 100644
--- a/generic/ttk/ttkNotebook.c
+++ b/generic/ttk/ttkNotebook.c
@@ -4,7 +4,6 @@
#include <string.h>
#include <ctype.h>
-#include <math.h>
#include <stdio.h>
#include <tk.h>
@@ -470,17 +469,15 @@ static void SqueezeTabs(
if (nTabs > 0) {
int difference = available - needed;
- double fraction = (double)difference / needed;
+ double delta = (double)difference / needed;
double slack = 0;
- double ad;
int i;
for (i = 0; i < nTabs; ++i) {
Tab *tab = Ttk_SlaveData(nb->notebook.mgr,i);
-
- ad = slack + tab->width * fraction;
+ double ad = slack + tab->width * delta;
tab->width += (int)ad;
- slack = ad - floor(ad);
+ slack = ad - (int)ad;
}
}
}
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index 80a7a11..3397f71 100644
--- a/macosx/tkMacOSXDialog.c
+++ b/macosx/tkMacOSXDialog.c
@@ -6,6 +6,7 @@
* Copyright (c) 1996-1997 Sun Microsystems, Inc.
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright (c) 2017 Christian Gollwitzer.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -24,6 +25,22 @@
#define modalOther -1
#define modalError -2
+/*Vars for filtering in "open file" and "save file" dialogs.*/
+typedef struct {
+ bool doFileTypes; // show the accessory view which displays the filter menu
+ bool preselectFilter; // a filter was selected by the typevariable
+ bool userHasSelectedFilter; // The user has changed the filter in the accessory view
+ NSMutableArray *fileTypeNames; // array of names, e.g. "Text document"
+ NSMutableArray *fileTypeExtensions; // array of allowed extensions per name, e.g. "txt", "doc"
+ NSMutableArray *fileTypeLabels; // displayed string, e.g. "Text document (.txt, .doc)"
+ NSMutableArray *allAllowedExtensions; // set of all allowed extensions
+ NSInteger fileTypeIndex; // index of currently selected filter
+} filepanelFilterInfo;
+
+filepanelFilterInfo filterInfo;
+
+NSOpenPanel *openpanel;
+NSSavePanel *savepanel;
static const char *const colorOptionStrings[] = {
"-initialcolor", "-parent", "-title", NULL
@@ -142,22 +159,6 @@ static const short alertNativeButtonIndexAndTypeToButtonIndex[][3] = {
[TYPE_YESNOCANCEL] = {5, 6, 4},
};
-/*
- * Construct a file URL from directory and filename. Either may
- * be nil. If both are nil, returns nil.
- */
-#if MAC_OS_X_VERSION_MIN_REQUIRED > 1050
-static NSURL *getFileURL(NSString *directory, NSString *filename) {
- NSURL *url = nil;
- if (directory) {
- url = [NSURL fileURLWithPath:directory];
- }
- if (filename) {
- url = [NSURL URLWithString:filename relativeToURL:url];
- }
- return url;
-}
-#endif
#pragma mark TKApplication(TKDialog)
@@ -212,6 +213,7 @@ static NSURL *getFileURL(NSString *directory, NSString *filename) {
}
}
+
- (void) tkAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode
contextInfo: (void *) contextInfo
{
@@ -247,6 +249,23 @@ static NSURL *getFileURL(NSString *directory, NSString *filename) {
ckfree(callbackInfo);
}
}
+
+- (void)selectFormat:(id)sender {
+ NSPopUpButton *button = (NSPopUpButton *)sender;
+ filterInfo.fileTypeIndex = [button indexOfSelectedItem];
+ NSMutableArray *allowedtypes = filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex];
+ [openpanel setAllowedFileTypes:allowedtypes];
+ filterInfo.userHasSelectedFilter = true;
+
+}
+
+- (void)saveFormat:(id)sender {
+ NSPopUpButton *button = (NSPopUpButton *)sender;
+ filterInfo.fileTypeIndex = [button indexOfSelectedItem];
+ NSMutableArray *allowedtypes = filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex];
+ [savepanel setAllowedFileTypes:allowedtypes];
+}
+
@end
#pragma mark -
@@ -360,6 +379,98 @@ Tk_ChooseColorObjCmd(
end:
return result;
}
+
+/* dissect the -filetype nested lists and store the information
+ * in the filterInfo structure */
+int parseFileFilters(Tcl_Interp *interp, Tcl_Obj *fileTypesPtr, Tcl_Obj *typeVariablePtr) {
+
+ if (!fileTypesPtr) {
+ filterInfo.doFileTypes = false;
+ return TCL_OK;
+ }
+
+ FileFilterList fl;
+ TkInitFileFilters(&fl);
+ if (TkGetFileFilters(interp, &fl, fileTypesPtr, 0) != TCL_OK) {
+ TkFreeFileFilters(&fl);
+ return TCL_ERROR;
+ }
+
+ filterInfo.doFileTypes = (fl.filters != NULL);
+
+ filterInfo.fileTypeIndex = 0;
+ filterInfo.fileTypeExtensions = [NSMutableArray array];
+ filterInfo.fileTypeNames = [NSMutableArray array];
+ filterInfo.fileTypeLabels = [NSMutableArray array];
+ filterInfo.allAllowedExtensions = [NSMutableArray array];
+
+ if (filterInfo.doFileTypes) {
+ for (FileFilter *filterPtr = fl.filters; filterPtr;
+ filterPtr = filterPtr->next) {
+ NSString * name = [[NSString alloc] initWithUTF8String: filterPtr -> name];
+ [filterInfo.fileTypeNames addObject:name];
+ [name release];
+ NSMutableArray * clauseextensions = [NSMutableArray array];
+ NSMutableArray * displayextensions = [NSMutableArray array];
+
+ for (FileFilterClause *clausePtr = filterPtr->clauses; clausePtr;
+ clausePtr = clausePtr->next) {
+ for (GlobPattern *globPtr = clausePtr->patterns; globPtr;
+ globPtr = globPtr->next) {
+ const char *str = globPtr->pattern;
+ while (*str && (*str == '*' || *str == '.')) {
+ str++;
+ }
+ if (*str) {
+ NSString *extension = [[NSString alloc] initWithUTF8String:str];
+ if (![filterInfo.allAllowedExtensions containsObject:extension]) {
+ [filterInfo.allAllowedExtensions addObject:extension];
+ }
+
+ [clauseextensions addObject:extension];
+ [displayextensions addObject:[@"." stringByAppendingString:extension]];
+
+ [extension release];
+ }
+ }
+ }
+ [filterInfo.fileTypeExtensions addObject:clauseextensions];
+
+ NSMutableString * label = [[NSMutableString alloc] initWithString:name];
+ [label appendString:@" ("];
+ [label appendString:[displayextensions componentsJoinedByString:@", "]];
+ [label appendString:@")"];
+ [filterInfo.fileTypeLabels addObject:label];
+ [label release];
+
+ }
+
+ /* Check if the typevariable exists and matches one of the names */
+ filterInfo.preselectFilter = false;
+ filterInfo.userHasSelectedFilter = false;
+ if (typeVariablePtr) {
+ /* extract the variable content as a NSString */
+ Tcl_Obj *selectedFileTypeObj = Tcl_ObjGetVar2(interp, typeVariablePtr, NULL, TCL_GLOBAL_ONLY);
+
+ /* check that the typevariable exists */
+ if (selectedFileTypeObj != NULL) {
+ const char *selectedFileType = Tcl_GetString(selectedFileTypeObj);
+ NSString *selectedFileTypeStr = [[NSString alloc] initWithUTF8String:selectedFileType];
+ NSUInteger index = [filterInfo.fileTypeNames indexOfObject:selectedFileTypeStr];
+
+ if (index != NSNotFound) {
+ filterInfo.fileTypeIndex = index;
+ filterInfo.preselectFilter = true;
+ }
+ }
+ }
+
+ }
+
+ TkFreeFileFilters(&fl);
+ return TCL_OK;
+}
+
/*
*----------------------------------------------------------------------
@@ -388,19 +499,16 @@ Tk_GetOpenFileObjCmd(
char *str;
int i, result = TCL_ERROR, haveParentOption = 0;
int index, len, multiple = 0;
- FileFilterList fl;
- Tcl_Obj *cmdObj = NULL, *typeVariablePtr = NULL;
+ Tcl_Obj *cmdObj = NULL, *typeVariablePtr = NULL, *fileTypesPtr = NULL;
FilePanelCallbackInfo callbackInfoStruct;
FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct;
NSString *directory = nil, *filename = nil;
- NSString *message, *title, *type;
+ NSString *message = nil, *title = nil;
NSWindow *parent;
- NSMutableArray *fileTypes = nil;
- NSOpenPanel *panel = [NSOpenPanel openPanel];
+ openpanel = [NSOpenPanel openPanel];
NSInteger modalReturnCode = modalError;
BOOL parentIsKey = NO;
- TkInitFileFilters(&fl);
for (i = 1; i < objc; i += 2) {
if (Tcl_GetIndexFromObjStruct(interp, objv[i], openOptionStrings,
sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) {
@@ -416,9 +524,7 @@ Tk_GetOpenFileObjCmd(
case OPEN_DEFAULT:
break;
case OPEN_FILETYPES:
- if (TkGetFileFilters(interp, &fl, objv[i + 1], 0) != TCL_OK) {
- goto end;
- }
+ fileTypesPtr = objv[i + 1];
break;
case OPEN_INITDIR:
str = Tcl_GetStringFromObj(objv[i + 1], &len);
@@ -432,13 +538,12 @@ Tk_GetOpenFileObjCmd(
if (len) {
filename = [[[NSString alloc] initWithUTF8String:str]
autorelease];
+ [openpanel setNameFieldStringValue:filename];
}
break;
case OPEN_MESSAGE:
message = [[NSString alloc] initWithUTF8String:
Tcl_GetString(objv[i + 1])];
- [panel setMessage:message];
- [message release];
break;
case OPEN_MULTIPLE:
if (Tcl_GetBooleanFromObj(interp, objv[i + 1],
@@ -457,8 +562,6 @@ Tk_GetOpenFileObjCmd(
case OPEN_TITLE:
title = [[NSString alloc] initWithUTF8String:
Tcl_GetString(objv[i + 1])];
- [panel setTitle:title];
- [title release];
break;
case OPEN_TYPEVARIABLE:
typeVariablePtr = objv[i + 1];
@@ -468,40 +571,70 @@ Tk_GetOpenFileObjCmd(
break;
}
}
- [panel setAllowsMultipleSelection:multiple];
- if (fl.filters) {
- fileTypes = [NSMutableArray array];
- for (FileFilter *filterPtr = fl.filters; filterPtr;
- filterPtr = filterPtr->next) {
- for (FileFilterClause *clausePtr = filterPtr->clauses; clausePtr;
- clausePtr = clausePtr->next) {
- for (GlobPattern *globPtr = clausePtr->patterns; globPtr;
- globPtr = globPtr->next) {
- str = globPtr->pattern;
- while (*str && (*str == '*' || *str == '.')) {
- str++;
- }
- if (*str) {
- type = [[NSString alloc] initWithUTF8String:str];
- if (![fileTypes containsObject:type]) {
- [fileTypes addObject:type];
- }
- [type release];
- }
- }
- for (MacFileType *mfPtr = clausePtr->macTypes; mfPtr;
- mfPtr = mfPtr->next) {
- if (mfPtr->type) {
- type = NSFileTypeForHFSTypeCode(mfPtr->type);
- if (![fileTypes containsObject:type]) {
- [fileTypes addObject:type];
- }
- }
- }
- }
+
+ /* From OSX 10.11, the title string is silently ignored.
+ * Prepend the title to the message
+ * NOTE should be conditional on OSX version, but
+ * -mmacosx-version-min does not revert this behaviour*/
+ if (title) {
+ [openpanel setTitle:title];
+ if (message) {
+ NSString *fullmessage = [[NSString alloc] initWithFormat:@"%@\n%@",title,message];
+ [message release];
+ [title release];
+ message = fullmessage;
+ } else {
+ message = title;
+ }
+ }
+
+ if (message) {
+ [openpanel setMessage:message];
+ [message release];
+ }
+
+ [openpanel setAllowsMultipleSelection:multiple];
+
+ if (parseFileFilters(interp, fileTypesPtr, typeVariablePtr) != TCL_OK) {
+ goto end;
+ }
+
+ if (filterInfo.doFileTypes) {
+ NSView *accessoryView = [[NSView alloc] initWithFrame:NSMakeRect(0.0, 0.0, 200, 32.0)];
+ NSTextField *label = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 60, 22)];
+ [label setEditable:NO];
+ [label setStringValue:@"Enable:"];
+ [label setBordered:NO];
+ [label setBezeled:NO];
+ [label setDrawsBackground:NO];
+
+ NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(50.0, 2, 140, 22.0) pullsDown:NO];
+ [popupButton addItemsWithTitles:filterInfo.fileTypeLabels];
+ [popupButton setAction:@selector(selectFormat:)];
+
+ [accessoryView addSubview:label];
+ [accessoryView addSubview:popupButton];
+
+ if (filterInfo.preselectFilter) {
+ /* A specific filter was selected from the typevariable. Select it and
+ * open the accessory view */
+ [popupButton selectItemAtIndex:filterInfo.fileTypeIndex];
+ /* on OSX > 10.11, the optons are not visible by default. Ergo allow all file types
+ [openpanel setAllowedFileTypes:filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex]];
+ */
+ [openpanel setAllowedFileTypes:filterInfo.allAllowedExtensions];
+ } else {
+ [openpanel setAllowedFileTypes:filterInfo.allAllowedExtensions];
}
+
+ [openpanel setAllowsOtherFileTypes:NO];
+
+ [openpanel setAccessoryView:accessoryView];
+ } else {
+ /* No filters are given. Allow picking all files */
+ [openpanel setAllowsOtherFileTypes:YES];
}
- [panel setAllowedFileTypes:fileTypes];
+
if (cmdObj) {
callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo));
if (Tcl_IsShared(cmdObj)) {
@@ -509,6 +642,7 @@ Tk_GetOpenFileObjCmd(
}
Tcl_IncrRefCount(cmdObj);
}
+
callbackInfo->cmdObj = cmdObj;
callbackInfo->interp = interp;
callbackInfo->multiple = multiple;
@@ -516,52 +650,63 @@ Tk_GetOpenFileObjCmd(
if (haveParentOption && parent && ![parent attachedSheet]) {
parentIsKey = [parent isKeyWindow];
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- [panel beginSheetForDirectory:directory
+ [openpanel beginSheetForDirectory:directory
file:filename
- types:fileTypes
+ types:openFileTypes
modalForWindow:parent
modalDelegate:NSApp
didEndSelector:
@selector(tkFilePanelDidEnd:returnCode:contextInfo:)
contextInfo:callbackInfo];
#else
- [panel setAllowedFileTypes:fileTypes];
- [panel setDirectoryURL:getFileURL(directory, filename)];
- [panel beginSheetModalForWindow:parent
+ if (directory) {
+ [openpanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
+ }
+ [openpanel setNameFieldStringValue:filename];
+ [openpanel beginSheetModalForWindow:parent
completionHandler:^(NSInteger returnCode)
- { [NSApp tkFilePanelDidEnd:panel
+ { [NSApp tkFilePanelDidEnd:openpanel
returnCode:returnCode
contextInfo:callbackInfo ]; } ];
#endif
- modalReturnCode = cmdObj ? modalOther : [NSApp runModalForWindow:panel];
+ modalReturnCode = cmdObj ? modalOther : [NSApp runModalForWindow:openpanel];
} else {
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- modalReturnCode = [panel runModalForDirectory:directory
+ modalReturnCode = [openpanel runModalForDirectory:directory
file:filename];
#else
- [panel setDirectoryURL:getFileURL(directory, filename)];
- modalReturnCode = [panel runModal];
+ if (directory) {
+ [openpanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
+ }
+ [openpanel setNameFieldStringValue:filename];
+ modalReturnCode = [openpanel runModal];
#endif
- [NSApp tkFilePanelDidEnd:panel returnCode:modalReturnCode
+ [NSApp tkFilePanelDidEnd:openpanel returnCode:modalReturnCode
contextInfo:callbackInfo];
}
result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR;
if (parentIsKey) {
[parent makeKeyWindow];
}
- if (typeVariablePtr && result == TCL_OK) {
+
+ if ((typeVariablePtr && (modalReturnCode == NSOKButton)) &&
+ filterInfo.doFileTypes && filterInfo.userHasSelectedFilter) {
/*
- * The -typevariable option is not really supported.
+ * The -typevariable must be set to the selected file type, if the dialog was not cancelled
*/
-
- Tcl_SetVar2(interp, Tcl_GetString(typeVariablePtr), NULL,
- "", TCL_GLOBAL_ONLY);
+ #if 0
+ NSLog(@"result: %i modal: %li", result, (long)modalReturnCode);
+ #endif
+ NSString * selectedFilter = filterInfo.fileTypeNames[filterInfo.fileTypeIndex];
+ Tcl_ObjSetVar2(interp, typeVariablePtr, NULL,
+ Tcl_NewStringObj([selectedFilter UTF8String], -1), TCL_GLOBAL_ONLY);
}
+
end:
- TkFreeFileFilters(&fl);
return result;
}
+
/*
*----------------------------------------------------------------------
@@ -591,19 +736,16 @@ Tk_GetSaveFileObjCmd(
int i, result = TCL_ERROR, haveParentOption = 0;
int confirmOverwrite = 1;
int index, len;
- FileFilterList fl;
- Tcl_Obj *cmdObj = NULL;
+ Tcl_Obj *cmdObj = NULL, *typeVariablePtr = NULL, *fileTypesPtr = NULL;
FilePanelCallbackInfo callbackInfoStruct;
FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct;
NSString *directory = nil, *filename = nil, *defaultType = nil;
- NSString *message, *title, *type;
+ NSString *message = nil, *title = nil;
NSWindow *parent;
- NSMutableArray *fileTypes = nil;
- NSSavePanel *panel = [NSSavePanel savePanel];
+ savepanel = [NSSavePanel savePanel];
NSInteger modalReturnCode = modalError;
BOOL parentIsKey = NO;
- TkInitFileFilters(&fl);
for (i = 1; i < objc; i += 2) {
if (Tcl_GetIndexFromObjStruct(interp, objv[i], saveOptionStrings,
sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) {
@@ -616,96 +758,120 @@ Tk_GetSaveFileObjCmd(
goto end;
}
switch (index) {
- case SAVE_DEFAULT:
- str = Tcl_GetStringFromObj(objv[i + 1], &len);
- while (*str && (*str == '*' || *str == '.')) {
- str++;
- }
- if (*str) {
- defaultType = [[[NSString alloc] initWithUTF8String:str]
- autorelease];
- }
- break;
- case SAVE_FILETYPES:
- if (TkGetFileFilters(interp, &fl, objv[i + 1], 0) != TCL_OK) {
- goto end;
- }
- break;
- case SAVE_INITDIR:
- str = Tcl_GetStringFromObj(objv[i + 1], &len);
- if (len) {
- directory = [[[NSString alloc] initWithUTF8String:str]
- autorelease];
- }
- break;
- case SAVE_INITFILE:
- str = Tcl_GetStringFromObj(objv[i + 1], &len);
- if (len) {
- filename = [[[NSString alloc] initWithUTF8String:str]
- autorelease];
- }
- break;
- case SAVE_MESSAGE:
- message = [[NSString alloc] initWithUTF8String:
- Tcl_GetString(objv[i + 1])];
- [panel setMessage:message];
+ case SAVE_DEFAULT:
+ str = Tcl_GetStringFromObj(objv[i + 1], &len);
+ while (*str && (*str == '*' || *str == '.')) {
+ str++;
+ }
+ if (*str) {
+ defaultType = [[[NSString alloc] initWithUTF8String:str]
+ autorelease];
+ }
+ break;
+ case SAVE_FILETYPES:
+ fileTypesPtr = objv[i + 1];
+ break;
+ case SAVE_INITDIR:
+ str = Tcl_GetStringFromObj(objv[i + 1], &len);
+ if (len) {
+ directory = [[[NSString alloc] initWithUTF8String:str]
+ autorelease];
+ }
+ break;
+ case SAVE_INITFILE:
+ str = Tcl_GetStringFromObj(objv[i + 1], &len);
+ if (len) {
+ filename = [[[NSString alloc] initWithUTF8String:str]
+ autorelease];
+ [savepanel setNameFieldStringValue:filename];
+ }
+ break;
+ case SAVE_MESSAGE:
+ message = [[NSString alloc] initWithUTF8String:
+ Tcl_GetString(objv[i + 1])];
+ break;
+ case SAVE_PARENT:
+ str = Tcl_GetStringFromObj(objv[i + 1], &len);
+ tkwin = Tk_NameToWindow(interp, str, tkwin);
+ if (!tkwin) {
+ goto end;
+ }
+ haveParentOption = 1;
+ break;
+ case SAVE_TITLE:
+ title = [[NSString alloc] initWithUTF8String:
+ Tcl_GetString(objv[i + 1])];
+ break;
+ case SAVE_TYPEVARIABLE:
+ typeVariablePtr = objv[i + 1];
+ break;
+ case SAVE_COMMAND:
+ cmdObj = objv[i+1];
+ break;
+ case SAVE_CONFIRMOW:
+ if (Tcl_GetBooleanFromObj(interp, objv[i + 1],
+ &confirmOverwrite) != TCL_OK) {
+ goto end;
+ }
+ break;
+ }
+ }
+
+ if (title) {
+ [savepanel setTitle:title];
+ if (message) {
+ NSString *fullmessage = [[NSString alloc] initWithFormat:@"%@\n%@",title,message];
[message release];
- break;
- case SAVE_PARENT:
- str = Tcl_GetStringFromObj(objv[i + 1], &len);
- tkwin = Tk_NameToWindow(interp, str, tkwin);
- if (!tkwin) {
- goto end;
- }
- haveParentOption = 1;
- break;
- case SAVE_TITLE:
- title = [[NSString alloc] initWithUTF8String:
- Tcl_GetString(objv[i + 1])];
- [panel setTitle:title];
[title release];
- break;
- case SAVE_TYPEVARIABLE:
- break;
- case SAVE_COMMAND:
- cmdObj = objv[i+1];
- break;
- case SAVE_CONFIRMOW:
- if (Tcl_GetBooleanFromObj(interp, objv[i + 1],
- &confirmOverwrite) != TCL_OK) {
- goto end;
- }
- break;
+ message = fullmessage;
+ } else {
+ message = title;
}
}
- if (fl.filters || defaultType) {
- fileTypes = [NSMutableArray array];
- [fileTypes addObject:defaultType ? defaultType : (id)kUTTypeContent];
- for (FileFilter *filterPtr = fl.filters; filterPtr;
- filterPtr = filterPtr->next) {
- for (FileFilterClause *clausePtr = filterPtr->clauses; clausePtr;
- clausePtr = clausePtr->next) {
- for (GlobPattern *globPtr = clausePtr->patterns; globPtr;
- globPtr = globPtr->next) {
- str = globPtr->pattern;
- while (*str && (*str == '*' || *str == '.')) {
- str++;
- }
- if (*str) {
- type = [[NSString alloc] initWithUTF8String:str];
- if (![fileTypes containsObject:type]) {
- [fileTypes addObject:type];
- }
- [type release];
- }
- }
- }
- }
- [panel setAllowedFileTypes:fileTypes];
- [panel setAllowsOtherFileTypes:YES];
+
+ if (message) {
+ [savepanel setMessage:message];
+ [message release];
+ }
+
+ if (parseFileFilters(interp, fileTypesPtr, typeVariablePtr) != TCL_OK) {
+ goto end;
}
- [panel setCanSelectHiddenExtension:YES];
- [panel setExtensionHidden:NO];
+
+ if (filterInfo.doFileTypes) {
+ NSView *accessoryView = [[NSView alloc] initWithFrame:NSMakeRect(0.0, 0.0, 200, 32.0)];
+ NSTextField *label = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 60, 22)];
+ [label setEditable:NO];
+ [label setStringValue:NSLocalizedString(@"Format:", nil)];
+ [label setBordered:NO];
+ [label setBezeled:NO];
+ [label setDrawsBackground:NO];
+
+ NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(50.0, 2, 140, 22.0) pullsDown:NO];
+ [popupButton addItemsWithTitles:filterInfo.fileTypeLabels];
+ [popupButton selectItemAtIndex:filterInfo.fileTypeIndex];
+ [popupButton setAction:@selector(saveFormat:)];
+
+ [accessoryView addSubview:label];
+ [accessoryView addSubview:popupButton];
+
+ [savepanel setAccessoryView:accessoryView];
+
+ [savepanel setAllowedFileTypes:filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex]];
+ [savepanel setAllowsOtherFileTypes:NO];
+ } else if (defaultType) {
+ /* If no filetypes are given, defaultextension is an alternative way
+ * to specify the attached extension. Just propose this extension,
+ * but don't display an accessory view */
+ NSMutableArray *AllowedFileTypes = [NSMutableArray array];
+ [AllowedFileTypes addObject:defaultType];
+ [savepanel setAllowedFileTypes:AllowedFileTypes];
+ [savepanel setAllowsOtherFileTypes:YES];
+ }
+
+ [savepanel setCanSelectHiddenExtension:YES];
+ [savepanel setExtensionHidden:NO];
+
if (cmdObj) {
callbackInfo = ckalloc(sizeof(FilePanelCallbackInfo));
if (Tcl_IsShared(cmdObj)) {
@@ -716,11 +882,12 @@ Tk_GetSaveFileObjCmd(
callbackInfo->cmdObj = cmdObj;
callbackInfo->interp = interp;
callbackInfo->multiple = 0;
+
parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window);
if (haveParentOption && parent && ![parent attachedSheet]) {
parentIsKey = [parent isKeyWindow];
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- [panel beginSheetForDirectory:directory
+ [savepanel beginSheetForDirectory:directory
file:filename
modalForWindow:parent
modalDelegate:NSApp
@@ -728,30 +895,52 @@ Tk_GetSaveFileObjCmd(
@selector(tkFilePanelDidEnd:returnCode:contextInfo:)
contextInfo:callbackInfo];
#else
- [panel setDirectoryURL:getFileURL(directory, filename)];
- [panel beginSheetModalForWindow:parent
+ if (directory) {
+ [savepanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
+ }
+ [savepanel setNameFieldStringValue:filename];
+ [savepanel beginSheetModalForWindow:parent
completionHandler:^(NSInteger returnCode)
- { [NSApp tkFilePanelDidEnd:panel
+ { [NSApp tkFilePanelDidEnd:savepanel
returnCode:returnCode
contextInfo:callbackInfo ]; } ];
#endif
- modalReturnCode = cmdObj ? modalOther : [NSApp runModalForWindow:panel];
+ modalReturnCode = cmdObj ? modalOther : [NSApp runModalForWindow:savepanel];
} else {
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- modalReturnCode = [panel runModalForDirectory:directory file:filename];
+ modalReturnCode = [savepanel runModalForDirectory:directory file:filename];
#else
- [panel setDirectoryURL:getFileURL(directory, filename)];
- modalReturnCode = [panel runModal];
+ if (directory) {
+ [savepanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
+ }
+ [savepanel setNameFieldStringValue:filename];
+ modalReturnCode = [savepanel runModal];
+ #if 0
+ NSLog(@"modal: %li", modalReturnCode);
+ #endif
#endif
- [NSApp tkFilePanelDidEnd:panel returnCode:modalReturnCode
+ [NSApp tkFilePanelDidEnd:savepanel returnCode:modalReturnCode
contextInfo:callbackInfo];
}
result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR;
if (parentIsKey) {
[parent makeKeyWindow];
}
+
+ if ((typeVariablePtr && (modalReturnCode == NSOKButton)) && filterInfo.doFileTypes) {
+ /*
+ * The -typevariable must be set to the selected file type, if the dialog was not cancelled
+ */
+ #if 0
+ NSLog(@"result: %i modal: %li", result, (long)modalReturnCode);
+ #endif
+ NSString * selectedFilter = filterInfo.fileTypeNames[filterInfo.fileTypeIndex];
+ Tcl_ObjSetVar2(interp, typeVariablePtr, NULL,
+ Tcl_NewStringObj([selectedFilter UTF8String], -1), TCL_GLOBAL_ONLY);
+ }
+
+
end:
- TkFreeFileFilters(&fl);
return result;
}
@@ -787,7 +976,7 @@ Tk_ChooseDirectoryObjCmd(
Tcl_Obj *cmdObj = NULL;
FilePanelCallbackInfo callbackInfoStruct;
FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct;
- NSString *directory = nil, *filename = nil;
+ NSString *directory = nil;
NSString *message, *title;
NSWindow *parent;
NSOpenPanel *panel = [NSOpenPanel openPanel];
@@ -863,13 +1052,13 @@ Tk_ChooseDirectoryObjCmd(
parentIsKey = [parent isKeyWindow];
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
[panel beginSheetForDirectory:directory
- file:filename
+ file:nil
modalForWindow:parent
modalDelegate:NSApp
didEndSelector: @selector(tkFilePanelDidEnd:returnCode:contextInfo:)
contextInfo:callbackInfo];
#else
- [panel setDirectoryURL:getFileURL(directory, filename)];
+ [panel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
[panel beginSheetModalForWindow:parent
completionHandler:^(NSInteger returnCode)
{ [NSApp tkFilePanelDidEnd:panel
@@ -881,7 +1070,7 @@ Tk_ChooseDirectoryObjCmd(
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
modalReturnCode = [panel runModalForDirectory:directory file:nil];
#else
- [panel setDirectoryURL:getFileURL(directory, filename)];
+ [panel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]];
modalReturnCode = [panel runModal];
#endif
[NSApp tkFilePanelDidEnd:panel returnCode:modalReturnCode
diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c
index b5ae1a3..fd4c19a 100644
--- a/macosx/tkMacOSXFont.c
+++ b/macosx/tkMacOSXFont.c
@@ -515,7 +515,7 @@ TkpGetFontFromAttributes(
/* Set of attributes to match. */
{
MacFont *fontPtr;
- int points = TkFontGetPoints(tkwin, faPtr->size);
+ int points = (int)(TkFontGetPoints(tkwin, faPtr->size) + 0.5);
NSFontTraitMask traits = GetNSFontTraitsFromTkFontAttributes(faPtr);
NSInteger weight = (faPtr->weight == TK_FW_BOLD ? 9 : 5);
NSFont *nsFont;
diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c
index 91cf112..49ba999 100644
--- a/macosx/tkMacOSXScrlbr.c
+++ b/macosx/tkMacOSXScrlbr.c
@@ -19,6 +19,13 @@
#define MIN_SCROLLBAR_VALUE 0
+/*
+ * Minimum slider length, in pixels (designed to make sure that the slider is
+ * always easy to grab with the mouse).
+ */
+
+#define MIN_SLIDER_LENGTH 5
+
/*Borrowed from ttkMacOSXTheme.c to provide appropriate scaling of scrollbar values.*/
#ifdef __LP64__
#define RangeToFactor(maximum) (((double) (INT_MAX >> 1)) / (maximum))
@@ -60,16 +67,14 @@ typedef struct ScrollbarMetrics {
} ScrollbarMetrics;
static ScrollbarMetrics metrics[2] = {
- {15, 54, 26, 14, 14, NSRegularControlSize}, /* kThemeScrollBarMedium */
- {11, 40, 20, 10, 10, NSSmallControlSize}, /* kThemeScrollBarSmall */
+ {15, 54, 26, 14, 14, kControlSizeNormal}, /* kThemeScrollBarMedium */
+ {11, 40, 20, 10, 10, kControlSizeSmall}, /* kThemeScrollBarSmall */
};
-
HIThemeTrackDrawInfo info = {
.version = 0,
.min = 0.0,
.max = 100.0,
.attributes = kThemeTrackShowThumb,
- .kind = kThemeScrollBarMedium,
};
@@ -107,7 +112,7 @@ TkpCreateScrollbar(
scrollPtr->troughGC = None;
scrollPtr->copyGC = None;
- Tk_CreateEventHandler(tkwin,ExposureMask|StructureNotifyMask|FocusChangeMask|ButtonPressMask|VisibilityChangeMask, ScrollbarEventProc, scrollPtr);
+ Tk_CreateEventHandler(tkwin,ExposureMask|StructureNotifyMask|FocusChangeMask|ButtonPressMask|ButtonReleaseMask|EnterWindowMask|LeaveWindowMask|VisibilityChangeMask, ScrollbarEventProc, scrollPtr);
return (TkScrollbar *) scrollPtr;
}
@@ -212,7 +217,8 @@ TkpDisplayScrollbar(
*----------------------------------------------------------------------
*/
-extern void
+
+ extern void
TkpComputeScrollbarGeometry(
register TkScrollbar *scrollPtr)
/* Scrollbar whose geometry may have
@@ -259,14 +265,12 @@ TkpComputeScrollbarGeometry(
if (scrollPtr->sliderLast > fieldLength) {
scrollPtr->sliderLast = fieldLength;
}
- if (!(MOUNTAIN_LION_STYLE)) {
- scrollPtr->sliderFirst += scrollPtr->inset +
- metrics[variant].topArrowHeight;
- scrollPtr->sliderLast += scrollPtr->inset +
- metrics[variant].bottomArrowHeight;
- }
- /*
- * Register the desired geometry for the window (leave enough space
+
+ scrollPtr->sliderFirst += scrollPtr->arrowLength + scrollPtr->inset;
+ scrollPtr->sliderLast += scrollPtr->arrowLength + scrollPtr->inset;
+
+
+ /* Register the desired geometry for the window (leave enough space
* for the two arrows plus a minimum-size slider, plus border around
* the whole window, if any). Then arrange for the window to be
* redisplayed.
@@ -281,6 +285,9 @@ TkpComputeScrollbarGeometry(
}
+
+
+
/*
*----------------------------------------------------------------------
*
@@ -376,21 +383,22 @@ TkpScrollbarPosition(
register const int arrowSize = scrollPtr->arrowLength + inset;
if (scrollPtr->vertical) {
- length = Tk_Height(scrollPtr->tkwin);
- fieldlength = length - 2 * arrowSize;
- width = Tk_Width(scrollPtr->tkwin);
+ length = Tk_Height(scrollPtr->tkwin);
+ fieldlength = length - 2 * arrowSize;
+ width = Tk_Width(scrollPtr->tkwin);
} else {
- tmp = x;
- x = y;
- y = tmp;
- length = Tk_Width(scrollPtr->tkwin);
- fieldlength = length - 2 * arrowSize;
- width = Tk_Height(scrollPtr->tkwin);
+ tmp = x;
+ x = y;
+ y = tmp;
+ length = Tk_Width(scrollPtr->tkwin);
+ fieldlength = length - 2 * arrowSize;
+ width = Tk_Height(scrollPtr->tkwin);
}
+
fieldlength = fieldlength < 0 ? 0 : fieldlength;
if (x<inset || x>=width-inset || y<inset || y>=length-inset) {
- return OUTSIDE;
+ return OUTSIDE;
}
/*
@@ -399,18 +407,19 @@ TkpScrollbarPosition(
*/
if (y < scrollPtr->sliderFirst) {
- return TOP_GAP;
+ return TOP_GAP;
}
if (y < scrollPtr->sliderLast) {
- return SLIDER;
+ return SLIDER;
}
if (y < fieldlength){
- return BOTTOM_GAP;
+ return BOTTOM_GAP;
}
if (y < fieldlength + arrowSize) {
- return TOP_ARROW;
+ return TOP_ARROW;
}
return BOTTOM_ARROW;
+
}
/*
@@ -458,7 +467,7 @@ UpdateControlValues(
width = contrlRect.size.width;
height = contrlRect.size.height;
- variant = contrlRect.size.width < metrics[0].width ? 1 : 0;
+ variant = contrlRect.size.width < metrics[0].width ? 1 : 0;
/*
* Ensure we set scrollbar control bounds only once all size adjustments
@@ -514,8 +523,8 @@ UpdateControlValues(
*
* ScrollbarPress --
*
- * This procedure is invoked in response to <ButtonPress> events.
- * Enters a modal loop to handle scrollbar interactions.
+ * This procedure is invoked in response to <ButtonPress>, <ButtonRelease>,
+ * <EnterNotify>, and <LeaveNotify> events. Scrollbar appearance is modified.
*
*--------------------------------------------------------------
*/
@@ -526,6 +535,13 @@ ScrollbarPress(TkScrollbar *scrollPtr, XEvent *eventPtr)
if (eventPtr->type == ButtonPress) {
UpdateControlValues(scrollPtr);
+ info.trackInfo.scrollbar.pressState = 1;
+ }
+ if (eventPtr->type == EnterNotify) {
+ info.trackInfo.scrollbar.pressState = 1;
+ }
+ if (eventPtr->type == ButtonRelease || eventPtr->type == LeaveNotify) {
+ info.trackInfo.scrollbar.pressState = 0;
}
return TCL_OK;
}
@@ -566,6 +582,9 @@ ScrollbarEventProc(
TkScrollbarEventuallyRedraw(scrollPtr);
break;
case ButtonPress:
+ case ButtonRelease:
+ case EnterNotify:
+ case LeaveNotify:
ScrollbarPress(clientData, eventPtr);
break;
default:
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 39990e6..75473bf 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -2893,17 +2893,20 @@ WmProtocolCmd(
} else {
prevPtr->nextPtr = protPtr->nextPtr;
}
+ if (protPtr->command)
+ ckfree(protPtr->command);
Tcl_EventuallyFree(protPtr, TCL_DYNAMIC);
break;
}
}
cmd = Tcl_GetStringFromObj(objv[4], &cmdLength);
if (cmdLength > 0) {
- protPtr = ckalloc(HANDLER_SIZE(cmdLength));
+ protPtr = ckalloc(sizeof(ProtocolHandler));
protPtr->protocol = protocol;
protPtr->nextPtr = wmPtr->protPtr;
wmPtr->protPtr = protPtr;
protPtr->interp = interp;
+ protPtr->command = ckalloc(cmdLength+1);
strcpy(protPtr->command, cmd);
}
return TCL_OK;
diff --git a/macosx/tkMacOSXWm.h b/macosx/tkMacOSXWm.h
index 0a128ef..e904f50 100644
--- a/macosx/tkMacOSXWm.h
+++ b/macosx/tkMacOSXWm.h
@@ -29,15 +29,13 @@ typedef struct ProtocolHandler {
* same top-level window, or NULL for end of
* list. */
Tcl_Interp *interp; /* Interpreter in which to invoke command. */
- char command[]; /* Tcl command to invoke when a client message
+ char* command; /* Tcl command to invoke when a client message
* for this protocol arrives. The actual size
* of the structure varies to accommodate the
* needs of the actual command. THIS MUST BE
* THE LAST FIELD OF THE STRUCTURE. */
} ProtocolHandler;
-#define HANDLER_SIZE(cmdLength) \
-((unsigned) (sizeof(ProtocolHandler) + cmdLength + 1))
/*
* A data structure of the following type holds window-manager-related
diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c
index 2251b8f..004ac1b 100644
--- a/macosx/tkMacOSXXStubs.c
+++ b/macosx/tkMacOSXXStubs.c
@@ -882,16 +882,18 @@ XGetImage(
int bitmap_pad = 0;
int bytes_per_row = 4*width;
int size;
- MacDrawable *macDraw = (MacDrawable *) d;
+ MacDrawable *macDraw = (MacDrawable *) d; // Where is this variable used? May it be removed?
+ int scalefactor = 1;
+#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
NSWindow *win = TkMacOSXDrawableWindow(d);
/* This code assumes that backing scale factors are integers. Currently
* Retina displays use a scale factor of 2.0 and normal displays use 1.0.
* We do not support any other values here.
*/
- int scalefactor = 1;
if (win && [win respondsToSelector:@selector(backingScaleFactor)]) {
scalefactor = ([win backingScaleFactor] == 2.0) ? 2 : 1;
}
+#endif
int scaled_height = height * scalefactor;
int scaled_width = width * scalefactor;
diff --git a/tests/imgBmap.test b/tests/imgBmap.test
index 5ffd7c4..e7f2c7e 100644
--- a/tests/imgBmap.test
+++ b/tests/imgBmap.test
@@ -380,7 +380,8 @@ test imageBmap-7.9 {ImgBmapCmd procedure} -body {
test imageBmap-7.10 {ImgBmapCmd procedure} -body {
i1 gorp
} -returnCodes error -result {bad option "gorp": must be cget or configure}
-
+# Clean it up after use!!
+imageCleanup
test imageBmap-8.1 {ImgBmapGet/Free procedures, shared instances} -setup {
destroy .c
diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test
index 0b8f95b..b643344 100644
--- a/tests/imgPhoto.test
+++ b/tests/imgPhoto.test
@@ -1496,7 +1496,44 @@ test imgPhoto-10.1 {Tk_ImgPhotoPutBlock procedure} -setup {
photo1 put "{#00ff00 #00ff00}" -to 2 0
list [photo1 get 2 0] [photo1 get 3 0] [photo1 get 4 0]
} -result {{0 255 0} {0 255 0} {255 0 0}}
-
+test imgPhoto-10.2 {Tk_ImgPhotoPutBlock, same source and dest img} -constraints {
+ hasTeapotPhoto
+} -setup {
+ imageCleanup
+} -body {
+ # Test for bug e4336bef5d
+ image create photo photo1 -file $teapotPhotoFile
+ image create photo photo2 -file $teapotPhotoFile
+ photo2 copy photo1 -to 1 2
+ photo1 copy photo1 -to 1 2
+ string equal [photo1 data] [photo2 data]
+} -cleanup {
+ imageCleanup
+} -result {1}
+test imgPhoto-10.3 {Tk_ImgPhotoPutBlock, same source and dest img} -constraints {
+ hasTeapotPhoto
+} -setup {
+ imageCleanup
+} -body {
+ # Test for bug e4336bef5d
+ image create photo photo1 -file $teapotPhotoFile
+ image create photo photo2 -file $teapotPhotoFile
+ photo2 copy photo1 -from 2 1 -to 4 5 300 300
+ photo1 copy photo1 -from 2 1 -to 4 5 300 300
+ string equal [photo1 data] [photo2 data]
+} -cleanup {
+ imageCleanup
+} -result {1}
+test imgPhoto-10.4 {Tk_ImgPhotoPutBlock, empty image} -setup {
+ imageCleanup
+} -body {
+ image create photo photo1
+ photo1 copy photo1 -to 0 5 10 20
+ list [image width photo1] [image height photo1]
+} -cleanup {
+ imageCleanup
+} -result {0 0}
+
test imgPhoto-11.1 {Tk_FindPhoto} -setup {
imageCleanup
} -body {
@@ -1515,7 +1552,42 @@ test imgPhoto-12.1 {Tk_PhotoPutZoomedBlock} -constraints hasTeapotPhoto -body {
} -cleanup {
image delete p3
} -result {{19 92 192} {169 117 90} 512 512 {19 92 192}}
-
+test imgPhoto-12.2 {Tk_ImgPhotoPutZoomedBlock, same source and dest img} -constraints {
+ hasTeapotPhoto
+} -setup {
+ imageCleanup
+} -body {
+ # Test for bug e4336bef5d
+ image create photo photo1 -file $teapotPhotoFile
+ image create photo photo2 -file $teapotPhotoFile
+ photo2 copy photo1 -to 0 1 200 200 -zoom 2 3
+ photo1 copy photo1 -to 0 1 200 200 -zoom 2 3
+ string equal [photo1 data] [photo2 data]
+} -cleanup {
+ imageCleanup
+} -result {1}
+test imgPhoto-12.3 {Tk_ImgPhotoPutZoomedBlock, same source and dest img} -setup {
+ imageCleanup
+} -body {
+ # Test for bug e4336bef5d
+ image create photo photo1 -file $teapotPhotoFile
+ image create photo photo2 -file $teapotPhotoFile
+ photo2 copy photo1 -from 1 0 -to 4 5 300 300 -zoom 1 2
+ photo1 copy photo1 -from 1 0 -to 4 5 300 300 -zoom 1 2
+ string equal [photo1 data] [photo2 data]
+} -cleanup {
+ imageCleanup
+} -result {1}
+test imgPhoto-12.4 {Tk_ImgPhotoPutZoomedBlock, empty image} -setup {
+ imageCleanup
+} -body {
+ image create photo photo1
+ photo1 copy photo1 -to 0 5 10 20
+ list [image width photo1] [image height photo1]
+} -cleanup {
+ imageCleanup
+} -result {0 0}
+
test imgPhoto-13.1 {check separation of images in different interpreters} -setup {
imageCleanup
set data {
diff --git a/tests/menu.test b/tests/menu.test
index 479978e..af78947 100644
--- a/tests/menu.test
+++ b/tests/menu.test
@@ -3879,7 +3879,7 @@ test menu-37.1 {menubar menues cannot be posted - bug 2160206} -setup {
} -result {1 {a menubar menu cannot be posted}}
test menu-38.1 {Can't dismiss ttk::menubutton menu until mouse has hovered over it - bug fa32290898} -setup {
-} -constraints {macOrUnix} -body {
+} -constraints {userInteraction} -body {
toplevel .top
ttk::menubutton .top.mb -text "Some menu";
menu .top.mb.m;
diff --git a/unix/configure b/unix/configure
index f76ae3b..ba3104d 100755
--- a/unix/configure
+++ b/unix/configure
@@ -2370,8 +2370,9 @@ $as_echo "$as_me: WARNING: --with-tcl argument should refer to directory contain
for i in `ls -d ${libdir} 2>/dev/null` \
`ls -d ${exec_prefix}/lib 2>/dev/null` \
`ls -d ${prefix}/lib 2>/dev/null` \
- `ls -d /usr/local/lib 2>/dev/null` \
`ls -d /usr/contrib/lib 2>/dev/null` \
+ `ls -d /usr/local/lib 2>/dev/null` \
+ `ls -d /usr/pkg/lib 2>/dev/null` \
`ls -d /usr/lib 2>/dev/null` \
`ls -d /usr/lib64 2>/dev/null` \
; do
@@ -4500,8 +4501,8 @@ if ${tcl_cv_sys_version+:} false; then :
$as_echo_n "(cached) " >&6
else
- if test -f /usr/lib/NextStep/software_version; then
- tcl_cv_sys_version=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
+ if test "${TEA_PLATFORM}" = "windows" ; then
+ tcl_cv_sys_version=windows
else
tcl_cv_sys_version=`uname -s`-`uname -r`
if test "$?" -ne 0 ; then
@@ -4509,12 +4510,6 @@ else
$as_echo "$as_me: WARNING: can't find uname command" >&2;}
tcl_cv_sys_version=unknown
else
- # Special check for weird MP-RAS system (uname returns weird
- # results, and the version is kept in special file).
-
- if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
- tcl_cv_sys_version=MP-RAS-`awk '{print $3}' /etc/.relid`
- fi
if test "`uname -s`" = "AIX" ; then
tcl_cv_sys_version=AIX-`uname -v`.`uname -r`
fi
@@ -4700,7 +4695,7 @@ fi
PLAT_OBJS=""
PLAT_SRCS=""
LDAIX_SRC=""
- if test x"${SHLIB_VERSION}" = x; then :
+ if test "x${SHLIB_VERSION}" = x; then :
SHLIB_VERSION="1.0"
fi
case $system in
@@ -5334,70 +5329,28 @@ fi
LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
fi
;;
- MP-RAS-02*)
- SHLIB_CFLAGS="-K PIC"
- SHLIB_LD='${CC} -G'
- SHLIB_LD_LIBS=""
- SHLIB_SUFFIX=".so"
- DL_OBJS="tclLoadDl.o"
- DL_LIBS="-ldl"
- CC_SEARCH_FLAGS=""
- LD_SEARCH_FLAGS=""
- ;;
- MP-RAS-*)
- SHLIB_CFLAGS="-K PIC"
- SHLIB_LD='${CC} -G'
- SHLIB_LD_LIBS=""
- SHLIB_SUFFIX=".so"
- DL_OBJS="tclLoadDl.o"
- DL_LIBS="-ldl"
- LDFLAGS="$LDFLAGS -Wl,-Bexport"
- CC_SEARCH_FLAGS=""
- LD_SEARCH_FLAGS=""
- ;;
OpenBSD-*)
arch=`arch -s`
case "$arch" in
- vax)
- # Equivalent using configure option --disable-load
- # Step 4 will set the necessary variables
- DL_OBJS=""
- SHLIB_LD_LIBS=""
- LDFLAGS=""
+ alpha|sparc64)
+ SHLIB_CFLAGS="-fPIC"
;;
*)
- case "$arch" in
- alpha|sparc|sparc64)
- SHLIB_CFLAGS="-fPIC"
- ;;
- *)
- SHLIB_CFLAGS="-fpic"
- ;;
- esac
- SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}'
- SHLIB_SUFFIX=".so"
- DL_OBJS="tclLoadDl.o"
- DL_LIBS=""
- if test $doRpath = yes; then :
-
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
-fi
- LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
- SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}'
- LDFLAGS="-Wl,-export-dynamic"
- ;;
- esac
- case "$arch" in
- vax)
- CFLAGS_OPTIMIZE="-O1"
- ;;
- sh)
- CFLAGS_OPTIMIZE="-O0"
- ;;
- *)
- CFLAGS_OPTIMIZE="-O2"
+ SHLIB_CFLAGS="-fpic"
;;
esac
+ SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}'
+ SHLIB_SUFFIX=".so"
+ DL_OBJS="tclLoadDl.o"
+ DL_LIBS=""
+ if test $doRpath = yes; then :
+
+ CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
+fi
+ LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
+ SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}'
+ LDFLAGS="-Wl,-export-dynamic"
+ CFLAGS_OPTIMIZE="-O2"
if test "${TCL_THREADS}" = "1"; then :
# On OpenBSD: Compile with -pthread
@@ -5780,16 +5733,6 @@ fi
fi
;;
- NEXTSTEP-*)
- SHLIB_CFLAGS=""
- SHLIB_LD='${CC} -nostdlib -r'
- SHLIB_LD_LIBS=""
- SHLIB_SUFFIX=".so"
- DL_OBJS="tclLoadNext.o"
- DL_LIBS=""
- CC_SEARCH_FLAGS=""
- LD_SEARCH_FLAGS=""
- ;;
OS/390-*)
SHLIB_LD_LIBS=""
CFLAGS_OPTIMIZE="" # Optimizer is buggy
@@ -5797,35 +5740,6 @@ fi
$as_echo "#define _OE_SOCKETS 1" >>confdefs.h
;;
- OSF1-1.0|OSF1-1.1|OSF1-1.2)
- # OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
- SHLIB_CFLAGS=""
- # Hack: make package name same as library name
- SHLIB_LD='ld -R -export :'
- SHLIB_LD_LIBS=""
- SHLIB_SUFFIX=".so"
- DL_OBJS="tclLoadOSF.o"
- DL_LIBS=""
- CC_SEARCH_FLAGS=""
- LD_SEARCH_FLAGS=""
- ;;
- OSF1-1.*)
- # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
- SHLIB_CFLAGS="-fPIC"
- if test "$SHARED_BUILD" = 1; then :
- SHLIB_LD="ld -shared"
-else
-
- SHLIB_LD="ld -non_shared"
-
-fi
- SHLIB_LD_LIBS=""
- SHLIB_SUFFIX=".so"
- DL_OBJS="tclLoadDl.o"
- DL_LIBS=""
- CC_SEARCH_FLAGS=""
- LD_SEARCH_FLAGS=""
- ;;
OSF1-V*)
# Digital OSF/1
SHLIB_CFLAGS=""
@@ -5907,35 +5821,6 @@ fi
CC_SEARCH_FLAGS=""
LD_SEARCH_FLAGS=""
;;
- SINIX*5.4*)
- SHLIB_CFLAGS="-K PIC"
- SHLIB_LD='${CC} -G'
- SHLIB_LD_LIBS=""
- SHLIB_SUFFIX=".so"
- DL_OBJS="tclLoadDl.o"
- DL_LIBS="-ldl"
- CC_SEARCH_FLAGS=""
- LD_SEARCH_FLAGS=""
- ;;
- SunOS-4*)
- SHLIB_CFLAGS="-PIC"
- SHLIB_LD="ld"
- SHLIB_LD_LIBS=""
- SHLIB_SUFFIX=".so"
- DL_OBJS="tclLoadDl.o"
- DL_LIBS="-ldl"
- CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
- LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
-
- # SunOS can't handle version numbers with dots in them in library
- # specs, like -ltcl7.5, so use -ltcl75 instead. Also, it
- # requires an extra version number at the end of .so file names.
- # So, the library has to have a name like libtcl75.so.1.0
-
- SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}'
- UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
- TCL_LIB_VERSIONS_OK=nodots
- ;;
SunOS-5.[0-6])
# Careful to not let 5.10+ fall into this case
diff --git a/unix/tcl.m4 b/unix/tcl.m4
index 2ab432c..45922e0 100644
--- a/unix/tcl.m4
+++ b/unix/tcl.m4
@@ -91,8 +91,9 @@ AC_DEFUN([SC_PATH_TCLCONFIG], [
for i in `ls -d ${libdir} 2>/dev/null` \
`ls -d ${exec_prefix}/lib 2>/dev/null` \
`ls -d ${prefix}/lib 2>/dev/null` \
- `ls -d /usr/local/lib 2>/dev/null` \
`ls -d /usr/contrib/lib 2>/dev/null` \
+ `ls -d /usr/local/lib 2>/dev/null` \
+ `ls -d /usr/pkg/lib 2>/dev/null` \
`ls -d /usr/lib 2>/dev/null` \
`ls -d /usr/lib64 2>/dev/null` \
; do
@@ -611,7 +612,6 @@ AC_DEFUN([SC_ENABLE_FRAMEWORK], [
# TCL_THREADS
# _REENTRANT
# _THREAD_SAFE
-#
#------------------------------------------------------------------------
AC_DEFUN([SC_ENABLE_THREADS], [
@@ -727,7 +727,6 @@ AC_DEFUN([SC_ENABLE_THREADS], [
# Sets to $(LDFLAGS_OPTIMIZE) if false
# DBGX Formerly used as debug library extension;
# always blank now.
-#
#------------------------------------------------------------------------
AC_DEFUN([SC_ENABLE_SYMBOLS], [
@@ -892,8 +891,7 @@ AC_DEFUN([SC_CONFIG_MANPAGES], [
#
# Determine what the system is (some things cannot be easily checked
# on a feature-driven basis, alas). This can usually be done via the
-# "uname" command, but there are a few systems, like Next, where
-# this doesn't work.
+# "uname" command.
#
# Arguments:
# none
@@ -902,25 +900,18 @@ AC_DEFUN([SC_CONFIG_MANPAGES], [
# Defines the following var:
#
# system - System/platform/version identification code.
-#
#--------------------------------------------------------------------
AC_DEFUN([SC_CONFIG_SYSTEM], [
AC_CACHE_CHECK([system version], tcl_cv_sys_version, [
- if test -f /usr/lib/NextStep/software_version; then
- tcl_cv_sys_version=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
+ if test "${TEA_PLATFORM}" = "windows" ; then
+ tcl_cv_sys_version=windows
else
tcl_cv_sys_version=`uname -s`-`uname -r`
if test "$?" -ne 0 ; then
AC_MSG_WARN([can't find uname command])
tcl_cv_sys_version=unknown
else
- # Special check for weird MP-RAS system (uname returns weird
- # results, and the version is kept in special file).
-
- if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
- tcl_cv_sys_version=MP-RAS-`awk '{print $[3]}' /etc/.relid`
- fi
if test "`uname -s`" = "AIX" ; then
tcl_cv_sys_version=AIX-`uname -v`.`uname -r`
fi
@@ -977,11 +968,11 @@ AC_DEFUN([SC_CONFIG_SYSTEM], [
# SHLIB_LD_LIBS - Dependent libraries for the linker to scan when
# creating shared libraries. This symbol typically
# goes at the end of the "ld" commands that build
-# shared libraries. The value of the symbol is
+# shared libraries. The value of the symbol defaults to
# "${LIBS}" if all of the dependent libraries should
# be specified when creating a shared library. If
-# dependent libraries should not be specified (as on
-# SunOS 4.x, where they cause the link to fail, or in
+# dependent libraries should not be specified (as on some
+# SunOS systems, where they cause the link to fail, or in
# general if Tcl and Tk aren't themselves shared
# libraries), then this symbol has an empty string
# as its value.
@@ -1107,7 +1098,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
PLAT_OBJS=""
PLAT_SRCS=""
LDAIX_SRC=""
- AS_IF([test x"${SHLIB_VERSION}" = x], [SHLIB_VERSION="1.0"])
+ AS_IF([test "x${SHLIB_VERSION}" = x], [SHLIB_VERSION="1.0"])
case $system in
AIX-*)
AS_IF([test "${TCL_THREADS}" = "1" -a "$GCC" != "yes"], [
@@ -1443,68 +1434,26 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
;;
- MP-RAS-02*)
- SHLIB_CFLAGS="-K PIC"
- SHLIB_LD='${CC} -G'
- SHLIB_LD_LIBS=""
- SHLIB_SUFFIX=".so"
- DL_OBJS="tclLoadDl.o"
- DL_LIBS="-ldl"
- CC_SEARCH_FLAGS=""
- LD_SEARCH_FLAGS=""
- ;;
- MP-RAS-*)
- SHLIB_CFLAGS="-K PIC"
- SHLIB_LD='${CC} -G'
- SHLIB_LD_LIBS=""
- SHLIB_SUFFIX=".so"
- DL_OBJS="tclLoadDl.o"
- DL_LIBS="-ldl"
- LDFLAGS="$LDFLAGS -Wl,-Bexport"
- CC_SEARCH_FLAGS=""
- LD_SEARCH_FLAGS=""
- ;;
OpenBSD-*)
arch=`arch -s`
case "$arch" in
- vax)
- # Equivalent using configure option --disable-load
- # Step 4 will set the necessary variables
- DL_OBJS=""
- SHLIB_LD_LIBS=""
- LDFLAGS=""
+ alpha|sparc64)
+ SHLIB_CFLAGS="-fPIC"
;;
*)
- case "$arch" in
- alpha|sparc|sparc64)
- SHLIB_CFLAGS="-fPIC"
- ;;
- *)
- SHLIB_CFLAGS="-fpic"
- ;;
- esac
- SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}'
- SHLIB_SUFFIX=".so"
- DL_OBJS="tclLoadDl.o"
- DL_LIBS=""
- AS_IF([test $doRpath = yes], [
- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
- LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
- SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}'
- LDFLAGS="-Wl,-export-dynamic"
- ;;
- esac
- case "$arch" in
- vax)
- CFLAGS_OPTIMIZE="-O1"
- ;;
- sh)
- CFLAGS_OPTIMIZE="-O0"
- ;;
- *)
- CFLAGS_OPTIMIZE="-O2"
+ SHLIB_CFLAGS="-fpic"
;;
esac
+ SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}'
+ SHLIB_SUFFIX=".so"
+ DL_OBJS="tclLoadDl.o"
+ DL_LIBS=""
+ AS_IF([test $doRpath = yes], [
+ CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
+ LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
+ SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}'
+ LDFLAGS="-Wl,-export-dynamic"
+ CFLAGS_OPTIMIZE="-O2"
AS_IF([test "${TCL_THREADS}" = "1"], [
# On OpenBSD: Compile with -pthread
# Don't link with -lpthread
@@ -1698,47 +1647,12 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
])
])
;;
- NEXTSTEP-*)
- SHLIB_CFLAGS=""
- SHLIB_LD='${CC} -nostdlib -r'
- SHLIB_LD_LIBS=""
- SHLIB_SUFFIX=".so"
- DL_OBJS="tclLoadNext.o"
- DL_LIBS=""
- CC_SEARCH_FLAGS=""
- LD_SEARCH_FLAGS=""
- ;;
OS/390-*)
SHLIB_LD_LIBS=""
CFLAGS_OPTIMIZE="" # Optimizer is buggy
AC_DEFINE(_OE_SOCKETS, 1, # needed in sys/socket.h
[Should OS/390 do the right thing with sockets?])
;;
- OSF1-1.0|OSF1-1.1|OSF1-1.2)
- # OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
- SHLIB_CFLAGS=""
- # Hack: make package name same as library name
- SHLIB_LD='ld -R -export $@:'
- SHLIB_LD_LIBS=""
- SHLIB_SUFFIX=".so"
- DL_OBJS="tclLoadOSF.o"
- DL_LIBS=""
- CC_SEARCH_FLAGS=""
- LD_SEARCH_FLAGS=""
- ;;
- OSF1-1.*)
- # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
- SHLIB_CFLAGS="-fPIC"
- AS_IF([test "$SHARED_BUILD" = 1], [SHLIB_LD="ld -shared"], [
- SHLIB_LD="ld -non_shared"
- ])
- SHLIB_LD_LIBS=""
- SHLIB_SUFFIX=".so"
- DL_OBJS="tclLoadDl.o"
- DL_LIBS=""
- CC_SEARCH_FLAGS=""
- LD_SEARCH_FLAGS=""
- ;;
OSF1-V*)
# Digital OSF/1
SHLIB_CFLAGS=""
@@ -1800,35 +1714,6 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
CC_SEARCH_FLAGS=""
LD_SEARCH_FLAGS=""
;;
- SINIX*5.4*)
- SHLIB_CFLAGS="-K PIC"
- SHLIB_LD='${CC} -G'
- SHLIB_LD_LIBS=""
- SHLIB_SUFFIX=".so"
- DL_OBJS="tclLoadDl.o"
- DL_LIBS="-ldl"
- CC_SEARCH_FLAGS=""
- LD_SEARCH_FLAGS=""
- ;;
- SunOS-4*)
- SHLIB_CFLAGS="-PIC"
- SHLIB_LD="ld"
- SHLIB_LD_LIBS=""
- SHLIB_SUFFIX=".so"
- DL_OBJS="tclLoadDl.o"
- DL_LIBS="-ldl"
- CC_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
- LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
-
- # SunOS can't handle version numbers with dots in them in library
- # specs, like -ltcl7.5, so use -ltcl75 instead. Also, it
- # requires an extra version number at the end of .so file names.
- # So, the library has to have a name like libtcl75.so.1.0
-
- SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}'
- UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
- TCL_LIB_VERSIONS_OK=nodots
- ;;
SunOS-5.[[0-6]])
# Careful to not let 5.10+ fall into this case
@@ -2337,10 +2222,6 @@ AC_DEFUN([SC_BLOCKING_STYLE], [
AC_DEFINE(USE_FIONBIO, 1, [Should we use FIONBIO?])
AC_MSG_RESULT([FIONBIO])
;;
- SunOS-4*)
- AC_DEFINE(USE_FIONBIO, 1, [Should we use FIONBIO?])
- AC_MSG_RESULT([FIONBIO])
- ;;
*)
AC_MSG_RESULT([O_NONBLOCK])
;;
@@ -2706,7 +2587,7 @@ AC_DEFUN([SC_TCL_CFG_ENCODING], [
# advancedTest - the advanced test to run if the function is present
#
# Results:
-# Might cause compatability versions of the function to be used.
+# Might cause compatibility versions of the function to be used.
# Might affect the following vars:
# USE_COMPAT (implicit)
#
diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c
index 1aeefac..6a99124 100644
--- a/unix/tkUnixButton.c
+++ b/unix/tkUnixButton.c
@@ -351,6 +351,47 @@ TkpCreateButton(
*----------------------------------------------------------------------
*/
+static void
+ShiftByOffset(
+ TkButton *butPtr,
+ int relief,
+ int *x, /* shift this x coordinate */
+ int *y, /* shift this y coordinate */
+ int width, /* width of image/text */
+ int height) /* height of image/text */
+{
+ if (relief != TK_RELIEF_RAISED
+ && butPtr->type == TYPE_BUTTON
+ && !Tk_StrictMotif(butPtr->tkwin)) {
+ int shiftX;
+ int shiftY;
+
+ /*
+ * This is an (unraised) button widget, so we offset the text to make
+ * the button appear to move up and down as the relief changes.
+ */
+
+ shiftX = shiftY = (relief == TK_RELIEF_SUNKEN) ? 2 : 1;
+
+ if (relief != TK_RELIEF_RIDGE) {
+ /*
+ * Take back one pixel if the padding is even, otherwise the
+ * content will be displayed too far right/down.
+ */
+
+ if ((Tk_Width(butPtr->tkwin) - width) % 2 == 0) {
+ shiftX -= 1;
+ }
+ if ((Tk_Height(butPtr->tkwin) - height) % 2 == 0) {
+ shiftY -= 1;
+ }
+ }
+
+ *x += shiftX;
+ *y += shiftY;
+ }
+}
+
void
TkpDisplayButton(
ClientData clientData) /* Information about widget. */
@@ -366,10 +407,6 @@ TkpDisplayButton(
int width = 0, height = 0, fullWidth, fullHeight;
int textXOffset, textYOffset;
int haveImage = 0, haveText = 0;
- int offset; /* 1 means this is a button widget, so we
- * offset the text to make the button appear
- * to move up and down as the relief
- * changes. */
int imageWidth, imageHeight;
int imageXOffset = 0, imageYOffset = 0;
/* image information that will be used to
@@ -432,8 +469,6 @@ TkpDisplayButton(
}
}
- offset = (butPtr->type == TYPE_BUTTON) && !Tk_StrictMotif(butPtr->tkwin);
-
/*
* In order to avoid screen flashes, this function redraws the button in a
* pixmap, then copies the pixmap to the screen in a single operation.
@@ -525,17 +560,7 @@ TkpDisplayButton(
butPtr->indicatorSpace + fullWidth, fullHeight, &x, &y);
x += butPtr->indicatorSpace;
-
- x += offset;
- y += offset;
- if (relief == TK_RELIEF_RAISED) {
- x -= offset;
- y -= offset;
- } else if (relief == TK_RELIEF_SUNKEN) {
- x += offset;
- y += offset;
- }
-
+ ShiftByOffset(butPtr, relief, &x, &y, width, height);
imageXOffset += x;
imageYOffset += y;
@@ -593,16 +618,7 @@ TkpDisplayButton(
TkComputeAnchor(butPtr->anchor, tkwin, 0, 0,
butPtr->indicatorSpace + width, height, &x, &y);
x += butPtr->indicatorSpace;
-
- x += offset;
- y += offset;
- if (relief == TK_RELIEF_RAISED) {
- x -= offset;
- y -= offset;
- } else if (relief == TK_RELIEF_SUNKEN) {
- x += offset;
- y += offset;
- }
+ ShiftByOffset(butPtr, relief, &x, &y, width, height);
imageXOffset += x;
imageYOffset += y;
if (butPtr->image != NULL) {
@@ -655,16 +671,7 @@ TkpDisplayButton(
butPtr->textHeight, &x, &y);
x += butPtr->indicatorSpace;
-
- x += offset;
- y += offset;
- if (relief == TK_RELIEF_RAISED) {
- x -= offset;
- y -= offset;
- } else if (relief == TK_RELIEF_SUNKEN) {
- x += offset;
- y += offset;
- }
+ ShiftByOffset(butPtr, relief, &x, &y, width, height);
Tk_DrawTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout,
x, y, 0, -1);
Tk_UnderlineTextLayout(butPtr->display, pixmap, gc,
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c
index e5aceb1..6f37c15 100644
--- a/unix/tkUnixFont.c
+++ b/unix/tkUnixFont.c
@@ -1535,7 +1535,7 @@ CreateClosestFont(
continue;
}
IdentifySymbolEncodings(&got);
- scalable = (got.fa.size == 0);
+ scalable = (got.fa.size == 0.0);
score = RankAttributes(&want, &got);
if (score < bestScore[scalable]) {
bestIdx[scalable] = nameIdx;
@@ -1642,7 +1642,7 @@ InitFont(
fmPtr->fixed = fixed;
fontPtr->display = display;
- fontPtr->pixelSize = TkFontGetPixels(tkwin, fa.fa.size);
+ fontPtr->pixelSize = (int)(TkFontGetPixels(tkwin, fa.fa.size) + 0.5);
fontPtr->xa = fa.xa;
fontPtr->numSubFonts = 1;
@@ -2452,7 +2452,7 @@ CanUseFallback(
want.xa = fontPtr->xa;
want.fa.family = Tk_GetUid(faceName);
- want.fa.size = -fontPtr->pixelSize;
+ want.fa.size = (double)-fontPtr->pixelSize;
hateFoundry = NULL;
hateCharset = NULL;
@@ -2535,7 +2535,7 @@ CanUseFallback(
* D. Rank each name and pick the best match.
*/
- scalable = (got.fa.size == 0);
+ scalable = (got.fa.size == 0.0);
score = RankAttributes(&want, &got);
if (score < bestScore[scalable]) {
bestIdx[scalable] = nameIdx;
@@ -2664,7 +2664,7 @@ RankAttributes(
penalty += 1000;
}
- if (gotPtr->fa.size == 0) {
+ if (gotPtr->fa.size == 0.0) {
/*
* A scalable font is almost always acceptable, but the corresponding
* bitmapped font would be better.
@@ -2678,14 +2678,14 @@ RankAttributes(
* It's worse to be too large than to be too small.
*/
- diff = (-gotPtr->fa.size - -wantPtr->fa.size);
+ diff = (int) (150 * (-gotPtr->fa.size - -wantPtr->fa.size));
if (diff > 0) {
penalty += 600;
} else if (diff < 0) {
penalty += 150;
diff = -diff;
}
- penalty += 150 * diff;
+ penalty += diff;
}
if (gotPtr->xa.charset != wantPtr->xa.charset) {
size_t i;
@@ -2772,7 +2772,7 @@ GetScreenFont(
}
*str = '\0';
sprintf(buf, "%.200s-%d-*-*-*-*-*%s", nameList[bestIdx[1]],
- -wantPtr->fa.size, rest);
+ (int)(-wantPtr->fa.size+0.5), rest);
*str = '-';
fontStructPtr = XLoadQueryFont(display, buf);
bestScore[1] = INT_MAX;
diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c
index 36c4540..ccf77a3 100644
--- a/unix/tkUnixRFont.c
+++ b/unix/tkUnixRFont.c
@@ -170,18 +170,21 @@ GetTkFontAttributes(
{
const char *family = "Unknown";
const char *const *familyPtr = &family;
- int weight, slant, size, pxsize;
- double ptsize;
+ int weight, slant, pxsize;
+ double size, ptsize;
(void) XftPatternGetString(ftFont->pattern, XFT_FAMILY, 0, familyPtr);
if (XftPatternGetDouble(ftFont->pattern, XFT_SIZE, 0,
&ptsize) == XftResultMatch) {
- size = (int) ptsize;
+ size = ptsize;
+ } else if (XftPatternGetDouble(ftFont->pattern, XFT_PIXEL_SIZE, 0,
+ &ptsize) == XftResultMatch) {
+ size = -ptsize;
} else if (XftPatternGetInteger(ftFont->pattern, XFT_PIXEL_SIZE, 0,
&pxsize) == XftResultMatch) {
- size = -pxsize;
+ size = (double)-pxsize;
} else {
- size = 12;
+ size = 12.0;
}
if (XftPatternGetInteger(ftFont->pattern, XFT_WEIGHT, 0,
&weight) != XftResultMatch) {
@@ -194,7 +197,7 @@ GetTkFontAttributes(
#if DEBUG_FONTSEL
printf("family %s size %d weight %d slant %d\n",
- family, size, weight, slant);
+ family, (int)size, weight, slant);
#endif /* DEBUG_FONTSEL */
faPtr->family = Tk_GetUid(family);
@@ -441,10 +444,10 @@ TkpGetFontFromAttributes(
if (faPtr->family) {
XftPatternAddString(pattern, XFT_FAMILY, faPtr->family);
}
- if (faPtr->size > 0) {
- XftPatternAddDouble(pattern, XFT_SIZE, (double)faPtr->size);
- } else if (faPtr->size < 0) {
- XftPatternAddInteger(pattern, XFT_PIXEL_SIZE, -faPtr->size);
+ if (faPtr->size > 0.0) {
+ XftPatternAddDouble(pattern, XFT_SIZE, faPtr->size);
+ } else if (faPtr->size < 0.0) {
+ XftPatternAddDouble(pattern, XFT_SIZE, TkFontGetPoints(tkwin, faPtr->size));
} else {
XftPatternAddDouble(pattern, XFT_SIZE, 12.0);
}
diff --git a/win/tcl.m4 b/win/tcl.m4
index 4d28744..b4fbcce 100644
--- a/win/tcl.m4
+++ b/win/tcl.m4
@@ -1132,7 +1132,7 @@ AC_DEFUN([SC_WITH_TCL], [
TCL_BIN_DEFAULT=../../tcl8.7/win
fi
- AC_ARG_WITH(tcl, [ --with-tcl=DIR use Tcl 8.6+ binaries from DIR],
+ AC_ARG_WITH(tcl, [ --with-tcl=DIR use Tcl 8.7 binaries from DIR],
TCL_BIN_DIR=$withval, TCL_BIN_DIR=`cd $TCL_BIN_DEFAULT; pwd`)
if test ! -d $TCL_BIN_DIR; then
AC_MSG_ERROR(Tcl directory $TCL_BIN_DIR does not exist)
diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c
index 929070b..03c0cde 100644
--- a/win/tkWinClipboard.c
+++ b/win/tkWinClipboard.c
@@ -331,7 +331,7 @@ TkWinClipboardRender(
#ifdef UNICODE
Tcl_DStringInit(&ds);
- Tcl_UtfToUniCharDString(rawText, -1, &ds);
+ Tcl_WinUtfToTChar(rawText, -1, &ds);
ckfree(rawText);
handle = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,
(unsigned) Tcl_DStringLength(&ds) + 2);
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index a7d8c7d..5be6776 100644
--- a/win/tkWinDialog.c
+++ b/win/tkWinDialog.c
@@ -1379,17 +1379,27 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
goto vamoose;
if (optsPtr->extObj != NULL) {
- wstr = Tcl_GetUnicode(optsPtr->extObj);
+ Tcl_DString ds;
+ const char *src;
+
+ src = Tcl_GetString(optsPtr->extObj);
+ wstr = (LPWSTR) Tcl_WinUtfToTChar(src, optsPtr->extObj->length, &ds);
if (wstr[0] == L'.')
++wstr;
hr = fdlgIf->lpVtbl->SetDefaultExtension(fdlgIf, wstr);
+ Tcl_DStringFree(&ds);
if (FAILED(hr))
goto vamoose;
}
if (optsPtr->titleObj != NULL) {
- hr = fdlgIf->lpVtbl->SetTitle(fdlgIf,
- Tcl_GetUnicode(optsPtr->titleObj));
+ Tcl_DString ds;
+ const char *src;
+
+ src = Tcl_GetString(optsPtr->titleObj);
+ wstr = (LPWSTR) Tcl_WinUtfToTChar(src, optsPtr->titleObj->length, &ds);
+ hr = fdlgIf->lpVtbl->SetTitle(fdlgIf, wstr);
+ Tcl_DStringFree(&ds);
if (FAILED(hr))
goto vamoose;
}
@@ -1464,12 +1474,14 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
SIGDN_FILESYSPATH, &wstr);
if (SUCCEEDED(hr)) {
Tcl_DString fnds;
+
ConvertExternalFilename(wstr, &fnds);
CoTaskMemFree(wstr);
Tcl_ListObjAppendElement(
interp, multiObj,
Tcl_NewStringObj(Tcl_DStringValue(&fnds),
Tcl_DStringLength(&fnds)));
+ Tcl_DStringFree(&fnds);
}
itemIf->lpVtbl->Release(itemIf);
if (FAILED(hr))
@@ -1490,10 +1502,12 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
&wstr);
if (SUCCEEDED(hr)) {
Tcl_DString fnds;
+
ConvertExternalFilename(wstr, &fnds);
resultObj = Tcl_NewStringObj(Tcl_DStringValue(&fnds),
Tcl_DStringLength(&fnds));
CoTaskMemFree(wstr);
+ Tcl_DStringFree(&fnds);
}
resultIf->lpVtbl->Release(resultIf);
}
@@ -1501,13 +1515,20 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
if (SUCCEEDED(hr)) {
if (filterPtr && optsPtr->typeVariableObj) {
UINT ftix;
+
hr = fdlgIf->lpVtbl->GetFileTypeIndex(fdlgIf, &ftix);
if (SUCCEEDED(hr)) {
/* Note ftix is a 1-based index */
if (ftix > 0 && ftix <= nfilters) {
+ Tcl_DString ftds;
+ Tcl_Obj *ftobj;
+
+ Tcl_WinTCharToUtf(filterPtr[ftix-1].pszName, -1, &ftds);
+ ftobj = Tcl_NewStringObj(Tcl_DStringValue(&ftds),
+ Tcl_DStringLength(&ftds));
Tcl_ObjSetVar2(interp, optsPtr->typeVariableObj, NULL,
- Tcl_NewUnicodeObj(filterPtr[ftix-1].pszName, -1),
- TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG);
+ ftobj, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG);
+ Tcl_DStringFree(&ftds);
}
}
}
@@ -2786,6 +2807,9 @@ Tk_MessageBoxObjCmd(
};
ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ Tcl_DString titleBuf, tmpBuf;
+ const WCHAR *titlePtr, *tmpPtr;
+ const char *src;
defaultBtn = -1;
detailObj = NULL;
@@ -2896,7 +2920,9 @@ Tk_MessageBoxObjCmd(
: Tcl_NewUnicodeObj(NULL, 0);
Tcl_IncrRefCount(tmpObj);
if (detailObj) {
- Tcl_AppendUnicodeToObj(tmpObj, L"\n\n", 2);
+ const Tcl_UniChar twoNL[] = { '\n', '\n' };
+
+ Tcl_AppendUnicodeToObj(tmpObj, twoNL, 2);
Tcl_AppendObjToObj(tmpObj, detailObj);
}
@@ -2915,8 +2941,18 @@ Tk_MessageBoxObjCmd(
tsdPtr->hBigIcon = TkWinGetIcon(parent, ICON_BIG);
tsdPtr->hMsgBoxHook = SetWindowsHookEx(WH_CBT, MsgBoxCBTProc, NULL,
GetCurrentThreadId());
- winCode = MessageBox(hWnd, Tcl_GetUnicode(tmpObj),
- titleObj ? Tcl_GetUnicode(titleObj) : L"", flags);
+ src = Tcl_GetString(tmpObj);
+ tmpPtr = Tcl_WinUtfToTChar(src, tmpObj->length, &tmpBuf);
+ if (titleObj != NULL) {
+ src = Tcl_GetString(titleObj);
+ titlePtr = Tcl_WinUtfToTChar(src, titleObj->length, &titleBuf);
+ } else {
+ titlePtr = L"";
+ Tcl_DStringInit(&titleBuf);
+ }
+ winCode = MessageBox(hWnd, tmpPtr, titlePtr, flags);
+ Tcl_DStringFree(&titleBuf);
+ Tcl_DStringFree(&tmpBuf);
UnhookWindowsHookEx(tsdPtr->hMsgBoxHook);
(void) Tcl_SetServiceMode(oldMode);
@@ -3451,7 +3487,7 @@ FontchooserShowCmd(
LF_FACESIZE-1);
Tcl_DStringFree(&ds);
lf.lfFaceName[LF_FACESIZE-1] = 0;
- lf.lfHeight = -MulDiv(TkFontGetPoints(tkwin, fontPtr->fa.size),
+ lf.lfHeight = -MulDiv((int)(TkFontGetPoints(tkwin, fontPtr->fa.size) + 0.5),
GetDeviceCaps(hdc, LOGPIXELSY), 72);
if (fontPtr->fa.weight == TK_FW_BOLD) {
lf.lfWeight = FW_BOLD;
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index c01dc3f..aa0697c 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -562,7 +562,7 @@ TkpGetFontFromAttributes(
ReleaseDC(hwnd, hdc);
hFont = GetScreenFont(faPtr, faceName,
- TkFontGetPixels(tkwin, faPtr->size), 0.0);
+ (int)(TkFontGetPixels(tkwin, faPtr->size) + 0.5), 0.0);
if (tkFontPtr == NULL) {
fontPtr = ckalloc(sizeof(WinFont));
} else {
@@ -763,7 +763,7 @@ TkpGetFontAttrsForChar(
ReleaseDC(fontPtr->hwnd, hdc);
faPtr->family = familyPtr->faceName;
faPtr->size = TkFontGetPoints(tkwin,
- tm.tmInternalLeading - tm.tmHeight);
+ (double)(tm.tmInternalLeading - tm.tmHeight));
faPtr->weight = (tm.tmWeight > FW_MEDIUM) ? TK_FW_BOLD : TK_FW_NORMAL;
faPtr->slant = tm.tmItalic ? TK_FS_ITALIC : TK_FS_ROMAN;
faPtr->underline = (tm.tmUnderlined != 0);
@@ -1600,7 +1600,7 @@ InitFont(
faPtr->family = Tk_GetUid(Tcl_DStringValue(&faceString));
faPtr->size =
- TkFontGetPoints(tkwin, -(fontPtr->pixelSize));
+ TkFontGetPoints(tkwin, (double)-(fontPtr->pixelSize));
faPtr->weight =
(tm.tmWeight > FW_MEDIUM) ? TK_FW_BOLD : TK_FW_NORMAL;
faPtr->slant = (tm.tmItalic != 0) ? TK_FS_ITALIC : TK_FS_ROMAN;
diff --git a/win/tkWinInit.c b/win/tkWinInit.c
index b1b2d6b..4c18399 100644
--- a/win/tkWinInit.c
+++ b/win/tkWinInit.c
@@ -181,6 +181,9 @@ TkWin32ErrorObj(
LPTSTR lpBuffer = NULL, p = NULL;
TCHAR sBuffer[30];
Tcl_Obj* errPtr = NULL;
+#ifdef _UNICODE
+ Tcl_DString ds;
+#endif
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS, NULL, (DWORD)hrError,
@@ -196,7 +199,9 @@ TkWin32ErrorObj(
}
#ifdef _UNICODE
- errPtr = Tcl_NewUnicodeObj(lpBuffer, (int)wcslen(lpBuffer));
+ Tcl_WinTCharToUtf(lpBuffer, (int)wcslen(lpBuffer) * sizeof (WCHAR), &ds);
+ errPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
+ Tcl_DStringFree(&ds);
#else
errPtr = Tcl_NewStringObj(lpBuffer, (int)strlen(lpBuffer));
#endif /* _UNICODE */
diff --git a/win/tkWinSend.c b/win/tkWinSend.c
index 6c4731a..fca8561 100644
--- a/win/tkWinSend.c
+++ b/win/tkWinSend.c
@@ -252,8 +252,14 @@ TkGetInterpNames(
LPOLESTR p = olestr + wcslen(oleszStub);
if (*p) {
+ Tcl_DString ds;
+
+ Tcl_WinTCharToUtf(p + 1, -1, &ds);
result = Tcl_ListObjAppendElement(interp,
- objList, Tcl_NewUnicodeObj(p + 1, -1));
+ objList,
+ Tcl_NewStringObj(Tcl_DStringValue(&ds),
+ Tcl_DStringLength(&ds)));
+ Tcl_DStringFree(&ds);
}
}
@@ -613,8 +619,7 @@ BuildMoniker(
LPMONIKER pmkItem = NULL;
Tcl_DString dString;
- Tcl_DStringInit(&dString);
- Tcl_UtfToUniCharDString(name, -1, &dString);
+ Tcl_WinUtfToTChar(name, -1, &dString);
hr = CreateFileMoniker((LPOLESTR)Tcl_DStringValue(&dString), &pmkItem);
Tcl_DStringFree(&dString);
if (SUCCEEDED(hr)) {
@@ -740,6 +745,8 @@ Send(
HRESULT hr = S_OK, ehr = S_OK;
Tcl_Obj *cmd = NULL;
DISPID dispid;
+ Tcl_DString ds;
+ const char *src;
cmd = Tcl_ConcatObj(objc, objv);
@@ -753,7 +760,10 @@ Send(
memset(&ei, 0, sizeof(ei));
vCmd.vt = VT_BSTR;
- vCmd.bstrVal = SysAllocString(Tcl_GetUnicode(cmd));
+ src = Tcl_GetString(cmd);
+ Tcl_WinUtfToTChar(src, cmd->length, &ds);
+ vCmd.bstrVal = SysAllocString((WCHAR *) Tcl_DStringValue(&ds));
+ Tcl_DStringFree(&ds);
dp.cArgs = 1;
dp.rgvarg = &vCmd;
@@ -774,7 +784,9 @@ Send(
ehr = VariantChangeType(&vResult, &vResult, 0, VT_BSTR);
if (SUCCEEDED(ehr)) {
- Tcl_SetObjResult(interp, Tcl_NewUnicodeObj(vResult.bstrVal, -1));
+ Tcl_WinTCharToUtf(vResult.bstrVal, (int) SysStringLen(vResult.bstrVal) *
+ sizeof (WCHAR), &ds);
+ Tcl_DStringResult(interp, &ds);
}
/*
@@ -785,8 +797,11 @@ Send(
if (hr == DISP_E_EXCEPTION && ei.bstrSource != NULL) {
Tcl_Obj *opError, *opErrorCode, *opErrorInfo;
-
- opError = Tcl_NewUnicodeObj(ei.bstrSource, -1);
+ Tcl_WinTCharToUtf(ei.bstrSource, (int) SysStringLen(ei.bstrSource) *
+ sizeof (WCHAR), &ds);
+ opError = Tcl_NewStringObj(Tcl_DStringValue(&ds),
+ Tcl_DStringLength(&ds));
+ Tcl_DStringFree(&ds);
Tcl_ListObjIndex(interp, opError, 0, &opErrorCode);
Tcl_SetObjErrorCode(interp, opErrorCode);
Tcl_ListObjIndex(interp, opError, 1, &opErrorInfo);
@@ -833,6 +848,8 @@ TkWinSend_SetExcepInfo(
ICreateErrorInfo *pCEI;
IErrorInfo *pEI, **ppEI = &pEI;
HRESULT hr;
+ Tcl_DString ds;
+ const char *src;
if (!pExcepInfo) {
return;
@@ -851,8 +868,16 @@ TkWinSend_SetExcepInfo(
Tcl_ListObjAppendElement(interp, opErrorCode, opErrorInfo);
/* TODO: Handle failure to append */
- pExcepInfo->bstrDescription = SysAllocString(Tcl_GetUnicode(opError));
- pExcepInfo->bstrSource = SysAllocString(Tcl_GetUnicode(opErrorCode));
+ src = Tcl_GetString(opError);
+ Tcl_WinUtfToTChar(src, opError->length, &ds);
+ pExcepInfo->bstrDescription =
+ SysAllocString((WCHAR *) Tcl_DStringValue(&ds));
+ Tcl_DStringFree(&ds);
+ src = Tcl_GetString(opErrorCode);
+ Tcl_WinUtfToTChar(src, opErrorCode->length, &ds);
+ pExcepInfo->bstrSource =
+ SysAllocString((WCHAR *) Tcl_DStringValue(&ds));
+ Tcl_DStringFree(&ds);
Tcl_DecrRefCount(opErrorCode);
pExcepInfo->scode = E_FAIL;
diff --git a/win/tkWinSendCom.c b/win/tkWinSendCom.c
index 83dd56b..9e5b7a0 100644
--- a/win/tkWinSendCom.c
+++ b/win/tkWinSendCom.c
@@ -370,6 +370,7 @@ Async(
{
HRESULT hr = S_OK;
VARIANT vCmd;
+ Tcl_DString ds;
VariantInit(&vCmd);
@@ -382,9 +383,13 @@ Async(
}
if (SUCCEEDED(hr) && obj->interp) {
- Tcl_Obj *scriptPtr = Tcl_NewUnicodeObj(vCmd.bstrVal,
- (int) SysStringLen(vCmd.bstrVal));
+ Tcl_Obj *scriptPtr;
+ Tcl_WinTCharToUtf(vCmd.bstrVal, (int) SysStringLen(vCmd.bstrVal) *
+ sizeof (WCHAR), &ds);
+ scriptPtr =
+ Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
+ Tcl_DStringFree(&ds);
TkWinSend_QueueCommand(obj->interp, scriptPtr);
}
@@ -424,6 +429,7 @@ Send(
VARIANT v;
register Tcl_Interp *interp = obj->interp;
Tcl_Obj *scriptPtr;
+ Tcl_DString ds;
if (interp == NULL) {
return S_OK;
@@ -434,17 +440,26 @@ Send(
return hr;
}
- scriptPtr = Tcl_NewUnicodeObj(v.bstrVal, (int) SysStringLen(v.bstrVal));
+ Tcl_WinTCharToUtf(v.bstrVal, (int) SysStringLen(v.bstrVal) *
+ sizeof (WCHAR), &ds);
+ scriptPtr = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
+ Tcl_DStringFree(&ds);
Tcl_Preserve(interp);
Tcl_IncrRefCount(scriptPtr);
result = Tcl_EvalObjEx(interp, scriptPtr,
TCL_EVAL_DIRECT | TCL_EVAL_GLOBAL);
Tcl_DecrRefCount(scriptPtr);
if (pvResult != NULL) {
+ Tcl_Obj *obj;
+ const char *src;
+
VariantInit(pvResult);
pvResult->vt = VT_BSTR;
- pvResult->bstrVal = SysAllocString(Tcl_GetUnicode(
- Tcl_GetObjResult(interp)));
+ obj = Tcl_GetObjResult(interp);
+ src = Tcl_GetString(obj);
+ Tcl_WinUtfToTChar(src, obj->length, &ds);
+ pvResult->bstrVal = SysAllocString((WCHAR *) Tcl_DStringValue(&ds));
+ Tcl_DStringFree(&ds);
}
if (result == TCL_ERROR) {
hr = DISP_E_EXCEPTION;
diff --git a/win/tkWinTest.c b/win/tkWinTest.c
index 095358d..1c121cc 100644
--- a/win/tkWinTest.c
+++ b/win/tkWinTest.c
@@ -515,6 +515,7 @@ TestgetwindowinfoObjCmd(
Tcl_Obj *childrenObj = NULL;
TCHAR buf[512];
int cch, cchBuf = 256;
+ Tcl_DString ds;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "hwnd");
@@ -542,7 +543,9 @@ TestgetwindowinfoObjCmd(
Tcl_NewWideIntObj(GetWindowLongPtr((HWND)(size_t)hwnd, GWL_ID)));
cch = GetWindowText((HWND)(size_t)hwnd, (LPTSTR)buf, cchBuf);
- textObj = Tcl_NewUnicodeObj((LPCWSTR)buf, cch);
+ Tcl_WinTCharToUtf(buf, cch * sizeof (WCHAR), &ds);
+ textObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
+ Tcl_DStringFree(&ds);
Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("text", 4), textObj);
Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("parent", 6),
diff --git a/win/tkWinX.c b/win/tkWinX.c
index d41b6c1..6293ce7 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -676,19 +676,6 @@ TkClipCleanup(
TkDisplay *dispPtr) /* Display associated with clipboard. */
{
if (dispPtr->clipWindow != NULL) {
- /*
- * Force the clipboard to be rendered if we are the clipboard owner.
- */
-
- HWND hwnd = Tk_GetHWND(Tk_WindowId(dispPtr->clipWindow));
-
- if (GetClipboardOwner() == hwnd) {
- OpenClipboard(hwnd);
- EmptyClipboard();
- TkWinClipboardRender(dispPtr, CF_TEXT);
- CloseClipboard();
- }
-
Tk_DeleteSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom,
dispPtr->applicationAtom);
Tk_DeleteSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom,
@@ -865,6 +852,23 @@ Tk_TranslateWinEvent(
return 1;
}
+ case WM_RENDERALLFORMATS: {
+ TkWindow *winPtr = (TkWindow *) Tk_HWNDToWindow(hwnd);
+
+ if (winPtr && OpenClipboard(hwnd)) {
+ /*
+ * Make sure that nobody had taken ownership of the clipboard
+ * before we opened it.
+ */
+
+ if (GetClipboardOwner() == hwnd) {
+ TkWinClipboardRender(winPtr->dispPtr, CF_TEXT);
+ }
+ CloseClipboard();
+ }
+ return 1;
+ }
+
case WM_COMMAND:
case WM_NOTIFY:
case WM_VSCROLL:
diff --git a/xlib/xcolors.c b/xlib/xcolors.c
index 36dc67c..78fd44b 100644
--- a/xlib/xcolors.c
+++ b/xlib/xcolors.c
@@ -350,11 +350,11 @@ XParseColor(
* digits in the spec. Ergo, it is not a vailid color string.
* (Bug f0188aca9e)
*/
-
+
if (*p != '\0') {
return 0;
}
-
+
switch ((int)(p-spec)) {
case 3:
colorPtr->red = US(((value >> 8) & 0xf) * 0x1111);
diff --git a/xlib/xgc.c b/xlib/xgc.c
index 78c7501..984c949 100644
--- a/xlib/xgc.c
+++ b/xlib/xgc.c
@@ -560,7 +560,7 @@ XDrawSegments(
XSegment *segments,
int nsegments)
{
- return Success;
+ return BadDrawable;
}
#endif