kernel32: Implementation of GetLargestConsoleWindowSize. 2nd ed.
Reijo Sund
reijo.sund at helsinki.fi
Fri May 2 10:31:16 CDT 2008
The function should return the largest available size instead of hard
coded constants. A fix for the bug 10919. Second edition.
---
dlls/kernel32/console.c | 64 ++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 60 insertions(+), 4 deletions(-)
diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index 21ce10a..71c0a01 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -1075,6 +1075,64 @@ DWORD WINAPI GetConsoleTitleW(LPWSTR title, DWORD size)
return ret;
}
+static inline COORD GetLargestConsoleWindowSize_helper(HANDLE hConOut)
+{
+ COORD c;
+ BOOL ret;
+ HWND hWnd;
+ /* Sensible values for variables even if server call fails */
+ int col=80,lin=24,colpix=640,linpix=480,colext=0,linext=0,maxcolpix=640,maxlinpix=480;
+
+ SERVER_START_REQ( get_console_output_info )
+ {
+ req->handle = console_handle_unmap(hConOut);
+ if ((ret = !wine_server_call_err( req ))) {
+ col = reply->win_right - reply->win_left + 1;
+ lin = reply->win_bottom - reply->win_top + 1;
+ }
+ }
+ SERVER_END_REQ;
+
+ hWnd = GetConsoleWindow();
+
+ SERVER_START_REQ( get_window_rectangles )
+ {
+ req->handle = hWnd;
+ if ((ret = !wine_server_call_err( req ))) {
+ colpix = reply->client.right - reply->client.left;
+ linpix = reply->client.bottom - reply->client.top;
+ colext = (reply->window.right - reply->window.left) - colpix;
+ linext = (reply->window.bottom - reply->window.top) - linpix;
+ }
+ }
+ SERVER_END_REQ;
+
+ SERVER_START_REQ( get_desktop_window )
+ {
+ req->force = 1;
+ if ((ret = !wine_server_call_err( req ))) {
+ hWnd = reply->handle;
+ }
+ }
+ SERVER_END_REQ;
+
+ SERVER_START_REQ( get_window_rectangles )
+ {
+ req->handle = hWnd;
+ if ((ret = !wine_server_call_err( req ))) {
+ maxcolpix = reply->window.right - reply->window.left - 2 * colext;
+ maxlinpix = reply->window.bottom - reply->window.top - 3 * linext;
+ }
+ }
+ SERVER_END_REQ;
+
+ c.X=80;
+ c.Y=24;
+ if (colpix > 0) c.X = maxcolpix*col/colpix;
+ if (linpix > 0) c.Y = maxlinpix*lin/linpix;
+
+ return c;
+}
/***********************************************************************
* GetLargestConsoleWindowSize (KERNEL32.@)
@@ -1093,8 +1151,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;
}
@@ -1114,8 +1171,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;
}
--
1.5.4.3
More information about the wine-patches
mailing list