Tk Source Code

Check-in [5442d6af]
Login

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

Overview
Comment:Use geometry masters, not parents, to find the nesting depth.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-0d63621b6c
Files: files | file ages | folders
SHA3-256: 5442d6af3443aa0ffc4016cee9a4f76061098eac84ac9937f999d7788bfbfbc7
User & Date: culler 2019-04-01 15:03:24
Context
2019-04-01
17:18
Oops. Following those underscore conventions is tricky. check-in: 1d7c6c85 user: culler tags: bug-0d63621b6c
15:03
Use geometry masters, not parents, to find the nesting depth. check-in: 5442d6af user: culler tags: bug-0d63621b6c
2019-03-30
19:40
Remove extraneous CGContextSaveGState with no matching CGContextRestoreGState. check-in: bae24649 user: culler tags: bug-0d63621b6c
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tk.h.

757
758
759
760
761
762
763

764
765
766
767
768
769
770
    (((Tk_FakeWin *) (tkwin))->internalBorderTop)
#define Tk_InternalBorderBottom(tkwin) \
    (((Tk_FakeWin *) (tkwin))->internalBorderBottom)
#define Tk_MinReqWidth(tkwin)	(((Tk_FakeWin *) (tkwin))->minReqWidth)
#define Tk_MinReqHeight(tkwin)	(((Tk_FakeWin *) (tkwin))->minReqHeight)
#define Tk_Parent(tkwin)	(((Tk_FakeWin *) (tkwin))->parentPtr)
#define Tk_Colormap(tkwin)	(((Tk_FakeWin *) (tkwin))->atts.colormap)


/*
 * The structure below is needed by the macros above so that they can access
 * the fields of a Tk_Window. The fields not needed by the macros are declared
 * as "dummyX". The structure has its own type in order to prevent apps from
 * accessing Tk_Window fields except using official macros. WARNING!! The
 * structure definition must be kept consistent with the TkWindow structure in







>







757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
    (((Tk_FakeWin *) (tkwin))->internalBorderTop)
#define Tk_InternalBorderBottom(tkwin) \
    (((Tk_FakeWin *) (tkwin))->internalBorderBottom)
#define Tk_MinReqWidth(tkwin)	(((Tk_FakeWin *) (tkwin))->minReqWidth)
#define Tk_MinReqHeight(tkwin)	(((Tk_FakeWin *) (tkwin))->minReqHeight)
#define Tk_Parent(tkwin)	(((Tk_FakeWin *) (tkwin))->parentPtr)
#define Tk_Colormap(tkwin)	(((Tk_FakeWin *) (tkwin))->atts.colormap)
#define Tk_GeomMaster(tkwin)	(((Tk_FakeWin *) (tkwin))->geomMasterPtr)

/*
 * The structure below is needed by the macros above so that they can access
 * the fields of a Tk_Window. The fields not needed by the macros are declared
 * as "dummyX". The structure has its own type in order to prevent apps from
 * accessing Tk_Window fields except using official macros. WARNING!! The
 * structure definition must be kept consistent with the TkWindow structure in
798
799
800
801
802
803
804

805
806
807
808
809
810
811
#endif /* TK_USE_INPUT_METHODS */
    ClientData *dummy10;	/* tagPtr */
    int dummy11;		/* numTags */
    int dummy12;		/* optionLevel */
    char *dummy13;		/* selHandlerList */
    char *dummy14;		/* geomMgrPtr */
    ClientData dummy15;		/* geomData */

    int reqWidth, reqHeight;
    int internalBorderLeft;
    char *dummy16;		/* wmInfoPtr */
    char *dummy17;		/* classProcPtr */
    ClientData dummy18;		/* instanceData */
    char *dummy19;		/* privatePtr */
    int internalBorderRight;







>







799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
#endif /* TK_USE_INPUT_METHODS */
    ClientData *dummy10;	/* tagPtr */
    int dummy11;		/* numTags */
    int dummy12;		/* optionLevel */
    char *dummy13;		/* selHandlerList */
    char *dummy14;		/* geomMgrPtr */
    ClientData dummy15;		/* geomData */
    Tk_Window geomMasterPtr;
    int reqWidth, reqHeight;
    int internalBorderLeft;
    char *dummy16;		/* wmInfoPtr */
    char *dummy17;		/* classProcPtr */
    ClientData dummy18;		/* instanceData */
    char *dummy19;		/* privatePtr */
    int internalBorderRight;

Changes to generic/tkGeometry.c.

421
422
423
424
425
426
427


428
429
430
431
432
433
434
    Tcl_HashEntry *hPtr;
    MaintainMaster *masterPtr;
    register MaintainSlave *slavePtr;
    int isNew, map;
    Tk_Window ancestor, parent;
    TkDisplay *dispPtr = ((TkWindow *) master)->dispPtr;



    if (master == Tk_Parent(slave)) {
	/*
	 * If the slave is a direct descendant of the master, don't bother
	 * setting up the extra infrastructure for management, just make a
	 * call to Tk_MoveResizeWindow; the parent/child relationship will
	 * take care of the rest.
	 */







>
>







421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
    Tcl_HashEntry *hPtr;
    MaintainMaster *masterPtr;
    register MaintainSlave *slavePtr;
    int isNew, map;
    Tk_Window ancestor, parent;
    TkDisplay *dispPtr = ((TkWindow *) master)->dispPtr;

    Tk_GeomMaster(slave) = master;
    
    if (master == Tk_Parent(slave)) {
	/*
	 * If the slave is a direct descendant of the master, don't bother
	 * setting up the extra infrastructure for management, just make a
	 * call to Tk_MoveResizeWindow; the parent/child relationship will
	 * take care of the rest.
	 */
565
566
567
568
569
570
571


572
573
574
575
576
577
578
				 * slave's parent. */
{
    Tcl_HashEntry *hPtr;
    MaintainMaster *masterPtr;
    register MaintainSlave *slavePtr, *prevPtr;
    Tk_Window ancestor;
    TkDisplay *dispPtr = ((TkWindow *) slave)->dispPtr;



    if (master == Tk_Parent(slave)) {
	/*
	 * If the slave is a direct descendant of the master,
	 * Tk_MaintainGeometry will not have set up any of the extra
	 * infrastructure. Don't even bother to look for it, just return.
	 */







>
>







567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
				 * slave's parent. */
{
    Tcl_HashEntry *hPtr;
    MaintainMaster *masterPtr;
    register MaintainSlave *slavePtr, *prevPtr;
    Tk_Window ancestor;
    TkDisplay *dispPtr = ((TkWindow *) slave)->dispPtr;

    Tk_GeomMaster(slave) = NULL;

    if (master == Tk_Parent(slave)) {
	/*
	 * If the slave is a direct descendant of the master,
	 * Tk_MaintainGeometry will not have set up any of the extra
	 * infrastructure. Don't even bother to look for it, just return.
	 */

Changes to generic/tkInt.h.

765
766
767
768
769
770
771

772
773
774
775
776
777
778
     * Information used by tkGeometry.c for geometry management.
     */

    const Tk_GeomMgr *geomMgrPtr;
				/* Information about geometry manager for this
				 * window. */
    ClientData geomData;	/* Argument for geometry manager functions. */

    int reqWidth, reqHeight;	/* Arguments from last call to
				 * Tk_GeometryRequest, or 0's if
				 * Tk_GeometryRequest hasn't been called. */
    int internalBorderLeft;	/* Width of internal border of window (0 means
				 * no internal border). Geometry managers
				 * should not normally place children on top
				 * of the border. Fields for the other three







>







765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
     * Information used by tkGeometry.c for geometry management.
     */

    const Tk_GeomMgr *geomMgrPtr;
				/* Information about geometry manager for this
				 * window. */
    ClientData geomData;	/* Argument for geometry manager functions. */
    Tk_Window *geomMasterPtr;   /* Tk_MaintainGeometry maintains this field. */
    int reqWidth, reqHeight;	/* Arguments from last call to
				 * Tk_GeometryRequest, or 0's if
				 * Tk_GeometryRequest hasn't been called. */
    int internalBorderLeft;	/* Width of internal border of window (0 means
				 * no internal border). Geometry managers
				 * should not normally place children on top
				 * of the border. Fields for the other three

Changes to generic/tkWindow.c.

660
661
662
663
664
665
666

667
668
669
670
671
672
673
#endif /* TK_USE_INPUT_METHODS */
    winPtr->tagPtr = NULL;
    winPtr->numTags = 0;
    winPtr->optionLevel = -1;
    winPtr->selHandlerList = NULL;
    winPtr->geomMgrPtr = NULL;
    winPtr->geomData = NULL;

    winPtr->reqWidth = winPtr->reqHeight = 1;
    winPtr->internalBorderLeft = 0;
    winPtr->wmInfoPtr = NULL;
    winPtr->classProcsPtr = NULL;
    winPtr->instanceData = NULL;
    winPtr->privatePtr = NULL;
    winPtr->internalBorderRight = 0;







>







660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
#endif /* TK_USE_INPUT_METHODS */
    winPtr->tagPtr = NULL;
    winPtr->numTags = 0;
    winPtr->optionLevel = -1;
    winPtr->selHandlerList = NULL;
    winPtr->geomMgrPtr = NULL;
    winPtr->geomData = NULL;
    winPtr->geomMasterPtr = NULL;
    winPtr->reqWidth = winPtr->reqHeight = 1;
    winPtr->internalBorderLeft = 0;
    winPtr->wmInfoPtr = NULL;
    winPtr->classProcsPtr = NULL;
    winPtr->instanceData = NULL;
    winPtr->privatePtr = NULL;
    winPtr->internalBorderRight = 0;

Changes to library/ttk/aquaTheme.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#
# Aqua theme (OSX native look and feel)
#

namespace eval ttk::theme::aqua {
    ttk::style theme settings aqua {

	ttk::style configure . \
	    -font TkDefaultFont \
	    -background systemWindowBody \
	    -foreground systemLabelColor \
	    -selectbackground systemHighlight \
	    -selectforeground systemLabelColor \
	    -selectborderwidth 0 \
	    -insertwidth 1

	ttk::style map . \









|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#
# Aqua theme (OSX native look and feel)
#

namespace eval ttk::theme::aqua {
    ttk::style theme settings aqua {

	ttk::style configure . \
	    -font TkDefaultFont \
	    -background systemTtkBackground \
	    -foreground systemLabelColor \
	    -selectbackground systemHighlight \
	    -selectforeground systemLabelColor \
	    -selectborderwidth 0 \
	    -insertwidth 1

	ttk::style map . \

Changes to macosx/ttkMacOSXTheme.c.

152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186

static int GetBoxColor(
    CGContextRef context,
    Tk_Window tkwin,
    int depth,
    CGFloat *fill)
{
    TkWindow *winPtr = (TkWindow *)tkwin;
    NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
    if ([NSApp macMinorVersion] > 13) {
        NSColor *windowColor = [[NSColor windowBackgroundColor]
				   colorUsingColorSpace: deviceRGB];
        [windowColor getComponents: fill];
    } else {
	for (int i = 0; i < 4; i++) {
	    fill[i] = windowBackground[i];
	}
    }
    int isDark  = (fill[0] + fill[1] + fill[2] < 1.5);

    /*
     * Compute the nesting depth of the widget.
     */

    for (TkWindow *topPtr = winPtr->parentPtr; topPtr != NULL;
	 topPtr = topPtr->parentPtr) {
	if (topPtr->privatePtr &&
	    (topPtr->privatePtr->flags & TTK_HAS_DARKER_BG)) {
	    depth++;
	}
	if (depth > 7) {
	    break;
	}
    }








<
















|
|
|
|







152
153
154
155
156
157
158

159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185

static int GetBoxColor(
    CGContextRef context,
    Tk_Window tkwin,
    int depth,
    CGFloat *fill)
{

    NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace];
    if ([NSApp macMinorVersion] > 13) {
        NSColor *windowColor = [[NSColor windowBackgroundColor]
				   colorUsingColorSpace: deviceRGB];
        [windowColor getComponents: fill];
    } else {
	for (int i = 0; i < 4; i++) {
	    fill[i] = windowBackground[i];
	}
    }
    int isDark  = (fill[0] + fill[1] + fill[2] < 1.5);

    /*
     * Compute the nesting depth of the widget.
     */

    for (TkWindow *masterPtr = (TkWindow *)Tk_GeomMaster(tkwin); masterPtr != NULL;
	 masterPtr = (TkWindow *)Tk_GeomMaster(masterPtr)) {
	if (masterPtr->privatePtr &&
	    (masterPtr->privatePtr->flags & TTK_HAS_DARKER_BG)) {
	    depth++;
	}
	if (depth > 7) {
	    break;
	}
    }