|
@@ -52,6 +52,52 @@
|
|
|
// Make sure the type in the SDL_Event aligns properly across the union
|
|
|
SDL_COMPILE_TIME_ASSERT(SDL_Event_type, sizeof(Uint32) == sizeof(SDL_EventType));
|
|
|
|
|
|
+#define SDL2_SYSWMEVENT 0x201
|
|
|
+
|
|
|
+#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
|
|
+#include "../core/windows/SDL_windows.h"
|
|
|
+#endif
|
|
|
+
|
|
|
+#ifdef SDL_VIDEO_DRIVER_X11
|
|
|
+#include <X11/Xlib.h>
|
|
|
+#endif
|
|
|
+
|
|
|
+typedef struct SDL2_version
|
|
|
+{
|
|
|
+ Uint8 major;
|
|
|
+ Uint8 minor;
|
|
|
+ Uint8 patch;
|
|
|
+} SDL2_version;
|
|
|
+
|
|
|
+typedef enum
|
|
|
+{
|
|
|
+ SDL2_SYSWM_UNKNOWN
|
|
|
+} SDL2_SYSWM_TYPE;
|
|
|
+
|
|
|
+typedef struct SDL2_SysWMmsg
|
|
|
+{
|
|
|
+ SDL2_version version;
|
|
|
+ SDL2_SYSWM_TYPE subsystem;
|
|
|
+ union
|
|
|
+ {
|
|
|
+#ifdef SDL_VIDEO_DRIVER_WINDOWS
|
|
|
+ struct {
|
|
|
+ HWND hwnd; /**< The window for the message */
|
|
|
+ UINT msg; /**< The type of message */
|
|
|
+ WPARAM wParam; /**< WORD message parameter */
|
|
|
+ LPARAM lParam; /**< LONG message parameter */
|
|
|
+ } win;
|
|
|
+#endif
|
|
|
+#ifdef SDL_VIDEO_DRIVER_X11
|
|
|
+ struct {
|
|
|
+ XEvent event;
|
|
|
+ } x11;
|
|
|
+#endif
|
|
|
+ /* Can't have an empty union */
|
|
|
+ int dummy;
|
|
|
+ } msg;
|
|
|
+} SDL2_SysWMmsg;
|
|
|
+
|
|
|
typedef struct SDL_EventWatcher
|
|
|
{
|
|
|
SDL_EventFilter callback;
|
|
@@ -214,6 +260,17 @@ static void SDL_LinkTemporaryMemoryToEvent(SDL_EventEntry *event, const void *me
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+static void SDL_TransferSysWMMemoryToEvent(SDL_EventEntry *event)
|
|
|
+{
|
|
|
+ SDL2_SysWMmsg **wmmsg = (SDL2_SysWMmsg **)((&event->event.common)+1);
|
|
|
+ SDL2_SysWMmsg *mem = SDL_AllocateTemporaryMemory(sizeof(*mem));
|
|
|
+ if (mem) {
|
|
|
+ SDL_copyp(mem, *wmmsg);
|
|
|
+ *wmmsg = mem;
|
|
|
+ SDL_LinkTemporaryMemoryToEvent(event, mem);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// Transfer the event memory from the thread-local event memory list to the event
|
|
|
static void SDL_TransferTemporaryMemoryToEvent(SDL_EventEntry *event)
|
|
|
{
|
|
@@ -238,6 +295,10 @@ static void SDL_TransferTemporaryMemoryToEvent(SDL_EventEntry *event)
|
|
|
case SDL_EVENT_CLIPBOARD_UPDATE:
|
|
|
SDL_LinkTemporaryMemoryToEvent(event, event->event.clipboard.mime_types);
|
|
|
break;
|
|
|
+ case SDL2_SYSWMEVENT:
|
|
|
+ // We need to copy the stack pointer into temporary memory
|
|
|
+ SDL_TransferSysWMMemoryToEvent(event);
|
|
|
+ break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|