diff options
| author | kkard2 <[email protected]> | 2025-09-24 15:18:56 +0200 |
|---|---|---|
| committer | kkard2 <[email protected]> | 2025-09-24 15:18:56 +0200 |
| commit | 83413173c00e0387fbf05cc3d764fcd6a43bf991 (patch) | |
| tree | ed9b74aaa0dbfc29a02ec6d22247403f844b0b50 | |
| parent | bcfd31ce9ea9ea067b285a78eb747e3d68561bca (diff) | |
fix BadDrawable on x11 termination
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | examples/platform/platform_x11.c | 21 |
2 files changed, 15 insertions, 7 deletions
@@ -3,3 +3,4 @@ *.ilk *.pdb *.rdi +example diff --git a/examples/platform/platform_x11.c b/examples/platform/platform_x11.c index 3136e51..70a827e 100644 --- a/examples/platform/platform_x11.c +++ b/examples/platform/platform_x11.c @@ -91,6 +91,9 @@ int main() { BlackPixel(dpy, screen) ); + Atom atom_wm_delete_window = XInternAtom(dpy, "WM_DELETE_WINDOW", False); + XSetWMProtocols(dpy, win, &atom_wm_delete_window, 1); + XStoreName(dpy, win, "sponge"); XSelectInput(dpy, win, ExposureMask | PointerMotionMask | StructureNotifyMask); @@ -103,6 +106,12 @@ int main() { int running = 1; while (running) { + if (sponge_texture_valid(canvas)) { + draw_frame_3d(canvas, depths); + XPutImage(dpy, win, gc, ximg, 0, 0, 0, 0, canvas.width, canvas.height); + usleep(16000); + } + while (XPending(dpy)) { XEvent ev; XNextEvent(dpy, &ev); @@ -116,15 +125,13 @@ int main() { case MotionNotify: mouse_move(ev.xmotion.x, ev.xmotion.y); break; + case ClientMessage: + if ((Atom)ev.xclient.data.l[0] == atom_wm_delete_window) { + running = 0; + } + break; } } - - if (sponge_texture_valid(canvas)) { - draw_frame_3d(canvas, depths); - XPutImage(dpy, win, gc, ximg, 0, 0, 0, 0, canvas.width, canvas.height); - } - - usleep(16000); } if (ximg) { |
