Skip to content

Commit c8b16ca

Browse files
committed
Revert "[DXDIAG] Rework display enumeration, to use DirectDrawEnumerateEx"
This reverts commit aa0089a.
1 parent d1b0a76 commit c8b16ca

1 file changed

Lines changed: 39 additions & 66 deletions

File tree

‎base/applications/dxdiag/display.c‎

Lines changed: 39 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -305,89 +305,62 @@ InitializeDialog(HWND hwndDlg, PDISPLAY_DEVICEW pDispDevice)
305305
return TRUE;
306306
}
307307

308-
309-
static BOOL WINAPI
310-
DDEnumerateCallback(
311-
IN GUID *lpGuid,
312-
IN LPSTR lpDriverName,
313-
IN LPSTR lpDriverDescription,
314-
IN LPVOID lpContext,
315-
IN HMONITOR hMonitor)
308+
void InitializeDisplayAdapters(PDXDIAG_CONTEXT pContext)
316309
{
317310
DISPLAY_DEVICEW DispDevice;
318-
LPWSTR lpDriverDescriptionW;
319-
PDXDIAG_CONTEXT pContext = lpContext;
320311
PDXDIAG_DISPLAY *pDisplayAdapters;
321312
PDXDIAG_DISPLAY pDisplayAdapter;
322313
HWND hwndDlg;
323314
WCHAR szDisplay[20];
324315
WCHAR szText[30];
325-
int len;
326-
BOOL ret;
316+
DWORD dwOffset = 0;
327317

328-
/* Convert lpDriverDescription to WCHAR */
329-
len = MultiByteToWideChar(CP_ACP, 0, lpDriverDescription, strlen(lpDriverDescription), NULL, 0);
330-
if (!len)
331-
return FALSE;
332-
lpDriverDescriptionW = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
333-
if (!lpDriverDescriptionW)
334-
return FALSE;
335-
MultiByteToWideChar(CP_ACP, 0, lpDriverDescription, strlen(lpDriverDescription), lpDriverDescriptionW, len);
336-
lpDriverDescriptionW[len] = UNICODE_NULL;
337-
338-
/* Get associated display device */
339-
ZeroMemory(&DispDevice, sizeof(DispDevice));
340-
DispDevice.cb = sizeof(DispDevice);
341-
ret = EnumDisplayDevicesW(lpDriverDescriptionW, 0, &DispDevice, 0);
342-
HeapFree(GetProcessHeap(), 0, lpDriverDescriptionW);
343-
if (!ret)
344-
return TRUE;
345-
346-
pDisplayAdapter = HeapAlloc(GetProcessHeap(), 0, sizeof(DXDIAG_DISPLAY));
347-
if (!pDisplayAdapter)
348-
return FALSE;
318+
while(TRUE)
319+
{
320+
ZeroMemory(&DispDevice, sizeof(DISPLAY_DEVICEW));
321+
DispDevice.cb = sizeof(DISPLAY_DEVICEW);
322+
if (!EnumDisplayDevicesW(NULL, pContext->NumDisplayAdapter + dwOffset, &DispDevice, 0))
323+
return;
349324

350-
if (pContext->NumDisplayAdapter)
351-
pDisplayAdapters = HeapReAlloc(GetProcessHeap(), 0, pContext->DisplayAdapters, (pContext->NumDisplayAdapter + 1) * sizeof(PDXDIAG_DISPLAY));
352-
else
353-
pDisplayAdapters = HeapAlloc(GetProcessHeap(), 0, (pContext->NumDisplayAdapter + 1) * sizeof(PDXDIAG_DISPLAY));
325+
/* skip devices not attached to the desktop and mirror drivers */
326+
if (!(DispDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) || (DispDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER))
327+
{
328+
dwOffset++;
329+
continue;
330+
}
331+
if (pContext->NumDisplayAdapter)
332+
pDisplayAdapters = HeapReAlloc(GetProcessHeap(), 0, pContext->DisplayAdapters, (pContext->NumDisplayAdapter + 1) * sizeof(PDXDIAG_DISPLAY));
333+
else
334+
pDisplayAdapters = HeapAlloc(GetProcessHeap(), 0, sizeof(PDXDIAG_DISPLAY));
354335

355-
if (!pDisplayAdapters)
356-
{
357-
HeapFree(GetProcessHeap(), 0, pDisplayAdapter);
358-
return FALSE;
359-
}
336+
if (!pDisplayAdapters)
337+
break;
360338

361-
pContext->DisplayAdapters = pDisplayAdapters;
362-
hwndDlg = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_DISPLAY_DIALOG), pContext->hMainDialog, DisplayPageWndProc, (LPARAM)pDisplayAdapter);
363-
EnableDialogTheme(hwndDlg);
364-
if (!hwndDlg)
365-
{
366-
HeapFree(GetProcessHeap(), 0, pDisplayAdapter);
367-
return FALSE;
368-
}
339+
pDisplayAdapter = HeapAlloc(GetProcessHeap(), 0, sizeof(DXDIAG_DISPLAY));
340+
if (!pDisplayAdapter)
341+
break;
369342

370-
/* initialize the dialog */
371-
InitializeDialog(hwndDlg, &DispDevice);
343+
pContext->DisplayAdapters = pDisplayAdapters;
344+
hwndDlg = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_DISPLAY_DIALOG), pContext->hMainDialog, DisplayPageWndProc, (LPARAM)pDisplayAdapter); EnableDialogTheme(hwndDlg);
345+
if (!hwndDlg)
346+
break;
372347

373-
szDisplay[0] = UNICODE_NULL;
374-
LoadStringW(hInst, IDS_DISPLAY_DIALOG, szDisplay, ARRAYSIZE(szDisplay));
375-
szDisplay[ARRAYSIZE(szDisplay) - 1] = UNICODE_NULL;
348+
/* initialize the dialog */
349+
InitializeDialog(hwndDlg, &DispDevice);
376350

377-
wsprintfW(szText, L"%s %u", szDisplay, pContext->NumDisplayAdapter + 1);
378-
InsertTabCtrlItem(GetDlgItem(pContext->hMainDialog, IDC_TAB_CONTROL), pContext->NumDisplayAdapter + 1, szText);
351+
szDisplay[0] = L'\0';
352+
LoadStringW(hInst, IDS_DISPLAY_DIALOG, szDisplay, sizeof(szDisplay)/sizeof(WCHAR));
353+
szDisplay[(sizeof(szDisplay)/sizeof(WCHAR))-1] = L'\0';
379354

380-
pDisplayAdapter->hDisplayWnd = hwndDlg;
381-
if (lpGuid)
382-
pDisplayAdapter->guid = *lpGuid;
383-
pContext->DisplayAdapters[pContext->NumDisplayAdapter++] = pDisplayAdapter;
384-
return TRUE;
385-
}
355+
wsprintfW (szText, L"%s %u", szDisplay, pContext->NumDisplayAdapter + 1);
356+
InsertTabCtrlItem(GetDlgItem(pContext->hMainDialog, IDC_TAB_CONTROL), pContext->NumDisplayAdapter + 1, szText);
357+
358+
pDisplayAdapter->hDisplayWnd = hwndDlg;
359+
pDisplayAdapters[pContext->NumDisplayAdapter] = pDisplayAdapter;
360+
pContext->NumDisplayAdapter++;
361+
}
386362

387363

388-
void InitializeDisplayAdapters(PDXDIAG_CONTEXT pContext)
389-
{
390-
DirectDrawEnumerateExA(DDEnumerateCallback, pContext, DDENUM_ATTACHEDSECONDARYDEVICES);
391364
}
392365

393366

0 commit comments

Comments
 (0)