-
- T((T_CALLED("adjust_window(%p,%d,%d) currently %dx%d at %d,%d"),
- win, ToLines, ToCols,
- getmaxy(win), getmaxx(win),
- getbegy(win), getbegx(win)));
-
- if (win->_begy >= bottom) {
- win->_begy += (ToLines - current_lines);
+ ripoff_t *rop = ripped_window(win);
+
+ T((T_CALLED("adjust_window(%p,%d,%d)%s depth %d/%d currently %ldx%ld at %ld,%ld"),
+ (void *) win, ToLines, ToCols,
+ (rop != 0) ? " (rip)" : "",
+ parent_depth(win),
+ child_depth(win),
+ (long) getmaxy(win), (long) getmaxx(win),
+ (long) getbegy(win) + win->_yoffset, (long) getbegx(win)));
+
+ if (rop != 0 && rop->line < 0) {
+ /*
+ * If it is a ripped-off window at the bottom of the screen, simply
+ * move it to the same relative position.
+ */
+ win->_begy = (NCURSES_SIZE_T) (ToLines - ripped_bottom(win) - 0 - win->_yoffset);
+ if (rop->hook == _nc_slk_initialize)
+ _nc_format_slks(
+#if NCURSES_SP_FUNCS
+ _nc_screen_of(win),
+#endif
+ ToCols);
+ } else if (win->_begy >= bottom) {
+ /*
+ * If it is below the bottom of the new screen, move up by the same
+ * amount that the screen shrank.
+ */
+ win->_begy = (NCURSES_SIZE_T) (win->_begy + (ToLines - CurLines));