From e6055c156f1861a12b72d136fe4008c655d05bc9 Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Sat, 6 Apr 2013 21:41:26 +1100 Subject: Get screen resolution for GetLargestConsoleWindowSize function --- dlls/kernel32/console.c | 56 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c index d6d1414..4f79685 100644 --- a/dlls/kernel32/console.c +++ b/dlls/kernel32/console.c @@ -61,6 +61,9 @@ #include "console_private.h" #include "kernel_private.h" +#include "winreg.h" +#include "wineconsole/winecon_private.h" + WINE_DEFAULT_DEBUG_CHANNEL(console); static CRITICAL_SECTION CONSOLE_CritSect; @@ -1362,6 +1365,33 @@ DWORD WINAPI GetConsoleTitleW(LPWSTR title, DWORD size) return ret; } +/*********************************************************************** + * GetLargestConsoleWindowSize_helper + */ +COORD GetLargestConsoleWindowSize_helper(HANDLE hConsoleOutput) +{ + struct config_data cfg; + COORD screensize; + COORD fontsize; + COORD max_console; + + WINECON_RegLoad(NULL, &cfg); + screensize.X = cfg.screen_width; + screensize.Y = cfg.screen_height; + + fontsize = GetConsoleFontSize(hConsoleOutput, 0); + + max_console.X = (screensize.X / fontsize.X) - 6; + max_console.Y = (screensize.Y / fontsize.Y) - 5; + + if (max_console.X < 0 || max_console.Y < 0) + { + max_console.X = 80; + max_console.Y = 25; + } + + return max_console; +} /*********************************************************************** * GetLargestConsoleWindowSize (KERNEL32.@) @@ -1380,8 +1410,7 @@ DWORD WINAPI GetLargestConsoleWindowSize(HANDLE hConsoleOutput) COORD c; DWORD w; } x; - x.c.X = 80; - x.c.Y = 24; + x.c = GetLargestConsoleWindowSize_helper(hConsoleOutput); TRACE("(%p), returning %dx%d (%x)\n", hConsoleOutput, x.c.X, x.c.Y, x.w); return x.w; } @@ -1401,8 +1430,7 @@ DWORD WINAPI GetLargestConsoleWindowSize(HANDLE hConsoleOutput) COORD WINAPI GetLargestConsoleWindowSize(HANDLE hConsoleOutput) { COORD c; - c.X = 80; - c.Y = 24; + c = GetLargestConsoleWindowSize_helper(hConsoleOutput); TRACE("(%p), returning %dx%d\n", hConsoleOutput, c.X, c.Y); return c; } @@ -3236,28 +3264,32 @@ BOOL WINAPI GetCurrentConsoleFont(HANDLE hConsole, BOOL maxwindow, LPCONSOLE_FON #undef GetConsoleFontSize DWORD WINAPI GetConsoleFontSize(HANDLE hConsole, DWORD font) { + struct config_data cfg; + union { COORD c; DWORD w; } x; - FIXME(": (%p, %d) stub!\n", hConsole, font); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + WINECON_RegLoad(NULL, &cfg); + + x.c.X = cfg.cell_width; + x.c.Y = cfg.cell_height; - x.c.X = 0; - x.c.Y = 0; return x.w; } #endif /* defined(__i386__) */ - #ifndef __i386__ COORD WINAPI GetConsoleFontSize(HANDLE hConsole, DWORD font) { + struct config_data cfg; COORD c; - c.X = 80; - c.Y = 24; - FIXME(": (%p, %d) stub!\n", hConsole, font); + WINECON_RegLoad(NULL, &cfg); + + c.X = cfg.cell_width; + c.Y = cfg.cell_height; + return c; } #endif /* defined(__i386__) */ -- 1.7.10.4