From 44913ff4a312e97fc7695bbb96fd002ce97a40e9 Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Tue, 29 Oct 2013 21:49:43 +1100 Subject: winecon-server --- dlls/kernel32/console.c | 28 ++++++++++++++++++++++++---- programs/wineconsole/wineconsole.c | 33 +++++++++++++++++++-------------- server/console.c | 2 ++ server/protocol.def | 2 ++ 4 files changed, 47 insertions(+), 18 deletions(-) diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c index 4f0ed09..316c39e 100644 --- a/dlls/kernel32/console.c +++ b/dlls/kernel32/console.c @@ -1364,6 +1364,28 @@ DWORD WINAPI GetConsoleTitleW(LPWSTR title, DWORD size) return ret; } +/*********************************************************************** + * GetMaxConsoleWindowSize + * + * Helper function for GetLargestConsoleWindowSize + */ +static COORD GetMaxConsoleWindowSize(HANDLE hConsoleOutput) +{ + COORD c; + + SERVER_START_REQ(get_console_output_info) + { + req->handle = console_handle_unmap(hConsoleOutput); + if (!wine_server_call_err(req)) + { + c.X = reply->max_width; + c.Y = reply->max_height; + } + } + SERVER_END_REQ; + + return c; +} /*********************************************************************** * GetLargestConsoleWindowSize (KERNEL32.@) @@ -1382,8 +1404,7 @@ DWORD WINAPI GetLargestConsoleWindowSize(HANDLE hConsoleOutput) COORD c; DWORD w; } x; - x.c.X = 80; - x.c.Y = 24; + x.c = GetMaxConsoleWindowSize(hConsoleOutput); TRACE("(%p), returning %dx%d (%x)\n", hConsoleOutput, x.c.X, x.c.Y, x.w); return x.w; } @@ -1403,8 +1424,7 @@ DWORD WINAPI GetLargestConsoleWindowSize(HANDLE hConsoleOutput) COORD WINAPI GetLargestConsoleWindowSize(HANDLE hConsoleOutput) { COORD c; - c.X = 80; - c.Y = 24; + c = GetMaxConsoleWindowSize(hConsoleOutput); TRACE("(%p), returning %dx%d\n", hConsoleOutput, c.X, c.Y); return c; } diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c index 5f01095..f838313 100644 --- a/programs/wineconsole/wineconsole.c +++ b/programs/wineconsole/wineconsole.c @@ -583,6 +583,7 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna DWORD ret; struct config_data cfg; STARTUPINFOW si; + COORD max_window; data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data)); if (!data) return 0; @@ -632,20 +633,6 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna if (!ret) goto error; WINE_TRACE("using hConIn %p, hSynchro event %p\n", data->hConIn, data->hSynchro); - SERVER_START_REQ(create_console_output) - { - req->handle_in = wine_server_obj_handle( data->hConIn ); - req->access = GENERIC_WRITE|GENERIC_READ; - req->attributes = 0; - req->share = FILE_SHARE_READ|FILE_SHARE_WRITE; - req->fd = -1; - ret = !wine_server_call_err( req ); - data->hConOut = wine_server_ptr_handle( reply->handle_out ); - } - SERVER_END_REQ; - if (!ret) goto error; - WINE_TRACE("using hConOut %p\n", data->hConOut); - /* filling data->curcfg from cfg */ switch ((*backend)(data)) { @@ -660,6 +647,24 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna } /* fall through */ case init_success: + max_window = data->fnSetMaxWindowSize(cfg.cell_width, cfg.cell_height); + + SERVER_START_REQ(create_console_output) + { + req->handle_in = wine_server_obj_handle( data->hConIn ); + req->access = GENERIC_WRITE|GENERIC_READ; + req->attributes = 0; + req->share = FILE_SHARE_READ|FILE_SHARE_WRITE; + req->fd = -1; + req->max_width = max_window.X; + req->max_height = max_window.Y; + ret = !wine_server_call_err( req ); + data->hConOut = wine_server_ptr_handle( reply->handle_out ); + } + SERVER_END_REQ; + if (!ret) goto error; + WINE_TRACE("using hConOut %p\n", data->hConOut); + WINECON_GetServerConfig(data); data->cells = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, data->curcfg.sb_width * data->curcfg.sb_height * sizeof(CHAR_INFO)); diff --git a/server/console.c b/server/console.c index 2a5ca80..989b4d8 100644 --- a/server/console.c +++ b/server/console.c @@ -1618,6 +1618,8 @@ DECL_HANDLER(create_console_output) screen_buffer = create_console_output( console, fd ); if (screen_buffer) { + screen_buffer->max_width = req->max_width; + screen_buffer->max_height = req->max_height; /* FIXME: should store sharing and test it when opening the CONOUT$ device * see file.c on how this could be done */ reply->handle_out = alloc_handle( current->process, screen_buffer, req->access, req->attributes ); diff --git a/server/protocol.def b/server/protocol.def index 95d7994..7bdbfeb 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1423,6 +1423,8 @@ struct console_renderer_event unsigned int attributes; /* object attributes */ unsigned int share; /* sharing credentials */ int fd; /* for bare consoles, fd the screen-buffer is attached to */ + short int max_width; /* maximum width of the console window */ + short int max_height; /* maximum height of the console window */ @REPLY obj_handle_t handle_out; /* handle to the screen buffer */ @END -- 1.7.10.4