Commit 544dbb51 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

wineconsole: Properly manage window position (in wineconsole) from within wineserver.

parent b53edc6d
...@@ -422,17 +422,16 @@ static void WCCURSES_SetFont(struct inner_data* data, const WCHAR* font, ...@@ -422,17 +422,16 @@ static void WCCURSES_SetFont(struct inner_data* data, const WCHAR* font,
*/ */
static void WCCURSES_ScrollV(struct inner_data* data, int delta) static void WCCURSES_ScrollV(struct inner_data* data, int delta)
{ {
int pos = data->curcfg.win_pos.Y; struct config_data cfg = data->curcfg;
pos += delta; cfg.win_pos.Y += delta;
if (pos < 0) pos = 0; if (cfg.win_pos.Y < 0) cfg.win_pos.Y = 0;
if (pos > data->curcfg.sb_height - data->curcfg.win_height) if (cfg.win_pos.Y > data->curcfg.sb_height - data->curcfg.win_height)
pos = data->curcfg.sb_height - data->curcfg.win_height; cfg.win_pos.Y = data->curcfg.sb_height - data->curcfg.win_height;
if (pos != data->curcfg.win_pos.Y) if (cfg.win_pos.Y != data->curcfg.win_pos.Y)
{ {
data->curcfg.win_pos.Y = pos;
WCCURSES_PosCursor(data); WCCURSES_PosCursor(data);
WINECON_NotifyWindowChange(data); WINECON_SetConfig(data, &cfg);
} }
} }
......
...@@ -800,11 +800,13 @@ static void WCUSER_Scroll(struct inner_data* data, int pos, BOOL horz) ...@@ -800,11 +800,13 @@ static void WCUSER_Scroll(struct inner_data* data, int pos, BOOL horz)
{ {
if (horz) if (horz)
{ {
ScrollWindow(data->hWnd, (data->curcfg.win_pos.X - pos) * data->curcfg.cell_width, 0, NULL, NULL);
SetScrollPos(data->hWnd, SB_HORZ, pos, TRUE); SetScrollPos(data->hWnd, SB_HORZ, pos, TRUE);
data->curcfg.win_pos.X = pos; data->curcfg.win_pos.X = pos;
} }
else else
{ {
ScrollWindow(data->hWnd, 0, (data->curcfg.win_pos.Y - pos) * data->curcfg.cell_height, NULL, NULL);
SetScrollPos(data->hWnd, SB_VERT, pos, TRUE); SetScrollPos(data->hWnd, SB_VERT, pos, TRUE);
data->curcfg.win_pos.Y = pos; data->curcfg.win_pos.Y = pos;
} }
...@@ -1211,29 +1213,23 @@ static LRESULT CALLBACK WCUSER_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM ...@@ -1211,29 +1213,23 @@ static LRESULT CALLBACK WCUSER_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
break; break;
case WM_HSCROLL: case WM_HSCROLL:
{ {
int pos = data->curcfg.win_pos.X; struct config_data cfg = data->curcfg;
switch (LOWORD(wParam)) switch (LOWORD(wParam))
{ {
case SB_PAGEUP: pos -= 8; break; case SB_PAGEUP: cfg.win_pos.X -= 8; break;
case SB_PAGEDOWN: pos += 8; break; case SB_PAGEDOWN: cfg.win_pos.X += 8; break;
case SB_LINEUP: pos--; break; case SB_LINEUP: cfg.win_pos.X--; break;
case SB_LINEDOWN: pos++; break; case SB_LINEDOWN: cfg.win_pos.X++; break;
case SB_THUMBTRACK: pos = HIWORD(wParam); break; case SB_THUMBTRACK: cfg.win_pos.X = HIWORD(wParam); break;
default: break; default: break;
} }
if (pos < 0) pos = 0; if (cfg.win_pos.X < 0) cfg.win_pos.X = 0;
if (pos > data->curcfg.sb_width - data->curcfg.win_width) if (cfg.win_pos.X > data->curcfg.sb_width - data->curcfg.win_width)
pos = data->curcfg.sb_width - data->curcfg.win_width; cfg.win_pos.X = data->curcfg.sb_width - data->curcfg.win_width;
if (pos != data->curcfg.win_pos.X) if (cfg.win_pos.X != data->curcfg.win_pos.X)
{ {
ScrollWindow(hWnd, (data->curcfg.win_pos.X - pos) * data->curcfg.cell_width, 0, WINECON_SetConfig(data, &cfg);
NULL, NULL);
data->curcfg.win_pos.X = pos;
SetScrollPos(hWnd, SB_HORZ, pos, TRUE);
UpdateWindow(hWnd);
WCUSER_PosCursor(data);
WINECON_NotifyWindowChange(data);
} }
} }
break; break;
...@@ -1246,40 +1242,33 @@ static LRESULT CALLBACK WCUSER_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM ...@@ -1246,40 +1242,33 @@ static LRESULT CALLBACK WCUSER_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
/* else fallthrough */ /* else fallthrough */
case WM_VSCROLL: case WM_VSCROLL:
{ {
int pos = data->curcfg.win_pos.Y; struct config_data cfg = data->curcfg;
if (uMsg == WM_MOUSEWHEEL) if (uMsg == WM_MOUSEWHEEL)
{ {
UINT scrollLines = 3; UINT scrollLines = 3;
SystemParametersInfoW(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0); SystemParametersInfoW(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0);
scrollLines *= -GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA; scrollLines *= -GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA;
pos += scrollLines; cfg.win_pos.Y += scrollLines;
} else { } else {
switch (LOWORD(wParam)) switch (LOWORD(wParam))
{ {
case SB_PAGEUP: pos -= 8; break; case SB_PAGEUP: cfg.win_pos.Y -= 8; break;
case SB_PAGEDOWN: pos += 8; break; case SB_PAGEDOWN: cfg.win_pos.Y += 8; break;
case SB_LINEUP: pos--; break; case SB_LINEUP: cfg.win_pos.Y--; break;
case SB_LINEDOWN: pos++; break; case SB_LINEDOWN: cfg.win_pos.Y++; break;
case SB_THUMBTRACK: pos = HIWORD(wParam); break; case SB_THUMBTRACK: cfg.win_pos.Y = HIWORD(wParam); break;
default: break; default: break;
} }
} }
if (pos < 0) pos = 0; if (cfg.win_pos.Y < 0) cfg.win_pos.Y = 0;
if (pos > data->curcfg.sb_height - data->curcfg.win_height) if (cfg.win_pos.Y > data->curcfg.sb_height - data->curcfg.win_height)
pos = data->curcfg.sb_height - data->curcfg.win_height; cfg.win_pos.Y = data->curcfg.sb_height - data->curcfg.win_height;
if (pos != data->curcfg.win_pos.Y) if (cfg.win_pos.Y != data->curcfg.win_pos.Y)
{ {
ScrollWindow(hWnd, 0, (data->curcfg.win_pos.Y - pos) * data->curcfg.cell_height, WINECON_SetConfig(data, &cfg);
NULL, NULL);
data->curcfg.win_pos.Y = pos;
SetScrollPos(hWnd, SB_VERT, pos, TRUE);
UpdateWindow(hWnd);
WCUSER_PosCursor(data);
WINECON_NotifyWindowChange(data);
} }
} }
break; break;
case WM_SYSCOMMAND: case WM_SYSCOMMAND:
......
...@@ -77,7 +77,6 @@ struct inner_data { ...@@ -77,7 +77,6 @@ struct inner_data {
/* from wineconsole.c */ /* from wineconsole.c */
extern void WINECON_Fatal(const char* msg); extern void WINECON_Fatal(const char* msg);
extern void WINECON_NotifyWindowChange(struct inner_data* data);
extern int WINECON_GetHistorySize(HANDLE hConIn); extern int WINECON_GetHistorySize(HANDLE hConIn);
extern int WINECON_GetHistoryMode(HANDLE hConIn); extern int WINECON_GetHistoryMode(HANDLE hConIn);
extern BOOL WINECON_GetConsoleTitle(HANDLE hConIn, WCHAR* buffer, size_t len); extern BOOL WINECON_GetConsoleTitle(HANDLE hConIn, WCHAR* buffer, size_t len);
......
...@@ -82,26 +82,6 @@ static void WINECON_FetchCells(struct inner_data* data, int upd_tp, int upd_bm) ...@@ -82,26 +82,6 @@ static void WINECON_FetchCells(struct inner_data* data, int upd_tp, int upd_bm)
} }
/****************************************************************** /******************************************************************
* WINECON_NotifyWindowChange
*
* Inform server that visible window on sb has changed
*/
void WINECON_NotifyWindowChange(struct inner_data* data)
{
SERVER_START_REQ( set_console_output_info )
{
req->handle = wine_server_obj_handle( data->hConOut );
req->win_left = data->curcfg.win_pos.X;
req->win_top = data->curcfg.win_pos.Y;
req->win_right = data->curcfg.win_pos.X + data->curcfg.win_width - 1;
req->win_bottom = data->curcfg.win_pos.Y + data->curcfg.win_height - 1;
req->mask = SET_CONSOLE_OUTPUT_INFO_DISPLAY_WINDOW;
wine_server_call( req );
}
SERVER_END_REQ;
}
/******************************************************************
* WINECON_SetHistorySize * WINECON_SetHistorySize
* *
* *
...@@ -402,28 +382,30 @@ void WINECON_SetConfig(struct inner_data* data, const struct config_data* cf ...@@ -402,28 +382,30 @@ void WINECON_SetConfig(struct inner_data* data, const struct config_data* cf
* The Change<A><B> actually modify the <B> dimension of <A>. * The Change<A><B> actually modify the <B> dimension of <A>.
*/ */
#define TstSBfWidth() (data->curcfg.sb_width != cfg->sb_width) #define TstSBfWidth() (data->curcfg.sb_width != cfg->sb_width)
#define TstWinWidth() (data->curcfg.win_width != cfg->win_width) #define TstWinHPos() (data->curcfg.win_width != cfg->win_width || data->curcfg.win_pos.X != cfg->win_pos.X)
#define ChgSBfWidth() do {c.X = cfg->sb_width; \ #define ChgSBfWidth() do {c.X = cfg->sb_width; \
c.Y = data->curcfg.sb_height;\ c.Y = data->curcfg.sb_height;\
SetConsoleScreenBufferSize(data->hConOut, c);\ SetConsoleScreenBufferSize(data->hConOut, c);\
} while (0) } while (0)
#define ChgWinWidth() do {pos.Left = pos.Top = 0; \ #define ChgWinHPos() do {pos.Left = cfg->win_pos.X - data->curcfg.win_pos.X; \
pos.Right = cfg->win_width - data->curcfg.win_width; \ pos.Top = 0; \
pos.Right = pos.Left + cfg->win_width - data->curcfg.win_width; \
pos.Bottom = 0; \ pos.Bottom = 0; \
SetConsoleWindowInfo(data->hConOut, FALSE, &pos);\ SetConsoleWindowInfo(data->hConOut, FALSE, &pos);\
} while (0) } while (0)
#define TstSBfHeight() (data->curcfg.sb_height != cfg->sb_height) #define TstSBfHeight() (data->curcfg.sb_height != cfg->sb_height)
#define TstWinHeight() (data->curcfg.win_height != cfg->win_height) #define TstWinVPos() (data->curcfg.win_height != cfg->win_height || data->curcfg.win_pos.Y != cfg->win_pos.Y)
/* since we're going to apply height after width is done, we use width as defined /* since we're going to apply height after width is done, we use width as defined
* in cfg, and not in data->curcfg because if won't be updated yet */ * in cfg, and not in data->curcfg because if won't be updated yet */
#define ChgSBfHeight() do {c.X = cfg->sb_width; c.Y = cfg->sb_height; \ #define ChgSBfHeight() do {c.X = cfg->sb_width; c.Y = cfg->sb_height; \
SetConsoleScreenBufferSize(data->hConOut, c); \ SetConsoleScreenBufferSize(data->hConOut, c); \
} while (0) } while (0)
#define ChgWinHeight() do {pos.Left = pos.Top = 0; \ #define ChgWinVPos() do {pos.Left = 0; \
pos.Top = cfg->win_pos.Y - data->curcfg.win_pos.Y; \
pos.Right = 0; \ pos.Right = 0; \
pos.Bottom = cfg->win_height - data->curcfg.win_height; \ pos.Bottom = pos.Top + cfg->win_height - data->curcfg.win_height; \
SetConsoleWindowInfo(data->hConOut, FALSE, &pos);\ SetConsoleWindowInfo(data->hConOut, FALSE, &pos);\
} while (0) } while (0)
...@@ -434,46 +416,46 @@ void WINECON_SetConfig(struct inner_data* data, const struct config_data* cf ...@@ -434,46 +416,46 @@ void WINECON_SetConfig(struct inner_data* data, const struct config_data* cf
if (TstSBfWidth()) if (TstSBfWidth())
{ {
if (TstWinWidth()) if (TstWinHPos())
{ {
/* we're changing both at the same time, do it in the right order */ /* we're changing both at the same time, do it in the right order */
if (cfg->sb_width >= data->curcfg.win_width) if (cfg->sb_width >= data->curcfg.win_width)
{ {
ChgSBfWidth(); ChgWinWidth(); ChgSBfWidth(); ChgWinHPos();
} }
else else
{ {
ChgWinWidth(); ChgSBfWidth(); ChgWinHPos(); ChgSBfWidth();
} }
} }
else ChgSBfWidth(); else ChgSBfWidth();
} }
else if (TstWinWidth()) ChgWinWidth(); else if (TstWinHPos()) ChgWinHPos();
if (TstSBfHeight()) if (TstSBfHeight())
{ {
if (TstWinHeight()) if (TstWinVPos())
{ {
if (cfg->sb_height >= data->curcfg.win_height) if (cfg->sb_height >= data->curcfg.win_height)
{ {
ChgSBfHeight(); ChgWinHeight(); ChgSBfHeight(); ChgWinVPos();
} }
else else
{ {
ChgWinHeight(); ChgSBfHeight(); ChgWinVPos(); ChgSBfHeight();
} }
} }
else ChgSBfHeight(); else ChgSBfHeight();
} }
else if (TstWinHeight()) ChgWinHeight(); else if (TstWinVPos()) ChgWinVPos();
} while (0); } while (0);
#undef TstSBfWidth #undef TstSBfWidth
#undef TstWinWidth #undef TstWinHPos
#undef ChgSBfWidth #undef ChgSBfWidth
#undef ChgWinWidth #undef ChgWinHPos
#undef TstSBfHeight #undef TstSBfHeight
#undef TstWinHeight #undef TstWinVPos
#undef ChgSBfHeight #undef ChgSBfHeight
#undef ChgWinHeight #undef ChgWinVPos
data->curcfg.exit_on_die = cfg->exit_on_die; data->curcfg.exit_on_die = cfg->exit_on_die;
if (data->curcfg.edition_mode != cfg->edition_mode) if (data->curcfg.edition_mode != cfg->edition_mode)
......
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