summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/onefiledist.yml2
-rw-r--r--README.md2
-rw-r--r--changes81
-rw-r--r--doc/grid.n2
-rw-r--r--doc/pack.n2
-rw-r--r--doc/place.n2
-rw-r--r--generic/tk.h4
-rw-r--r--generic/tkCanvas.c54
-rw-r--r--macosx/tkMacOSXEmbed.c3
-rw-r--r--macosx/tkMacOSXImage.c259
-rw-r--r--macosx/tkMacOSXPort.h6
-rwxr-xr-xunix/configure8
-rw-r--r--unix/configure.ac2
-rw-r--r--unix/tcl.m46
-rw-r--r--unix/tk.spec2
-rw-r--r--unix/tkUnixEmbed.c1
-rw-r--r--win/Makefile.in5
-rwxr-xr-xwin/configure8
-rw-r--r--win/configure.ac4
-rw-r--r--win/rules.vc2
-rw-r--r--win/tcl.m42
-rw-r--r--win/tkWinEmbed.c2
22 files changed, 329 insertions, 130 deletions
diff --git a/.github/workflows/onefiledist.yml b/.github/workflows/onefiledist.yml
index f32e8ed..37f34b1 100644
--- a/.github/workflows/onefiledist.yml
+++ b/.github/workflows/onefiledist.yml
@@ -3,7 +3,7 @@ on: [push]
jobs:
linux:
name: Linux
- runs-on: ubuntu-16.04
+ runs-on: ubuntu-18.04
defaults:
run:
shell: bash
diff --git a/README.md b/README.md
index 2c68e9d..5e8ad56 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# README: Tk
-This is the **Tk 8.7a4** source distribution.
+This is the **Tk 8.7a6** source distribution.
You can get any source release of Tk from [our distribution
site](https://sourceforge.net/projects/tcl/files/Tcl/).
diff --git a/changes b/changes
index 96ecfb9..80bc6a9 100644
--- a/changes
+++ b/changes
@@ -7806,7 +7806,7 @@ in this changeset (new minor version) rather than bug fixes:
2020-07-02 (bug)[2d2459] default style for combobox (bll)
-2020-07-06 (bug)[40c4bf] double free, entry-19.21 (vogel)
+2020-07-06 (bug)[40e4bf] double free, entry-19.21 (vogel)
2020-07-06 (bug)[e3888d] grab & warp, bind-36.1 (vogel)
@@ -7885,7 +7885,7 @@ in this changeset (new minor version) rather than bug fixes:
2018-11-06 [TIP 415] New option -height for [$canvas create arc] (geard)
-2018-11-06 [TIP 518] New event <<NoMangedChild>> (oehlmann)
+2018-11-06 [TIP 518] New event <<NoManagedChild>> (oehlmann)
2019-04-14 [TIP 164] New subcommand [$canvas rotate] (fellows)
@@ -7902,3 +7902,80 @@ in this changeset (new minor version) rather than bug fixes:
2019-08-19 [TIP 545] Revised options for photo image format 'svg' (oehlmann)
--- Released 8.7a3, November 25, 2019 --- http://core.tcl.tk/tk/ for details
+
+Changes to 8.7a5 include all changes to the 8.6 line through 8.6.11,
+plus the following, which focuses on the high-level feature changes
+in this changeset (new minor version) rather than bug fixes:
+
+2020-02-22 [TIP 565] Gracefully ignore non-existent tags in canvas raise/lower
+
+2020-02-22 [TIP 564] Specify ttk font sizes in points on X11
+
+2020-02-24 [TIP 563] Scrollwheel on Horizontal Scrollbar Scrolls Without Shift too
+
+2020-02-28 [TIP 557] C++ support
+
+2020-03-12 (bug)[355180] solve XKeycodeToKeysym deprecation
+ *** POTENTIAL INCOMPATIBILITY -- Tk 8.7 now requires X11R6 ***
+
+2020-03-18 [TIP 569] Eliminate comments that serve lint
+
+2020-05-17 [d87dc2] Remove TkMacOSXGetStringObjFromCFString()
+
+2020-05-24 [TIP 574] Add a 'tag delete' command to the ttk::treeview widget
+
+2020-06-27 (bug)[50ed1e] spinbox with duplicate values
+
+2020-07-03 [TIP 578] Death to TCL_DBGX
+
+2020-08-23 (bug)[bb85d2] valgrind on TIP 489
+
+2020-08024 (bug)[d30c21] default colors for TIP 496
+
+2020-09-02 [TIP 580] Export Tk_GetDoublePixelsFromObj and 5 more
+
+2020-10-21 [TIP 474] Uniform mouse wheel events
+
+2020-11-15 [TIP 584] Better introspection for ttk
+
+2020-11-16 [TIP 588] Unicode for (X11) keysyms
+
+2020-12-03 [TIP 590] Recommend lowercase package names
+
+2020-12-09 (bug)[d6e9b4] SVG memory overflow
+
+2020-12-11 [TIP 591] Rotate ttk::notebook window with mousewheel on tab
+
+2020-12-12 [TIP 325] System tray and system notification
+
+2021-01-08 [TIP 592] End support: Windows XP, Server 2003, Vista, Server 2008
+
+2021-01-08 (bug)[822330] Prevent buffer overflow in SVG image.
+
+2021-01-28 (bug)[237971] 'end' argument to [$canvas insert]
+
+2021-02-25 (bug)[be9cad] crash in [tkwait]
+
+2021-02-27 [TIP 529] Add metadata dictionary property to tk photo image
+
+2021-03-02 (bug)[1626ed] Aqua crash: dead keys as meny accelerator
+
+2021-03-29 (bug)[9b6065] Restore Tcl [update] when Tk is destroyed
+
+2021-04-08 (bug)[58222c] background colors
+
+2021-04-09 [TIP 595] Unicode-aware/case-sensitive Loadable Library handling
+
+2021-04-21 (bug)[cde766] update scrollbars on treeview
+
+2021-04-26 (bug)[c97464] memleak in aqua fonts
+
+2021-05-02 (bug)[2ecb09] Follow Mac OSX Key-repeat setting
+
+2021-05-03 (bug)[8a5086] ttk::entry issue
+
+2021-05-22 (bug)[3e3360] bind substitution %S
+
+2021-05-25 (bug)[7bda98] aqua: double click bind with changing focus
+
+- Released 8.7a5, Jun 18, 2021 --- http://core.tcl-lang.org/tcl/ for details -
diff --git a/doc/grid.n b/doc/grid.n
index 684474b..90f80cd 100644
--- a/doc/grid.n
+++ b/doc/grid.n
@@ -311,7 +311,7 @@ to be returned.
.TP
\fBgrid slaves \fIwindow\fR ?\fI\-option value\fR?
.
-Synonym for . \fBgrid content \fIwindow\fR ?\fI\-option value\fR?
+Synonym for \fBgrid content \fIwindow\fR ?\fI\-option value\fR?.
.SH "RELATIVE PLACEMENT"
.PP
The \fBgrid\fR command contains a limited set of capabilities that
diff --git a/doc/pack.n b/doc/pack.n
index da09a6d..cdcfeb8 100644
--- a/doc/pack.n
+++ b/doc/pack.n
@@ -166,7 +166,7 @@ If \fIwindow\fR has no content then an empty string is returned.
.TP
\fBpack slaves \fIwindow\fR
.
-Synonym for . \fBpack content \fIwindow\fR
+Synonym for \fBpack content \fIwindow\fR.
.SH "THE PACKER ALGORITHM"
.PP
For each container the packer maintains an ordered list of content
diff --git a/doc/place.n b/doc/place.n
index d887ee7..b56ad58 100644
--- a/doc/place.n
+++ b/doc/place.n
@@ -197,7 +197,7 @@ If there is no content for \fIwindow\fR then an empty string is returned.
.TP
\fBplace slaves \fIwindow\fR
.
-Synonym for . \fBplace content \fIwindow\fR
+Synonym for \fBplace content \fIwindow\fR.
.PP
If the configuration of a window has been retrieved with
\fBplace info\fR, that configuration can be restored later by
diff --git a/generic/tk.h b/generic/tk.h
index 7f74434..3f87a43 100644
--- a/generic/tk.h
+++ b/generic/tk.h
@@ -68,10 +68,10 @@ extern "C" {
#define TK_MAJOR_VERSION 8
#define TK_MINOR_VERSION 7
#define TK_RELEASE_LEVEL TCL_ALPHA_RELEASE
-#define TK_RELEASE_SERIAL 4
+#define TK_RELEASE_SERIAL 6
#define TK_VERSION "8.7"
-#define TK_PATCH_LEVEL "8.7a4"
+#define TK_PATCH_LEVEL "8.7a6"
/*
* A special definition used to allow this header file to be included from
diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c
index fd65796..95fec62 100644
--- a/generic/tkCanvas.c
+++ b/generic/tkCanvas.c
@@ -16,11 +16,10 @@
#include "tkInt.h"
#include "tkCanvas.h"
#include "default.h"
-#ifdef TK_NO_DOUBLE_BUFFERING
+#include "tkPort.h"
#ifdef MAC_OSX_TK
#include "tkMacOSXInt.h"
#endif
-#endif /* TK_NO_DOUBLE_BUFFERING */
/*
* See tkCanvas.h for key data structures used to implement canvases.
@@ -2808,10 +2807,19 @@ DrawCanvas(
blockPtr.height = cHeight;
blockPtr.pixelSize = 4;
blockPtr.pitch = blockPtr.pixelSize * blockPtr.width;
+
+#ifdef TK_XGETIMAGE_USES_ABGR32
+ blockPtr.offset[0] = 1;
+ blockPtr.offset[1] = 2;
+ blockPtr.offset[2] = 3;
+ blockPtr.offset[3] = 0;
+#else
blockPtr.offset[0] = 0;
blockPtr.offset[1] = 1;
blockPtr.offset[2] = 2;
blockPtr.offset[3] = 3;
+#endif
+
blockPtr.pixelPtr = (unsigned char *)ckalloc(blockPtr.pixelSize * blockPtr.height * blockPtr.width);
/*
@@ -2848,7 +2856,7 @@ DrawCanvas(
for(x = 0; x < blockPtr.width; ++x) {
unsigned int pixel = 0;
-
+ int pixel_offset = blockPtr.pitch * y + blockPtr.pixelSize * x;
switch (ximagePtr->bits_per_pixel) {
/*
@@ -2901,21 +2909,45 @@ DrawCanvas(
*/
#ifdef _WIN32
-#define R_OFFSET 2
-#define B_OFFSET 0
+#define R_OFFSET blockPtr.offset[2]
+#define G_OFFSET blockPtr.offset[1]
+#define B_OFFSET blockPtr.offset[0]
+#define A_OFFSET blockPtr.offset[3]
#else
-#define R_OFFSET 0
-#define B_OFFSET 2
+#define R_OFFSET blockPtr.offset[0]
+#define G_OFFSET blockPtr.offset[1]
+#define B_OFFSET blockPtr.offset[2]
+#define A_OFFSET blockPtr.offset[3]
#endif
- blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x + R_OFFSET] =
+#ifdef TK_XGETIMAGE_USES_ABGR32
+#define COPY_PIXEL (ximagePtr->bits_per_pixel == 32)
+#else
+#define COPY_PIXEL 0
+#endif
+
+ if (COPY_PIXEL) {
+ /*
+ * This platform packs pixels in RGBA byte order, as expected
+ * by Tk_PhotoPutBlock() so we can just copy the pixel as an int.
+ */
+ *((unsigned int *) (blockPtr.pixelPtr + pixel_offset)) = pixel;
+ } else {
+ blockPtr.pixelPtr[pixel_offset + R_OFFSET] =
(unsigned char)((pixel & visualPtr->red_mask) >> rshift);
- blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x +1] =
+ blockPtr.pixelPtr[pixel_offset + G_OFFSET] =
(unsigned char)((pixel & visualPtr->green_mask) >> gshift);
- blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x + B_OFFSET] =
+ blockPtr.pixelPtr[pixel_offset + B_OFFSET] =
(unsigned char)((pixel & visualPtr->blue_mask) >> bshift);
- blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x +3] = 0xFF;
+ blockPtr.pixelPtr[pixel_offset + A_OFFSET] = 0xFF;
+ }
#ifdef DEBUG_DRAWCANVAS
+ fprintf(stderr, "Converted pixel %x to %hhx %hhx %hhx %hhx \n",
+ pixel,
+ blockPtr.pixelPtr[pixel_offset + 0],
+ blockPtr.pixelPtr[pixel_offset + 1],
+ blockPtr.pixelPtr[pixel_offset + 2],
+ blockPtr.pixelPtr[pixel_offset + 3]);
{
int ix;
if (x > 0)
diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c
index 832f404..029624d 100644
--- a/macosx/tkMacOSXEmbed.c
+++ b/macosx/tkMacOSXEmbed.c
@@ -1082,6 +1082,9 @@ EmbedWindowDeleted(
prevPtr = NULL;
containerPtr = firstContainerPtr;
while (1) {
+ if (containerPtr == NULL) {
+ return;
+ }
if (containerPtr->embeddedPtr == winPtr) {
/*
* We also have to destroy our parent, to clean up the container.
diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c
index 6b0a8c6..7eadb39 100644
--- a/macosx/tkMacOSXImage.c
+++ b/macosx/tkMacOSXImage.c
@@ -3,10 +3,10 @@
*
* The code in this file provides an interface for XImages,
*
- * Copyright © 1995-1997 Sun Microsystems, Inc.
- * Copyright © 2001-2009, Apple Inc.
- * Copyright © 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
- * Copyright © 2017-2020 Marc Culler.
+ * Copyright (c) 1995-1997 Sun Microsystems, Inc.
+ * Copyright (c) 2001-2009, Apple Inc.
+ * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright (c) 2017-2021 Marc Culler.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -19,6 +19,71 @@ static CGImageRef CreateCGImageFromPixmap(Drawable pixmap);
static CGImageRef CreateCGImageFromDrawableRect( Drawable drawable,
int x, int y, unsigned int width, unsigned int height);
+/* Pixel formats
+ *
+ * Tk uses the XImage structure defined in Xlib.h for storing images. The
+ * image data in an XImage is a 32-bit aligned array of bytes. Interpretation
+ * of that data is not specified, but the structure includes parameters which
+ * provide interpretation hints so that an application can use a family of
+ * different data structures.
+ *
+ * The possible values for the XImage format field are XYBitmap, XYPixmap and
+ * ZPixmap. The macOS port does not support the XYPixmap format. This means
+ * that bitmap images are stored as a single bit plane (XYBitmap) and that
+ * color images are stored as a sequence of pixel values (ZPixmap).
+ *
+ * For a ZPixmap, the number of bits allocated to each pixel is specified by
+ * the bits_per_pixel field of the XImage structure. The functions in this
+ * module which convert between XImage and native CGImage or NSImage structures
+ * only support XImages with 32 bits per pixel. The ImageGetPixel and PutPixel
+ * implementations in this file allow 1, 4, 8, 16 or 32 bits per pixel, however.
+ *
+ * In tkImgPhInstance.c the layout used for pixels is determined by the values
+ * of the red_mask, blue_mask and green_mask fields in the XImage structure.
+ * The Aqua port always sets red_mask = 0xFF0000, green_mask = 0xFF00, and
+ * blue_mask = 0xFF. This means that a 32bpp ZPixmap XImage uses ARGB32 pixels,
+ * with small-endian byte order BGRA. The data array for such an XImage can be
+ * passed directly to construct a CGBitmapImageRep if one specifies the
+ * bitmapInfo as kCGBitmapByteOrder32Big | kCGImageAlphaLast.
+ *
+ * The structures below describe the bitfields in two common 32 bpp pixel
+ * layouts. Note that bit field layouts are compiler dependent. The layouts
+ * shown in the comments are those produced by clang and gcc. Also note
+ * that kCGBitmapByteOrder32Big is consistently set when creating CGImages or
+ * CGImageBitmapReps.
+ */
+
+/* RGBA32 0xRRGGBBAA (Byte order is RGBA on big-endian systems.)
+ * This is used by NSBitmapImageRep when the bitmapFormat property is 0,
+ * the default value.
+ */
+
+typedef struct RGBA32pixel_t {
+ unsigned red: 8;
+ unsigned green: 8;
+ unsigned blue: 8;
+ unsigned alpha: 8;
+} RGBA32pixel;
+
+/*
+ * ARGB32 0xAARRGGBB (Byte order is ARGB on big-endian systems.)
+ * This is used by Aqua Tk for XImages and by NSBitmapImageReps whose
+ * bitmapFormat property is NSBitmapFormatAlphaFirst.
+ */
+
+typedef struct ARGB32pixel_t {
+ unsigned blue: 8;
+ unsigned green: 8;
+ unsigned red: 8;
+ unsigned alpha: 8;
+} ARGB32pixel;
+
+typedef union pixel32_t {
+ unsigned int uint;
+ RGBA32pixel rgba;
+ ARGB32pixel argb;
+} pixel32;
+
#pragma mark XImage handling
int
@@ -116,9 +181,7 @@ TkMacOSXCreateCGImageWithXImage(
}
bitsPerComponent = 8;
bitsPerPixel = 32;
- bitmapInfo = (image->byte_order == MSBFirst ?
- kCGBitmapByteOrder32Little : kCGBitmapByteOrder32Big);
- bitmapInfo |= alphaInfo;
+ bitmapInfo = kCGBitmapByteOrder32Big | alphaInfo;
data = (char *)memcpy(ckalloc(len), image->data + image->xoffset, len);
if (data) {
provider = CGDataProviderCreateWithData(data, data, len,
@@ -208,14 +271,12 @@ ImageGetPixel(
switch (image->bits_per_pixel) {
case 32: /* 8 bits per channel */
- r = (*((unsigned int*) srcPtr) >> 16) & 0xff;
- g = (*((unsigned int*) srcPtr) >> 8) & 0xff;
- b = (*((unsigned int*) srcPtr) ) & 0xff;
- /*if (image->byte_order == LSBFirst) {
- r = srcPtr[2]; g = srcPtr[1]; b = srcPtr[0];
- } else {
- r = srcPtr[1]; g = srcPtr[2]; b = srcPtr[3];
- }*/
+ {
+ ARGB32pixel *pixel = (ARGB32pixel *)srcPtr;
+ r = pixel->red;
+ g = pixel->green;
+ b = pixel->blue;
+ }
break;
case 16: /* 5 bits per channel */
r = (*((unsigned short*) srcPtr) >> 7) & 0xf8;
@@ -252,7 +313,10 @@ ImageGetPixel(
*
* ImagePutPixel --
*
- * Set a single pixel in an image.
+ * Set a single pixel in an image. The pixel is provided as an unsigned
+ * 32-bit integer. The value of that integer is interpreted by assuming
+ * that its low-order N bits have the format specified by the XImage,
+ * where N is equal to the bits_per_pixel field of the XImage.
*
* Results:
* None.
@@ -278,27 +342,20 @@ ImagePutPixel(
if (image->bits_per_pixel == 32) {
*((unsigned int*) dstPtr) = pixel;
} else {
- unsigned char r = ((pixel & image->red_mask) >> 16) & 0xff;
- unsigned char g = ((pixel & image->green_mask) >> 8) & 0xff;
- unsigned char b = ((pixel & image->blue_mask) ) & 0xff;
switch (image->bits_per_pixel) {
case 16:
- *((unsigned short*) dstPtr) = ((r & 0xf8) << 7) |
- ((g & 0xf8) << 2) | ((b & 0xf8) >> 3);
+ *((unsigned short*) dstPtr) = pixel & 0xffff;
break;
case 8:
- *dstPtr = ((r & 0xc0) >> 2) | ((g & 0xc0) >> 4) |
- ((b & 0xc0) >> 6);
+ *dstPtr = pixel & 0xff;
break;
case 4: {
- unsigned char c = ((r & 0x80) >> 5) | ((g & 0x80) >> 6) |
- ((b & 0x80) >> 7);
- *dstPtr = (x % 2) ? ((*dstPtr & 0xf0) | (c & 0x0f)) :
- ((*dstPtr & 0x0f) | ((c << 4) & 0xf0));
+ *dstPtr = (x % 2) ? ((*dstPtr & 0xf0) | (pixel & 0x0f)) :
+ ((*dstPtr & 0x0f) | ((pixel << 4) & 0xf0));
break;
}
case 1:
- *dstPtr = ((r|g|b) & 0x80) ? (*dstPtr | (0x80 >> (x % 8))) :
+ *dstPtr = pixel ? (*dstPtr | (0x80 >> (x % 8))) :
(*dstPtr & ~(0x80 >> (x % 8)));
break;
}
@@ -422,10 +479,8 @@ XCreateImage(
*----------------------------------------------------------------------
*/
-#define PIXEL_RGBA kCGImageAlphaLast
-#define PIXEL_ARGB kCGImageAlphaFirst
-#define PIXEL_XRGB kCGImageAlphaNoneSkipFirst
-#define PIXEL_RGBX kCGImageAlphaNoneSkipLast
+#define USE_ALPHA kCGImageAlphaLast
+#define IGNORE_ALPHA kCGImageAlphaNoneSkipLast
static int
TkMacOSXPutImage(
@@ -480,19 +535,34 @@ TkMacOSXPutImage(
return result;
}
-int XPutImage(Display* display, Drawable drawable, GC gc, XImage* image,
- int src_x, int src_y, int dest_x, int dest_y,
- unsigned int width, unsigned int height) {
- return TkMacOSXPutImage(PIXEL_RGBX, display, drawable, gc, image,
+int XPutImage(
+ Display* display,
+ Drawable drawable,
+ GC gc,
+ XImage* image,
+ int src_x,
+ int src_y,
+ int dest_x,
+ int dest_y,
+ unsigned int width,
+ unsigned int height) {
+ return TkMacOSXPutImage(IGNORE_ALPHA, display, drawable, gc, image,
src_x, src_y, dest_x, dest_y, width, height);
}
-int TkpPutRGBAImage(Display* display,
- Drawable drawable, GC gc, XImage* image,
- int src_x, int src_y, int dest_x, int dest_y,
- unsigned int width, unsigned int height) {
- return TkMacOSXPutImage(PIXEL_RGBA, display, drawable, gc, image,
- src_x, src_y, dest_x, dest_y, width, height);
+int TkpPutRGBAImage(
+ Display* display,
+ Drawable drawable,
+ GC gc,
+ XImage* image,
+ int src_x,
+ int src_y,
+ int dest_x,
+ int dest_y,
+ unsigned int width,
+ unsigned int height) {
+ return TkMacOSXPutImage(USE_ALPHA, display, drawable, gc, image,
+ src_x, src_y, dest_x, dest_y, width, height);
}
@@ -501,33 +571,40 @@ int TkpPutRGBAImage(Display* display,
*
* CreateCGImageFromDrawableRect
*
- * Extract image data from a MacOSX drawable as a CGImage.
- *
- * This is only called by XGetImage and XCopyArea. The Tk core uses
- * these functions on some platforms, but on macOS the core does not
- * call them with a source drawable which is a window. Such calls are
- * used only for double-buffered drawing. Since macOS defines the
- * macro TK_NO_DOUBLE_BUFFERING, the generic code never calls XGetImage
- * or XCopyArea on macOS. Nonetheless, these function are in the stubs
- * table and therefore could be used by extensions.
- *
- * This implementation does not work correctly. Originally it relied on
+ * Extract image data from a MacOSX drawable as a CGImage. The drawable
+ * may be either a pixmap or a window, but there issues in the case of
+ * a window.
+ *
+ * CreateCGImageFromDrawableRect is called by XGetImage and XCopyArea.
+ * The Tk core uses these two functions on some platforms in order to
+ * implement explicit double-buffered drawing -- a pixmap is copied from a
+ * window, modified using CPU-based graphics composition, and then copied
+ * back to the window. Platforms, such as macOS, on which the system
+ * provides double-buffered drawing and GPU-based composition operations
+ * can avoid calls to XGetImage and XCopyArea from the core by defining
+ * the compile-time variable TK_NO_DOUBLE_BUFFERING. Nonetheless, these
+ * two functions are in the stubs table and therefore could be used by
+ * extensions.
+ *
+ * The implementation here does not always work correctly when the source
+ * is a window. The original version of this function relied on
* [NSBitmapImageRep initWithFocusedViewRect:view_rect] which was
* deprecated by Apple in OSX 10.14 and also required the use of other
* deprecated functions such as [NSView lockFocus]. Apple's suggested
* replacement is [NSView cacheDisplayInRect: toBitmapImageRep:] and that
- * is what is being used here. However, that method only works when the
- * view has a valid CGContext, and a view is only guaranteed to have a
- * valid context during a call to [NSView drawRect]. To further complicate
- * matters, cacheDisplayInRect calls [NSView drawRect]. Essentially it is
- * asking the view to draw a subrectangle of itself using a special
- * graphics context which is linked to the BitmapImageRep. But our
- * implementation of [NSView drawRect] does not allow recursive calls. If
- * called recursively it returns immediately without doing any drawing.
- * So the bottom line is that this function either returns a NULL pointer
- * or a black image. To make it useful would require a significant amount
- * of rewriting of the drawRect method. Perhaps the next release of OSX
- * will include some more helpful ways of doing this.
+ * is being used here. However, cacheDisplayInRect works by calling
+ * [NSView drawRect] after setting the current graphics context to be one
+ * which draws to a bitmap. There are situations in which this can be
+ * used, e.g. when taking a screenshot of a window. But it cannot be used
+ * as part of a normal display procedure, using the copy-modify-paste
+ * paradigm that is the basis of the explicit double-buffering. Since the
+ * copy operation will call the same display procedure that is calling
+ * this function via XGetImage or XCopyArea, this would create an infinite
+ * recursion.
+ *
+ * An alternative to the copy-modify-paste paradigm is to use GPU-based
+ * graphics composition, clipping to the specified rectangle. That is
+ * the approach that must be followed by display procedures on macOS.
*
* Results:
* Returns an NSBitmapRep representing the image of the given rectangle of
@@ -577,7 +654,8 @@ CreateCGImageFromDrawableRect(
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
cg_context = CGBitmapContextCreate(imageData, view_width, view_height,
bitsPerComponent, bytesPerRow, colorSpace,
- kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
+ kCGImageAlphaPremultipliedLast |
+ kCGBitmapByteOrder32Big);
CFRelease(colorSpace);
[view.layer renderInContext:cg_context];
}
@@ -644,9 +722,6 @@ CreateCGImageFromPixmap(
*
*----------------------------------------------------------------------
*/
-struct pixel_fmt {int r; int g; int b; int a;};
-static const struct pixel_fmt bgra = {2, 1, 0, 3};
-static const struct pixel_fmt abgr = {3, 2, 1, 0};
XImage *
XGetImage(
@@ -663,7 +738,6 @@ XGetImage(
NSUInteger bitmap_fmt = 0;
XImage* imagePtr = NULL;
char *bitmap = NULL;
- char R, G, B, A;
int depth = 32, offset = 0, bitmap_pad = 0;
unsigned int bytes_per_row, size, row, n, m;
@@ -686,12 +760,11 @@ XGetImage(
size = [bitmapRep bytesPerPlane];
bytes_per_row = [bitmapRep bytesPerRow];
bitmap = (char *)ckalloc(size);
- if (!bitmap
- || (bitmap_fmt != 0 && bitmap_fmt != 1)
- || [bitmapRep samplesPerPixel] != 4
- || [bitmapRep isPlanar] != 0
- || bytes_per_row < 4 * width
- || size != bytes_per_row * height) {
+ if ((bitmap_fmt != 0 && bitmap_fmt != NSBitmapFormatAlphaFirst)
+ || [bitmapRep samplesPerPixel] != 4
+ || [bitmapRep isPlanar] != 0
+ || bytes_per_row < 4 * width
+ || size != bytes_per_row * height) {
TkMacOSXDbgMsg("XGetImage: Unrecognized bitmap format");
[bitmapRep release];
return NULL;
@@ -699,35 +772,37 @@ XGetImage(
memcpy(bitmap, (char *)[bitmapRep bitmapData], size);
[bitmapRep release];
- /*
- * When Apple extracts a bitmap from an NSView, it may be in either
- * BGRA or ABGR format. For an XImage we need RGBA.
- */
-
- struct pixel_fmt pixel = bitmap_fmt == 0 ? bgra : abgr;
-
for (row = 0, n = 0; row < height; row++, n += bytes_per_row) {
for (m = n; m < n + 4*width; m += 4) {
- R = *(bitmap + m + pixel.r);
- G = *(bitmap + m + pixel.g);
- B = *(bitmap + m + pixel.b);
- A = *(bitmap + m + pixel.a);
-
- *(bitmap + m) = R;
- *(bitmap + m + 1) = G;
- *(bitmap + m + 2) = B;
- *(bitmap + m + 3) = A;
+ pixel32 pixel = *((pixel32 *)(bitmap + m));
+ if (bitmap_fmt == 0) { // default format
+
+ /*
+ * This pixel is in ARGB32 format. We need RGBA32.
+ */
+
+ pixel32 flipped;
+ flipped.rgba.red = pixel.argb.red;
+ flipped.rgba.green = pixel.argb.green;
+ flipped.rgba.blue = pixel.argb.blue;
+ flipped.rgba.alpha = pixel.argb.alpha;
+ *((pixel32 *)(bitmap + m)) = flipped;
+ } else { // bitmap_fmt = NSBitmapFormatAlphaFirst
+ *((pixel32 *)(bitmap + m)) = pixel;
+ }
}
}
imagePtr = XCreateImage(display, NULL, depth, format, offset,
(char*) bitmap, width, height,
bitmap_pad, bytes_per_row);
} else {
+
/*
* There are some calls to XGetImage in the generic Tk code which pass
* an XYPixmap rather than a ZPixmap. XYPixmaps should be handled
* here.
*/
+
TkMacOSXDbgMsg("XGetImage does not handle XYPixmaps at the moment.");
}
return imagePtr;
diff --git a/macosx/tkMacOSXPort.h b/macosx/tkMacOSXPort.h
index b977610..cf8f615 100644
--- a/macosx/tkMacOSXPort.h
+++ b/macosx/tkMacOSXPort.h
@@ -141,6 +141,12 @@ MODULE_SCOPE int TkpPutRGBAImage(
unsigned int width, unsigned int height);
/*
+ * Inform tkCanvas.c that our XGetImage returns a 32pp pixmap packed as 0xAABBGGRR
+ */
+
+#define TK_XGETIMAGE_USES_ABGR32
+
+/*
* Used by xcolor.c
*/
diff --git a/unix/configure b/unix/configure
index c05d9b4..34a1968 100755
--- a/unix/configure
+++ b/unix/configure
@@ -2584,7 +2584,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
TK_VERSION=8.7
TK_MAJOR_VERSION=8
TK_MINOR_VERSION=7
-TK_PATCH_LEVEL="a4"
+TK_PATCH_LEVEL="a6"
VERSION=${TK_VERSION}
LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv"
@@ -6026,12 +6026,12 @@ then :
AIX-*) ;;
BSD/OS*) ;;
CYGWIN_*|MINGW32_*|MSYS_*) ;;
- HP_UX*) ;;
+ HP-UX*) ;;
Darwin-*) ;;
IRIX*) ;;
Linux*|GNU*) ;;
- NetBSD-*|DragonFly-*|FreeBSD-*|OpenBSD-*) ;;
- OSF1-V*) ;;
+ NetBSD-*|OpenBSD-*) ;;
+ OSF1-*) ;;
SCO_SV-3.2*) ;;
*) SHLIB_CFLAGS="-fPIC" ;;
esac
diff --git a/unix/configure.ac b/unix/configure.ac
index adbf461..58edbce 100644
--- a/unix/configure.ac
+++ b/unix/configure.ac
@@ -26,7 +26,7 @@ m4_ifdef([SC_USE_CONFIG_HEADERS], [
TK_VERSION=8.7
TK_MAJOR_VERSION=8
TK_MINOR_VERSION=7
-TK_PATCH_LEVEL="a4"
+TK_PATCH_LEVEL="a6"
VERSION=${TK_VERSION}
LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv"
diff --git a/unix/tcl.m4 b/unix/tcl.m4
index 7fc696e..9cfec6b 100644
--- a/unix/tcl.m4
+++ b/unix/tcl.m4
@@ -1782,12 +1782,12 @@ dnl # preprocessing tests use only CPPFLAGS.
AIX-*) ;;
BSD/OS*) ;;
CYGWIN_*|MINGW32_*|MSYS_*) ;;
- HP_UX*) ;;
+ HP-UX*) ;;
Darwin-*) ;;
IRIX*) ;;
Linux*|GNU*) ;;
- NetBSD-*|DragonFly-*|FreeBSD-*|OpenBSD-*) ;;
- OSF1-V*) ;;
+ NetBSD-*|OpenBSD-*) ;;
+ OSF1-*) ;;
SCO_SV-3.2*) ;;
*) SHLIB_CFLAGS="-fPIC" ;;
esac])
diff --git a/unix/tk.spec b/unix/tk.spec
index be98664..6a6924c 100644
--- a/unix/tk.spec
+++ b/unix/tk.spec
@@ -4,7 +4,7 @@
Name: tk
Summary: Tk graphical toolkit for the Tcl scripting language.
-Version: 8.7a4
+Version: 8.7a6
Release: 2
License: BSD
Group: Development/Languages
diff --git a/unix/tkUnixEmbed.c b/unix/tkUnixEmbed.c
index 231ec3d..bdb6950 100644
--- a/unix/tkUnixEmbed.c
+++ b/unix/tkUnixEmbed.c
@@ -981,6 +981,7 @@ EmbedWindowDeleted(
prevPtr = NULL;
containerPtr = tsdPtr->firstContainerPtr;
while (1) {
+ if (containerPtr == NULL) return;
if (containerPtr->embeddedPtr == winPtr) {
containerPtr->wrapper = None;
containerPtr->embeddedPtr = NULL;
diff --git a/win/Makefile.in b/win/Makefile.in
index 1211a9c..c1665ba 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -126,6 +126,7 @@ TCL_SRC_DIR_NATIVE = $(shell $(CYGPATH) '$(TCL_SRC_DIR)')
DLLSUFFIX = @DLLSUFFIX@
LIBSUFFIX = @LIBSUFFIX@
EXESUFFIX = @EXESUFFIX@
+TCLVER = @TCL_MAJOR_VERSION@@TCL_MINOR_VERSION@
VER = @TK_MAJOR_VERSION@@TK_MINOR_VERSION@
DOTVER = @TK_MAJOR_VERSION@.@TK_MINOR_VERSION@
@@ -203,8 +204,6 @@ RM = rm -f
COPY = cp
LN = ln
-BUILD_TCLSH = @BUILD_TCLSH@
-
# Tk does not used deprecated Tcl constructs so it should
# compile fine with -DTCL_NO_DEPRECATED. To remove its own
# set of deprecated code uncomment the second line.
@@ -709,7 +708,7 @@ ${TK_ZIP_FILE}: ${ZIP_INSTALL_OBJS}
)
@$(RMDIR) $(TK_VFS_PATH)/demos
-@if test "${ZIPFS_BUILD}" = "2" ; then \
- cp ${BUILD_TCLSH}${EXESUFFIX} ${TK_VFS_ROOT}/../${TK_ZIP_FILE} ; \
+ cp ${TCL_BIN_DIR}/tclsh${TCLVER}s.exe ${TK_VFS_ROOT}/../${TK_ZIP_FILE} || cp ${TCL_BIN_DIR}/../bin/tclsh${TCLVER}s.exe ${TK_VFS_ROOT}/../${TK_ZIP_FILE}; \
(zip=`(realpath '${NATIVE_ZIP}' || readlink -m '${NATIVE_ZIP}') 2>/dev/null || \
(echo '${NATIVE_ZIP}' | sed "s?^\./?$$(pwd)/?")`; \
cd ${TK_VFS_ROOT} && $$zip -J ../${TK_ZIP_FILE}) \
diff --git a/win/configure b/win/configure
index d815777..4e212c5 100755
--- a/win/configure
+++ b/win/configure
@@ -698,6 +698,8 @@ TK_SRC_DIR
TK_BUILD_STUB_LIB_SPEC
TK_STUB_LIB_FLAG
TK_STUB_LIB_FILE
+TK_DLL_FILE_TCL9
+TK_DLL_FILE_TCL8
TK_DLL_FILE
TK_LIB_FILE
TK_PATCH_LEVEL
@@ -2394,7 +2396,7 @@ SHELL=/bin/sh
TK_VERSION=8.7
TK_MAJOR_VERSION=8
TK_MINOR_VERSION=7
-TK_PATCH_LEVEL="a4"
+TK_PATCH_LEVEL="a6"
VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION
#------------------------------------------------------------------------
@@ -5577,7 +5579,7 @@ printf "%s\n" "$result" >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for tclsh in Tcl build directory" >&5
printf %s "checking for tclsh in Tcl build directory... " >&6; }
- BUILD_TCLSH=${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${EXEEXT}
+ BUILD_TCLSH=${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}\${EXESUFFIX}
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $BUILD_TCLSH" >&5
printf "%s\n" "$BUILD_TCLSH" >&6; }
@@ -5907,6 +5909,8 @@ TK_WIN_VERSION="$TK_VERSION.$TK_RELEASE_LEVEL.`echo $TK_PATCH_LEVEL | tr -d ab.`
+
+
# win/tcl.m4 doesn't set (LDFLAGS)
diff --git a/win/configure.ac b/win/configure.ac
index d7f89e6..0c5fe71 100644
--- a/win/configure.ac
+++ b/win/configure.ac
@@ -15,7 +15,7 @@ SHELL=/bin/sh
TK_VERSION=8.7
TK_MAJOR_VERSION=8
TK_MINOR_VERSION=7
-TK_PATCH_LEVEL="a4"
+TK_PATCH_LEVEL="a6"
VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION
#------------------------------------------------------------------------
@@ -318,6 +318,8 @@ AC_SUBST(TK_MINOR_VERSION)
AC_SUBST(TK_PATCH_LEVEL)
AC_SUBST(TK_LIB_FILE)
AC_SUBST(TK_DLL_FILE)
+AC_SUBST(TK_DLL_FILE_TCL8)
+AC_SUBST(TK_DLL_FILE_TCL9)
AC_SUBST(TK_STUB_LIB_FILE)
AC_SUBST(TK_STUB_LIB_FLAG)
AC_SUBST(TK_BUILD_STUB_LIB_SPEC)
diff --git a/win/rules.vc b/win/rules.vc
index 19f0dd8..c24fce3 100644
--- a/win/rules.vc
+++ b/win/rules.vc
@@ -1123,7 +1123,7 @@ STUBPREFIX = $(PROJECT)stub
# TIP 430. Unused for 8.6 but no harm defining it to allow a common rules.vc
TCLSCRIPTZIPNAME = libtcl$(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)$(TCL_PATCH_LETTER)$(TCL_RELEASE_SERIAL).zip
-TKSCRIPTZIPNAME = libtk$(TK_MAJOR_VERSION)$(TK_MINOR_VERSION)$(TK_PATCH_LETTER)$(TK_RELEASE_SERIAL).zip
+TKSCRIPTZIPNAME = libtk$(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)$(TK_PATCH_LETTER)$(TK_RELEASE_SERIAL).zip
!if $(DOING_TCL)
TCLSHNAME = $(PROJECT)sh$(VERSION)$(SUFX).exe
diff --git a/win/tcl.m4 b/win/tcl.m4
index 3b3fc78..ee2256d 100644
--- a/win/tcl.m4
+++ b/win/tcl.m4
@@ -1067,7 +1067,7 @@ AC_DEFUN([SC_PROG_TCLSH], [
AC_DEFUN([SC_BUILD_TCLSH], [
AC_MSG_CHECKING([for tclsh in Tcl build directory])
- BUILD_TCLSH=${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${EXEEXT}
+ BUILD_TCLSH=${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}\${EXESUFFIX}
AC_MSG_RESULT($BUILD_TCLSH)
AC_SUBST(BUILD_TCLSH)
])
diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c
index d653713..126b6d1 100644
--- a/win/tkWinEmbed.c
+++ b/win/tkWinEmbed.c
@@ -1094,8 +1094,8 @@ EmbedWindowDeleted(
prevPtr = NULL;
containerPtr = tsdPtr->firstContainerPtr;
- if (containerPtr == NULL) return;
while (1) {
+ if (containerPtr == NULL) return;
if (containerPtr->embeddedPtr == winPtr) {
containerPtr->embeddedHWnd = NULL;
containerPtr->embeddedPtr = NULL;