summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXInit.c
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/tkMacOSXInit.c')
-rw-r--r--macosx/tkMacOSXInit.c118
1 files changed, 82 insertions, 36 deletions
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index dfdde24..375d20e 100644
--- a/macosx/tkMacOSXInit.c
+++ b/macosx/tkMacOSXInit.c
@@ -33,7 +33,9 @@ static char scriptPath[PATH_MAX + 1] = "";
* Forward declarations...
*/
-static int TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip,
+static int TkMacOSXGetAppPathObjCmd(TCL_UNUSED(void *), Tcl_Interp *ip,
+ int objc, Tcl_Obj *const objv[]);
+static int TkMacOSVersionObjCmd(ClientData cd, Tcl_Interp *ip,
int objc, Tcl_Obj *const objv[]);
#pragma mark TKApplication(TKInit)
@@ -42,7 +44,6 @@ static int TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip,
@synthesize poolLock = _poolLock;
@synthesize macOSVersion = _macOSVersion;
@synthesize isDrawing = _isDrawing;
-@synthesize needsToDraw = _needsToDraw;
@synthesize isSigned = _isSigned;
@synthesize tkLiveResizeEnded = _tkLiveResizeEnded;
@synthesize tkPointerWindow = _tkPointerWindow;
@@ -145,6 +146,7 @@ static int TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip,
/*
* Initialize the graphics context.
*/
+
TkMacOSXUseAntialiasedText(_eventInterp, -1);
TkMacOSXInitCGDrawing(_eventInterp, TRUE, 0);
@@ -156,6 +158,12 @@ static int TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip,
[self _setupMenus];
/*
+ * Run initialization routines that depend on the OS version.
+ */
+
+ Ttk_MacOSXInit();
+
+ /*
* It is not safe to force activation of the NSApp until this method is
* called. Activating too early can cause the menu bar to be unresponsive.
* The call to activateIgnoringOtherApps was moved here to avoid this.
@@ -563,12 +571,13 @@ TkpInit(
}
/*
- * Initialize the NSServices object here. Apple's docs say to do this
- * in applicationDidFinishLaunching, but the Tcl interpreter is not
- * initialized until this function call.
+ * Now we can run initialization routines which require that both the
+ * NSApplication and the Tcl interpreter have been created and
+ * initialized.
*/
TkMacOSXServices_Init(interp);
+ TkMacOSXNSImage_Init(interp);
/*
* The root window has been created and mapped, but XMapWindow deferred its
@@ -604,7 +613,6 @@ TkpInit(
signal(SIGHUP, TkMacOSXSignalHandler);
signal(SIGTERM, TkMacOSXSignalHandler);
}
-
/*
* Initialization steps that are needed for all interpreters.
*/
@@ -612,18 +620,66 @@ TkpInit(
if (tkLibPath[0] != '\0') {
Tcl_SetVar2(interp, "tk_library", NULL, tkLibPath, TCL_GLOBAL_ONLY);
}
-
if (scriptPath[0] != '\0') {
Tcl_SetVar2(interp, "auto_path", NULL, scriptPath,
TCL_GLOBAL_ONLY|TCL_LIST_ELEMENT|TCL_APPEND_VALUE);
}
-
Tcl_CreateObjCommand(interp, "::tk::mac::standardAboutPanel",
TkMacOSXStandardAboutPanelObjCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap",
TkMacOSXIconBitmapObjCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "::tk::mac::GetAppPath",
- TkMacOSXGetAppPathCmd, NULL, NULL);
+ TkMacOSXGetAppPathObjCmd, NULL, NULL);
+ Tcl_CreateObjCommand(interp, "::tk::mac::macOSVersion",
+ TkMacOSVersionObjCmd, NULL, NULL);
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXGetAppPathObjCmd --
+ *
+ * Returns the path of the Wish application bundle.
+ *
+ * Results:
+ * Returns the application path.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+TkMacOSXGetAppPathObjCmd(
+ TCL_UNUSED(void *),
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *const objv[])
+{
+ if (objc != 1) {
+ Tcl_WrongNumArgs(interp, 1, objv, NULL);
+ return TCL_ERROR;
+ }
+
+ /*
+ * Get the application path URL and convert it to a string path reference.
+ */
+
+ CFURLRef mainBundleURL = CFBundleCopyBundleURL(CFBundleGetMainBundle());
+ CFStringRef appPath =
+ CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle);
+
+ /*
+ * Convert (and copy) the string reference into a Tcl result.
+ */
+
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ CFStringGetCStringPtr(appPath, CFStringGetSystemEncoding()), -1));
+
+ CFRelease(mainBundleURL);
+ CFRelease(appPath);
MacSystrayInit(interp);
MacPrint_Init(interp);
@@ -670,48 +726,37 @@ TkpGetAppName(
/*
*----------------------------------------------------------------------
*
- * TkMacOSXGetAppPathCmd --
+ * TkMacOSVersionObjCmd --
*
- * Returns the path of the Wish application bundle.
+ * Tcl command which returns an integer encoding the major and minor
+ * version numbers of the currently running operating system in the
+ * form 10000*majorVersion + 100*minorVersion.
*
* Results:
- * Returns the application path.
+ * Returns the OS version.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
-
+
static int
-TkMacOSXGetAppPathCmd(
- TCL_UNUSED(void *),
+TkMacOSVersionObjCmd(
+ TCL_UNUSED(void *), /* ClientData */
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
- if (objc != 1) {
+ static char version[16] = "";
+ if (objc > 1) {
Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
}
-
- /*
- * Get the application path URL and convert it to a string path reference.
- */
-
- CFURLRef mainBundleURL = CFBundleCopyBundleURL(CFBundleGetMainBundle());
- CFStringRef appPath =
- CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle);
-
- /*
- * Convert (and copy) the string reference into a Tcl result.
- */
-
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- CFStringGetCStringPtr(appPath, CFStringGetSystemEncoding()), -1));
-
- CFRelease(mainBundleURL);
- CFRelease(appPath);
+ if (version[0] == '\0') {
+ snprintf(version, 16, "%d", [NSApp macOSVersion]);
+ }
+ Tcl_SetResult(interp, version, NULL);
return TCL_OK;
}
@@ -818,10 +863,11 @@ TkMacOSXDefaultStartupScript(void)
MODULE_SCOPE void*
TkMacOSXGetNamedSymbol(
- TCL_UNUSED(const char *),
- const char *symbol)
+ const char* module,
+ const char* symbol)
{
void *addr = dlsym(RTLD_NEXT, symbol);
+ (void)module;
if (!addr) {
(void) dlerror(); /* Clear dlfcn error state */