From 4bea89e945c6028abe8bdbda83d065c39e0a45aa Mon Sep 17 00:00:00 2001
From: Ethan Lee <[EMAIL REDACTED]>
Date: Sun, 4 Aug 2024 15:31:15 -0400
Subject: [PATCH] Xbox buildfixes
---
src/video/windows/SDL_windowsvideo.c | 4 ++++
src/video/windows/SDL_windowsvideo.h | 2 ++
src/video/windows/SDL_windowswindow.c | 3 +--
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c
index 118717b9a0355..ee768c1e1698b 100644
--- a/src/video/windows/SDL_windowsvideo.c
+++ b/src/video/windows/SDL_windowsvideo.c
@@ -473,12 +473,14 @@ int WIN_VideoInit(SDL_VideoDevice *_this)
if (SUCCEEDED(hr)) {
data->coinitialized = SDL_TRUE;
+#if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
hr = OleInitialize(NULL);
if (SUCCEEDED(hr)) {
data->oleinitialized = SDL_TRUE;
} else {
SDL_LogInfo(SDL_LOG_CATEGORY_VIDEO, "OleInitialize() failed: 0x%.8x, using fallback drag-n-drop functionality\n", (unsigned int)hr);
}
+#endif /* !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) */
} else {
SDL_LogInfo(SDL_LOG_CATEGORY_VIDEO, "CoInitialize() failed: 0x%.8x, using fallback drag-n-drop functionality\n", (unsigned int)hr);
}
@@ -543,10 +545,12 @@ void WIN_VideoQuit(SDL_VideoDevice *_this)
WIN_SetRawMouseEnabled(_this, SDL_FALSE);
WIN_SetRawKeyboardEnabled(_this, SDL_FALSE);
+#if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
if (data->oleinitialized) {
OleUninitialize();
data->oleinitialized = SDL_FALSE;
}
+#endif /* !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) */
if (data->coinitialized) {
WIN_CoUninitialize();
data->coinitialized = SDL_FALSE;
diff --git a/src/video/windows/SDL_windowsvideo.h b/src/video/windows/SDL_windowsvideo.h
index fa3aba980df74..2265ac01922f4 100644
--- a/src/video/windows/SDL_windowsvideo.h
+++ b/src/video/windows/SDL_windowsvideo.h
@@ -380,7 +380,9 @@ struct SDL_VideoData
int render;
SDL_bool coinitialized;
+#if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
SDL_bool oleinitialized;
+#endif /* !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) */
DWORD clipboard_count;
diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
index c15e40ca08a75..019fdd68c7561 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -589,11 +589,10 @@ static void CleanupWindowData(SDL_VideoDevice *_this, SDL_Window *window)
if (data) {
SDL_DelHintCallback(SDL_HINT_MOUSE_RELATIVE_MODE_CENTER, WIN_MouseRelativeModeCenterChanged, data);
+#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
if (data->drop_target) {
WIN_AcceptDragAndDrop(window, SDL_FALSE);
}
-
-#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
if (data->ICMFileName) {
SDL_free(data->ICMFileName);
}