Tk Source Code

Check-in [d35955f2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Support for light and dark modes on macOS.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | mac-appearance
Files: files | file ages | folders
SHA3-256:d35955f27fc97bb1a082201cd48af6c6d5db306c2c486f654605e8a33e527c00
User & Date: culler 2018-11-10 22:31:04
Context
2018-11-11
05:33
Restore the README description of virtual events for appearance changes. check-in: bf9398d9 user: culler tags: mac-appearance
2018-11-10
22:31
Support for light and dark modes on macOS. check-in: d35955f2 user: culler tags: mac-appearance
19:37
The 'option readfile' sub-command should maintain existing list structure for values. Fix for [766ef52f31]. check-in: 5550a138 user: mistachkin tags: core-8-6-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to macosx/tkMacOSXWindowEvent.c.

987
988
989
990
991
992
993
994
















































995
996
997
998
999
1000
1001
	 *
	 * Fortunately, Tk schedules all drawing to be done while Tcl is idle.
	 * So we can do the drawing by processing all of the idle events that
	 * were created when the expose events were processed.
	 */
	while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {}
    }
} 

















































/*
 * This is no-op on 10.7 and up because Apple has removed this widget,
 * but we are leaving it here for backwards compatibility.
 */

- (void) tkToolbarButton: (id) sender







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
	 *
	 * Fortunately, Tk schedules all drawing to be done while Tcl is idle.
	 * So we can do the drawing by processing all of the idle events that
	 * were created when the expose events were processed.
	 */
	while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {}
    }
}

/*
 * This method is called when a user changes between light and dark mode.
 * The implementation here generates a Tk virtual event which can be bound
 * to a function that redraws the window in an appropriate style.
 */

- (void) viewDidChangeEffectiveAppearance
{
    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;

    /*
     * If there is no Tk window associated to this NSWindow, just return.
     */

    if (!winPtr) {
	return;
    }

    bzero(&event, sizeof(XVirtualEvent));
    event.type = VirtualEvent;
    event.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
    event.send_event = false;
    event.display = Tk_Display(tkwin);
    event.event = Tk_WindowId(tkwin);
    event.root = XRootWindow(Tk_Display(tkwin), 0);
    event.subwindow = None;
    event.time = TkpGetMS();
    XQueryPointer(NULL, winPtr->window, NULL, NULL,
    		  &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"]) {
	event.name = Tk_GetUid("DarkAqua");
	Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL);
	return;
    }
}

/*
 * This is no-op on 10.7 and up because Apple has removed this widget,
 * but we are leaving it here for backwards compatibility.
 */

- (void) tkToolbarButton: (id) sender