Added a hint to disable windows message processing in SDL_PumpEvents() SDL_SetHint( SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP, "0" );
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
diff --git a/include/SDL_hints.h b/include/SDL_hints.h
index eec2ddf..249f24d 100644
--- a/include/SDL_hints.h
+++ b/include/SDL_hints.h
@@ -197,6 +197,17 @@ extern "C" {
#define SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN "SDL_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN"
/**
+ * \brief A variable controlling whether the windows message loop is processed by SDL
+ *
+ * This variable can be set to the following values:
+ * "0" - The window message loop is not run
+ * "1" - The window message loop is processed in SDL_PumpEvents()
+ *
+ * By default SDL will process the windows message loop
+ */
+#define SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP "SDL_WINDOWS_ENABLE_MESSAGELOOP"
+
+/**
* \brief A variable controlling whether grabbing input grabs the keyboard
*
* This variable can be set to the following values:
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index d3cdd6c..2aa1814 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -890,14 +890,16 @@ WIN_PumpEvents(_THIS)
MSG msg;
DWORD start_ticks = GetTickCount();
- while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
- /* Always translate the message in case it's a non-SDL window (e.g. with Qt integration) */
- TranslateMessage(&msg);
- DispatchMessage(&msg);
-
- /* Make sure we don't busy loop here forever if there are lots of events coming in */
- if (SDL_TICKS_PASSED(msg.time, start_ticks)) {
- break;
+ if (g_WindowsEnableMessageLoop) {
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ /* Always translate the message in case it's a non-SDL window (e.g. with Qt integration) */
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+
+ /* Make sure we don't busy loop here forever if there are lots of events coming in */
+ if (SDL_TICKS_PASSED(msg.time, start_ticks)) {
+ break;
+ }
}
}
diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c
index f8bb34b..12eca03 100644
--- a/src/video/windows/SDL_windowsvideo.c
+++ b/src/video/windows/SDL_windowsvideo.c
@@ -39,8 +39,18 @@ static int WIN_VideoInit(_THIS);
static void WIN_VideoQuit(_THIS);
/* Hints */
+SDL_bool g_WindowsEnableMessageLoop = SDL_TRUE;
SDL_bool g_WindowFrameUsableWhileCursorHidden = SDL_TRUE;
+static void UpdateWindowsEnableMessageLoop(void *userdata, const char *name, const char *oldValue, const char *newValue)
+{
+ if (newValue && *newValue == '0') {
+ g_WindowsEnableMessageLoop = SDL_FALSE;
+ } else {
+ g_WindowsEnableMessageLoop = SDL_TRUE;
+ }
+}
+
static void UpdateWindowFrameUsableWhileCursorHidden(void *userdata, const char *name, const char *oldValue, const char *newValue)
{
if (newValue && *newValue == '0') {
@@ -97,9 +107,9 @@ WIN_CreateDevice(int devindex)
data->userDLL = SDL_LoadObject("USER32.DLL");
if (data->userDLL) {
- data->CloseTouchInputHandle = (BOOL (WINAPI *)( HTOUCHINPUT )) SDL_LoadFunction(data->userDLL, "CloseTouchInputHandle");
- data->GetTouchInputInfo = (BOOL (WINAPI *)( HTOUCHINPUT, UINT, PTOUCHINPUT, int )) SDL_LoadFunction(data->userDLL, "GetTouchInputInfo");
- data->RegisterTouchWindow = (BOOL (WINAPI *)( HWND, ULONG )) SDL_LoadFunction(data->userDLL, "RegisterTouchWindow");
+ data->CloseTouchInputHandle = (BOOL (WINAPI *)(HTOUCHINPUT)) SDL_LoadFunction(data->userDLL, "CloseTouchInputHandle");
+ data->GetTouchInputInfo = (BOOL (WINAPI *)(HTOUCHINPUT, UINT, PTOUCHINPUT, int)) SDL_LoadFunction(data->userDLL, "GetTouchInputInfo");
+ data->RegisterTouchWindow = (BOOL (WINAPI *)(HWND, ULONG)) SDL_LoadFunction(data->userDLL, "RegisterTouchWindow");
}
/* Set the function pointers */
@@ -178,7 +188,8 @@ WIN_VideoInit(_THIS)
WIN_InitKeyboard(_this);
WIN_InitMouse(_this);
- SDL_AddHintCallback( SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN, UpdateWindowFrameUsableWhileCursorHidden, NULL );
+ SDL_AddHintCallback(SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP, UpdateWindowsEnableMessageLoop, NULL);
+ SDL_AddHintCallback(SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN, UpdateWindowFrameUsableWhileCursorHidden, NULL);
return 0;
}
@@ -196,7 +207,7 @@ WIN_VideoQuit(_THIS)
#include <d3d9.h>
SDL_bool
-D3D_LoadDLL( void **pD3DDLL, IDirect3D9 **pDirect3D9Interface )
+D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface)
{
*pD3DDLL = SDL_LoadObject("D3D9.DLL");
if (*pD3DDLL) {
@@ -239,7 +250,7 @@ D3D_LoadDLL( void **pD3DDLL, IDirect3D9 **pDirect3D9Interface )
int
-SDL_Direct3D9GetAdapterIndex( int displayIndex )
+SDL_Direct3D9GetAdapterIndex(int displayIndex)
{
void *pD3DDLL;
IDirect3D9 *pD3D;
@@ -287,7 +298,7 @@ DXGI_LoadDLL(void **pDXGIDLL, IDXGIFactory **pDXGIFactory)
{
*pDXGIDLL = SDL_LoadObject("DXGI.DLL");
if (*pDXGIDLL) {
- HRESULT (WINAPI *CreateDXGI)( REFIID riid, void **ppFactory );
+ HRESULT (WINAPI *CreateDXGI)(REFIID riid, void **ppFactory);
CreateDXGI =
(HRESULT (WINAPI *) (REFIID, void**)) SDL_LoadFunction(*pDXGIDLL,
@@ -365,7 +376,7 @@ SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputIndex)
*adapterIndex = nAdapter;
*outputIndex = nOutput;
}
- SDL_free( outputName );
+ SDL_free(outputName);
}
IDXGIOutput_Release(pDXGIOutput);
nOutput++;
diff --git a/src/video/windows/SDL_windowsvideo.h b/src/video/windows/SDL_windowsvideo.h
index 406f88d..aaedc04 100644
--- a/src/video/windows/SDL_windowsvideo.h
+++ b/src/video/windows/SDL_windowsvideo.h
@@ -171,6 +171,7 @@ typedef struct SDL_VideoData
TSFSink *ime_ippasink;
} SDL_VideoData;
+extern SDL_bool g_WindowsEnableMessageLoop;
extern SDL_bool g_WindowFrameUsableWhileCursorHidden;
typedef struct IDirect3D9 IDirect3D9;