Immediate-Mode-UI / Immediate-Mode-UI/Nuklear
x11_rawfb demo will not exit cleanly
- Dominant language
- C
- Stars
- 11.4k
- Forks
- 686
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 3
Description
The normal `demo/x11/main.c` has this loop:
```c
while (XPending(xw.dpy)) {
XNextEvent(xw.dpy, &evt);
if (evt.type == ClientMessage) goto cleanup;
if (XFilterEvent(&evt, xw.win)) continue;
nk_xlib_handle_event(xw.dpy, xw.screen, xw.win, &evt);
}
```
Where "ClientMessage" is the window closing (user clicked the "X"), and the goto shuts down the app gracefully and exits from main like it should.
However the x11_rawfb demo does not handle `ClientMessage`, and its loop is slightly different:
```c
while (XCheckWindowEvent(xw.dpy, xw.win, xw.swa.event_mask, &evt)) {
if (XFilterEvent(&evt, xw.win)) continue;
nk_xlib_handle_event(xw.dpy, xw.screen, xw.win, &evt, rawfb);
}
```
Causing the closing of the window to instantly `exit()` the program with `X connection to :0 broken (explicit kill or server shutdown).`. In the case of my own app that uses x11_rawfb this means I cannot save any final settings once the user closes the window.
Also, even if the while loop from the regular x11 demo is copied over to x11_rawfb, the `ClientMessage` event is still never fired and the same issue persists.
How can this be solved?
Contributor guide
Research direction
Compare the event loops in demo/x11/main.c and the x11_rawfb demo, then reproduce closing the rawfb window while tracing the events handled by XCheckWindowEvent. Determine why the close event is not delivered as ClientMessage in the rawfb path. Done means the window can close through the rawfb demo without an immediate X connection error, allowing normal cleanup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100