Window resizing fixes - switching between resizable and non-resizable modes no longer distorts the renderer output, and moving the window while it's resizing should (hopefully) no longer trigger spurious resizes.
This commit is contained in:
8
src/pc.c
8
src/pc.c
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Main emulator module where most things are controlled.
|
* Main emulator module where most things are controlled.
|
||||||
*
|
*
|
||||||
* Version: @(#)pc.c 1.0.58 2018/02/10
|
* Version: @(#)pc.c 1.0.59 2018/02/14
|
||||||
*
|
*
|
||||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -166,9 +166,9 @@ int title_update;
|
|||||||
int64_t main_time;
|
int64_t main_time;
|
||||||
|
|
||||||
|
|
||||||
static int unscaled_size_x = SCREEN_RES_X, /* current unscaled size X */
|
int unscaled_size_x = SCREEN_RES_X, /* current unscaled size X */
|
||||||
unscaled_size_y = SCREEN_RES_Y, /* current unscaled size Y */
|
unscaled_size_y = SCREEN_RES_Y, /* current unscaled size Y */
|
||||||
efscrnsz_y = SCREEN_RES_Y;
|
efscrnsz_y = SCREEN_RES_Y;
|
||||||
|
|
||||||
|
|
||||||
static char buff[1024];
|
static char buff[1024];
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* user Interface module for WinAPI on Windows.
|
* user Interface module for WinAPI on Windows.
|
||||||
*
|
*
|
||||||
* Version: @(#)win_ui.c 1.0.18 2018/02/11
|
* Version: @(#)win_ui.c 1.0.19 2018/02/14
|
||||||
*
|
*
|
||||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -277,6 +277,8 @@ static LRESULT CALLBACK
|
|||||||
MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
HMENU hmenu;
|
HMENU hmenu;
|
||||||
|
|
||||||
|
int sb_borders[3];
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
|
||||||
switch (message) {
|
switch (message) {
|
||||||
@@ -343,14 +345,36 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
case IDM_VID_RESIZE:
|
case IDM_VID_RESIZE:
|
||||||
vid_resize = !vid_resize;
|
vid_resize = !vid_resize;
|
||||||
CheckMenuItem(hmenu, IDM_VID_RESIZE, (vid_resize)? MF_CHECKED : MF_UNCHECKED);
|
CheckMenuItem(hmenu, IDM_VID_RESIZE, (vid_resize)? MF_CHECKED : MF_UNCHECKED);
|
||||||
|
GetWindowRect(hwnd, &rect);
|
||||||
|
|
||||||
if (vid_resize)
|
if (vid_resize)
|
||||||
SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW) | WS_VISIBLE);
|
SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW) | WS_VISIBLE);
|
||||||
else
|
else
|
||||||
SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX) | WS_VISIBLE);
|
SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX) | WS_VISIBLE);
|
||||||
GetWindowRect(hwnd, &rect);
|
|
||||||
SetWindowPos(hwnd, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_FRAMECHANGED);
|
SendMessage(hwndSBAR, SB_GETBORDERS, 0, (LPARAM) sb_borders);
|
||||||
GetWindowRect(hwndSBAR,&rect);
|
|
||||||
SetWindowPos(hwndSBAR, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_FRAMECHANGED);
|
/* Main Window. */
|
||||||
|
MoveWindow(hwnd, rect.left, rect.top,
|
||||||
|
unscaled_size_x + (GetSystemMetrics(vid_resize ? SM_CXSIZEFRAME : SM_CXFIXEDFRAME) * 2),
|
||||||
|
unscaled_size_y + (GetSystemMetrics(SM_CYEDGE) * 2) + (GetSystemMetrics(vid_resize ? SM_CYSIZEFRAME : SM_CYFIXEDFRAME) * 2) + GetSystemMetrics(SM_CYMENUSIZE) + GetSystemMetrics(SM_CYCAPTION) + 17 + sb_borders[1] + 1,
|
||||||
|
TRUE);
|
||||||
|
|
||||||
|
/* Render window. */
|
||||||
|
MoveWindow(hwndRender, 0, 0, unscaled_size_x, unscaled_size_y, TRUE);
|
||||||
|
GetWindowRect(hwndRender, &rect);
|
||||||
|
|
||||||
|
/* Status bar. */
|
||||||
|
MoveWindow(hwndSBAR,
|
||||||
|
0, rect.bottom + GetSystemMetrics(SM_CYEDGE),
|
||||||
|
unscaled_size_x, 17, TRUE);
|
||||||
|
|
||||||
|
if (mouse_capture) {
|
||||||
|
GetWindowRect(hwndRender, &rect);
|
||||||
|
|
||||||
|
ClipCursor(&rect);
|
||||||
|
}
|
||||||
|
|
||||||
if (vid_resize) {
|
if (vid_resize) {
|
||||||
CheckMenuItem(hmenu, IDM_VID_SCALE_1X + scale, MF_UNCHECKED);
|
CheckMenuItem(hmenu, IDM_VID_SCALE_1X + scale, MF_UNCHECKED);
|
||||||
CheckMenuItem(hmenu, IDM_VID_SCALE_2X, MF_CHECKED);
|
CheckMenuItem(hmenu, IDM_VID_SCALE_2X, MF_CHECKED);
|
||||||
@@ -586,6 +610,9 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
|
if (!vid_resize)
|
||||||
|
break;
|
||||||
|
|
||||||
scrnsz_x = (lParam & 0xFFFF);
|
scrnsz_x = (lParam & 0xFFFF);
|
||||||
scrnsz_y = (lParam >> 16) - (17 + 6);
|
scrnsz_y = (lParam >> 16) - (17 + 6);
|
||||||
if (scrnsz_y < 0)
|
if (scrnsz_y < 0)
|
||||||
@@ -982,18 +1009,20 @@ pclog("PLAT: VID[%d,%d] resizing to %dx%d\n", video_fullscreen, vid_api, x, y);
|
|||||||
if (!vid_resize) {
|
if (!vid_resize) {
|
||||||
video_wait_for_blit();
|
video_wait_for_blit();
|
||||||
SendMessage(hwndSBAR, SB_GETBORDERS, 0, (LPARAM) sb_borders);
|
SendMessage(hwndSBAR, SB_GETBORDERS, 0, (LPARAM) sb_borders);
|
||||||
GetWindowRect(hwndMain, &r);
|
|
||||||
MoveWindow(hwndRender, 0, 0, x, y, TRUE);
|
|
||||||
GetWindowRect(hwndRender, &r);
|
|
||||||
MoveWindow(hwndSBAR,
|
|
||||||
0, r.bottom + GetSystemMetrics(SM_CYEDGE),
|
|
||||||
x, 17, TRUE);
|
|
||||||
GetWindowRect(hwndMain, &r);
|
|
||||||
|
|
||||||
|
GetWindowRect(hwndMain, &r);
|
||||||
MoveWindow(hwndMain, r.left, r.top,
|
MoveWindow(hwndMain, r.left, r.top,
|
||||||
x + (GetSystemMetrics(vid_resize ? SM_CXSIZEFRAME : SM_CXFIXEDFRAME) * 2),
|
x + (GetSystemMetrics(vid_resize ? SM_CXSIZEFRAME : SM_CXFIXEDFRAME) * 2),
|
||||||
y + (GetSystemMetrics(SM_CYEDGE) * 2) + (GetSystemMetrics(vid_resize ? SM_CYSIZEFRAME : SM_CYFIXEDFRAME) * 2) + GetSystemMetrics(SM_CYMENUSIZE) + GetSystemMetrics(SM_CYCAPTION) + 17 + sb_borders[1] + 1,
|
y + (GetSystemMetrics(SM_CYEDGE) * 2) + (GetSystemMetrics(vid_resize ? SM_CYSIZEFRAME : SM_CYFIXEDFRAME) * 2) + GetSystemMetrics(SM_CYMENUSIZE) + GetSystemMetrics(SM_CYCAPTION) + 17 + sb_borders[1] + 1,
|
||||||
TRUE);
|
TRUE);
|
||||||
|
GetWindowRect(hwndMain, &r);
|
||||||
|
|
||||||
|
MoveWindow(hwndRender, 0, 0, x, y, TRUE);
|
||||||
|
GetWindowRect(hwndRender, &r);
|
||||||
|
|
||||||
|
MoveWindow(hwndSBAR,
|
||||||
|
0, r.bottom + GetSystemMetrics(SM_CYEDGE),
|
||||||
|
x, 17, TRUE);
|
||||||
|
|
||||||
if (mouse_capture) {
|
if (mouse_capture) {
|
||||||
GetWindowRect(hwndRender, &r);
|
GetWindowRect(hwndRender, &r);
|
||||||
|
|||||||
Reference in New Issue
Block a user