summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorculler <culler>2019-04-14 22:22:28 (GMT)
committerculler <culler>2019-04-14 22:22:28 (GMT)
commit1b8c968e6e5ac74c9cfaf79ea456117418509ed8 (patch)
treebfed39c5ad08ec1b6e273102e090365885af1b89 /macosx
parent129eaeff4027eccba2a3c092d3609655911cce8d (diff)
parent1b1e4cc61c4f9772610d0e1c4c539d2562203ac6 (diff)
downloadtk-1b8c968e6e5ac74c9cfaf79ea456117418509ed8.zip
tk-1b8c968e6e5ac74c9cfaf79ea456117418509ed8.tar.gz
tk-1b8c968e6e5ac74c9cfaf79ea456117418509ed8.tar.bz2
Implement "tk::unsupported::MacWindowStyle isdark" to determine whether an
Aqua toplevel is currently being displayed in Dark Mode.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/README17
-rw-r--r--macosx/tkMacOSXWindowEvent.c13
-rw-r--r--macosx/tkMacOSXWm.c12
3 files changed, 25 insertions, 17 deletions
diff --git a/macosx/README b/macosx/README
index 7e015b7..3f7ec40 100644
--- a/macosx/README
+++ b/macosx/README
@@ -184,12 +184,13 @@ Note that not all attributes are valid for all window classes. Support for the
support for some legacy Carbon-specific classes and attributes was removed
(they are still accepted by the command but no longer have any effect).
-- Another command available in the tk::unsupported::MacWindowStyle namespace is
-tk::unsupported::MacWindowStyle tabbingid window ?newId? which can be used to
-get or set the tabbingIdentifier for the NSWindow associated with a Tk Window.
-See section 3 for details.
+- Another command available in the tk::unsupported::MacWindowStyle namespace is:
+ tk::unsupported::MacWindowStyle tabbingid window ?newId?
+which can be used to get or set the tabbingIdentifier for the NSWindow
+associated with a Tk Window. See section 3 for details.
-- A command tk::unsupported::MacWindowStyle appearance window ?newAappearance?
+- The command:
+ tk::unsupported::MacWindowStyle appearance window ?newAappearance?
is available when Tk is built and run on macOS 10.14 (Mojave) or later. In
that case the Ttk widgets all support the "Dark Mode" appearance which was
introduced in 10.14. The command accepts the following values for the optional
@@ -199,6 +200,12 @@ appearance independent of any preferences settings. If it is set to "auto"
the appearance will be determined by the preferences. This command can be
used to opt out of Dark Mode on a per-window basis.
+- To determine the current appearance of a window in macOS 10.14 (Mojave) and
+higher, one can use the command:
+ tk::unsupported::MacWindowStyle isdark
+The boolean return value is true if the window is currently displayed with the
+dark appearance.
+
- If you want to use Remote Debugging with Xcode, you need to set the
environment variable XCNOSTDIN to 1 in the Executable editor for Wish. That will
cause us to force closing stdin & stdout. Otherwise, given how Xcode launches
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index 212381e..54e1272 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -1070,7 +1070,6 @@ ConfigureRestrictProc(
{
XVirtualEvent event;
int x, y;
- NSString *osxMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"];
NSWindow *w = [self window];
TkWindow *winPtr = TkMacOSXGetTkWindow(w);
Tk_Window tkwin = (Tk_Window) winPtr;
@@ -1091,16 +1090,12 @@ ConfigureRestrictProc(
&event.x_root, &event.y_root, &x, &y, &event.state);
Tk_TopCoordsToWindow(tkwin, x, y, &event.x, &event.y);
event.same_screen = true;
- if (osxMode == nil) {
- event.name = Tk_GetUid("LightAqua");
- Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
- return;
- }
- if ([osxMode isEqual:@"Dark"]) {
+ if (TkMacOSXInDarkMode(tkwin)) {
event.name = Tk_GetUid("DarkAqua");
- Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
- return;
+ } else {
+ event.name = Tk_GetUid("LightAqua");
}
+ Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
}
/*
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 8cf05df..60277d1 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -1021,7 +1021,6 @@ TkWmDeadWindow(
while (Tk_DoOneEvent(TK_WINDOW_EVENTS|TK_DONT_WAIT)) {}
}
[NSApp _resetAutoreleasePool];
-
#if DEBUG_ZOMBIES > 0
fprintf(stderr, "================= Pool dump ===================\n");
[NSAutoreleasePool showPools];
@@ -5520,10 +5519,10 @@ TkUnsupported1ObjCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
static const char *const subcmds[] = {
- "style", "tabbingid", "appearance", NULL
+ "style", "tabbingid", "appearance", "isdark", NULL
};
enum SubCmds {
- TKMWS_STYLE, TKMWS_TABID, TKMWS_APPEARANCE
+ TKMWS_STYLE, TKMWS_TABID, TKMWS_APPEARANCE, TKMWS_ISDARK
};
Tk_Window tkwin = clientData;
TkWindow *winPtr;
@@ -5589,6 +5588,13 @@ TkUnsupported1ObjCmd(
return TCL_ERROR;
}
return WmWinAppearance(interp, winPtr, objc, objv);
+ case TKMWS_ISDARK:
+ if ((objc != 3)) {
+ Tcl_WrongNumArgs(interp, 2, objv, "isdark window");
+ return TCL_ERROR;
+ }
+ Tcl_SetObjResult(interp, Tcl_NewBooleanObj(TkMacOSXInDarkMode(tkwin)));
+ return TCL_OK;
default:
return TCL_ERROR;
}