blob: 39c719d86bf6b18dcb4650bce892a956505e0bd2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# Phase 10 — Robustness & Cleanup
---
## Step 10.1 — Proper error handling
- Set `XSetErrorHandler()` to a handler that logs but doesn't crash on
`BadWindow`, `BadPixmap`, `BadDrawable` (windows can vanish between
operations).
- Wrap all X calls that reference a window in the handler's
error-checked scope.
- On fatal errors (`XSetIOErrorHandler`), clean up gracefully.
**Verify:** Rapidly spawn and kill clients (a stress loop script). No
crashes, no X error floods. Clean log output.
---
## Step 10.2 — Clean shutdown
On `SIGINT`/`SIGTERM` or raylib `WindowShouldClose()`:
1. Unredirect all windows (`XCompositeUnredirectSubwindows`).
2. Free all pixmaps, textures, damage objects.
3. Release the overlay (if used later).
4. `XCloseDisplay()`.
5. `CloseWindow()` (raylib).
**Verify:** Killing the WM with Ctrl+C cleanly restores windows in
Xephyr (they become visible via X's normal rendering again). No
orphaned resources.
---
## Step 10.3 — Stress test script
Create `bin/stress-test.sh` that:
1. Starts Xephyr.
2. Starts the WM.
3. Rapidly spawns 20 `xterm` instances.
4. Randomly moves, resizes, and closes them via `xdotool`.
5. Checks that `wmctrl -l` count matches expectations.
6. Screenshots the result.
7. Tears everything down.
**Verify:** No crashes, no hangs, no leaked windows. Screenshot looks
sane.
|