mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-28 12:27:24 +02:00
Allow the application to draw while Windows is in a modal move/resize loop
If you're using the application main callbacks, your SDL_AppIterate() function will be called while Windows is moving and resizing your window. If not, then SDL will send an SDL_EVENT_WINDOW_EXPOSED event for your window and you can use an event watcher to redraw your window directly from the callback. Fixes https://github.com/libsdl-org/SDL/issues/1059 Closes https://github.com/libsdl-org/SDL/pull/4836
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "../../events/SDL_events_c.h"
|
||||
#include "../../events/SDL_touch_c.h"
|
||||
#include "../../events/scancodes_windows.h"
|
||||
#include "../../main/SDL_main_callbacks.h"
|
||||
|
||||
/* Dropfile support */
|
||||
#include <shellapi.h>
|
||||
@@ -106,6 +107,10 @@
|
||||
#define IS_SURROGATE_PAIR(h, l) (IS_HIGH_SURROGATE(h) && IS_LOW_SURROGATE(l))
|
||||
#endif
|
||||
|
||||
#ifndef USER_TIMER_MINIMUM
|
||||
#define USER_TIMER_MINIMUM 0x0000000A
|
||||
#endif
|
||||
|
||||
/* Used to compare Windows message timestamps */
|
||||
#define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0)
|
||||
|
||||
@@ -1283,6 +1288,31 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
} break;
|
||||
|
||||
case WM_ENTERSIZEMOVE:
|
||||
case WM_ENTERMENULOOP:
|
||||
{
|
||||
SetTimer(hwnd, (UINT_PTR)SDL_IterateMainCallbacks, USER_TIMER_MINIMUM, NULL);
|
||||
} break;
|
||||
|
||||
case WM_TIMER:
|
||||
{
|
||||
if (wParam == (UINT_PTR)SDL_IterateMainCallbacks) {
|
||||
if (SDL_HasMainCallbacks()) {
|
||||
SDL_IterateMainCallbacks(SDL_FALSE);
|
||||
} else {
|
||||
// Send an expose event so the application can redraw
|
||||
SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_EXPOSED, 0, 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
} break;
|
||||
|
||||
case WM_EXITSIZEMOVE:
|
||||
case WM_EXITMENULOOP:
|
||||
{
|
||||
KillTimer(hwnd, (UINT_PTR)SDL_IterateMainCallbacks);
|
||||
} break;
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
switch (wParam) {
|
||||
|
||||
Reference in New Issue
Block a user