+ struct Win * old_prev = world.wmeta->active->prev;
+ struct Win * old_next = world.wmeta->active->next;
+ if (world.wmeta->chain_start == world.wmeta->active->prev)
+ {
+ world.wmeta->chain_start = world.wmeta->active;
+ world.wmeta->active->prev = 0;
+ }
+ else
+ {
+ world.wmeta->active->prev = old_prev->prev;
+ world.wmeta->active->prev->next = world.wmeta->active;
+ }
+ if (world.wmeta->chain_end == world.wmeta->active)
+ {
+ world.wmeta->chain_end = old_prev;
+ }
+ else
+ {
+ old_next->prev = old_prev;
+ }
+ old_prev->next = old_next;
+ old_prev->prev = world.wmeta->active;
+ world.wmeta->active->next = old_prev;
+ }
+}
+
+
+
+extern void init_win_meta(WINDOW * screen)
+{
+ char * f_name = "init_win_meta()";
+ char * err_s = "init_win_meta() creates virtual screen beyond legal size.";
+ char * err_m = "init_win_meta() triggers memory alloc error via newpad().";
+ world.wmeta = try_malloc(sizeof(struct WinMeta), f_name);
+ world.wmeta->screen = screen;
+ uint32_t maxy_test = getmaxy(screen);
+ uint32_t maxx_test = getmaxx(screen);
+ uint8_t test = (maxy_test > UINT16_MAX || maxx_test > UINT16_MAX);
+ exit_err(test, err_s);
+ world.wmeta->padsize.y = maxy_test;
+ world.wmeta->padsize.x = maxx_test;
+ world.wmeta->chain_start = 0;
+ world.wmeta->chain_end = 0;
+ world.wmeta->pad_offset = 0;
+ world.wmeta->pad = newpad(world.wmeta->padsize.y, 1);
+ exit_err(NULL == world.wmeta->pad, err_m);
+ world.wmeta->active = 0;
+}
+
+
+
+extern void init_win(struct Win ** wp, char * title, int16_t height,
+ int16_t width, void * func)
+{
+ char * f_name = "init_win()";
+ struct Win * w = try_malloc(sizeof(struct Win), f_name);
+ w->prev = 0;
+ w->next = 0;
+ w->winmapsize.y = 0;
+ w->winmapsize.x = 0;
+ w->winmap = NULL;
+ w->title = try_malloc(strlen(title) + 1, f_name);
+ sprintf(w->title, "%s", title);
+ w->draw = func;
+ w->center.y = 0;
+ w->center.x = 0;
+ if (0 < width)
+ {
+ w->framesize.x = width;