Check-in [0b3392c913]
Not logged in

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

Overview
Comment:add tk upstream changes
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0b3392c9134c228fdff10be56043c9c15879a2ff
User & Date: chw 2017-04-10 19:01:48
Context
2017-04-12
08:33
update tclws to version 2.4.0 check-in: 76ff69e683 user: chw tags: trunk
2017-04-10
19:01
add tk upstream changes check-in: 0b3392c913 user: chw tags: trunk
2017-04-09
21:03
make librun.so into a PIE binary check-in: 98d106ce40 user: chw tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to jni/sdl2tk/doc/ttk_notebook.n.

167
168
169
170
171
172
173
174

175
176
177
178
179
180
181
returns a dictionary of the tab option values.
If one \fI\-option\fR is specified,
returns the value of that \fIoption\fR.
Otherwise, sets the \fI\-option\fRs to the corresponding \fIvalue\fRs.
See \fBTAB OPTIONS\fR for the available options.
.TP
\fIpathname \fBtabs\fR
Returns the list of windows managed by the notebook.

.SH "KEYBOARD TRAVERSAL"
To enable keyboard traversal for a toplevel window
containing a notebook widget \fI$nb\fR, call:
.CS
ttk::notebook::enableTraversal $nb
.CE
.PP







|
>







167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
returns a dictionary of the tab option values.
If one \fI\-option\fR is specified,
returns the value of that \fIoption\fR.
Otherwise, sets the \fI\-option\fRs to the corresponding \fIvalue\fRs.
See \fBTAB OPTIONS\fR for the available options.
.TP
\fIpathname \fBtabs\fR
Returns the list of windows managed by the notebook, in the index order of
their associated tabs.
.SH "KEYBOARD TRAVERSAL"
To enable keyboard traversal for a toplevel window
containing a notebook widget \fI$nb\fR, call:
.CS
ttk::notebook::enableTraversal $nb
.CE
.PP

Changes to jni/sdl2tk/doc/ttk_panedwindow.n.

87
88
89
90
91
92
93
94

95
96
97
98
99
100
101
where \fIpane\fR is either an integer index or the name of a managed subwindow.
If no \fI\-option\fR is specified, returns a dictionary of the pane
option values.
If one \fI\-option\fR is specified, returns the value of that \fIoption\fR.
Otherwise, sets the \fI\-option\fRs to the corresponding \fIvalue\fRs.
.TP
\fIpathname \fBpanes\fR
Returns the list of all windows managed by the widget.

.TP
\fIpathname \fBsashpos \fIindex\fR ?\fInewpos\fR?
If \fInewpos\fR is specified, sets the position
of sash number \fIindex\fR.
May adjust the positions of adjacent sashes
to ensure that positions are monotonically increasing.
Sash positions are further constrained to be between 0







|
>







87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
where \fIpane\fR is either an integer index or the name of a managed subwindow.
If no \fI\-option\fR is specified, returns a dictionary of the pane
option values.
If one \fI\-option\fR is specified, returns the value of that \fIoption\fR.
Otherwise, sets the \fI\-option\fRs to the corresponding \fIvalue\fRs.
.TP
\fIpathname \fBpanes\fR
Returns the list of all windows managed by the widget, in the index order of
their associated panes.
.TP
\fIpathname \fBsashpos \fIindex\fR ?\fInewpos\fR?
If \fInewpos\fR is specified, sets the position
of sash number \fIindex\fR.
May adjust the positions of adjacent sashes
to ensure that positions are monotonically increasing.
Sash positions are further constrained to be between 0

Changes to jni/sdl2tk/generic/tkBind.c.

3474
3475
3476
3477
3478
3479
3480


3481
3482
3483
3484
3485








3486
3487

3488
3489
3490
3491
3492
3493
3494

    /*
     * We only allow warping if the window is mapped.
     */

    if ((warp != 0) && Tk_IsMapped(tkwin)) {
	TkDisplay *dispPtr = TkGetDisplay(event.general.xmotion.display);



	if (!(dispPtr->flags & TK_DISPLAY_IN_WARP)) {
	    Tcl_DoWhenIdle(DoWarp, dispPtr);
	    dispPtr->flags |= TK_DISPLAY_IN_WARP;
	}








	dispPtr->warpWindow = Tk_IdToWindow(dispPtr->display,
		event.general.xmotion.window);

	dispPtr->warpMainwin = mainWin;
	dispPtr->warpX = event.general.xmotion.x;
	dispPtr->warpY = event.general.xmotion.y;
    }

  done:
    Tcl_ResetResult(interp);







>
>





>
>
>
>
>
>
>
>
|
<
>







3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496

3497
3498
3499
3500
3501
3502
3503
3504

    /*
     * We only allow warping if the window is mapped.
     */

    if ((warp != 0) && Tk_IsMapped(tkwin)) {
	TkDisplay *dispPtr = TkGetDisplay(event.general.xmotion.display);
	Tk_Window warpWindow = Tk_IdToWindow(dispPtr->display,
		event.general.xmotion.window);

	if (!(dispPtr->flags & TK_DISPLAY_IN_WARP)) {
	    Tcl_DoWhenIdle(DoWarp, dispPtr);
	    dispPtr->flags |= TK_DISPLAY_IN_WARP;
	}

	if (warpWindow != dispPtr->warpWindow) {
	    if (warpWindow) {
		Tcl_Preserve(warpWindow);
	    }
	    if (dispPtr->warpWindow) {
		Tcl_Release(dispPtr->warpWindow);
	    }
	    dispPtr->warpWindow = warpWindow;

	}
	dispPtr->warpMainwin = mainWin;
	dispPtr->warpX = event.general.xmotion.x;
	dispPtr->warpY = event.general.xmotion.y;
    }

  done:
    Tcl_ResetResult(interp);
3568
3569
3570
3571
3572
3573
3574





3575
3576
3577
3578
3579
3580
3581

    if ((dispPtr->warpWindow == NULL) ||
            (Tk_IsMapped(dispPtr->warpWindow)
            && (Tk_WindowId(dispPtr->warpWindow) != None))) {
        TkpWarpPointer(dispPtr);
        XForceScreenSaver(dispPtr->display, ScreenSaverReset);
    }





    dispPtr->flags &= ~TK_DISPLAY_IN_WARP;
}

/*
 *-------------------------------------------------------------------------
 *
 * GetVirtualEventUid --







>
>
>
>
>







3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596

    if ((dispPtr->warpWindow == NULL) ||
            (Tk_IsMapped(dispPtr->warpWindow)
            && (Tk_WindowId(dispPtr->warpWindow) != None))) {
        TkpWarpPointer(dispPtr);
        XForceScreenSaver(dispPtr->display, ScreenSaverReset);
    }

    if (dispPtr->warpWindow) {
	Tcl_Release(dispPtr->warpWindow);
	dispPtr->warpWindow = None;
    }
    dispPtr->flags &= ~TK_DISPLAY_IN_WARP;
}

/*
 *-------------------------------------------------------------------------
 *
 * GetVirtualEventUid --
4327
4328
4329
4330
4331
4332
4333



























4334
4335
4336
4337
4338
4339
4340
4341
    Tcl_Interp *interp)		/* Interpreter. */
{
   TkWindow *winPtr = (TkWindow *) Tk_MainWindow(interp);
   BindingTable *bindPtr = winPtr->mainPtr->bindingTable;

   return &(bindPtr->eventRing[bindPtr->curEvent]);
}




























/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>








4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
    Tcl_Interp *interp)		/* Interpreter. */
{
   TkWindow *winPtr = (TkWindow *) Tk_MainWindow(interp);
   BindingTable *bindPtr = winPtr->mainPtr->bindingTable;

   return &(bindPtr->eventRing[bindPtr->curEvent]);
}

/*
 *----------------------------------------------------------------------
 *
 * TkpCancelWarp --
 *
 *	This function cancels an outstanding pointer warp and
 *	is called during tear down of the display.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

void
TkpCancelWarp(
    TkDisplay *dispPtr)
{
    if (dispPtr->flags & TK_DISPLAY_IN_WARP) {
	Tcl_CancelIdleCall(DoWarp, dispPtr);
	dispPtr->flags &= ~TK_DISPLAY_IN_WARP;
    }
}

/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */

Changes to jni/sdl2tk/generic/tkInt.h.

1229
1230
1231
1232
1233
1234
1235

1236
1237
1238
1239
1240
1241
1242
			    const char *nsname, const char *name,
			    ClientData clientData, const TkEnsemble *map);
MODULE_SCOPE int	TkInitTkCmd(Tcl_Interp *interp,
			    ClientData clientData);
MODULE_SCOPE int	TkInitFontchooser(Tcl_Interp *interp,
			    ClientData clientData);
MODULE_SCOPE void	TkpWarpPointer(TkDisplay *dispPtr);

MODULE_SCOPE int	TkListCreateFrame(ClientData clientData,
			    Tcl_Interp *interp, Tcl_Obj *listObj,
			    int toplevel, Tcl_Obj *nameObj);
#ifdef PLATFORM_SDL
MODULE_SCOPE int	TkInitSdltkCmd(Tcl_Interp *interp,
			    ClientData clientData);
#endif







>







1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
			    const char *nsname, const char *name,
			    ClientData clientData, const TkEnsemble *map);
MODULE_SCOPE int	TkInitTkCmd(Tcl_Interp *interp,
			    ClientData clientData);
MODULE_SCOPE int	TkInitFontchooser(Tcl_Interp *interp,
			    ClientData clientData);
MODULE_SCOPE void	TkpWarpPointer(TkDisplay *dispPtr);
MODULE_SCOPE void	TkpCancelWarp(TkDisplay *dispPtr);
MODULE_SCOPE int	TkListCreateFrame(ClientData clientData,
			    Tcl_Interp *interp, Tcl_Obj *listObj,
			    int toplevel, Tcl_Obj *nameObj);
#ifdef PLATFORM_SDL
MODULE_SCOPE int	TkInitSdltkCmd(Tcl_Interp *interp,
			    ClientData clientData);
#endif

Changes to jni/sdl2tk/generic/tkWindow.c.

315
316
317
318
319
320
321


322
323
324
325
326
327
328
 */

static void
TkCloseDisplay(
    TkDisplay *dispPtr)
{
    TkClipCleanup(dispPtr);



    if (dispPtr->name != NULL) {
	ckfree(dispPtr->name);
    }

    if (dispPtr->atomInit) {
	Tcl_DeleteHashTable(&dispPtr->nameTable);







>
>







315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
 */

static void
TkCloseDisplay(
    TkDisplay *dispPtr)
{
    TkClipCleanup(dispPtr);

    TkpCancelWarp(dispPtr);

    if (dispPtr->name != NULL) {
	ckfree(dispPtr->name);
    }

    if (dispPtr->atomInit) {
	Tcl_DeleteHashTable(&dispPtr->nameTable);

Changes to jni/sdl2tk/generic/ttk/ttkNotebook.c.

1
2
3
4
5
6

7
8
9
10
11
12
13
/*
 * Copyright (c) 2004, Joe English
 */

#include <string.h>
#include <ctype.h>

#include <stdio.h>
#include <tk.h>

#include "ttkTheme.h"
#include "ttkWidget.h"
#include "ttkManager.h"







>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
 * Copyright (c) 2004, Joe English
 */

#include <string.h>
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <tk.h>

#include "ttkTheme.h"
#include "ttkWidget.h"
#include "ttkManager.h"

288
289
290
291
292
293
294
295
296
297
298
299
300
301

302
303
304
305
306
307
308
309
310
311





312
313
314


315





316


317
318
319
320
321
322
323
324
325
326
327
328
329
330
331


332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352

353
354
355
356
357
358
359
    }
}

/*
 * TabState --
 * 	Return the state of the specified tab, based on
 * 	notebook state, currentIndex, activeIndex, and user-specified tab state.
 *	The USER1 bit is set for the leftmost tab, and USER2
 * 	is set for the rightmost tab.
 */
static Ttk_State TabState(Notebook *nb, int index)
{
    Ttk_State state = nb->core.state;
    Tab *tab = Ttk_SlaveData(nb->notebook.mgr, index);


    if (index == nb->notebook.currentIndex) {
	state |= TTK_STATE_SELECTED;
    } else {
	state &= ~TTK_STATE_FOCUS;
    }

    if (index == nb->notebook.activeIndex) {
	state |= TTK_STATE_ACTIVE;
    }





    if (index == 0) {
    	state |= TTK_STATE_USER1;
    }


    if (index == Ttk_NumberSlaves(nb->notebook.mgr) - 1) {





    	state |= TTK_STATE_USER2;


    }
    if (tab->state == TAB_STATE_DISABLED) {
	state |= TTK_STATE_DISABLED;
    }

    return state;
}

/*------------------------------------------------------------------------
 * +++ Geometry management - size computation.
 */

/* TabrowSize --
 *	Compute max height and total width of all tabs (horizontal layouts)
 *	or total height and max width (vertical layouts).


 *
 * Side effects:
 * 	Sets width and height fields for all tabs.
 *
 * Notes:
 * 	Hidden tabs are included in the perpendicular computation
 * 	(max height/width) but not parallel (total width/height).
 */
static void TabrowSize(
    Notebook *nb, Ttk_Orient orient, int *widthPtr, int *heightPtr)
{
    Ttk_Layout tabLayout = nb->notebook.tabLayout;
    int tabrowWidth = 0, tabrowHeight = 0;
    int i;

    for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) {
	Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
	Ttk_State tabState = TabState(nb,i);

	Ttk_RebindSublayout(tabLayout, tab);
	Ttk_LayoutSize(tabLayout,tabState,&tab->width,&tab->height);


	if (orient == TTK_ORIENT_HORIZONTAL) {
	    tabrowHeight = MAX(tabrowHeight, tab->height);
	    if (tab->state != TAB_STATE_HIDDEN) { tabrowWidth += tab->width; }
	} else {
	    tabrowWidth = MAX(tabrowWidth, tab->width);
	    if (tab->state != TAB_STATE_HIDDEN) { tabrowHeight += tab->height; }







|
|





>










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















>
>









|











>







289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
    }
}

/*
 * TabState --
 * 	Return the state of the specified tab, based on
 * 	notebook state, currentIndex, activeIndex, and user-specified tab state.
 *	The USER1 bit is set for the leftmost visible tab, and USER2
 * 	is set for the rightmost visible tab.
 */
static Ttk_State TabState(Notebook *nb, int index)
{
    Ttk_State state = nb->core.state;
    Tab *tab = Ttk_SlaveData(nb->notebook.mgr, index);
    int i = 0;

    if (index == nb->notebook.currentIndex) {
	state |= TTK_STATE_SELECTED;
    } else {
	state &= ~TTK_STATE_FOCUS;
    }

    if (index == nb->notebook.activeIndex) {
	state |= TTK_STATE_ACTIVE;
    }
    for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) {
	Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
	if (tab->state == TAB_STATE_HIDDEN) {
	    continue;
	}
	if (index == i) {
	    state |= TTK_STATE_USER1;
	}
	break;
    }
    for (i = Ttk_NumberSlaves(nb->notebook.mgr) - 1; i >= 0; --i) {
	Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
	if (tab->state == TAB_STATE_HIDDEN) {
	    continue;
	}
	if (index == i) {
	    state |= TTK_STATE_USER2;
	}
	break;
    }
    if (tab->state == TAB_STATE_DISABLED) {
	state |= TTK_STATE_DISABLED;
    }

    return state;
}

/*------------------------------------------------------------------------
 * +++ Geometry management - size computation.
 */

/* TabrowSize --
 *	Compute max height and total width of all tabs (horizontal layouts)
 *	or total height and max width (vertical layouts).
 *	The -mintabwidth style option is taken into account (for the width
 *	only).
 *
 * Side effects:
 * 	Sets width and height fields for all tabs.
 *
 * Notes:
 * 	Hidden tabs are included in the perpendicular computation
 * 	(max height/width) but not parallel (total width/height).
 */
static void TabrowSize(
    Notebook *nb, Ttk_Orient orient, int minTabWidth, int *widthPtr, int *heightPtr)
{
    Ttk_Layout tabLayout = nb->notebook.tabLayout;
    int tabrowWidth = 0, tabrowHeight = 0;
    int i;

    for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) {
	Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i);
	Ttk_State tabState = TabState(nb,i);

	Ttk_RebindSublayout(tabLayout, tab);
	Ttk_LayoutSize(tabLayout,tabState,&tab->width,&tab->height);
        tab->width = MAX(tab->width, minTabWidth);

	if (orient == TTK_ORIENT_HORIZONTAL) {
	    tabrowHeight = MAX(tabrowHeight, tab->height);
	    if (tab->state != TAB_STATE_HIDDEN) { tabrowWidth += tab->width; }
	} else {
	    tabrowWidth = MAX(tabrowWidth, tab->width);
	    if (tab->state != TAB_STATE_HIDDEN) { tabrowHeight += tab->height; }
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
    if (reqWidth > 0)
	clientWidth = reqWidth;
    if (reqHeight > 0)
	clientHeight = reqHeight;

    /* Tab row:
     */
    TabrowSize(nb, nbstyle.tabOrient, &tabrowWidth, &tabrowHeight);
    tabrowHeight += Ttk_PaddingHeight(nbstyle.tabMargins);
    tabrowWidth += Ttk_PaddingWidth(nbstyle.tabMargins);

    /* Account for exterior and interior padding:
     */
    padding = nbstyle.padding;
    if (clientNode) {







|







425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
    if (reqWidth > 0)
	clientWidth = reqWidth;
    if (reqHeight > 0)
	clientHeight = reqHeight;

    /* Tab row:
     */
    TabrowSize(nb, nbstyle.tabOrient, nbstyle.minTabWidth, &tabrowWidth, &tabrowHeight);
    tabrowHeight += Ttk_PaddingHeight(nbstyle.tabMargins);
    tabrowWidth += Ttk_PaddingWidth(nbstyle.tabMargins);

    /* Account for exterior and interior padding:
     */
    padding = nbstyle.padding;
    if (clientNode) {
436
437
438
439
440
441
442

443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468

469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490

/*------------------------------------------------------------------------
 * +++ Geometry management - layout.
 */

/* SqueezeTabs --
 *	Squeeze or stretch tabs to fit within the tab area parcel.

 *
 *	All tabs are adjusted by an equal amount, but will not be made
 *	smaller than the minimum width.  (If all the tabs still do
 *	not fit in the available space, the rightmost ones will
 *	be further squozen by PlaceTabs()).
 *
 *	The algorithm does not always yield an optimal layout, but does
 *	have the important property that decreasing the available width
 *	by one pixel will cause at most one tab to shrink by one pixel;
 *	this means that tabs resize "smoothly" when the window shrinks
 *	and grows.
 *
 * @@@ <<NOTE-TABPOSITION>> bug: only works for horizontal orientations
 * @@@ <<NOTE-SQUEEZE-HIDDEN>> does not account for hidden tabs.
 */

static void SqueezeTabs(
    Notebook *nb, int needed, int available, int minTabWidth)
{
    int nTabs = Ttk_NumberSlaves(nb->notebook.mgr);

    if (nTabs > 0) {
	int difference = available - needed,
	    delta = difference / nTabs,
	    remainder = difference % nTabs,
	    slack = 0;

	int i;

	if (remainder < 0) { remainder += nTabs; --delta; }

	for (i = 0; i < nTabs; ++i) {
	    Tab *tab = Ttk_SlaveData(nb->notebook.mgr,i);
	    int adj = delta + (i < remainder) + slack;

	    if (tab->width + adj >= minTabWidth) {
		tab->width += adj;
		slack = 0;
	    } else {
		slack = adj - (minTabWidth - tab->width);
		tab->width = minTabWidth;
	    }
	}
    }
}

/* PlaceTabs --
 * 	Compute all tab parcels.
 */







>

|
<
<
<
<
<
<
<
<
<






|




|
|
<
|
>


<
<


<

|
|
|
<
<
<
<







455
456
457
458
459
460
461
462
463
464









465
466
467
468
469
470
471
472
473
474
475
476
477

478
479
480
481


482
483

484
485
486
487




488
489
490
491
492
493
494

/*------------------------------------------------------------------------
 * +++ Geometry management - layout.
 */

/* SqueezeTabs --
 *	Squeeze or stretch tabs to fit within the tab area parcel.
 *	This happens independently of the -mintabwidth style option.
 *
 *	All tabs are adjusted by an equal amount.









 *
 * @@@ <<NOTE-TABPOSITION>> bug: only works for horizontal orientations
 * @@@ <<NOTE-SQUEEZE-HIDDEN>> does not account for hidden tabs.
 */

static void SqueezeTabs(
    Notebook *nb, int needed, int available)
{
    int nTabs = Ttk_NumberSlaves(nb->notebook.mgr);

    if (nTabs > 0) {
	int difference = available - needed;
	double fraction = (double)difference / needed;

	double slack = 0;
	double ad;
	int i;



	for (i = 0; i < nTabs; ++i) {
	    Tab *tab = Ttk_SlaveData(nb->notebook.mgr,i);


	    ad = slack + tab->width * fraction;
	    tab->width += (int)ad;
	    slack = ad - floor(ad);




	}
    }
}

/* PlaceTabs --
 * 	Compute all tab parcels.
 */
539
540
541
542
543
544
545





546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
    cavity = Ttk_PadBox(cavity, nbstyle.padding);

    /* Layout for notebook background (base layout):
     */
    Ttk_PlaceLayout(nb->core.layout, nb->core.state, Ttk_WinBox(nbwin));

    /* Place tabs:





     */
    TabrowSize(nb, nbstyle.tabOrient, &tabrowWidth, &tabrowHeight);
    tabrowBox = Ttk_PadBox(
		    Ttk_PositionBox(&cavity,
			tabrowWidth + Ttk_PaddingWidth(nbstyle.tabMargins),
			tabrowHeight + Ttk_PaddingHeight(nbstyle.tabMargins),
			nbstyle.tabPosition),
		    nbstyle.tabMargins);

    SqueezeTabs(nb, tabrowWidth, tabrowBox.width, nbstyle.minTabWidth);
    PlaceTabs(nb, tabrowBox, nbstyle.tabPlacement);

    /* Layout for client area frame:
     */
    if (clientNode) {
	Ttk_PlaceElement(nb->core.layout, clientNode, cavity);
	cavity = Ttk_LayoutNodeInternalParcel(nb->core.layout, clientNode);







>
>
>
>
>

|







|







543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
    cavity = Ttk_PadBox(cavity, nbstyle.padding);

    /* Layout for notebook background (base layout):
     */
    Ttk_PlaceLayout(nb->core.layout, nb->core.state, Ttk_WinBox(nbwin));

    /* Place tabs:
     * Note: TabrowSize() takes into account -mintabwidth, but the tabs will
     * actually have this minimum size when displayed only if there is enough
     * space to draw the tabs with this width. Otherwise some of the tabs can
     * be squeezed to a size smaller than -mintabwidth because we prefer
     * displaying all tabs than than honoring -mintabwidth for all of them.
     */
    TabrowSize(nb, nbstyle.tabOrient, nbstyle.minTabWidth, &tabrowWidth, &tabrowHeight);
    tabrowBox = Ttk_PadBox(
		    Ttk_PositionBox(&cavity,
			tabrowWidth + Ttk_PaddingWidth(nbstyle.tabMargins),
			tabrowHeight + Ttk_PaddingHeight(nbstyle.tabMargins),
			nbstyle.tabPosition),
		    nbstyle.tabMargins);

    SqueezeTabs(nb, tabrowWidth, tabrowBox.width);
    PlaceTabs(nb, tabrowBox, nbstyle.tabPlacement);

    /* Layout for client area frame:
     */
    if (clientNode) {
	Ttk_PlaceElement(nb->core.layout, clientNode, cavity);
	cavity = Ttk_LayoutNodeInternalParcel(nb->core.layout, clientNode);

Changes to jni/sdl2tk/macosx/tkMacOSXWm.h.

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
typedef struct ProtocolHandler {
    Atom protocol;		/* Identifies the protocol. */
    struct ProtocolHandler *nextPtr;
				/* Next in list of protocol handlers for the
				 * same top-level window, or NULL for end of
				 * list. */
    Tcl_Interp *interp;		/* Interpreter in which to invoke command. */
    char command[4];		/* Tcl command to invoke when a client message
				 * for this protocol arrives. The actual size
				 * of the structure varies to accommodate the
				 * needs of the actual command. THIS MUST BE
				 * THE LAST FIELD OF THE STRUCTURE. */
} ProtocolHandler;

#define HANDLER_SIZE(cmdLength) \
((unsigned) (sizeof(ProtocolHandler) - 3 + cmdLength))

/*
 * A data structure of the following type holds window-manager-related
 * information for each top-level window in an application.
 */

typedef struct TkWmInfo {







|







|







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
typedef struct ProtocolHandler {
    Atom protocol;		/* Identifies the protocol. */
    struct ProtocolHandler *nextPtr;
				/* Next in list of protocol handlers for the
				 * same top-level window, or NULL for end of
				 * list. */
    Tcl_Interp *interp;		/* Interpreter in which to invoke command. */
    char command[];		/* Tcl command to invoke when a client message
				 * for this protocol arrives. The actual size
				 * of the structure varies to accommodate the
				 * needs of the actual command. THIS MUST BE
				 * THE LAST FIELD OF THE STRUCTURE. */
} ProtocolHandler;

#define HANDLER_SIZE(cmdLength) \
((unsigned) (sizeof(ProtocolHandler) + cmdLength + 1))

/*
 * A data structure of the following type holds window-manager-related
 * information for each top-level window in an application.
 */

typedef struct TkWmInfo {

Changes to jni/sdl2tk/tests/color.test.

86
87
88
89
90
91
92










93
94
95
96
97
98
99
100

proc colorsFree {w {red 31} {green 245} {blue 192}} {
    set vals [winfo rgb $w [format #%02x%02x%02x $red $green $blue]]
    expr ([lindex $vals 0]/256 == $red) && ([lindex $vals 1]/256 == $green) \
	    && ([lindex $vals 2]/256 == $blue)
}











if {[testConstraint psuedocolor8]} {
    toplevel .t -visual {pseudocolor 8} -colormap new
    wm geom .t +0+0
    mkColors .t.c 40 6 0 0 0 0 6 0 0 0 40
    pack .t.c
    update

    testConstraint colorsFree [colorsFree .t.c 101 233 17]







>
>
>
>
>
>
>
>
>
>
|







86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110

proc colorsFree {w {red 31} {green 245} {blue 192}} {
    set vals [winfo rgb $w [format #%02x%02x%02x $red $green $blue]]
    expr ([lindex $vals 0]/256 == $red) && ([lindex $vals 1]/256 == $green) \
	    && ([lindex $vals 2]/256 == $blue)
}

# -- WARNING (SB, 6.4.2017) --
#
# The if block below looks _very_ outdated. It didn't get any
# substantial changes as far back as the fossil history goes. It might
# be from a time, when 256 color was the best you could get! :-o.
#
# The problem is, on machines with a fancy 24 truecolor display, the
# 'colorsFree' constraint doesn't get set, turning off pretty much every test
# in this file.

if {[testConstraint pseudocolor8]} {
    toplevel .t -visual {pseudocolor 8} -colormap new
    wm geom .t +0+0
    mkColors .t.c 40 6 0 0 0 0 6 0 0 0 40
    pack .t.c
    update

    testConstraint colorsFree [colorsFree .t.c 101 233 17]
181
182
183
184
185
186
187












188
189
190
191
192
193
194
test color-2.6 {Tk_GetColor procedure} {colorsFree nonPortable} {
    # Red doesn't always map to *pure* red
    winfo rgb .t red
} {65535 0 0}
test color-2.7 {Tk_GetColor procedure} colorsFree {
    winfo rgb .t #ff0000
} {65535 0 0}













test color-3.1 {Tk_FreeColor procedure, reference counting} colorsFree {
    eval destroy [winfo child .t]
    mkColors .t.c 40 6 0 240 240 0 -6 0 0 0 -40
    pack .t.c
    mkColors .t.c2 20 1 250 0 0 -10 0 0 0 0 0
    pack .t.c2







>
>
>
>
>
>
>
>
>
>
>
>







191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
test color-2.6 {Tk_GetColor procedure} {colorsFree nonPortable} {
    # Red doesn't always map to *pure* red
    winfo rgb .t red
} {65535 0 0}
test color-2.7 {Tk_GetColor procedure} colorsFree {
    winfo rgb .t #ff0000
} {65535 0 0}
test color-2.8 {Tk_GetColor, invalid char after 3 valid hex digits} -body {
    winfo rgb . #abcg
} -returnCodes error -result {invalid color name "#abcg"}
test color-2.9 {Tk_GetColor, invalid char after 6 vaild hex digits} -body {
    winfo rgb . #aabbccz
} -returnCodes error -result {invalid color name "#aabbccz"}
test color-2.10 {Tk_GetColor, 3 hex digits, last one invalid} -body {
    winfo rgb . #abz
} -returnCodes error -result {invalid color name "#abz"}
test color-2.11 {Tk_GetColor, 6 hex digits, last one invalid} -body {
    winfo rgb . #12345g
} -returnCodes error -result {invalid color name "#12345g"}

test color-3.1 {Tk_FreeColor procedure, reference counting} colorsFree {
    eval destroy [winfo child .t]
    mkColors .t.c 40 6 0 240 240 0 -6 0 0 0 -40
    pack .t.c
    mkColors .t.c2 20 1 250 0 0 -10 0 0 0 0 0
    pack .t.c2

Changes to jni/sdl2tk/xlib/xcolors.c.

386
387
388
389
390
391
392










393
394
395
396
397
398
399
    const elem *p;
    const char *q;

    if (spec[0] == '#') {
	char *p;
	Tcl_WideInt value = parseHex64bit(++spec, &p);











	switch ((int)(p-spec)) {
	case 3:
	    colorPtr->red = US(((value >> 8) & 0xf) * 0x1111);
	    colorPtr->green = US(((value >> 4) & 0xf) * 0x1111);
	    colorPtr->blue = US((value & 0xf) * 0x1111);
	    break;
	case 6:







>
>
>
>
>
>
>
>
>
>







386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
    const elem *p;
    const char *q;

    if (spec[0] == '#') {
	char *p;
	Tcl_WideInt value = parseHex64bit(++spec, &p);

	/*
	 * If *p does not point to the end of the string, there were invalid
	 * digits in the spec. Ergo, it is not a vailid color string.
	 * (Bug f0188aca9e)
	 */
	
	if (*p != '\0') {
	    return 0;
	}
	
	switch ((int)(p-spec)) {
	case 3:
	    colorPtr->red = US(((value >> 8) & 0xf) * 0x1111);
	    colorPtr->green = US(((value >> 4) & 0xf) * 0x1111);
	    colorPtr->blue = US((value & 0xf) * 0x1111);
	    break;
	case 6: