mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 23:08:06 +11:00
emul/hw/(ti|sms): detect window being closed
Previously, it would never get out of the event loop.
This commit is contained in:
parent
9cddaf1b59
commit
b60252e330
@ -99,6 +99,7 @@ void draw_pixels()
|
|||||||
int innerh = psize * VDP_SCREENH;
|
int innerh = psize * VDP_SCREENH;
|
||||||
int innerx = (geom->width - innerw) / 2;
|
int innerx = (geom->width - innerw) / 2;
|
||||||
int innery = (geom->height - innerh) / 2;
|
int innery = (geom->height - innerh) / 2;
|
||||||
|
free(geom);
|
||||||
int drawcnt = 0;
|
int drawcnt = 0;
|
||||||
for (int i=0; i<VDP_SCREENW; i++) {
|
for (int i=0; i<VDP_SCREENW; i++) {
|
||||||
for (int j=0; j<VDP_SCREENH; j++) {
|
for (int j=0; j<VDP_SCREENH; j++) {
|
||||||
@ -131,6 +132,15 @@ void event_loop()
|
|||||||
emul_steps(100);
|
emul_steps(100);
|
||||||
draw_pixels();
|
draw_pixels();
|
||||||
}
|
}
|
||||||
|
// A low tech way of checking when the window was closed. The proper way
|
||||||
|
// involving WM_DELETE is too complicated.
|
||||||
|
xcb_get_geometry_reply_t *geom;
|
||||||
|
geom = xcb_get_geometry_reply(conn, xcb_get_geometry(conn, win), NULL);
|
||||||
|
if (geom == NULL) {
|
||||||
|
return; // window has been closed.
|
||||||
|
} else {
|
||||||
|
free(geom);
|
||||||
|
}
|
||||||
xcb_generic_event_t *e = xcb_poll_for_event(conn);
|
xcb_generic_event_t *e = xcb_poll_for_event(conn);
|
||||||
if (!e) {
|
if (!e) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -199,6 +199,7 @@ void draw_pixels()
|
|||||||
int innerh = psize * 64;
|
int innerh = psize * 64;
|
||||||
int innerx = (geom->width - innerw) / 2;
|
int innerx = (geom->width - innerw) / 2;
|
||||||
int innery = (geom->height - innerh) / 2;
|
int innery = (geom->height - innerh) / 2;
|
||||||
|
free(geom);
|
||||||
int drawcnt = 0;
|
int drawcnt = 0;
|
||||||
for (int i=0; i<96; i++) {
|
for (int i=0; i<96; i++) {
|
||||||
for (int j=0; j<64; j++) {
|
for (int j=0; j<64; j++) {
|
||||||
@ -231,6 +232,15 @@ void event_loop()
|
|||||||
emul_steps(100);
|
emul_steps(100);
|
||||||
draw_pixels();
|
draw_pixels();
|
||||||
}
|
}
|
||||||
|
// A low tech way of checking when the window was closed. The proper way
|
||||||
|
// involving WM_DELETE is too complicated.
|
||||||
|
xcb_get_geometry_reply_t *geom;
|
||||||
|
geom = xcb_get_geometry_reply(conn, xcb_get_geometry(conn, win), NULL);
|
||||||
|
if (geom == NULL) {
|
||||||
|
return; // window has been closed.
|
||||||
|
} else {
|
||||||
|
free(geom);
|
||||||
|
}
|
||||||
xcb_generic_event_t *e = xcb_poll_for_event(conn);
|
xcb_generic_event_t *e = xcb_poll_for_event(conn);
|
||||||
if (!e) {
|
if (!e) {
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user