kernel32: Clamp maximum console window size to screen buffer size.

Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Sebastian Lackner 2016-01-06 01:05:04 +01:00 committed by Alexandre Julliard
parent 9171865661
commit dfe42ca506
2 changed files with 11 additions and 2 deletions

View File

@ -2160,8 +2160,8 @@ BOOL WINAPI GetConsoleScreenBufferInfo(HANDLE hConsoleOutput, LPCONSOLE_SCREEN_B
csbi->srWindow.Right = reply->win_right;
csbi->srWindow.Top = reply->win_top;
csbi->srWindow.Bottom = reply->win_bottom;
csbi->dwMaximumWindowSize.X = reply->max_width;
csbi->dwMaximumWindowSize.Y = reply->max_height;
csbi->dwMaximumWindowSize.X = min(reply->width, reply->max_width);
csbi->dwMaximumWindowSize.Y = min(reply->height, reply->max_height);
}
}
SERVER_END_REQ;

View File

@ -2686,9 +2686,11 @@ static void test_GetLargestConsoleWindowSize(HANDLE std_output)
COORD c, font;
RECT r;
LONG workarea_w, workarea_h, maxcon_w, maxcon_h;
CONSOLE_SCREEN_BUFFER_INFO sbi;
CONSOLE_FONT_INFO cfi;
DWORD index, i;
HMODULE hmod;
BOOL ret;
DWORD (WINAPI *pGetNumberOfConsoleFonts)(void);
BOOL (WINAPI *pSetConsoleFont)(HANDLE, DWORD);
@ -2740,6 +2742,13 @@ static void test_GetLargestConsoleWindowSize(HANDLE std_output)
maxcon_h = workarea_h / font.Y;
ok(c.X == maxcon_w || c.X == maxcon_w - 1 /* Win10 */, "got %d, expected %d\n", c.X, maxcon_w);
ok(c.Y == maxcon_h || c.Y == maxcon_h - 1 /* Win10 */, "got %d, expected %d\n", c.Y, maxcon_h);
ret = GetConsoleScreenBufferInfo(std_output, &sbi);
ok(ret, "GetConsoleScreenBufferInfo failed %u\n", GetLastError());
ok(sbi.dwMaximumWindowSize.X == min(c.X, sbi.dwSize.X), "got %d, expected %d\n",
sbi.dwMaximumWindowSize.X, min(c.X, sbi.dwSize.X));
ok(sbi.dwMaximumWindowSize.Y == min(c.Y, sbi.dwSize.Y), "got %d, expected %d\n",
sbi.dwMaximumWindowSize.Y, min(c.Y, sbi.dwSize.Y));
}
pSetConsoleFont(std_output, index); /* restore original font size */
}