+static void
+WolframAutomata_reshape(Display * dpy, Window win, void * closure, unsigned int w, unsigned int h)
+{
+ struct state * state = closure;
+ XWindowAttributes xgwa;
+ XGetWindowAttributes(state->dpy, state->win, &xgwa);
+
+ /* Only restart the simulation if the window changed size. */
+ if (state->dpy_width != xgwa.width || state->dpy_height != xgwa.height) {
+ WolframAutomata_free(dpy, win, closure);
+ closure = WolframAutomata_init(dpy, win);
+ }
+}
+