A+
--
Eric Pouech
Name: wc_set ChangeLog: fixed behavior when changing both sb and win size, as the order of operation is important to keep sb always bigger than win License: X11 GenDate: 2003/02/23 09:18:57 UTC ModifiedFiles: programs/wineconsole/wineconsole.c AddedFiles: =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/programs/wineconsole/wineconsole.c,v retrieving revision 1.20 diff -u -u -r1.20 wineconsole.c --- programs/wineconsole/wineconsole.c 9 Jan 2003 06:01:51 -0000 1.20 +++ programs/wineconsole/wineconsole.c 23 Feb 2003 09:18:21 -0000 @@ -410,28 +410,89 @@ data->curcfg.def_attr = cfg->def_attr; SetConsoleTextAttribute(data->hConOut, cfg->def_attr); } - if (force || data->curcfg.sb_width != cfg->sb_width || - data->curcfg.sb_height != cfg->sb_height) - { - COORD c; + /* now let's look at the window / sb size changes... + * since the server checks that sb is always bigger than window, + * we have to take care of doing the operations in the right order + */ + /* a set of macros to make things easier to read + * The Test<A><B> macros test if the <A> (width/height) needs to be changed + * for <B> (window / ScreenBuffer) + * The Change<A><B> actually modify the <B> dimension of <A>. + */ +#define TstSBfWidth() (force || data->curcfg.sb_width != cfg->sb_width) +#define TstWinWidth() (force || data->curcfg.win_width != cfg->win_width) - c.X = cfg->sb_width; - c.Y = cfg->sb_height; +#define ChgSBfWidth() do {c.X = cfg->sb_width; \ + c.Y = data->curcfg.sb_height;\ + SetConsoleScreenBufferSize(data->hConOut, c);\ + } while (0) +#define ChgWinWidth() do {pos.Left = pos.Top = 0; \ + pos.Right = cfg->win_width - 1; \ + pos.Bottom = data->curcfg.win_height - 1; \ + SetConsoleWindowInfo(data->hConOut, FALSE, &pos);\ + } while (0) +#define TstSBfHeight() (force || data->curcfg.sb_height != cfg->sb_height) +#define TstWinHeight() (force || data->curcfg.win_height != cfg->win_height) + +/* 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 */ +#define ChgSBfHeight() do {c.X = cfg->sb_width; c.Y = cfg->sb_height; \ + SetConsoleScreenBufferSize(data->hConOut, c); \ + } while (0) +#define ChgWinHeight() do {pos.Left = pos.Top = 0; \ + pos.Right = cfg->win_width - 1; \ + pos.Bottom = cfg->win_height - 1; \ + SetConsoleWindowInfo(data->hConOut, FALSE, &pos);\ + } while (0) - /* this shall update (through notif) curcfg */ - SetConsoleScreenBufferSize(data->hConOut, c); - } - if (force || data->curcfg.win_width != cfg->win_width || - data->curcfg.win_height != cfg->win_height) + do { + COORD c; SMALL_RECT pos; - pos.Left = pos.Top = 0; - pos.Right = cfg->win_width - 1; - pos.Bottom = cfg->win_height - 1; - /* this shall update (through notif) curcfg */ - SetConsoleWindowInfo(data->hConOut, FALSE, &pos); - } + if (TstSBfWidth()) + { + if (TstWinWidth()) + { + /* we're changing both at the same time, do it in the right order */ + if (cfg->sb_width >= data->curcfg.win_width) + { + ChgSBfWidth(); ChgWinWidth(); + } + else + { + ChgWinWidth(); ChgSBfWidth(); + } + } + else ChgSBfWidth(); + } + else if (TstWinWidth()) ChgWinWidth(); + if (TstSBfHeight()) + { + if (TstWinHeight()) + { + if (cfg->sb_height >= data->curcfg.win_height) + { + ChgSBfHeight(); ChgWinHeight(); + } + else + { + ChgWinHeight(); ChgSBfHeight(); + } + } + else ChgSBfHeight(); + } + else if (TstWinHeight()) ChgWinHeight(); + } while (0); +#undef TstSBfWidth +#undef TstWinWidth +#undef ChgSBfWidth +#undef ChgWinWidth +#undef TstSBfHeight +#undef TstWinHeight +#undef ChgSBfHeight +#undef ChgWinHeight + data->curcfg.exit_on_die = cfg->exit_on_die; if (force || data->curcfg.edition_mode != cfg->edition_mode) {