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

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jan 6 14:50:56 CST 2016


Module: wine
Branch: master
Commit: dfe42ca50652517db365bd1f02f848c7029072d5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=dfe42ca50652517db365bd1f02f848c7029072d5

Author: Sebastian Lackner <sebastian at fds-team.de>
Date:   Wed Jan  6 01:05:04 2016 +0100

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

Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/console.c       | 4 ++--
 dlls/kernel32/tests/console.c | 9 +++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index 3c53b52..85e4ba8 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -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;
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index f362415..43a4b75 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -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 */
 }




More information about the wine-cvs mailing list