summaryrefslogtreecommitdiffstats
path: root/generic/tkTest.c
diff options
context:
space:
mode:
authorculler <culler>2018-11-05 16:03:56 (GMT)
committerculler <culler>2018-11-05 16:03:56 (GMT)
commit31f82fb5b5ae52d1893a87e7a5a83c0e9eae2f58 (patch)
tree55a223472c4e168f0c0b29d3aa178a70c75b629f /generic/tkTest.c
parentb236ac696bc5e78bb9aa87505d01d388b1b8cb07 (diff)
downloadtk-31f82fb5b5ae52d1893a87e7a5a83c0e9eae2f58.zip
tk-31f82fb5b5ae52d1893a87e7a5a83c0e9eae2f58.tar.gz
tk-31f82fb5b5ae52d1893a87e7a5a83c0e9eae2f58.tar.bz2
Make XSync, and hence update, be synchronous so test results are consistent. Fix duplicate
reports of calls to the test image displayProc.
Diffstat (limited to 'generic/tkTest.c')
-rw-r--r--generic/tkTest.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/generic/tkTest.c b/generic/tkTest.c
index 2dbd877..e95d274 100644
--- a/generic/tkTest.c
+++ b/generic/tkTest.c
@@ -31,6 +31,9 @@
#if defined(MAC_OSX_TK)
#include "tkMacOSXInt.h"
#include "tkScrollbar.h"
+#define APP_IS_DRAWING (TkTestAppIsDrawing())
+#else
+#define APP_IS_DRAWING 1
#endif
#ifdef __UNIX__
@@ -1550,15 +1553,26 @@ ImageDisplay(
TImageInstance *instPtr = (TImageInstance *) clientData;
char buffer[200 + TCL_INTEGER_SPACE * 6];
- sprintf(buffer, "%s display %d %d %d %d",
- instPtr->masterPtr->imageName, imageX, imageY, width, height);
- Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, NULL,
- buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
- if (width > (instPtr->masterPtr->width - imageX)) {
- width = instPtr->masterPtr->width - imageX;
- }
- if (height > (instPtr->masterPtr->height - imageY)) {
- height = instPtr->masterPtr->height - imageY;
+ /*
+ * On macOS the fake drawing below will not take place when this
+ * displayProc is run as an idle task. That is because the idle task will
+ * not have a valid graphics context available. Instead, the window will
+ * be marked as needing redisplay and will get redrawn in the next call to
+ * its contentView's drawRect method. We only record the display
+ * information when the actual drawing takes place to avoid duplicate
+ * records which would cause some image tests to fail.
+ */
+ if (APP_IS_DRAWING) {
+ sprintf(buffer, "%s display %d %d %d %d",
+ instPtr->masterPtr->imageName, imageX, imageY, width, height);
+ Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, NULL,
+ buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
+ if (width > (instPtr->masterPtr->width - imageX)) {
+ width = instPtr->masterPtr->width - imageX;
+ }
+ if (height > (instPtr->masterPtr->height - imageY)) {
+ height = instPtr->masterPtr->height - imageY;
+ }
}
XDrawRectangle(display, drawable, instPtr->gc, drawableX, drawableY,
(unsigned) (width-1), (unsigned) (height-1));