summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2019-05-18 13:05:43 (GMT)
committerKevin Walzer <kw@codebykevin.com>2019-05-18 13:05:43 (GMT)
commit53fd39ddc9ce3ad71ec95bc66101342c70032784 (patch)
tree95ab250e6f8824455fdf479e4c8120c9004f4bcd /macosx
parenteb47f72e2905e940a3f2b3c81f9d0a8944df5143 (diff)
parent19351002aaa78f907ef8b1fabb4814b74aaca32c (diff)
downloadtk-53fd39ddc9ce3ad71ec95bc66101342c70032784.zip
tk-53fd39ddc9ce3ad71ec95bc66101342c70032784.tar.gz
tk-53fd39ddc9ce3ad71ec95bc66101342c70032784.tar.bz2
Finally got timing of initializing NSServices object correct; code cleanup; merge in 8.6 to pick up changes in Tk initialization code
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXDefault.h4
-rw-r--r--macosx/tkMacOSXDialog.c2
-rw-r--r--macosx/tkMacOSXInit.c49
-rw-r--r--macosx/tkMacOSXKeyboard.c4
-rw-r--r--macosx/tkMacOSXMenubutton.c11
-rw-r--r--macosx/tkMacOSXServices.c2
-rw-r--r--macosx/tkMacOSXSubwindows.c9
7 files changed, 56 insertions, 25 deletions
diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h
index f965d22..660b240 100644
--- a/macosx/tkMacOSXDefault.h
+++ b/macosx/tkMacOSXDefault.h
@@ -335,9 +335,9 @@
#define DEF_MENUBUTTON_ANCHOR "w"
#define DEF_MENUBUTTON_ACTIVE_BG_COLOR ACTIVE_BG
-#define DEF_MENUBUTTON_ACTIVE_BG_MONO BLACK
+#define DEF_MENUBUTTON_ACTIVE_BG_MONO WHITE
#define DEF_MENUBUTTON_ACTIVE_FG_COLOR ACTIVE_FG
-#define DEF_MENUBUTTON_ACTIVE_FG_MONO WHITE
+#define DEF_MENUBUTTON_ACTIVE_FG_MONO BLACK
#define DEF_MENUBUTTON_BG_COLOR NORMAL_BG
#define DEF_MENUBUTTON_BG_MONO WHITE
#define DEF_MENUBUTTON_BITMAP ""
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index 90d0dc7..322519a 100644
--- a/macosx/tkMacOSXDialog.c
+++ b/macosx/tkMacOSXDialog.c
@@ -2080,7 +2080,7 @@ FontchooserParentEventHandler(
if (eventPtr->type == DestroyNotify) {
Tk_DeleteEventHandler(fcdPtr->parent, StructureNotifyMask,
FontchooserParentEventHandler, fcdPtr);
- fcdPtr->parent = None;
+ fcdPtr->parent = NULL;
FontchooserHideCmd(NULL, NULL, 0, NULL);
}
}
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index f33c0a0..3efe0c6 100644
--- a/macosx/tkMacOSXInit.c
+++ b/macosx/tkMacOSXInit.c
@@ -132,8 +132,6 @@ static char scriptPath[PATH_MAX + 1] = "";
[NSApp _lockAutoreleasePool];
while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS| TCL_DONT_WAIT)) {}
[NSApp _unlockAutoreleasePool];
-
- TkMacOSXServices_Init(_eventInterp);
}
- (void) _setup: (Tcl_Interp *) interp
@@ -328,6 +326,17 @@ TkpInit(
[pool drain];
[NSApp _setup:interp];
[NSApp finishLaunching];
+ Tk_MacOSXSetupTkNotifier();
+
+ /*
+ * If the root window is mapped before the App has finished launching
+ * it will open off screen (see ticket 56a1823c73). To avoid this we
+ * ask Tk to process an event with no wait. We expect Tcl_DoOneEvent
+ * to wait until the Mac event loop has been created and then return
+ * immediately since the queue is empty.
+ */
+
+ Tcl_DoOneEvent(TCL_WINDOW_EVENTS | TCL_DONT_WAIT);
/*
* If we don't have a TTY and stdin is a special character file of
@@ -364,8 +373,6 @@ TkpInit(
}
- Tk_MacOSXSetupTkNotifier();
-
if (tkLibPath[0] != '\0') {
Tcl_SetVar2(interp, "tk_library", NULL, tkLibPath, TCL_GLOBAL_ONLY);
}
@@ -383,6 +390,14 @@ TkpInit(
TkMacOSXIconBitmapObjCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "::tk::mac::GetAppPath", TkMacOSXGetAppPath,(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+ /*
+ * 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.
+ */
+
+ TkMacOSXServices_Init(interp);
+
return TCL_OK;
}
@@ -437,19 +452,33 @@ TkpGetAppName(
* None.
*
*----------------------------------------------------------------------
- *//*Tcl function to get path to app bundle.*/
-int TkMacOSXGetAppPath(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST objv[]) {
+ */
+int TkMacOSXGetAppPath(
+ ClientData cd,
+ Tcl_Interp *ip,
+ int objc,
+ Tcl_Obj *CONST objv[])
+{
CFURLRef mainBundleURL = CFBundleCopyBundleURL(CFBundleGetMainBundle());
- /* Convert the URL reference into a string reference. */
+ /*
+ * Convert the URL reference into a string reference.
+ */
+
CFStringRef appPath = CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle);
- /* Get the system encoding method. */
+ /*
+ * Get the system encoding method.
+ */
+
CFStringEncoding encodingMethod = CFStringGetSystemEncoding();
- /* Convert the string reference into a C string. */
+ /*
+ * Convert the string reference into a C string.
+ */
+
char *path = (char *) CFStringGetCStringPtr(appPath, encodingMethod);
Tcl_SetResult(ip, path, NULL);
@@ -459,7 +488,7 @@ int TkMacOSXGetAppPath(ClientData cd, Tcl_Interp *ip, int objc, Tcl_Obj *CONST o
return TCL_OK;
}
-
+
/*
*----------------------------------------------------------------------
*
diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c
index 31f842a..5899064 100644
--- a/macosx/tkMacOSXKeyboard.c
+++ b/macosx/tkMacOSXKeyboard.c
@@ -180,13 +180,13 @@ InitKeyMaps(void)
for (kPtr = keyArray; kPtr->keycode != 0; kPtr++) {
hPtr = Tcl_CreateHashEntry(&keycodeTable, INT2PTR(kPtr->keycode),
&dummy);
- Tcl_SetHashValue(hPtr, kPtr->keysym);
+ Tcl_SetHashValue(hPtr, INT2PTR(kPtr->keysym));
}
Tcl_InitHashTable(&vkeyTable, TCL_ONE_WORD_KEYS);
for (kPtr = virtualkeyArray; kPtr->keycode != 0; kPtr++) {
hPtr = Tcl_CreateHashEntry(&vkeyTable, INT2PTR(kPtr->keycode),
&dummy);
- Tcl_SetHashValue(hPtr, kPtr->keysym);
+ Tcl_SetHashValue(hPtr, INT2PTR(kPtr->keysym));
}
initialized = 1;
}
diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c
index dbad8db..53adb01 100644
--- a/macosx/tkMacOSXMenubutton.c
+++ b/macosx/tkMacOSXMenubutton.c
@@ -580,6 +580,17 @@ TkMacOSXDrawMenuButton(
hiinfo.animation.time.start = hiinfo.animation.time.current;
}
+ /*
+ * To avoid menubuttons with white text on a white background, we
+ * always set the state to inactive in Dark Mode. It isn't perfect but
+ * it is usable. Using a ttk::menubutton would be a better choice,
+ * however.
+ */
+
+ if (TkMacOSXInDarkMode(butPtr->tkwin)) {
+ hiinfo.state = kThemeStateInactive;
+ }
+
HIThemeDrawButton(&cntrRect, &hiinfo, dc.context,
kHIThemeOrientationNormal, &contHIRec);
TkMacOSXRestoreDrawingContext(&dc);
diff --git a/macosx/tkMacOSXServices.c b/macosx/tkMacOSXServices.c
index 30e851d..39874b7 100644
--- a/macosx/tkMacOSXServices.c
+++ b/macosx/tkMacOSXServices.c
@@ -215,7 +215,7 @@ int TkMacOSXRegisterServiceWidgetObjCmd (
}
/*
- * Initalize the package in the tcl interpreter, create tcl commands.
+ * Initalize the package in the Tcl interpreter, create Tcl commands.
*/
int TkMacOSXServices_Init(
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index 21f40ce..2579892 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.c
@@ -168,15 +168,6 @@ XMapWindow(
} else {
[win orderFrontRegardless];
}
-
- /*
- * In some cases the toplevel will not be drawn unless we process
- * all pending events now. See ticket 56a1823c73.
- */
-
- [NSApp _lockAutoreleasePool];
- while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS| TCL_DONT_WAIT)) {}
- [NSApp _unlockAutoreleasePool];
} else {
TkWindow *contWinPtr = TkpGetOtherWindow(winPtr);