mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Improved handling of primary monitor.
This commit is contained in:
parent
d21e79642b
commit
20a49a7eee
@ -263,9 +263,9 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
{
|
||||
const CGSize size = CGDisplayScreenSize(displays[i]);
|
||||
const CGRect bounds = CGDisplayBounds(displays[i]);
|
||||
const char* name = getDisplayName(displays[i]);
|
||||
|
||||
monitors[found] = _glfwCreateMonitor(name,
|
||||
monitors[found] = _glfwCreateMonitor(getDisplayName(displays[i]),
|
||||
CGDisplayIsMain(displays[i]),
|
||||
size.width, size.height,
|
||||
bounds.origin.x, bounds.origin.y);
|
||||
|
||||
|
@ -209,6 +209,9 @@ struct _GLFWmonitor
|
||||
void* userPointer;
|
||||
|
||||
char* name;
|
||||
|
||||
GLboolean primary;
|
||||
|
||||
// physical dimensions in millimeters.
|
||||
int physicalWidth;
|
||||
int physicalHeight;
|
||||
@ -393,6 +396,7 @@ GLboolean _glfwIsValidContext(_GLFWwndconfig* wndconfig);
|
||||
|
||||
// Monitor management (monitor.c)
|
||||
_GLFWmonitor* _glfwCreateMonitor(const char* name,
|
||||
GLboolean primary,
|
||||
int physicalWidth, int physicalHeight,
|
||||
int screenX, int screenY);
|
||||
void _glfwDestroyMonitor(_GLFWmonitor* monitor);
|
||||
|
@ -78,6 +78,7 @@ static int compareVideoModes(const void* firstPtr, const void* secondPtr)
|
||||
//========================================================================
|
||||
|
||||
_GLFWmonitor* _glfwCreateMonitor(const char* name,
|
||||
GLboolean primary,
|
||||
int physicalWidth, int physicalHeight,
|
||||
int screenX, int screenY)
|
||||
{
|
||||
@ -89,6 +90,7 @@ _GLFWmonitor* _glfwCreateMonitor(const char* name,
|
||||
}
|
||||
|
||||
monitor->name = strdup(name);
|
||||
monitor->primary = primary;
|
||||
monitor->physicalWidth = physicalWidth;
|
||||
monitor->physicalHeight = physicalHeight;
|
||||
monitor->screenX = screenX;
|
||||
@ -253,13 +255,31 @@ GLFWAPI GLFWmonitor* glfwGetMonitors(int* count)
|
||||
|
||||
GLFWAPI GLFWmonitor glfwGetPrimaryMonitor(void)
|
||||
{
|
||||
int i;
|
||||
GLFWmonitor handle = NULL;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return _glfwLibrary.monitors[0];
|
||||
for (i = 0; i < _glfwLibrary.monitorCount; i++)
|
||||
{
|
||||
if (_glfwLibrary.monitors[i]->primary)
|
||||
{
|
||||
handle = _glfwLibrary.monitors[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!handle)
|
||||
{
|
||||
_glfwSetError(GLFW_PLATFORM_ERROR, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
|
@ -257,7 +257,9 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
EnumDisplayDevices(adapter.DeviceName, 0, &monitor, 0);
|
||||
dc = CreateDC(L"DISPLAY", monitor.DeviceString, NULL, NULL);
|
||||
|
||||
monitors[found] = _glfwCreateMonitor(name,
|
||||
const GLboolean primary = adapter.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE;
|
||||
|
||||
monitors[found] = _glfwCreateMonitor(name, primary,
|
||||
GetDeviceCaps(dc, HORZSIZE),
|
||||
GetDeviceCaps(dc, VERTSIZE),
|
||||
settings.dmPosition.x,
|
||||
|
@ -465,6 +465,7 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
ci = XRRGetCrtcInfo(_glfwLibrary.X11.display, sr, oi->crtc);
|
||||
|
||||
monitors[found] = _glfwCreateMonitor(oi->name,
|
||||
i == 0,
|
||||
oi->mm_width, oi->mm_height,
|
||||
ci->x, ci->y);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user