mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Win32: Improve monitor enumeration
This changes enumeration to add as a GLFW monitor any active adapter without displays, even if other active adapters do have displays. Related to #441. Fixes #960.
This commit is contained in:
parent
e2ce3026a0
commit
0df9cc2fc5
@ -165,6 +165,7 @@ information on what to include when reporting a bug.
|
|||||||
- [Win32] Bugfix: Mouse capture logic lost secondary release messages (#954)
|
- [Win32] Bugfix: Mouse capture logic lost secondary release messages (#954)
|
||||||
- [Win32] Bugfix: The 32-bit Vulkan loader library static was not searched for
|
- [Win32] Bugfix: The 32-bit Vulkan loader library static was not searched for
|
||||||
- [Win32] Bugfix: Vulkan libraries have a new path as of SDK 1.0.42.0 (#956)
|
- [Win32] Bugfix: Vulkan libraries have a new path as of SDK 1.0.42.0 (#956)
|
||||||
|
- [Win32] Bugfix: Monitors with no display devices were not enumerated (#960)
|
||||||
- [X11] Replaced `_GLFW_HAS_XF86VM` compile-time option with dynamic loading
|
- [X11] Replaced `_GLFW_HAS_XF86VM` compile-time option with dynamic loading
|
||||||
- [X11] Bugfix: `glfwGetVideoMode` would segfault on Cygwin/X
|
- [X11] Bugfix: `glfwGetVideoMode` would segfault on Cygwin/X
|
||||||
- [X11] Bugfix: Dynamic X11 library loading did not use full sonames (#941)
|
- [X11] Bugfix: Dynamic X11 library loading did not use full sonames (#941)
|
||||||
|
@ -94,7 +94,6 @@ void _glfwPollMonitorsWin32(void)
|
|||||||
_GLFWmonitor** disconnected = NULL;
|
_GLFWmonitor** disconnected = NULL;
|
||||||
DWORD adapterIndex, displayIndex;
|
DWORD adapterIndex, displayIndex;
|
||||||
DISPLAY_DEVICEW adapter, display;
|
DISPLAY_DEVICEW adapter, display;
|
||||||
GLFWbool hasDisplays = GLFW_FALSE;
|
|
||||||
|
|
||||||
disconnectedCount = _glfw.monitorCount;
|
disconnectedCount = _glfw.monitorCount;
|
||||||
if (disconnectedCount)
|
if (disconnectedCount)
|
||||||
@ -105,30 +104,6 @@ void _glfwPollMonitorsWin32(void)
|
|||||||
_glfw.monitorCount * sizeof(_GLFWmonitor*));
|
_glfw.monitorCount * sizeof(_GLFWmonitor*));
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK: Check if any active adapters have connected displays
|
|
||||||
// If not, this is a headless system or a VMware guest
|
|
||||||
|
|
||||||
for (adapterIndex = 0; ; adapterIndex++)
|
|
||||||
{
|
|
||||||
ZeroMemory(&adapter, sizeof(DISPLAY_DEVICEW));
|
|
||||||
adapter.cb = sizeof(DISPLAY_DEVICEW);
|
|
||||||
|
|
||||||
if (!EnumDisplayDevicesW(NULL, adapterIndex, &adapter, 0))
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!(adapter.StateFlags & DISPLAY_DEVICE_ACTIVE))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ZeroMemory(&display, sizeof(DISPLAY_DEVICEW));
|
|
||||||
display.cb = sizeof(DISPLAY_DEVICEW);
|
|
||||||
|
|
||||||
if (EnumDisplayDevicesW(adapter.DeviceName, 0, &display, 0))
|
|
||||||
{
|
|
||||||
hasDisplays = GLFW_TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (adapterIndex = 0; ; adapterIndex++)
|
for (adapterIndex = 0; ; adapterIndex++)
|
||||||
{
|
{
|
||||||
int type = _GLFW_INSERT_LAST;
|
int type = _GLFW_INSERT_LAST;
|
||||||
@ -145,8 +120,6 @@ void _glfwPollMonitorsWin32(void)
|
|||||||
if (adapter.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
|
if (adapter.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
|
||||||
type = _GLFW_INSERT_FIRST;
|
type = _GLFW_INSERT_FIRST;
|
||||||
|
|
||||||
if (hasDisplays)
|
|
||||||
{
|
|
||||||
for (displayIndex = 0; ; displayIndex++)
|
for (displayIndex = 0; ; displayIndex++)
|
||||||
{
|
{
|
||||||
ZeroMemory(&display, sizeof(DISPLAY_DEVICEW));
|
ZeroMemory(&display, sizeof(DISPLAY_DEVICEW));
|
||||||
@ -155,6 +128,9 @@ void _glfwPollMonitorsWin32(void)
|
|||||||
if (!EnumDisplayDevicesW(adapter.DeviceName, displayIndex, &display, 0))
|
if (!EnumDisplayDevicesW(adapter.DeviceName, displayIndex, &display, 0))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if (!(display.StateFlags & DISPLAY_DEVICE_ACTIVE))
|
||||||
|
continue;
|
||||||
|
|
||||||
for (i = 0; i < disconnectedCount; i++)
|
for (i = 0; i < disconnectedCount; i++)
|
||||||
{
|
{
|
||||||
if (disconnected[i] &&
|
if (disconnected[i] &&
|
||||||
@ -174,8 +150,10 @@ void _glfwPollMonitorsWin32(void)
|
|||||||
|
|
||||||
type = _GLFW_INSERT_LAST;
|
type = _GLFW_INSERT_LAST;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
// HACK: If an active adapter does not have any display devices
|
||||||
|
// (as sometimes happens), add it directly as a monitor
|
||||||
|
if (displayIndex == 0)
|
||||||
{
|
{
|
||||||
for (i = 0; i < disconnectedCount; i++)
|
for (i = 0; i < disconnectedCount; i++)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user