Now NEDsim maintains the simulator when the window resizes, only resetting the displa...
authorAaron Taylor <ataylor@subgeniuskitty.com>
Thu, 8 Jul 2021 23:35:08 +0000 (16:35 -0700)
committerAaron Taylor <ataylor@subgeniuskitty.com>
Thu, 8 Jul 2021 23:35:08 +0000 (16:35 -0700)
hacks/NEDsim/NEDsim.c

index df95105..2b576f0 100644 (file)
@@ -781,8 +781,12 @@ NEDsim_reshape(Display * dpy, Window win, void * closure, unsigned int w, unsign
     XGetWindowAttributes(nedsim->dpy, nedsim->win, &xgwa);
     /* Only restart the simulation if the window changed size.                */
     if (nedsim->dpy_width != xgwa.width || nedsim->dpy_height != xgwa.height) {
     XGetWindowAttributes(nedsim->dpy, nedsim->win, &xgwa);
     /* Only restart the simulation if the window changed size.                */
     if (nedsim->dpy_width != xgwa.width || nedsim->dpy_height != xgwa.height) {
-        NEDsim_free(dpy, win, closure);
-        closure = NEDsim_init(dpy, win);
+        struct NEDstate * original_nedstate = nedsim->nedstate;
+        nedsim->nedstate = NULL;
+        NEDsim_free(dpy, win, nedsim);
+        struct NEDsim * new_nedsim = NEDsim_init(dpy, win);
+        new_nedsim->nedstate = original_nedstate;
+        closure = new_nedsim;
     }
 }
 
     }
 }