Attempt to fix the UI gliches on Windows Clang build
Where the main window keeps getting smaller while moving around, and the mouse can get out of the guest when grabbed.
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* user Interface module for WinAPI on Windows.
|
* user Interface module for WinAPI on Windows.
|
||||||
*
|
*
|
||||||
* Version: @(#)win_ui.c 1.0.38 2018/11/18
|
* Version: @(#)win_ui.c 1.0.39 2019/3/20
|
||||||
*
|
*
|
||||||
* 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>
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
* Copyright 2008-2018 Sarah Walker.
|
* Copyright 2008-2018 Sarah Walker.
|
||||||
* Copyright 2016-2018 Miran Grca.
|
* Copyright 2016-2018 Miran Grca.
|
||||||
* Copyright 2017,2018 Fred N. van Kempen.
|
* Copyright 2017,2018 Fred N. van Kempen.
|
||||||
|
* Copyright 2019 GH Cao.
|
||||||
*/
|
*/
|
||||||
#define UNICODE
|
#define UNICODE
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@@ -50,6 +51,7 @@ HWND hwndMain, /* application main window */
|
|||||||
HMENU menuMain; /* application main menu */
|
HMENU menuMain; /* application main menu */
|
||||||
HICON hIcon[256]; /* icon data loaded from resources */
|
HICON hIcon[256]; /* icon data loaded from resources */
|
||||||
RECT oldclip; /* mouse rect */
|
RECT oldclip; /* mouse rect */
|
||||||
|
int sbar_height = 23; /* statusbar height */
|
||||||
int infocus = 1;
|
int infocus = 1;
|
||||||
int rctrl_is_lalt = 0;
|
int rctrl_is_lalt = 0;
|
||||||
int user_resize = 0;
|
int user_resize = 0;
|
||||||
@@ -273,9 +275,10 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
HMENU hmenu;
|
HMENU hmenu;
|
||||||
|
|
||||||
int sb_borders[3];
|
int sb_borders[3];
|
||||||
RECT rect;
|
RECT rect, rc;
|
||||||
|
|
||||||
int temp_x, temp_y;
|
int temp_x, temp_y;
|
||||||
|
int non_client_width, non_client_height;
|
||||||
|
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
@@ -337,7 +340,6 @@ 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);
|
||||||
@@ -346,10 +348,15 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
SendMessage(hwndSBAR, SB_GETBORDERS, 0, (LPARAM) sb_borders);
|
SendMessage(hwndSBAR, SB_GETBORDERS, 0, (LPARAM) sb_borders);
|
||||||
|
|
||||||
|
GetWindowRect(hwnd, &rect);
|
||||||
|
GetClientRect(hwnd, &rc);
|
||||||
|
non_client_width = (rect.right-rect.left) - (rc.right-rc.left);
|
||||||
|
non_client_height = (rect.bottom-rect.top) - (rc.bottom-rc.top);
|
||||||
|
|
||||||
/* Main Window. */
|
/* Main Window. */
|
||||||
MoveWindow(hwnd, rect.left, rect.top,
|
MoveWindow(hwnd, rect.left, rect.top,
|
||||||
unscaled_size_x + (GetSystemMetrics(vid_resize ? SM_CXSIZEFRAME : SM_CXFIXEDFRAME) * 2),
|
unscaled_size_x + non_client_width,
|
||||||
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,
|
unscaled_size_y + non_client_height + sbar_height,
|
||||||
TRUE);
|
TRUE);
|
||||||
|
|
||||||
/* Render window. */
|
/* Render window. */
|
||||||
@@ -556,7 +563,7 @@ unscaled_size_y + (GetSystemMetrics(SM_CYEDGE) * 2) + (GetSystemMetrics(vid_resi
|
|||||||
SendMessage(hwndSBAR, SB_GETBORDERS, 0, (LPARAM) sb_borders);
|
SendMessage(hwndSBAR, SB_GETBORDERS, 0, (LPARAM) sb_borders);
|
||||||
|
|
||||||
temp_x = (lParam & 0xFFFF);
|
temp_x = (lParam & 0xFFFF);
|
||||||
temp_y = (lParam >> 16) - (21 + sb_borders[1]);
|
temp_y = (lParam >> 16) - sbar_height;
|
||||||
if (temp_x < 1)
|
if (temp_x < 1)
|
||||||
temp_x = 1;
|
temp_x = 1;
|
||||||
if (temp_y < 1)
|
if (temp_y < 1)
|
||||||
@@ -728,6 +735,7 @@ ui_init(int nCmdShow)
|
|||||||
MSG messages; /* received-messages buffer */
|
MSG messages; /* received-messages buffer */
|
||||||
HWND hwnd = NULL; /* handle for our window */
|
HWND hwnd = NULL; /* handle for our window */
|
||||||
HACCEL haccel; /* handle to accelerator table */
|
HACCEL haccel; /* handle to accelerator table */
|
||||||
|
RECT sbar_rect; /* RECT of the status bar */
|
||||||
int bRet;
|
int bRet;
|
||||||
|
|
||||||
if (settings_only) {
|
if (settings_only) {
|
||||||
@@ -838,6 +846,12 @@ ui_init(int nCmdShow)
|
|||||||
/* Create the status bar window. */
|
/* Create the status bar window. */
|
||||||
StatusBarCreate(hwndMain, IDC_STATUS, hinstance);
|
StatusBarCreate(hwndMain, IDC_STATUS, hinstance);
|
||||||
|
|
||||||
|
/* Get the actual height of the statusbar,
|
||||||
|
* since that is not something we can change.
|
||||||
|
*/
|
||||||
|
GetWindowRect(hwndSBAR, &sbar_rect);
|
||||||
|
sbar_height = sbar_rect.bottom - sbar_rect.top;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Before we can create the Render window, we first have
|
* Before we can create the Render window, we first have
|
||||||
* to prepare some other things that it depends on.
|
* to prepare some other things that it depends on.
|
||||||
@@ -1002,7 +1016,9 @@ void
|
|||||||
plat_resize(int x, int y)
|
plat_resize(int x, int y)
|
||||||
{
|
{
|
||||||
int sb_borders[3];
|
int sb_borders[3];
|
||||||
RECT r;
|
RECT r, rc;
|
||||||
|
int non_client_width;
|
||||||
|
int non_client_height;
|
||||||
|
|
||||||
/* First, see if we should resize the UI window. */
|
/* First, see if we should resize the UI window. */
|
||||||
if (!vid_resize) {
|
if (!vid_resize) {
|
||||||
@@ -1011,11 +1027,14 @@ plat_resize(int x, int y)
|
|||||||
SendMessage(hwndSBAR, SB_GETBORDERS, 0, (LPARAM) sb_borders);
|
SendMessage(hwndSBAR, SB_GETBORDERS, 0, (LPARAM) sb_borders);
|
||||||
|
|
||||||
GetWindowRect(hwndMain, &r);
|
GetWindowRect(hwndMain, &r);
|
||||||
|
GetClientRect(hwndMain, &rc);
|
||||||
|
non_client_width = (r.right-r.left) - (rc.right-rc.left);
|
||||||
|
non_client_height = (r.bottom-r.top) - (rc.bottom-rc.top);
|
||||||
|
|
||||||
MoveWindow(hwndMain, r.left, r.top,
|
MoveWindow(hwndMain, r.left, r.top,
|
||||||
x + (GetSystemMetrics(vid_resize ? SM_CXSIZEFRAME : SM_CXFIXEDFRAME) * 2),
|
x + non_client_width,
|
||||||
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 + non_client_height + sbar_height,
|
||||||
TRUE);
|
TRUE);
|
||||||
GetWindowRect(hwndMain, &r);
|
|
||||||
|
|
||||||
MoveWindow(hwndRender, 0, 0, x, y, TRUE);
|
MoveWindow(hwndRender, 0, 0, x, y, TRUE);
|
||||||
GetWindowRect(hwndRender, &r);
|
GetWindowRect(hwndRender, &r);
|
||||||
|
Reference in New Issue
Block a user