From 54b0a7f98deef149bc46dabc51be3ddea54c4626 Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Fri, 29 Nov 2013 13:44:30 +1100 Subject: wineconsole-server --- dlls/kernel32/console.c | 29 ++++++++++++++++++++++++----- programs/wineconsole/wineconsole.c | 9 +++++++++ server/console.c | 11 +++++++++++ server/protocol.def | 6 +++++- 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c index 4f0ed09..359c841 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->maxconwin_w; + c.Y = reply->maxconwin_h; + } + } + 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; } @@ -1402,9 +1423,7 @@ DWORD WINAPI GetLargestConsoleWindowSize(HANDLE hConsoleOutput) #ifndef __i386__ COORD WINAPI GetLargestConsoleWindowSize(HANDLE hConsoleOutput) { - COORD c; - c.X = 80; - c.Y = 24; + COORD 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 5b67103..199d87e 100644 --- a/programs/wineconsole/wineconsole.c +++ b/programs/wineconsole/wineconsole.c @@ -412,6 +412,15 @@ void WINECON_SetConfig(struct inner_data* data, const struct config_data* cf SetConsoleTextAttribute(data->hConOut, cfg->def_attr); } maxconwin = data->fnGetMaxConsoleWindowSize(cfg->cell_width, cfg->cell_height); + SERVER_START_REQ(set_console_output_info) + { + req->handle = wine_server_obj_handle(data->hConOut); + req->maxconwin_w = maxconwin.X; + req->maxconwin_h = maxconwin.Y; + req->mask = SET_CONSOLE_OUTPUT_INFO_MAXCONWIN_SIZE; + wine_server_call(req); + } + SERVER_END_REQ; window_width = cfg->sb_width > maxconwin.X ? maxconwin.X : cfg->sb_width; window_height = cfg->sb_height > maxconwin.Y ? maxconwin.Y : cfg->sb_height; diff --git a/server/console.c b/server/console.c index 2a5ca80..709d7af 100644 --- a/server/console.c +++ b/server/console.c @@ -139,6 +139,8 @@ struct screen_buffer unsigned short attr; /* default attribute for screen buffer */ rectangle_t win; /* current visible window on the screen buffer * * as seen in wineconsole */ + int maxconwin_w; /* size (w-h) of the largest possible console window */ + int maxconwin_h; struct fd *fd; /* for bare console, attached output fd */ }; @@ -402,6 +404,8 @@ static struct screen_buffer *create_console_output( struct console_input *consol screen_buffer->win.right = screen_buffer->max_width - 1; screen_buffer->win.top = 0; screen_buffer->win.bottom = screen_buffer->max_height - 1; + screen_buffer->maxconwin_w = 80; + screen_buffer->maxconwin_h = 25; if (fd == -1) screen_buffer->fd = NULL; else @@ -1011,6 +1015,11 @@ static int set_console_output_info( struct screen_buffer *screen_buffer, screen_buffer->max_width = req->max_width; screen_buffer->max_height = req->max_height; } + if (req->mask & SET_CONSOLE_OUTPUT_INFO_MAXCONWIN_SIZE) + { + screen_buffer->maxconwin_w = req->maxconwin_w; + screen_buffer->maxconwin_h = req->maxconwin_h; + } return 1; } @@ -1660,6 +1669,8 @@ DECL_HANDLER(get_console_output_info) reply->win_bottom = screen_buffer->win.bottom; reply->max_width = screen_buffer->max_width; reply->max_height = screen_buffer->max_height; + reply->maxconwin_w = screen_buffer->maxconwin_w; + reply->maxconwin_h = screen_buffer->maxconwin_h; release_object( screen_buffer ); } } diff --git a/server/protocol.def b/server/protocol.def index 8c5f953..94a5eba 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1446,6 +1446,8 @@ struct console_renderer_event short int win_bottom; short int max_width; /* maximum size (width x height) for the window */ short int max_height; + short int maxconwin_w; /* width of the largest possible console window */ + short int maxconwin_h; /* height of the largest possible console window */ @END #define SET_CONSOLE_OUTPUT_INFO_CURSOR_GEOM 0x01 #define SET_CONSOLE_OUTPUT_INFO_CURSOR_POS 0x02 @@ -1453,7 +1455,7 @@ struct console_renderer_event #define SET_CONSOLE_OUTPUT_INFO_ATTR 0x08 #define SET_CONSOLE_OUTPUT_INFO_DISPLAY_WINDOW 0x10 #define SET_CONSOLE_OUTPUT_INFO_MAX_SIZE 0x20 - +#define SET_CONSOLE_OUTPUT_INFO_MAXCONWIN_SIZE 0x40 /* Get info about a console (output only) */ @REQ(get_console_output_info) @@ -1472,6 +1474,8 @@ struct console_renderer_event short int win_bottom; short int max_width; /* maximum size (width x height) for the window */ short int max_height; + short int maxconwin_w; /* width of the largest possible console window */ + short int maxconwin_h; /* height of the largest possible console window */ @END /* Add input records to a console input queue */ -- 1.7.10.4