Browse Source

Workaround bug in PDCurses wresize

If the current cursor position fell outside the new window dimensions, it would be moved to just-outside - which is still outside
We can workaround this by checking if it is outside, and moving it inside if so
Luke Dashjr 12 years ago
parent
commit
71adb95496
2 changed files with 27 additions and 5 deletions
  1. 1 1
      libblkmaker
  2. 26 4
      miner.c

+ 1 - 1
libblkmaker

@@ -1 +1 @@
-Subproject commit 19847fbab02450fb0db2ae519a35808cdc091991
+Subproject commit bca8f6f5e56c547e9bbc808fb644152e44f3344d

+ 26 - 4
miner.c

@@ -2000,6 +2000,28 @@ int my_cancellable_getch(void)
 
 	return rv;
 }
+
+#ifdef PDCURSES
+static
+int bfg_wresize(WINDOW *win, int lines, int columns)
+{
+	int rv = wresize(win, lines, columns);
+	int x, y;
+	getyx(win, y, x);
+	if (unlikely(y >= lines || x >= columns))
+	{
+		if (y >= lines)
+			y = lines - 1;
+		if (x >= columns)
+			x = columns - 1;
+		wmove(win, y, x);
+	}
+	return rv;
+}
+#else
+#	define bfg_wresize wresize
+#endif
+
 #endif
 
 void tailsprintf(char *f, const char *fmt, ...)
@@ -2359,14 +2381,14 @@ static inline void change_logwinsize(void)
 			statusy = logstart;
 		logcursor = statusy + 1;
 		mvwin(logwin, logcursor, 0);
-		wresize(statuswin, statusy, x);
+		bfg_wresize(statuswin, statusy, x);
 	}
 
 	y -= logcursor;
 	getmaxyx(logwin, logy, logx);
 	/* Detect screen size change */
 	if (x != logx || y != logy)
-		wresize(logwin, y, x);
+		bfg_wresize(logwin, y, x);
 }
 
 static void check_winsizes(void)
@@ -2383,10 +2405,10 @@ static void check_winsizes(void)
 		else
 			statusy = logstart;
 		logcursor = statusy + 1;
-		wresize(statuswin, statusy, x);
+		bfg_wresize(statuswin, statusy, x);
 		getmaxyx(mainwin, y, x);
 		y -= logcursor;
-		wresize(logwin, y, x);
+		bfg_wresize(logwin, y, x);
 		mvwin(logwin, logcursor, 0);
 		unlock_curses();
 	}