From 2c80218636b778e62c7c0707c891553b83a79a26 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 8 Sep 2020 11:02:00 +0000 Subject: Move up TkUnusedStubEntry a little. New test function "menubarheight" for MacOSX (backported from 8.6) --- generic/tk.decls | 3 +++ generic/tkInt.decls | 4 +-- generic/tkIntDecls.h | 12 ++++++--- generic/tkIntXlibDecls.h | 4 +-- generic/tkPlatDecls.h | 25 +++++++++++++++++++ generic/tkStubInit.c | 10 +++++++- macosx/tkMacOSXTest.c | 65 ++++++++++++++++++++++++++++++++++++++++-------- macosx/tkMacOSXXStubs.c | 2 +- 8 files changed, 105 insertions(+), 20 deletions(-) diff --git a/generic/tk.decls b/generic/tk.decls index 2825111..7f3d093 100644 --- a/generic/tk.decls +++ b/generic/tk.decls @@ -1141,6 +1141,9 @@ declare 9 aqua { declare 10 aqua { int Tk_MacOSXIsAppInFront(void) } +declare 16 aqua { + void TkUnusedStubEntry(void) +} ############################################################################## diff --git a/generic/tkInt.decls b/generic/tkInt.decls index 2b04cc1..d056110 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -568,7 +568,7 @@ declare 180 { char *TkSmoothPrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr) } -declare 184 { +declare 186 { void TkUnusedStubEntry(void) } @@ -1718,7 +1718,7 @@ declare 90 aqua { Window **w4, unsigned int *ui) } declare 91 aqua { - int XSync(Display *display, Bool flag) + int XSync(Display *display, Bool discard) } declare 158 aqua { void TkUnusedStubEntry(void) diff --git a/generic/tkIntDecls.h b/generic/tkIntDecls.h index 9dea8d4..d0a091d 100644 --- a/generic/tkIntDecls.h +++ b/generic/tkIntDecls.h @@ -969,9 +969,11 @@ EXTERN char * TkSmoothPrintProc(ClientData clientData, /* Slot 181 is reserved */ /* Slot 182 is reserved */ /* Slot 183 is reserved */ +/* Slot 184 is reserved */ +/* Slot 185 is reserved */ #ifndef TkUnusedStubEntry_TCL_DECLARED #define TkUnusedStubEntry_TCL_DECLARED -/* 184 */ +/* 186 */ EXTERN void TkUnusedStubEntry(void); #endif @@ -1190,7 +1192,9 @@ typedef struct TkIntStubs { VOID *reserved181; VOID *reserved182; VOID *reserved183; - void (*tkUnusedStubEntry) (void); /* 184 */ + VOID *reserved184; + VOID *reserved185; + void (*tkUnusedStubEntry) (void); /* 186 */ } TkIntStubs; extern TkIntStubs *tkIntStubsPtr; @@ -1863,9 +1867,11 @@ extern TkIntStubs *tkIntStubsPtr; /* Slot 181 is reserved */ /* Slot 182 is reserved */ /* Slot 183 is reserved */ +/* Slot 184 is reserved */ +/* Slot 185 is reserved */ #ifndef TkUnusedStubEntry #define TkUnusedStubEntry \ - (tkIntStubsPtr->tkUnusedStubEntry) /* 184 */ + (tkIntStubsPtr->tkUnusedStubEntry) /* 186 */ #endif #endif /* defined(USE_TK_STUBS) && !defined(USE_TK_STUB_PROCS) */ diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index 010dd9c..700aa3d 100644 --- a/generic/tkIntXlibDecls.h +++ b/generic/tkIntXlibDecls.h @@ -1299,7 +1299,7 @@ EXTERN Status XQueryTree(Display *d, Window w1, Window *w2, #ifndef XSync_TCL_DECLARED #define XSync_TCL_DECLARED /* 91 */ -EXTERN int XSync(Display *display, Bool flag); +EXTERN int XSync(Display *display, Bool discard); #endif /* Slot 92 is reserved */ /* Slot 93 is reserved */ @@ -1631,7 +1631,7 @@ typedef struct TkIntXlibStubs { void (*xQueryColor) (Display *display, Colormap colormap, XColor *def_in_out); /* 88 */ void (*xQueryColors) (Display *display, Colormap colormap, XColor *defs_in_out, int ncolors); /* 89 */ Status (*xQueryTree) (Display *d, Window w1, Window *w2, Window *w3, Window **w4, unsigned int *ui); /* 90 */ - int (*xSync) (Display *display, Bool flag); /* 91 */ + int (*xSync) (Display *display, Bool discard); /* 91 */ VOID *reserved92; VOID *reserved93; VOID *reserved94; diff --git a/generic/tkPlatDecls.h b/generic/tkPlatDecls.h index eb3d74d..9112f58 100644 --- a/generic/tkPlatDecls.h +++ b/generic/tkPlatDecls.h @@ -129,6 +129,16 @@ EXTERN void Tk_MacOSXSetupTkNotifier(void); /* 10 */ EXTERN int Tk_MacOSXIsAppInFront(void); #endif +/* Slot 11 is reserved */ +/* Slot 12 is reserved */ +/* Slot 13 is reserved */ +/* Slot 14 is reserved */ +/* Slot 15 is reserved */ +#ifndef TkUnusedStubEntry_TCL_DECLARED +#define TkUnusedStubEntry_TCL_DECLARED +/* 16 */ +EXTERN void TkUnusedStubEntry(void); +#endif #endif /* AQUA */ typedef struct TkPlatStubs { @@ -155,6 +165,12 @@ typedef struct TkPlatStubs { VOID * (*tkMacOSXGetRootControl) (Drawable drawable); /* 8 */ void (*tk_MacOSXSetupTkNotifier) (void); /* 9 */ int (*tk_MacOSXIsAppInFront) (void); /* 10 */ + VOID *reserved11; + VOID *reserved12; + VOID *reserved13; + VOID *reserved14; + VOID *reserved15; + void (*tkUnusedStubEntry) (void); /* 16 */ #endif /* AQUA */ } TkPlatStubs; @@ -241,6 +257,15 @@ extern TkPlatStubs *tkPlatStubsPtr; #define Tk_MacOSXIsAppInFront \ (tkPlatStubsPtr->tk_MacOSXIsAppInFront) /* 10 */ #endif +/* Slot 11 is reserved */ +/* Slot 12 is reserved */ +/* Slot 13 is reserved */ +/* Slot 14 is reserved */ +/* Slot 15 is reserved */ +#ifndef TkUnusedStubEntry +#define TkUnusedStubEntry \ + (tkPlatStubsPtr->tkUnusedStubEntry) /* 16 */ +#endif #endif /* AQUA */ #endif /* defined(USE_TK_STUBS) && !defined(USE_TK_STUB_PROCS) */ diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index 3f6d348..6054d50 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -481,7 +481,9 @@ TkIntStubs tkIntStubs = { NULL, /* 181 */ NULL, /* 182 */ NULL, /* 183 */ - TkUnusedStubEntry, /* 184 */ + NULL, /* 184 */ + NULL, /* 185 */ + TkUnusedStubEntry, /* 186 */ }; TkIntPlatStubs tkIntPlatStubs = { @@ -961,6 +963,12 @@ TkPlatStubs tkPlatStubs = { TkMacOSXGetRootControl, /* 8 */ Tk_MacOSXSetupTkNotifier, /* 9 */ Tk_MacOSXIsAppInFront, /* 10 */ + NULL, /* 11 */ + NULL, /* 12 */ + NULL, /* 13 */ + NULL, /* 14 */ + NULL, /* 15 */ + TkUnusedStubEntry, /* 16 */ #endif /* AQUA */ }; diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c index 0e43785..a8ae788 100644 --- a/macosx/tkMacOSXTest.c +++ b/macosx/tkMacOSXTest.c @@ -13,14 +13,20 @@ */ #include "tkMacOSXPrivate.h" +#include "tkMacOSXWm.h" + /* * Forward declarations of procedures defined later in this file: */ -static int DebuggerCmd (ClientData dummy, Tcl_Interp *interp, - int argc, const char **argv); -MODULE_SCOPE int TkplatformtestInit(Tcl_Interp *interp); +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1080 +static int DebuggerObjCmd(ClientData dummy, Tcl_Interp *interp, + int objc, Tcl_Obj *const objv[]); +#endif +static int MenuBarHeightObjCmd(ClientData dummy, Tcl_Interp *interp, + int objc, Tcl_Obj *const *objv); + /* *---------------------------------------------------------------------- @@ -47,18 +53,20 @@ TkplatformtestInit( * Add commands for platform specific tests on MacOS here. */ - Tcl_CreateCommand(interp, "debugger", DebuggerCmd, - (ClientData) 0, (Tcl_CmdDeleteProc *) NULL); - +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1080 + Tcl_CreateObjCommand(interp, "debugger", DebuggerObjCmd, NULL, NULL); +#endif + Tcl_CreateObjCommand(interp, "menubarheight", MenuBarHeightObjCmd, NULL, NULL); return TCL_OK; } /* *---------------------------------------------------------------------- * - * DebuggerCmd -- + * DebuggerObjCmd -- * - * This procedure simply calls the low level debugger. + * This procedure simply calls the low level debugger, which was + * deprecated in OSX 10.8. * * Results: * A standard Tcl result. @@ -69,16 +77,51 @@ TkplatformtestInit( *---------------------------------------------------------------------- */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1080 static int -DebuggerCmd( +DebuggerObjCmd( ClientData clientData, /* Not used. */ Tcl_Interp *interp, /* Not used. */ - int argc, /* Not used. */ - const char **argv) /* Not used. */ + int objc, /* Not used. */ + Tcl_Obj *const objv[]) /* Not used. */ { Debugger(); return TCL_OK; } +#endif + +/* + *---------------------------------------------------------------------- + * + * MenuBarHeightObjCmd -- + * + * This procedure calls [NSMenu menuBarHeight] and returns the result + * as an integer. Windows can never be placed to overlap the MenuBar, + * so tests need to be aware of its size. + * + * Results: + * A standard Tcl result. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static int +MenuBarHeightObjCmd( + ClientData clientData, /* Not used. */ + Tcl_Interp *interp, /* Not used. */ + int objc, /* Not used. */ + Tcl_Obj *const objv[]) /* Not used. */ +{ + static int height = 0; + if (height == 0) { + height = (int) [[NSApp mainMenu] menuBarHeight]; + } + Tcl_SetObjResult(interp, Tcl_NewIntObj(height)); + return TCL_OK; +} /* * Local Variables: diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index a541945..b6b1659 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -719,7 +719,7 @@ Tk_FreeXId( int XSync( Display *display, - Bool flag) + Bool discard) { TkMacOSXFlushWindows(); display->request++; -- cgit v0.12