Commit 70f24d6c authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

wineconsole: Properly handle (user)-window resizing wrt the console.

parent 544dbb51
......@@ -778,6 +778,7 @@ static void WCUSER_Paint(const struct inner_data* data)
{
PAINTSTRUCT ps;
if (data->in_set_config) return; /* in order to avoid some flicker */
BeginPaint(data->hWnd, &ps);
BitBlt(ps.hdc, 0, 0,
data->curcfg.win_width * data->curcfg.cell_width,
......@@ -1329,6 +1330,10 @@ static LRESULT CALLBACK WCUSER_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
if (!HIWORD(lParam)) return DefWindowProcW(hWnd, uMsg, wParam, lParam);
WCUSER_SetMenuDetails(data, GetSystemMenu(data->hWnd, FALSE));
break;
case WM_SIZE:
WINECON_ResizeWithContainer(data, LOWORD(lParam) / data->curcfg.cell_width,
HIWORD(lParam) / data->curcfg.cell_height);
break;
default:
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
}
......
......@@ -60,6 +60,7 @@ struct inner_data {
HANDLE hSynchro; /* waitable handle signalled by server when something in server has been modified */
HWND hWnd; /* handle of 'user' window or NULL for 'curses' */
INT nCmdShow; /* argument of WinMain */
BOOL in_set_config; /* to handle re-entrant calls to WINECON_SetConfig */
int (*fnMainLoop)(struct inner_data* data);
void (*fnPosCursor)(const struct inner_data* data);
......@@ -77,6 +78,7 @@ struct inner_data {
/* from wineconsole.c */
extern void WINECON_Fatal(const char* msg);
extern void WINECON_ResizeWithContainer(struct inner_data* data, int width, int height);
extern int WINECON_GetHistorySize(HANDLE hConIn);
extern int WINECON_GetHistoryMode(HANDLE hConIn);
extern BOOL WINECON_GetConsoleTitle(HANDLE hConIn, WCHAR* buffer, size_t len);
......
......@@ -82,6 +82,34 @@ static void WINECON_FetchCells(struct inner_data* data, int upd_tp, int upd_bm)
}
/******************************************************************
* WINECON_ResizeWithContainer
*
* For console embedded in a container (e.g. user in a win32 window, or (n)curses
* in a TERM, perform resize of console (screen buffer and window) to fit in
* (new) container size.
*/
void WINECON_ResizeWithContainer(struct inner_data* data, int width, int height)
{
struct config_data cfg;
if (data->in_set_config) return;
cfg = data->curcfg;
cfg.win_width = width;
cfg.win_height = height;
/* auto size screen-buffer if it's now smaller than window */
if (cfg.sb_width < cfg.win_width) cfg.sb_width = cfg.win_width;
if (cfg.sb_height < cfg.win_height) cfg.sb_height = cfg.win_height;
/* and reset window pos so that we don't display outside of the screen-buffer */
if (cfg.win_pos.X + cfg.win_width > cfg.sb_width) cfg.win_pos.X = cfg.sb_width - cfg.win_width;
if (cfg.win_pos.Y + cfg.win_height > cfg.sb_height) cfg.win_pos.Y = cfg.sb_height - cfg.win_height;
WINECON_SetConfig(data, &cfg);
}
/******************************************************************
* WINECON_SetHistorySize
*
*
......@@ -336,6 +364,8 @@ int WINECON_GrabChanges(struct inner_data* data)
*/
void WINECON_SetConfig(struct inner_data* data, const struct config_data* cfg)
{
if (data->in_set_config) return;
data->in_set_config = TRUE;
if (data->curcfg.cursor_size != cfg->cursor_size ||
data->curcfg.cursor_visible != cfg->cursor_visible)
{
......@@ -467,6 +497,7 @@ void WINECON_SetConfig(struct inner_data* data, const struct config_data* cf
* in order to get data correctly updated
*/
WINECON_GrabChanges(data);
data->in_set_config = FALSE;
}
/******************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment