|
@@ -193,19 +193,8 @@ static SDL_bool WIN_GetDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_D
|
|
|
return SDL_TRUE;
|
|
|
}
|
|
|
|
|
|
-/* The win32 API calls in this function require Windows Vista or later. */
|
|
|
-/* *INDENT-OFF* */ /* clang-format off */
|
|
|
-typedef LONG (WINAPI *SDL_WIN32PROC_GetDisplayConfigBufferSizes)(UINT32 flags, UINT32* numPathArrayElements, UINT32* numModeInfoArrayElements);
|
|
|
-typedef LONG (WINAPI *SDL_WIN32PROC_QueryDisplayConfig)(UINT32 flags, UINT32* numPathArrayElements, DISPLAYCONFIG_PATH_INFO* pathArray, UINT32* numModeInfoArrayElements, DISPLAYCONFIG_MODE_INFO* modeInfoArray, DISPLAYCONFIG_TOPOLOGY_ID* currentTopologyId);
|
|
|
-typedef LONG (WINAPI *SDL_WIN32PROC_DisplayConfigGetDeviceInfo)(DISPLAYCONFIG_DEVICE_INFO_HEADER* requestPacket);
|
|
|
-/* *INDENT-ON* */ /* clang-format on */
|
|
|
-
|
|
|
-static char *WIN_GetDisplayNameVista(const WCHAR *deviceName)
|
|
|
+static char *WIN_GetDisplayNameVista(SDL_VideoData *videodata, const WCHAR *deviceName)
|
|
|
{
|
|
|
- void *dll;
|
|
|
- SDL_WIN32PROC_GetDisplayConfigBufferSizes pGetDisplayConfigBufferSizes;
|
|
|
- SDL_WIN32PROC_QueryDisplayConfig pQueryDisplayConfig;
|
|
|
- SDL_WIN32PROC_DisplayConfigGetDeviceInfo pDisplayConfigGetDeviceInfo;
|
|
|
DISPLAYCONFIG_PATH_INFO *paths = NULL;
|
|
|
DISPLAYCONFIG_MODE_INFO *modes = NULL;
|
|
|
char *retval = NULL;
|
|
@@ -214,21 +203,12 @@ static char *WIN_GetDisplayNameVista(const WCHAR *deviceName)
|
|
|
UINT32 i;
|
|
|
LONG rc;
|
|
|
|
|
|
- dll = SDL_LoadObject("USER32.DLL");
|
|
|
- if (!dll) {
|
|
|
+ if (!videodata->GetDisplayConfigBufferSizes || !videodata->QueryDisplayConfig || !videodata->DisplayConfigGetDeviceInfo) {
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
- pGetDisplayConfigBufferSizes = (SDL_WIN32PROC_GetDisplayConfigBufferSizes)SDL_LoadFunction(dll, "GetDisplayConfigBufferSizes");
|
|
|
- pQueryDisplayConfig = (SDL_WIN32PROC_QueryDisplayConfig)SDL_LoadFunction(dll, "QueryDisplayConfig");
|
|
|
- pDisplayConfigGetDeviceInfo = (SDL_WIN32PROC_DisplayConfigGetDeviceInfo)SDL_LoadFunction(dll, "DisplayConfigGetDeviceInfo");
|
|
|
-
|
|
|
- if (!pGetDisplayConfigBufferSizes || !pQueryDisplayConfig || !pDisplayConfigGetDeviceInfo) {
|
|
|
- goto WIN_GetDisplayNameVista_failed;
|
|
|
- }
|
|
|
-
|
|
|
do {
|
|
|
- rc = pGetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &pathCount, &modeCount);
|
|
|
+ rc = videodata->GetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &pathCount, &modeCount);
|
|
|
if (rc != ERROR_SUCCESS) {
|
|
|
goto WIN_GetDisplayNameVista_failed;
|
|
|
}
|
|
@@ -242,7 +222,7 @@ static char *WIN_GetDisplayNameVista(const WCHAR *deviceName)
|
|
|
goto WIN_GetDisplayNameVista_failed;
|
|
|
}
|
|
|
|
|
|
- rc = pQueryDisplayConfig(QDC_ONLY_ACTIVE_PATHS, &pathCount, paths, &modeCount, modes, 0);
|
|
|
+ rc = videodata->QueryDisplayConfig(QDC_ONLY_ACTIVE_PATHS, &pathCount, paths, &modeCount, modes, 0);
|
|
|
} while (rc == ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
|
|
if (rc == ERROR_SUCCESS) {
|
|
@@ -255,7 +235,7 @@ static char *WIN_GetDisplayNameVista(const WCHAR *deviceName)
|
|
|
sourceName.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME;
|
|
|
sourceName.header.size = sizeof(sourceName);
|
|
|
sourceName.header.id = paths[i].sourceInfo.id;
|
|
|
- rc = pDisplayConfigGetDeviceInfo(&sourceName.header);
|
|
|
+ rc = videodata->DisplayConfigGetDeviceInfo(&sourceName.header);
|
|
|
if (rc != ERROR_SUCCESS) {
|
|
|
break;
|
|
|
} else if (SDL_wcscmp(deviceName, sourceName.viewGdiDeviceName) != 0) {
|
|
@@ -267,7 +247,7 @@ static char *WIN_GetDisplayNameVista(const WCHAR *deviceName)
|
|
|
targetName.header.id = paths[i].targetInfo.id;
|
|
|
targetName.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME;
|
|
|
targetName.header.size = sizeof(targetName);
|
|
|
- rc = pDisplayConfigGetDeviceInfo(&targetName.header);
|
|
|
+ rc = videodata->DisplayConfigGetDeviceInfo(&targetName.header);
|
|
|
if (rc == ERROR_SUCCESS) {
|
|
|
retval = WIN_StringToUTF8W(targetName.monitorFriendlyDeviceName);
|
|
|
/* if we got an empty string, treat it as failure so we'll fallback
|
|
@@ -283,14 +263,12 @@ static char *WIN_GetDisplayNameVista(const WCHAR *deviceName)
|
|
|
|
|
|
SDL_free(paths);
|
|
|
SDL_free(modes);
|
|
|
- SDL_UnloadObject(dll);
|
|
|
return retval;
|
|
|
|
|
|
WIN_GetDisplayNameVista_failed:
|
|
|
SDL_free(retval);
|
|
|
SDL_free(paths);
|
|
|
SDL_free(modes);
|
|
|
- SDL_UnloadObject(dll);
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
@@ -360,7 +338,7 @@ static void WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info,
|
|
|
displaydata->IsValid = SDL_TRUE;
|
|
|
|
|
|
SDL_zero(display);
|
|
|
- display.name = WIN_GetDisplayNameVista(info->szDevice);
|
|
|
+ display.name = WIN_GetDisplayNameVista(_this->driverdata, info->szDevice);
|
|
|
if (!display.name) {
|
|
|
DISPLAY_DEVICEW device;
|
|
|
SDL_zero(device);
|