Check-in [e7c3ae3334]
Not logged in

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

Overview
Comment:improve "wm attributes ... -topmost" from [c287e160cb]
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e7c3ae3334db9752c58df5813f93f2cb9ac24a2c
User & Date: chw 2019-05-21 04:49:53
Context
2019-05-21
04:54
add tk upstream changes check-in: 789cb8b5d8 user: chw tags: trunk
04:49
improve "wm attributes ... -topmost" from [c287e160cb] check-in: e7c3ae3334 user: chw tags: trunk
2019-05-19
05:36
add tk upstream changes check-in: 98d0400928 user: chw tags: trunk
Changes

Changes to jni/sdl2tk/sdl/SdlTkInt.c.

3404
3405
3406
3407
3408
3409
3410












































































3411
3412
3413
3414
3415
3416
3417
....
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450

3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
....
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582




3583
3584
3585
3586
3587
3588
3589
    prev->next = _w;
    _w->next = sibling;
}

/*
 *----------------------------------------------------------------------
 *












































































 * SdlTkRestackWindow --
 *
 *	Put a window above or below a sibling. This is the main
 *	window-restacking function.
 *
 * Results:
 *
................................................................................
	return;
    }

    for (child = parent->child; child != _w; child = child->next) {
	oldPos++;
    }

    if (sibling == NULL && stack_mode == Above && !_w->topmost) {
	/* Special handling for non-topmost windows. */
	int lastPos[2] = { -1, -1};

	for (child = parent->child; child != NULL; child = child->next) {
	     lastPos[0]++;
	     if (child->topmost) {
		lastPos[1] = lastPos[0];
	     }
	}
	if (lastPos[1] >= 0) {

	    stack_mode = Below;
	    lastPos[0] = 0;
	    for (sibling = parent->child; sibling != NULL;
		    sibling = sibling->next) {
		if (lastPos[0] >= lastPos[1]) {
		    break;
		}
		lastPos[0]++;
	    }
	}
    }

    SdlTkRemoveFromParent(_w);

    if (sibling == NULL) {
	switch (stack_mode) {
................................................................................
    _Window *sibling, *master;

    _w = SdlTkToplevelForWindow(_w, NULL, NULL);
    if (_w == NULL) {
	return;
    }

    sibling = _w->parent->child;
    while ((sibling != _w) &&
	(SdlTkIsTransientOf(sibling, _w) ||
	 (!_w->topmost &&
	  (sibling->topmost || (sibling->child && sibling->child->topmost)
	 )))) {




	sibling = sibling->next;
    }

    if (sibling != _w) {
	SdlTkRestackWindow(_w, sibling, Above);
	SdlTkRestackTransients(_w);
    }







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







 







|
|
|
<
<
<
|
<
<
<
<
>

<
<
<
<
<
<
<
<







 







|
|
|
|
|
|
>
>
>
>







3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
....
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518



3519




3520
3521








3522
3523
3524
3525
3526
3527
3528
....
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
    prev->next = _w;
    _w->next = sibling;
}

/*
 *----------------------------------------------------------------------
 *
 * SdlTkIsTopmost --
 *
 *	Return true if _Window is topmost or transient of topmost.
 *
 *----------------------------------------------------------------------
 */

static int
SdlTkIsTopmost(_Window *_w)
{
    _Window *master;
    int count;

    if (_w->topmost) {
	return 1;
    }
    count = 0;
    master = SdlTkWrapperForWindow(_w);
    while (master != NULL) {
	master = master->master;
	if (master == NULL) {
	    break;
	}
	if (master->topmost) {
	    count++;
	}
	master = SdlTkWrapperForWindow(master);
    }
    return count;
}

/*
 *----------------------------------------------------------------------
 *
 * SdlTkBottomTopmost --
 *
 *	Return bottom _Window with topmost flag set or NULL.
 *
 *----------------------------------------------------------------------
 */

_Window *
SdlTkBottomTopmost(_Window *parent, _Window *sibling)
{
    _Window *child;
    int count, last, pos;

    last = pos = -1;
    count = 0;
    for (child = parent->child; child != NULL; child = child->next) {
	if (child->topmost) {
	    last = count;
	}
	if (child == sibling) {
	    pos = count;
	}
	count++;
    }
    if (last >= 0) {
	count = 0;
	for (child = parent->child; child != NULL; child = child->next) {
	    if (count >= last) {
		break;
	    }
	    count++;
	}
    }
    if ((last >= 0) && (pos > last)) {
	return sibling;
    }
    return child;
}

/*
 *----------------------------------------------------------------------
 *
 * SdlTkRestackWindow --
 *
 *	Put a window above or below a sibling. This is the main
 *	window-restacking function.
 *
 * Results:
 *
................................................................................
	return;
    }

    for (child = parent->child; child != _w; child = child->next) {
	oldPos++;
    }

    if ((stack_mode == Above) &&
	    !SdlTkIsTopmost(_w) && !_w->atts.override_redirect) {
	child = SdlTkBottomTopmost(parent, sibling);



	if (child != NULL) {




	    sibling = child;
	    stack_mode = Below;








	}
    }

    SdlTkRemoveFromParent(_w);

    if (sibling == NULL) {
	switch (stack_mode) {
................................................................................
    _Window *sibling, *master;

    _w = SdlTkToplevelForWindow(_w, NULL, NULL);
    if (_w == NULL) {
	return;
    }

    if (SdlTkIsTopmost(_w)) {
	sibling = _w->parent->child;
    } else {
	sibling = SdlTkBottomTopmost(_w->parent, NULL);
	if (sibling == NULL) {
	    sibling = _w->parent->child;
	}
    }

    while ((sibling != _w) && SdlTkIsTransientOf(sibling, _w)) {
	sibling = sibling->next;
    }

    if (sibling != _w) {
	SdlTkRestackWindow(_w, sibling, Above);
	SdlTkRestackTransients(_w);
    }

Changes to jni/sdl2tk/sdl/SdlTkInt.h.

301
302
303
304
305
306
307

308
309
310
311
312
313
314
extern _Window *SdlTkWrapperForWindow(_Window *_w);
extern _Window *SdlTkTopVisibleWrapper(void);
extern SDL_Surface *SdlTkGetDrawableSurface(Drawable d, int *x, int *y,
    int *format);
extern _Window *SdlTkPointToWindow(_Window *_w, int x, int y,
    Bool mapped, Bool depth);
extern void SdlTkRemoveFromParent(_Window *_w);

extern void SdlTkRestackWindow(_Window *_w, _Window *sibling, int stack_mode);
extern void SdlTkRestackTransients(_Window *_w);
extern void SdlTkBringToFrontIfNeeded(_Window *_w);
extern int SdlTkIsTransientOf(_Window *_w, _Window *other);
extern void SdlTkCalculateVisibleRegion(_Window *_w);
extern Region SdlTkGetVisibleRegion(_Window *_w);
#define VRC_DO_PARENT 0x0001







>







301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
extern _Window *SdlTkWrapperForWindow(_Window *_w);
extern _Window *SdlTkTopVisibleWrapper(void);
extern SDL_Surface *SdlTkGetDrawableSurface(Drawable d, int *x, int *y,
    int *format);
extern _Window *SdlTkPointToWindow(_Window *_w, int x, int y,
    Bool mapped, Bool depth);
extern void SdlTkRemoveFromParent(_Window *_w);
extern _Window *SdlTkBottomTopmost(_Window *parent, _Window *sibling);
extern void SdlTkRestackWindow(_Window *_w, _Window *sibling, int stack_mode);
extern void SdlTkRestackTransients(_Window *_w);
extern void SdlTkBringToFrontIfNeeded(_Window *_w);
extern int SdlTkIsTransientOf(_Window *_w, _Window *other);
extern void SdlTkCalculateVisibleRegion(_Window *_w);
extern Region SdlTkGetVisibleRegion(_Window *_w);
#define VRC_DO_PARENT 0x0001

Changes to jni/sdl2tk/sdl/SdlTkX.c.

1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
....
1382
1383
1384
1385
1386
1387
1388


1389









1390
1391
1392
1393
1394
1395
1396
....
7804
7805
7806
7807
7808
7809
7810








7811
7812
7813
7814
7815
7816
7817

    _w->visRgn = SdlTkRgnPoolGet();
    _w->visRgnInParent = SdlTkRgnPoolGet();
    _w->dirtyRgn = SdlTkRgnPoolGet();

    _w->clazz = (clazz == InputOnly) ? InputOnly : InputOutput;

    /* Make first child of parent except for topmost children. */
    if (IS_ROOT(_parent)) {
	_Window *prev = NULL, *next = _parent->child;

	while (next != NULL) {
	    if (!next->topmost) {
		break;
	    }
	    prev = next;
	    next = next->next;
	}
	if (prev != NULL) {
	    _w->next = prev->next;
	    prev->next = _w;
	} else {
	    _w->next = _parent->child;
	    _parent->child = _w;
	}
    } else {
	_w->next = _parent->child;
	_parent->child = _w;
................................................................................

    SdlTkLock(display);
    display->request++;
    if (_w->display == NULL) {
	goto done;
    }
    if (property == XA_WM_TRANSIENT_FOR) {


	_w->master = NULL;









	goto done;
    }
    if (!prop_initialized) {
	Tcl_InitHashTable(&prop_table,
			  sizeof (struct prop_key) / sizeof (int));
	prop_initialized = 1;
    }
................................................................................
			       RevertToParent, CurrentTime);
	    /* Frames need redrawing if the focus changed. */
	    SdlTkScreenChanged();
	}
    }
    if ((_w->master != NULL) && (_w->master != oldMaster)) {
	SdlTkRestackTransients(_w->master);








    }

    SdlTkUnlock(display);
done:
    return ret;
}








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







 







>
>

>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319

1320
1321
1322
1323
1324
1325
1326
....
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
....
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835

    _w->visRgn = SdlTkRgnPoolGet();
    _w->visRgnInParent = SdlTkRgnPoolGet();
    _w->dirtyRgn = SdlTkRgnPoolGet();

    _w->clazz = (clazz == InputOnly) ? InputOnly : InputOutput;

    /*
     * Make first child of parent except for topmost children
     * in which case the new window is inserted after the last
     * topmost child.
     */
    if (IS_ROOT(_parent) && !_w->topmost &&
	!_w->atts.override_redirect && (_w->master == NULL)) {
	_Window *_child;

	_child = SdlTkBottomTopmost(_parent, NULL);
	if (_child != NULL) {
	    _w->next = _child->next;
	    _child->next = _w;

	} else {
	    _w->next = _parent->child;
	    _parent->child = _w;
	}
    } else {
	_w->next = _parent->child;
	_parent->child = _w;
................................................................................

    SdlTkLock(display);
    display->request++;
    if (_w->display == NULL) {
	goto done;
    }
    if (property == XA_WM_TRANSIENT_FOR) {
	_Window *oldMaster = _w->master;

	_w->master = NULL;
	if (oldMaster != NULL) {
	    if (_w->parent != NULL && _w->parent->dec != NULL) {
		if (!_w->parent->topmost && oldMaster->topmost) {
		    SdlTkRestackWindow(_w->parent, NULL, Above);
		}
	    } else if (!_w->topmost && oldMaster->topmost) {
		SdlTkRestackWindow(_w, NULL, Above);
	    }
	}
	goto done;
    }
    if (!prop_initialized) {
	Tcl_InitHashTable(&prop_table,
			  sizeof (struct prop_key) / sizeof (int));
	prop_initialized = 1;
    }
................................................................................
			       RevertToParent, CurrentTime);
	    /* Frames need redrawing if the focus changed. */
	    SdlTkScreenChanged();
	}
    }
    if ((_w->master != NULL) && (_w->master != oldMaster)) {
	SdlTkRestackTransients(_w->master);
    } else if ((_w->master == NULL) && (oldMaster != NULL)) {
	if (_w->parent != NULL && _w->parent->dec != NULL) {
	    if (!_w->parent->topmost && oldMaster->topmost) {
		SdlTkRestackWindow(_w->parent, NULL, Above);
	    }
	} else if (!_w->topmost && oldMaster->topmost) {
	    SdlTkRestackWindow(_w, NULL, Above);
	}
    }

    SdlTkUnlock(display);
done:
    return ret;
}