@@ -193,19 +193,8 @@ static SDL_bool WIN_GetDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_D
193
193
return SDL_TRUE ;
194
194
}
195
195
196
- /* The win32 API calls in this function require Windows Vista or later. */
197
- /* *INDENT-OFF* */ /* clang-format off */
198
- typedef LONG (WINAPI * SDL_WIN32PROC_GetDisplayConfigBufferSizes )(UINT32 flags , UINT32 * numPathArrayElements , UINT32 * numModeInfoArrayElements );
199
- typedef LONG (WINAPI * SDL_WIN32PROC_QueryDisplayConfig )(UINT32 flags , UINT32 * numPathArrayElements , DISPLAYCONFIG_PATH_INFO * pathArray , UINT32 * numModeInfoArrayElements , DISPLAYCONFIG_MODE_INFO * modeInfoArray , DISPLAYCONFIG_TOPOLOGY_ID * currentTopologyId );
200
- typedef LONG (WINAPI * SDL_WIN32PROC_DisplayConfigGetDeviceInfo )(DISPLAYCONFIG_DEVICE_INFO_HEADER * requestPacket );
201
- /* *INDENT-ON* */ /* clang-format on */
202
-
203
- static char * WIN_GetDisplayNameVista (const WCHAR * deviceName )
196
+ static char * WIN_GetDisplayNameVista (SDL_VideoData * videodata , const WCHAR * deviceName )
204
197
{
205
- void * dll ;
206
- SDL_WIN32PROC_GetDisplayConfigBufferSizes pGetDisplayConfigBufferSizes ;
207
- SDL_WIN32PROC_QueryDisplayConfig pQueryDisplayConfig ;
208
- SDL_WIN32PROC_DisplayConfigGetDeviceInfo pDisplayConfigGetDeviceInfo ;
209
198
DISPLAYCONFIG_PATH_INFO * paths = NULL ;
210
199
DISPLAYCONFIG_MODE_INFO * modes = NULL ;
211
200
char * retval = NULL ;
@@ -214,21 +203,12 @@ static char *WIN_GetDisplayNameVista(const WCHAR *deviceName)
214
203
UINT32 i ;
215
204
LONG rc ;
216
205
217
- dll = SDL_LoadObject ("USER32.DLL" );
218
- if (!dll ) {
206
+ if (!videodata -> GetDisplayConfigBufferSizes || !videodata -> QueryDisplayConfig || !videodata -> DisplayConfigGetDeviceInfo ) {
219
207
return NULL ;
220
208
}
221
209
222
- pGetDisplayConfigBufferSizes = (SDL_WIN32PROC_GetDisplayConfigBufferSizes )SDL_LoadFunction (dll , "GetDisplayConfigBufferSizes" );
223
- pQueryDisplayConfig = (SDL_WIN32PROC_QueryDisplayConfig )SDL_LoadFunction (dll , "QueryDisplayConfig" );
224
- pDisplayConfigGetDeviceInfo = (SDL_WIN32PROC_DisplayConfigGetDeviceInfo )SDL_LoadFunction (dll , "DisplayConfigGetDeviceInfo" );
225
-
226
- if (!pGetDisplayConfigBufferSizes || !pQueryDisplayConfig || !pDisplayConfigGetDeviceInfo ) {
227
- goto WIN_GetDisplayNameVista_failed ;
228
- }
229
-
230
210
do {
231
- rc = pGetDisplayConfigBufferSizes (QDC_ONLY_ACTIVE_PATHS , & pathCount , & modeCount );
211
+ rc = videodata -> GetDisplayConfigBufferSizes (QDC_ONLY_ACTIVE_PATHS , & pathCount , & modeCount );
232
212
if (rc != ERROR_SUCCESS ) {
233
213
goto WIN_GetDisplayNameVista_failed ;
234
214
}
@@ -242,7 +222,7 @@ static char *WIN_GetDisplayNameVista(const WCHAR *deviceName)
242
222
goto WIN_GetDisplayNameVista_failed ;
243
223
}
244
224
245
- rc = pQueryDisplayConfig (QDC_ONLY_ACTIVE_PATHS , & pathCount , paths , & modeCount , modes , 0 );
225
+ rc = videodata -> QueryDisplayConfig (QDC_ONLY_ACTIVE_PATHS , & pathCount , paths , & modeCount , modes , 0 );
246
226
} while (rc == ERROR_INSUFFICIENT_BUFFER );
247
227
248
228
if (rc == ERROR_SUCCESS ) {
@@ -255,7 +235,7 @@ static char *WIN_GetDisplayNameVista(const WCHAR *deviceName)
255
235
sourceName .header .type = DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME ;
256
236
sourceName .header .size = sizeof (sourceName );
257
237
sourceName .header .id = paths [i ].sourceInfo .id ;
258
- rc = pDisplayConfigGetDeviceInfo (& sourceName .header );
238
+ rc = videodata -> DisplayConfigGetDeviceInfo (& sourceName .header );
259
239
if (rc != ERROR_SUCCESS ) {
260
240
break ;
261
241
} else if (SDL_wcscmp (deviceName , sourceName .viewGdiDeviceName ) != 0 ) {
@@ -267,7 +247,7 @@ static char *WIN_GetDisplayNameVista(const WCHAR *deviceName)
267
247
targetName .header .id = paths [i ].targetInfo .id ;
268
248
targetName .header .type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME ;
269
249
targetName .header .size = sizeof (targetName );
270
- rc = pDisplayConfigGetDeviceInfo (& targetName .header );
250
+ rc = videodata -> DisplayConfigGetDeviceInfo (& targetName .header );
271
251
if (rc == ERROR_SUCCESS ) {
272
252
retval = WIN_StringToUTF8W (targetName .monitorFriendlyDeviceName );
273
253
/* 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)
283
263
284
264
SDL_free (paths );
285
265
SDL_free (modes );
286
- SDL_UnloadObject (dll );
287
266
return retval ;
288
267
289
268
WIN_GetDisplayNameVista_failed :
290
269
SDL_free (retval );
291
270
SDL_free (paths );
292
271
SDL_free (modes );
293
- SDL_UnloadObject (dll );
294
272
return NULL ;
295
273
}
296
274
@@ -360,7 +338,7 @@ static void WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info,
360
338
displaydata -> IsValid = SDL_TRUE ;
361
339
362
340
SDL_zero (display );
363
- display .name = WIN_GetDisplayNameVista (info -> szDevice );
341
+ display .name = WIN_GetDisplayNameVista (_this -> driverdata , info -> szDevice );
364
342
if (!display .name ) {
365
343
DISPLAY_DEVICEW device ;
366
344
SDL_zero (device );
0 commit comments