Skip to content

Commit 6ef0044

Browse files
committed
REVIEWED: Window messages WM_SIZING, WM_SIZE, WM_WINDOWPOSCHANGED #5720
1 parent 1122add commit 6ef0044

1 file changed

Lines changed: 29 additions & 17 deletions

File tree

src/platforms/rcore_desktop_win32.c

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,14 +1063,14 @@ Vector2 GetMonitorPosition(int monitor)
10631063
// Get selected monitor width (currently used by monitor)
10641064
int GetMonitorWidth(int monitor)
10651065
{
1066-
TRACELOG(LOG_WARNING, "GetMonitorWidth not implemented");
1066+
//TRACELOG(LOG_WARNING, "GetMonitorWidth not implemented");
10671067
return 0;
10681068
}
10691069

10701070
// Get selected monitor height (currently used by monitor)
10711071
int GetMonitorHeight(int monitor)
10721072
{
1073-
TRACELOG(LOG_WARNING, "GetMonitorHeight not implemented");
1073+
//TRACELOG(LOG_WARNING, "GetMonitorHeight not implemented");
10741074
return 0;
10751075
}
10761076

@@ -1105,7 +1105,7 @@ const char *GetMonitorName(int monitor)
11051105
// Get window position XY on monitor
11061106
Vector2 GetWindowPosition(void)
11071107
{
1108-
TRACELOG(LOG_WARNING, "GetWindowPosition not implemented");
1108+
//TRACELOG(LOG_WARNING, "GetWindowPosition not implemented");
11091109
return (Vector2){ 0, 0 };
11101110
}
11111111

@@ -1760,13 +1760,31 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
17601760
memset(CORE.Input.Keyboard.previousKeyState, 0, sizeof(CORE.Input.Keyboard.previousKeyState));
17611761
memset(CORE.Input.Keyboard.currentKeyState, 0, sizeof(CORE.Input.Keyboard.currentKeyState));
17621762
} break;
1763-
case WM_SIZING:
1763+
case WM_SIZING: // Sent to a window that the user is resizing
17641764
{
1765-
if (!(CORE.Window.flags & FLAG_WINDOW_RESIZABLE))
1766-
TRACELOG(LOG_WARNING, "WIN32: WINDOW: Trying to resize a non-resizable window");
1765+
if (CORE.Window.flags & FLAG_WINDOW_RESIZABLE)
1766+
{
1767+
//HandleWindowResize(hwnd, &platform.appScreenWidth, &platform.appScreenHeight);
1768+
}
17671769

17681770
result = TRUE;
17691771
} break;
1772+
case WM_SIZE:
1773+
{
1774+
// WARNING: Don't trust the docs, they say this message can not be obtained if not calling DefWindowProc()
1775+
// in response to WM_WINDOWPOSCHANGED but looks like when a window is created,
1776+
// this message can be obtained without getting WM_WINDOWPOSCHANGED
1777+
1778+
#if defined(GRAPHICS_API_OPENGL_SOFTWARE)
1779+
// WARNING: Waiting two frames before resizing because software-renderer backend is initilized with swInit() later
1780+
// than InitPlatform(), that triggers WM_SIZE, so avoid crashing
1781+
if (CORE.Time.frameCounter > 2) HandleWindowResize(hwnd, &platform.appScreenWidth, &platform.appScreenHeight);
1782+
#else
1783+
// NOTE: This message is only triggered on window creation
1784+
HandleWindowResize(hwnd, &platform.appScreenWidth, &platform.appScreenHeight);
1785+
#endif
1786+
result = 0; // If an application processes WM_SIZE message, it should return zero
1787+
} break;
17701788
case WM_GETMINMAXINFO:
17711789
{
17721790
DWORD style = MakeWindowStyle(platform.desiredFlags);
@@ -1865,19 +1883,13 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
18651883
default: break;
18661884
}
18671885
} break;
1868-
case WM_SIZE:
1869-
{
1870-
// WARNING: Don't trust the docs, they say this message can not be obtained if not calling DefWindowProc()
1871-
// in response to WM_WINDOWPOSCHANGED but looks like when a window is created,
1872-
// this message can be obtained without getting WM_WINDOWPOSCHANGED
1873-
// WARNING: This call fails for Software-Renderer backend
1874-
//HandleWindowResize(hwnd, &platform.appScreenWidth, &platform.appScreenHeight);
1875-
} break;
1876-
//case WM_MOVE
1886+
//case WM_MOVE: break;
18771887
case WM_WINDOWPOSCHANGED:
18781888
{
18791889
WINDOWPOS *pos = (WINDOWPOS*)lparam;
18801890
if (!(pos->flags & SWP_NOSIZE)) HandleWindowResize(hwnd, &platform.appScreenWidth, &platform.appScreenHeight);
1891+
1892+
DefWindowProc(hwnd, msg, wparam, lparam);
18811893
} break;
18821894
case WM_GETDPISCALEDSIZE:
18831895
{
@@ -2092,9 +2104,9 @@ static void HandleWindowResize(HWND hwnd, int *width, int *height)
20922104
CORE.Window.screenScale = MatrixScale( (float)CORE.Window.render.width/CORE.Window.screen.width,
20932105
(float)CORE.Window.render.height/CORE.Window.screen.height, 1.0f);
20942106

2095-
#if defined(GRAPHICS_API_OPENGL_SOFTWARE)
2107+
#if defined(GRAPHICS_API_OPENGL_SOFTWARE)
20962108
swResize(clientSize.cx, clientSize.cy);
2097-
#endif
2109+
#endif
20982110
}
20992111

21002112
// Update window style

0 commit comments

Comments
 (0)