Tk Source Code

Check-in [4f09dd1f]
Login

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

Overview
Comment:Remove new Mojave virtual events to register system appearance changes because Tk crashes unpredictably; window decotrations, menus and dialogs change when system appearance changes and virtual events are not required
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:4f09dd1fc9bcdbf90a1f373268b26f4d7aef568022749040fda16206cb00c67a
User & Date: kevin_walzer 2018-11-10 14:18:50
Context
2018-11-10
19:43
The 'option readfile' sub-command should maintain existing list structure for values. Fix for [766ef52f31]. Cherrypick of [5550a1383b]. check-in: 2322894e user: mistachkin tags: trunk
14:18
Remove new Mojave virtual events to register system appearance changes because Tk crashes unpredictably; window decotrations, menus and dialogs change when system appearance changes and virtual events are not required check-in: 4f09dd1f user: kevin_walzer tags: trunk
04:56
Fix a bug in TkPutImage for macOS. check-in: 15466b4d user: culler tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to macosx/README.

557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572

inefficient to iterate through all embedded windows in a Text widget,
looking for those which meet the scrolling area, the damage region
constructed by TkScrollWindow contains only the difference between the
source and destination rectangles for the scrolling.  The embedded
windows are redrawn within the DisplayText function by some
conditional code which is only used for macOS.

5.0 Virtual events on 10.14
~~~~~~~~~~~~~~~~~~~~~~~~~~~

10.14 supports system appearance changes, and has added a "Dark Mode"
that casts all window frames and menus as black. Tk 8.6.9 has added two
virtual events, <<LightAqua>> and <<DarkAqua>>, to allow you to update
your Tk app's appearance when the system appearance changes. Just bind
your appearance-updating code to these virtual events and you will see
it triggered when the system appearance toggles between dark and light.








|



|
|
|
|
|
>
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
inefficient to iterate through all embedded windows in a Text widget,
looking for those which meet the scrolling area, the damage region
constructed by TkScrollWindow contains only the difference between the
source and destination rectangles for the scrolling.  The embedded
windows are redrawn within the DisplayText function by some
conditional code which is only used for macOS.

5.0 Dark Mode on 10.14
~~~~~~~~~~~~~~~~~~~~~~~~~~~

10.14 supports system appearance changes, and has added a "Dark Mode"
that casts all window frames and menus as black. Tk 8.6.9 supports Dark
Mode by having the window decorations, menus, and dialogs automatically
take on the appropriate appearance when the system appearance is changed. 
Because the window content itself is drawn by Tk, it will not change when
the system mode changes.

Changes to macosx/tkMacOSXPrivate.h.

329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345

@interface TKContentView(TKKeyEvent)
- (void) deleteWorkingText;
@end

@interface TKContentView(TKWindowEvent)
- (void) drawRect: (NSRect) rect;
- (void) generateExposeEvents: (HIShapeRef) shape;
- (void) viewDidChangeEffectiveAppearance;
- (void) updateAppearanceEvent;
- (void) tkToolbarButton: (id) sender;
- (BOOL) isOpaque;
- (BOOL) wantsDefaultClipping;
- (BOOL) acceptsFirstResponder;
- (void) keyDown: (NSEvent *) theEvent;
@end








|
<
<







329
330
331
332
333
334
335
336


337
338
339
340
341
342
343

@interface TKContentView(TKKeyEvent)
- (void) deleteWorkingText;
@end

@interface TKContentView(TKWindowEvent)
- (void) drawRect: (NSRect) rect;
- (void) generateExposeEvents: (HIShapeRef) shape; 


- (void) tkToolbarButton: (id) sender;
- (BOOL) isOpaque;
- (BOOL) wantsDefaultClipping;
- (BOOL) acceptsFirstResponder;
- (void) keyDown: (NSEvent *) theEvent;
@end

Changes to macosx/tkMacOSXWindowEvent.c.

354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
...
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
	return 0;
    }
    if (!HIShapeIntersectsRect(updateRgn, &bounds)) {
	return 0;
    }

    /*
     * Compute the bounding box of the area that the damage occurred in.
     */

    boundsRgn = HIShapeCreateWithRect(&bounds);
    damageRgn = HIShapeCreateIntersection(updateRgn, boundsRgn);
    if (HIShapeIsEmpty(damageRgn)) {
	CFRelease(damageRgn);
	CFRelease(boundsRgn);
................................................................................
	 *
	 * 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)) {}
    }
}


/*
 * These two methods allow Tk to register a virtual event which fires when the
 * appearance changes on 10.14.
 */

- (void) viewDidChangeEffectiveAppearance
{
    [self updateAppearanceEvent];
}

- (void) updateAppearanceEvent
{
    NSString *osxMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"];
    NSWindow *w = [self window];
    TkWindow *winPtr = TkMacOSXGetTkWindow(w);
    XVirtualEvent event;
    int x, y;
    Tk_Window tkwin = (Tk_Window) winPtr;
    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







|







 







|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
...
987
988
989
990
991
992
993
994












































995
996
997
998
999
1000
1001
	return 0;
    }
    if (!HIShapeIntersectsRect(updateRgn, &bounds)) {
	return 0;
    }

    /*
     * Compute the bounding box of the area that the damage occured in.
     */

    boundsRgn = HIShapeCreateWithRect(&bounds);
    damageRgn = HIShapeCreateIntersection(updateRgn, boundsRgn);
    if (HIShapeIsEmpty(damageRgn)) {
	CFRelease(damageRgn);
	CFRelease(boundsRgn);
................................................................................
	 *
	 * 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