I'm trying to learn ncurses writting code in C++. I use Linux Mint and g++ for compiling. I've written the below code. I have two subwindows created with newwin() that always keep their size. What i want is when i shrink the window and then expand nothing to change. When i shrink horizontally and then expand, the windows edges are drawn as expected, nothing is corrupted. But when i do the same thing vertically it looks like a scrolling is done and blank lines are added below. Why does this happen when the change is vertical but when it's horizontal everything is fine?
#include <ncurses.h>
#include <signal.h>
WINDOW * mainWin;
WINDOW * sideWin;
void resizeHandler(int);
int main()
{
int mainwinStartX = 0;
int mainwinStartY = 0;
int mainwinWidth;
int mainwinHeight;
int sidewinStartX;
int sidewinStartY = 0;
int sidewinWidth;
int sidewinHeight;
signal(SIGWINCH, resizeHandler);
initscr();
noecho();
refresh();
// Prepairing mainWin sizes
mainwinWidth = float(2)/3 * COLS;
mainwinHeight = LINES;
// Prepairing side win sizes
sidewinStartX = mainwinWidth;
sidewinWidth = COLS - mainwinWidth;
sidewinHeight = LINES;
// creating window objects
mainWin = newwin(mainwinHeight, mainwinWidth, mainwinStartY, mainwinStartX);
sideWin = newwin(sidewinHeight, sidewinWidth, sidewinStartY, sidewinStartX);
box(mainWin, 0, 0);
box(sideWin, 0, 0);
wrefresh(mainWin);
wrefresh(sideWin);
while (getch() != 'x'){}
endwin();
return 0;
}
void resizeHandler(int sigNumber){}