Check-in [347ce47f40]
Not logged in

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

Overview
Comment:merge with trunk
Timelines: family | ancestors | descendants | both | wtf-8-experiment
Files: files | file ages | folders
SHA1: 347ce47f4045e9ccf7ea6e89242dfe3be1ead01a
User & Date: chw 2019-05-18 17:45:20
Context
2019-05-19
05:37
merge with trunk check-in: ec9ba40b00 user: chw tags: wtf-8-experiment
2019-05-18
17:45
merge with trunk check-in: 347ce47f40 user: chw tags: wtf-8-experiment
17:36
handle "wm attributes ... -topmost" in SDL tk port check-in: c287e160cb user: chw tags: trunk
06:18
merge with trunk check-in: 05ac57158a user: chw tags: wtf-8-experiment
Changes

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

525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
	if ((region->extents.x1 != region->extents.x2) &&
	    (region->extents.y1 != region->extents.y2)) {
	    region->numRects = 1;
	    *(region->rects) = region->extents;
	}
	return(region);
    }
    
    if (Count < 2) return region;

    if (! (pETEs = (EdgeTableEntry *)
	   Xmalloc((unsigned) (sizeof(EdgeTableEntry) * Count)))) {
	XDestroyRegion(region);
	return (Region) NULL;
    }







|







525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
	if ((region->extents.x1 != region->extents.x2) &&
	    (region->extents.y1 != region->extents.y2)) {
	    region->numRects = 1;
	    *(region->rects) = region->extents;
	}
	return(region);
    }

    if (Count < 2) return region;

    if (! (pETEs = (EdgeTableEntry *)
	   Xmalloc((unsigned) (sizeof(EdgeTableEntry) * Count)))) {
	XDestroyRegion(region);
	return (Region) NULL;
    }

Changes to jni/sdl2tk/sdl/SdlTkAGG.cpp.

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
....
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
....
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
....
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
....
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
    public:
        typedef PixFmt   pixfmt_type;
        typedef typename pixfmt_type::color_type color_type;
        typedef typename pixfmt_type::order_type order_type;
        typedef typename pixfmt_type::value_type value_type;

        image_accessor_wrap_gray8() {}
        explicit image_accessor_wrap_gray8(const pixfmt_type& pixf) : 
            m_pixf(&pixf), 
            m_wrap_x(pixf.width()), 
            m_wrap_y(pixf.height())
        {}

        void attach(const pixfmt_type& pixf)
        {
            m_pixf = &pixf;
        }
................................................................................
	    m_src(&src),
            m_offset_x(offset_x),
            m_offset_y(offset_y)
    {}

    //--------------------------------------------------------------------
    void generate(color_type* span, int x, int y, unsigned len)
    {   
	x += m_offset_x;
	y += m_offset_y;
	const Uint8* p = (const Uint8*)m_src->span(x, y, 1);
	do {
	    if (p[0]) {
		*span = m_color;
	    } else {
................................................................................
	Uint8* p = (Uint8*)m_rbuf->row_ptr(y) + x;
	p[0] ^= 0xFF;
	p[1] ^= 0xFF;
	p[2] ^= 0xFF;
    }

    //--------------------------------------------------------------------
    void copy_hline(int x, int y, 
			    unsigned len, 
			    const color_type& c)
    {
	Uint8* p = (Uint8*)m_rbuf->row_ptr(y) + x + x + x;
	do {
	    p[0] ^= 0xFF;
	    p[1] ^= 0xFF;
	    p[2] ^= 0xFF;
	    p += 3;
	} while(--len);
    }

    //--------------------------------------------------------------------
    void blend_hline(int x, int y,
		    unsigned len, 
		    const color_type& c,
		    agg::int8u cover)
    {
	Uint8* p = (Uint8*)m_rbuf->row_ptr(y) + x + x + x;
	do {
	    p[0] ^= 0xFF;
	    p[1] ^= 0xFF;
................................................................................
	    p[2] ^= 0xFF;
	    p += 3;
	} while(--len);
    }

    //--------------------------------------------------------------------
    void blend_vline(int x, int y,
		    unsigned len, 
		    const color_type& c,
		    agg::int8u cover)
    {
	Uint8* p = (Uint8*)m_rbuf->row_ptr(y) + x + x + x;
	do {
	    p[0] ^= 0xFF;
	    p[1] ^= 0xFF;
................................................................................
	    p[2] ^= 0xFF;
	    p += m_rbuf->stride();
	} while(--len);
    }

    //--------------------------------------------------------------------
    void blend_color_hspan(int x, int y,
			   unsigned len, 
			   const color_type* colors,
			   const agg::int8u* covers,
			   agg::int8u cover)
    {
    }

private:
................................................................................
    void copy_pixel(int x, int y, const color_type& c)
    {
	Type* p = (Type*)m_rbuf->row_ptr(y) + x;
	*p ^= 0xFFFFFFFF;
    }

    //--------------------------------------------------------------------
    void copy_hline(int x, int y, 
		    unsigned len, 
		    const color_type& c)
    {
	Type* p = (Type*)m_rbuf->row_ptr(y) + x;
	do {
	    *p ^= 0xFFFFFFFF;
	    p += 1;
	} while(--len);
    }

    //--------------------------------------------------------------------
    void blend_hline(int x, int y,
		    unsigned len, 
		    const color_type& c,
		    agg::int8u cover)
    {
	Type* p = (Type*)m_rbuf->row_ptr(y) + x;
	do {
	    *p ^= 0xFFFFFFFF;
	    p += 1;
	} while(--len);
    }

    //--------------------------------------------------------------------
    void blend_vline(int x, int y,
		    unsigned len, 
		    const color_type& c,
		    agg::int8u cover)
    {
	Type* p = (Type*)m_rbuf->row_ptr(y) + x;
	do {
	    *p ^= 0xFFFFFFFF;
	    y++;
	    p = (Type*)m_rbuf->row_ptr(y) + x;
	} while(--len);
    }

    //--------------------------------------------------------------------
    void blend_color_hspan(int x, int y,
			   unsigned len, 
			   const color_type* colors,
			   const agg::int8u* covers,
			   agg::int8u cover)
    {
    }

private:







|
|
|







 







|







 







|
|













|







 







|







 







|







 







|
|











|












|













|







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
....
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
....
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
....
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
....
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
    public:
        typedef PixFmt   pixfmt_type;
        typedef typename pixfmt_type::color_type color_type;
        typedef typename pixfmt_type::order_type order_type;
        typedef typename pixfmt_type::value_type value_type;

        image_accessor_wrap_gray8() {}
        explicit image_accessor_wrap_gray8(const pixfmt_type& pixf) :
            m_pixf(&pixf),
            m_wrap_x(pixf.width()),
            m_wrap_y(pixf.height())
        {}

        void attach(const pixfmt_type& pixf)
        {
            m_pixf = &pixf;
        }
................................................................................
	    m_src(&src),
            m_offset_x(offset_x),
            m_offset_y(offset_y)
    {}

    //--------------------------------------------------------------------
    void generate(color_type* span, int x, int y, unsigned len)
    {
	x += m_offset_x;
	y += m_offset_y;
	const Uint8* p = (const Uint8*)m_src->span(x, y, 1);
	do {
	    if (p[0]) {
		*span = m_color;
	    } else {
................................................................................
	Uint8* p = (Uint8*)m_rbuf->row_ptr(y) + x;
	p[0] ^= 0xFF;
	p[1] ^= 0xFF;
	p[2] ^= 0xFF;
    }

    //--------------------------------------------------------------------
    void copy_hline(int x, int y,
			    unsigned len,
			    const color_type& c)
    {
	Uint8* p = (Uint8*)m_rbuf->row_ptr(y) + x + x + x;
	do {
	    p[0] ^= 0xFF;
	    p[1] ^= 0xFF;
	    p[2] ^= 0xFF;
	    p += 3;
	} while(--len);
    }

    //--------------------------------------------------------------------
    void blend_hline(int x, int y,
		    unsigned len,
		    const color_type& c,
		    agg::int8u cover)
    {
	Uint8* p = (Uint8*)m_rbuf->row_ptr(y) + x + x + x;
	do {
	    p[0] ^= 0xFF;
	    p[1] ^= 0xFF;
................................................................................
	    p[2] ^= 0xFF;
	    p += 3;
	} while(--len);
    }

    //--------------------------------------------------------------------
    void blend_vline(int x, int y,
		    unsigned len,
		    const color_type& c,
		    agg::int8u cover)
    {
	Uint8* p = (Uint8*)m_rbuf->row_ptr(y) + x + x + x;
	do {
	    p[0] ^= 0xFF;
	    p[1] ^= 0xFF;
................................................................................
	    p[2] ^= 0xFF;
	    p += m_rbuf->stride();
	} while(--len);
    }

    //--------------------------------------------------------------------
    void blend_color_hspan(int x, int y,
			   unsigned len,
			   const color_type* colors,
			   const agg::int8u* covers,
			   agg::int8u cover)
    {
    }

private:
................................................................................
    void copy_pixel(int x, int y, const color_type& c)
    {
	Type* p = (Type*)m_rbuf->row_ptr(y) + x;
	*p ^= 0xFFFFFFFF;
    }

    //--------------------------------------------------------------------
    void copy_hline(int x, int y,
		    unsigned len,
		    const color_type& c)
    {
	Type* p = (Type*)m_rbuf->row_ptr(y) + x;
	do {
	    *p ^= 0xFFFFFFFF;
	    p += 1;
	} while(--len);
    }

    //--------------------------------------------------------------------
    void blend_hline(int x, int y,
		    unsigned len,
		    const color_type& c,
		    agg::int8u cover)
    {
	Type* p = (Type*)m_rbuf->row_ptr(y) + x;
	do {
	    *p ^= 0xFFFFFFFF;
	    p += 1;
	} while(--len);
    }

    //--------------------------------------------------------------------
    void blend_vline(int x, int y,
		    unsigned len,
		    const color_type& c,
		    agg::int8u cover)
    {
	Type* p = (Type*)m_rbuf->row_ptr(y) + x;
	do {
	    *p ^= 0xFFFFFFFF;
	    y++;
	    p = (Type*)m_rbuf->row_ptr(y) + x;
	} while(--len);
    }

    //--------------------------------------------------------------------
    void blend_color_hspan(int x, int y,
			   unsigned len,
			   const color_type* colors,
			   const agg::int8u* covers,
			   agg::int8u cover)
    {
    }

private:

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

3394
3395
3396
3397
3398
3399
3400























3401
3402
3403
3404
3405
3406
3407
....
3510
3511
3512
3513
3514
3515
3516

3517



3518

3519
3520
3521
3522
3523
3524
3525
    if ((parent->child == _w) && (_w->next == NULL)) {
	return;
    }

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
























    SdlTkRemoveFromParent(_w);

    if (sibling == NULL) {
	switch (stack_mode) {
	case Above:
	    sibling = parent->child;
................................................................................

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

    sibling = _w->parent->child;

    while ((sibling != _w) && SdlTkIsTransientOf(sibling, _w))



	sibling = sibling->next;


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

    master = SdlTkWrapperForWindow(_w);







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







 







>
|
>
>
>

>







3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
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
....
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
    if ((parent->child == _w) && (_w->next == NULL)) {
	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) {
	case Above:
	    sibling = parent->child;
................................................................................

    _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);
    }

    master = SdlTkWrapperForWindow(_w);

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

87
88
89
90
91
92
93

94
95
96
97
98
99
100
...
236
237
238
239
240
241
242

243
244
245
246
247
248
249
    _Window *master; /* Master if this is a transient */
    Display *display;
    XWindowAttributes atts, atts_saved;
    int back_pixel_set;
    unsigned long back_pixel;
    struct _Pixmap *back_pixmap;
    int fullscreen;

    int clazz;
    XSizeHints size;
    int parentWidth, parentHeight; /* our width/height + 2*atts.border_width */
    TkWindow *tkwin; /* NULL for decorative frame */
    DecFrame dec; /* only for decorative frame */
#ifdef ANDROID
    int gl_flags;
................................................................................
    int arg_nosysfonts;
    int arg_swcursor;

    /* Various atoms */
    Atom mwm_atom;
    Atom nwmn_atom;
    Atom nwms_atom;

    Atom nwmsf_atom;
    Atom clipboard_atom;
    Atom comm_atom;
    Atom interp_atom;
    Atom tkapp_atom;
    Atom wm_prot_atom;
    Atom wm_dele_atom;







>







 







>







87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
    _Window *master; /* Master if this is a transient */
    Display *display;
    XWindowAttributes atts, atts_saved;
    int back_pixel_set;
    unsigned long back_pixel;
    struct _Pixmap *back_pixmap;
    int fullscreen;
    int topmost;
    int clazz;
    XSizeHints size;
    int parentWidth, parentHeight; /* our width/height + 2*atts.border_width */
    TkWindow *tkwin; /* NULL for decorative frame */
    DecFrame dec; /* only for decorative frame */
#ifdef ANDROID
    int gl_flags;
................................................................................
    int arg_nosysfonts;
    int arg_swcursor;

    /* Various atoms */
    Atom mwm_atom;
    Atom nwmn_atom;
    Atom nwms_atom;
    Atom nwmsa_atom;
    Atom nwmsf_atom;
    Atom clipboard_atom;
    Atom comm_atom;
    Atom interp_atom;
    Atom tkapp_atom;
    Atom wm_prot_atom;
    Atom wm_dele_atom;

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

361
362
363
364
365
366
367
368
369
370
371
372
373



374
375
376


















377
378
379
380
381
382
383
....
1280
1281
1282
1283
1284
1285
1286
1287














1288
1289





1290
1291
1292
1293
1294
1295
1296
....
2386
2387
2388
2389
2390
2391
2392

2393
2394
2395
2396
2397


2398
2399




2400
2401
2402
2403
2404
2405
2406
....
6398
6399
6400
6401
6402
6403
6404

6405
6406
6407
6408
6409
6410
6411
....
7288
7289
7290
7291
7292
7293
7294
7295

7296
7297
7298
7299
7300
7301
7302
7303


7304




























7305
7306
7307
7308

7309
7310
7311

7312
7313
7314
7315
7316
7317
7318
....
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338

7339
7340
7341
7342
7343
7344
7345
....
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704

7705
7706
7707
7708
7709
7710
7711
....
7720
7721
7722
7723
7724
7725
7726



7727
7728
7729
7730
7731
7732
7733
		SdlTkChangeWindowAttributes(display, w,
					    CWOverrideRedirect, &atts);
	    }
	}
	goto done;
    }
    if (property == SdlTkX.nwms_atom) {
	int i, fullscreen = 0;
	Atom *props = (Atom *) data;
	XPropertyEvent xproperty;
	_Window *_ww = _w;

	for (i = 0; i < nelements; i++) {



	    if (props[i] == SdlTkX.nwmsf_atom) {
		fullscreen = 1;
		break;


















	    }
	}
	if (fullscreen && !_w->fullscreen) {
	    int xx, yy, ww, hh;

	    _w->atts_saved = _w->atts;
	    xx = yy = 0;
................................................................................

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

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

    /* Make first child of parent. */














    _w->next = _parent->child;
    _parent->child = _w;






    if (_parent->atts.your_event_mask & SubstructureNotifyMask) {
	/* Make CreateNotify event. */
	XEvent event;

	memset(&event, 0, sizeof (event));
	event.type = CreateNotify;
................................................................................
    *actual_type_return = None;
    *actual_format_return = 0;
    *nitems_return = 0;
    *bytes_after_return = 0;
    *prop_return = NULL;
    if (property == SdlTkX.nwms_atom) {
	_Window *_w = (_Window *) w;


	SdlTkLock(display);
	display->request++;
	if (_w->fullscreen) {
	    *prop_return = (unsigned char *) ckalloc(sizeof (Atom));


	    ((Atom *) *prop_return)[0] = SdlTkX.nwmsf_atom;
	    *nitems_return = 1;




	}
	SdlTkUnlock(display);
	return Success;
    }
    if (req_type != XA_STRING) {
	return BadValue;
    }
................................................................................

    SDL_EnableScreenSaver();

    /* Some well known atoms. */
    SdlTkX.mwm_atom = XInternAtom(NULL, "_MOTIF_WM_HINTS", False);
    SdlTkX.nwmn_atom = XInternAtom(NULL, "_NET_WM_NAME", False);
    SdlTkX.nwms_atom = XInternAtom(NULL, "_NET_WM_STATE", False);

    SdlTkX.nwmsf_atom = XInternAtom(NULL, "_NET_WM_STATE_FULLSCREEN", False);
    SdlTkX.clipboard_atom = XInternAtom(NULL, "CLIPBOARD", False);
    SdlTkX.comm_atom = XInternAtom(NULL, "Comm", False);
    SdlTkX.interp_atom = XInternAtom(NULL, "InterpRegistry", False);
    SdlTkX.tkapp_atom = XInternAtom(NULL, "TK_APPLICATION", False);
    SdlTkX.wm_prot_atom = XInternAtom(NULL, "WM_PROTOCOLS", False);
    SdlTkX.wm_dele_atom = XInternAtom(NULL, "WM_DELETE_WINDOW", False);
................................................................................
}

int
XSendEvent(Display *display, Window w, Bool propagate, long event_mask,
	   XEvent *event_send)
{
    XEvent event;
    int ret = 0;


    SdlTkLock(display);
    display->request++;
    event = *event_send;
    if ((event.xany.type == ClientMessage) && (w != None) &&
	(w != PointerRoot) && (w != InputFocus) &&
	(event.xclient.message_type == SdlTkX.nwms_atom) &&
	(event.xclient.data.a[1] == SdlTkX.nwmsf_atom)) {


	_Window *_w = (_Window *) event.xany.window;




























	int fullscreen = event.xclient.data.l[0];
	int send_nwms = 0;
	_Window *_ww = _w;


	if ((_w == NULL) || (_w->display == NULL)) {
	    goto done;
	}

	if (fullscreen && !_w->fullscreen) {
	    int xx, yy, ww, hh;

	    _w->atts_saved = _w->atts;
	    xx = yy = 0;
	    ww = SdlTkX.screen->width;
	    hh = SdlTkX.screen->height;
................................................................................
	    }
	    SdlTkMoveResizeWindow(display, (Window) _w, xx, yy, ww, hh);
	    while (!IS_ROOT((Window) _ww)) {
		_ww->fullscreen = 1;
		_ww = _ww->parent;
	    }
	    send_nwms = 1;
	} else if ((_w != NULL) && !fullscreen && _w->fullscreen) {
	    while (!IS_ROOT((Window) _ww)) {
		_ww->fullscreen = 0;
		_ww = _ww->parent;
	    }
	    SdlTkMoveResizeWindow(display, (Window) _w,
				  _w->atts_saved.x, _w->atts_saved.y,
				  _w->atts_saved.width, _w->atts_saved.height);
	    send_nwms = 1;
	}

	if (send_nwms) {
	    XPropertyEvent xproperty;

	    memset(&xproperty, 0, sizeof (xproperty));
	    xproperty.type = PropertyNotify;
	    xproperty.serial = _w->display->request;
	    xproperty.send_event = False;
................................................................................
    display->request++;
    SdlTkUnlock(display);
}

int
XSetTransientForHint(Display *display, Window w, Window prop_window)
{
    _Window *_w, *_p, *_parent;
    int ret = 1;

    SdlTkLock(display);
    display->request++;

    _w = (_Window *) w;
    _p = (_Window *) prop_window;
    if (_w->display == NULL) {
	ret = 0;
	goto done;
    }

    if (_p != NULL) {
	_parent = _p->parent;
	while ((_parent != NULL) && !IS_ROOT(_parent)) {
	    _p = _parent;
	    _parent = _p->parent;
	}
	if ((_p != NULL) && (_p->dec != NULL)) {
................................................................................
	if (SdlTkX.keyboard_window == NULL) {
	    SdlTkSetInputFocus(SdlTkX.display,
			       (Window) SdlTkWrapperForWindow(_w),
			       RevertToParent, CurrentTime);
	    /* Frames need redrawing if the focus changed. */
	    SdlTkScreenChanged();
	}



    }

    SdlTkUnlock(display);
done:
    return ret;
}








|





>
>
>


<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







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







 







>



|
|
>
>
|
|
>
>
>
>







 







>







 







|
>







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

<
|

>



>







 







|









>







 







|











>







 







>
>
>







361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378

379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
....
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
1328
1329
1330
1331
1332
1333
1334
1335
....
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
....
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
....
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383

7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
....
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
....
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
....
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
		SdlTkChangeWindowAttributes(display, w,
					    CWOverrideRedirect, &atts);
	    }
	}
	goto done;
    }
    if (property == SdlTkX.nwms_atom) {
	int i, fullscreen = 0, topmost = 0;
	Atom *props = (Atom *) data;
	XPropertyEvent xproperty;
	_Window *_ww = _w;

	for (i = 0; i < nelements; i++) {
	    if (props[i] == SdlTkX.nwmsa_atom) {
		topmost = 1;
	    }
	    if (props[i] == SdlTkX.nwmsf_atom) {
		fullscreen = 1;

	    }
	}
	if (topmost && !_w->topmost) {
	    _w->topmost = 1;
	    if (_w->parent != NULL && _w->parent->dec != NULL) {
		_w->parent->topmost = 1;
		SdlTkRestackWindow(_w->parent, NULL, Above);
	    } else {
		SdlTkRestackWindow(_w, NULL, Above);
	    }
	    SdlTkRestackTransients(_w);
	} else if (!topmost && _w->topmost) {
	    _w->topmost = 0;
	    if (_w->parent != NULL && _w->parent->dec != NULL) {
		_w->parent->topmost = 0;
		SdlTkRestackWindow(_w->parent, NULL, Above);
	    } else {
	    	SdlTkRestackWindow(_w, NULL, Above);
	    }
	}
	if (fullscreen && !_w->fullscreen) {
	    int xx, yy, ww, hh;

	    _w->atts_saved = _w->atts;
	    xx = yy = 0;
................................................................................

    _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;
    }

    if (_parent->atts.your_event_mask & SubstructureNotifyMask) {
	/* Make CreateNotify event. */
	XEvent event;

	memset(&event, 0, sizeof (event));
	event.type = CreateNotify;
................................................................................
    *actual_type_return = None;
    *actual_format_return = 0;
    *nitems_return = 0;
    *bytes_after_return = 0;
    *prop_return = NULL;
    if (property == SdlTkX.nwms_atom) {
	_Window *_w = (_Window *) w;
	int n = 0;

	SdlTkLock(display);
	display->request++;
	if (_w->fullscreen || _w->topmost) {
	    *prop_return = (unsigned char *) ckalloc(sizeof (Atom) * 2);
	}
	if (_w->fullscreen) {
	    ((Atom *) *prop_return)[n++] = SdlTkX.nwmsf_atom;
	    *nitems_return = n;
	}
	if (_w->topmost) {
	    ((Atom *) *prop_return)[n++] = SdlTkX.nwmsa_atom;
	    *nitems_return = n;
	}
	SdlTkUnlock(display);
	return Success;
    }
    if (req_type != XA_STRING) {
	return BadValue;
    }
................................................................................

    SDL_EnableScreenSaver();

    /* Some well known atoms. */
    SdlTkX.mwm_atom = XInternAtom(NULL, "_MOTIF_WM_HINTS", False);
    SdlTkX.nwmn_atom = XInternAtom(NULL, "_NET_WM_NAME", False);
    SdlTkX.nwms_atom = XInternAtom(NULL, "_NET_WM_STATE", False);
    SdlTkX.nwmsa_atom = XInternAtom(NULL, "_NET_WM_STATE_ABOVE", False);
    SdlTkX.nwmsf_atom = XInternAtom(NULL, "_NET_WM_STATE_FULLSCREEN", False);
    SdlTkX.clipboard_atom = XInternAtom(NULL, "CLIPBOARD", False);
    SdlTkX.comm_atom = XInternAtom(NULL, "Comm", False);
    SdlTkX.interp_atom = XInternAtom(NULL, "InterpRegistry", False);
    SdlTkX.tkapp_atom = XInternAtom(NULL, "TK_APPLICATION", False);
    SdlTkX.wm_prot_atom = XInternAtom(NULL, "WM_PROTOCOLS", False);
    SdlTkX.wm_dele_atom = XInternAtom(NULL, "WM_DELETE_WINDOW", False);
................................................................................
}

int
XSendEvent(Display *display, Window w, Bool propagate, long event_mask,
	   XEvent *event_send)
{
    XEvent event;
    int ret = 0, send_nwms = 0;
    _Window *_w = NULL;

    SdlTkLock(display);
    display->request++;
    event = *event_send;
    if ((event.xany.type == ClientMessage) && (w != None) &&
	(w != PointerRoot) && (w != InputFocus) &&
	(event.xclient.message_type == SdlTkX.nwms_atom) &&
	(event.xclient.data.a[1] == SdlTkX.nwmsa_atom)) {
	int topmost = event.xclient.data.l[0];

	_w = (_Window *) event.xany.window;
	if ((_w == NULL) || (_w->display == NULL)) {
	    goto done;
	}
	if (topmost && !_w->topmost) {
	    _w->topmost = 1;
	    if (_w->parent != NULL && _w->parent->dec != NULL) {
		_w->parent->topmost = 1;
	    	SdlTkRestackWindow(_w->parent, NULL, Above);
	    } else {
	    	SdlTkRestackWindow(_w, NULL, Above);
	    }
	    SdlTkRestackTransients(_w);
	    send_nwms = 1;
	} else if (!topmost && _w->topmost) {
	    _w->topmost = 0;
	    if (_w->parent != NULL && _w->parent->dec != NULL) {
		_w->parent->topmost = 0;
		SdlTkRestackWindow(_w->parent, NULL, Above);
	    } else {
	    	SdlTkRestackWindow(_w, NULL, Above);
	    }
	    send_nwms = 1;
	}
	goto send_nwms;
    } else if ((event.xany.type == ClientMessage) && (w != None) &&
	(w != PointerRoot) && (w != InputFocus) &&
	(event.xclient.message_type == SdlTkX.nwms_atom) &&
	(event.xclient.data.a[1] == SdlTkX.nwmsf_atom)) {
	int fullscreen = event.xclient.data.l[0];

	_Window *_ww;

	_w = (_Window *) event.xany.window;
	if ((_w == NULL) || (_w->display == NULL)) {
	    goto done;
	}
       	_ww = _w;
	if (fullscreen && !_w->fullscreen) {
	    int xx, yy, ww, hh;

	    _w->atts_saved = _w->atts;
	    xx = yy = 0;
	    ww = SdlTkX.screen->width;
	    hh = SdlTkX.screen->height;
................................................................................
	    }
	    SdlTkMoveResizeWindow(display, (Window) _w, xx, yy, ww, hh);
	    while (!IS_ROOT((Window) _ww)) {
		_ww->fullscreen = 1;
		_ww = _ww->parent;
	    }
	    send_nwms = 1;
	} else if (!fullscreen && _w->fullscreen) {
	    while (!IS_ROOT((Window) _ww)) {
		_ww->fullscreen = 0;
		_ww = _ww->parent;
	    }
	    SdlTkMoveResizeWindow(display, (Window) _w,
				  _w->atts_saved.x, _w->atts_saved.y,
				  _w->atts_saved.width, _w->atts_saved.height);
	    send_nwms = 1;
	}
send_nwms:
	if (send_nwms) {
	    XPropertyEvent xproperty;

	    memset(&xproperty, 0, sizeof (xproperty));
	    xproperty.type = PropertyNotify;
	    xproperty.serial = _w->display->request;
	    xproperty.send_event = False;
................................................................................
    display->request++;
    SdlTkUnlock(display);
}

int
XSetTransientForHint(Display *display, Window w, Window prop_window)
{
    _Window *_w, *_p, *_parent, *oldMaster;
    int ret = 1;

    SdlTkLock(display);
    display->request++;

    _w = (_Window *) w;
    _p = (_Window *) prop_window;
    if (_w->display == NULL) {
	ret = 0;
	goto done;
    }
    oldMaster = _w->master;
    if (_p != NULL) {
	_parent = _p->parent;
	while ((_parent != NULL) && !IS_ROOT(_parent)) {
	    _p = _parent;
	    _parent = _p->parent;
	}
	if ((_p != NULL) && (_p->dec != NULL)) {
................................................................................
	if (SdlTkX.keyboard_window == NULL) {
	    SdlTkSetInputFocus(SdlTkX.display,
			       (Window) SdlTkWrapperForWindow(_w),
			       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;
}

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

353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
#if defined(ANDROID) && defined(PLATFORM_SDL)
    const char *path, *temp;
#endif
#ifdef __APPLE__
    Tcl_ThreadId thrId;
    struct ThreadStartup startup;
    extern void SdlTkEventThread(void);
#endif    

#ifdef TK_LOCAL_MAIN_HOOK
    TK_LOCAL_MAIN_HOOK(&argc, &argv);
#endif
#ifdef ANDROID
    Tcl_InitSubsystems(AndroidPanic);








|







353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
#if defined(ANDROID) && defined(PLATFORM_SDL)
    const char *path, *temp;
#endif
#ifdef __APPLE__
    Tcl_ThreadId thrId;
    struct ThreadStartup startup;
    extern void SdlTkEventThread(void);
#endif

#ifdef TK_LOCAL_MAIN_HOOK
    TK_LOCAL_MAIN_HOOK(&argc, &argv);
#endif
#ifdef ANDROID
    Tcl_InitSubsystems(AndroidPanic);