Added proper monitor comparison.

master
Camilla Berglund ago%!(EXTRA string=12 years)
parent 2891c9629f
commit 7405bc48cd
  1. 5
      src/cocoa_monitor.m
  2. 10
      src/internal.h
  3. 2
      src/monitor.c
  4. 5
      src/win32_monitor.c
  5. 5
      src/x11_monitor.c

@ -305,6 +305,11 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
return monitors;
}
GLboolean _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second)
{
return first->ns.displayID == second->ns.displayID;
}
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
{
const CGRect bounds = CGDisplayBounds(monitor->ns.displayID);

@ -363,6 +363,16 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode);
*/
_GLFWmonitor** _glfwPlatformGetMonitors(int* count);
/*! @brief Checks whether two monitor objects represent the same monitor.
*
* @param[in] first The first monitor.
* @param[in] second The second monitor.
* @return @c GL_TRUE if the monitor objects represent the same monitor, or @c
* GL_FALSE otherwise.
* @ingroup platform
*/
GLboolean _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second);
/*! @copydoc glfwGetMonitorPos
* @ingroup platform
*/

@ -106,7 +106,7 @@ void _glfwInputMonitorChange(void)
if (_glfw.monitors[j] == NULL)
continue;
if (strcmp(monitors[i]->name, _glfw.monitors[j]->name) == 0)
if (_glfwPlatformIsSameMonitor(monitors[i], _glfw.monitors[j]))
{
// This monitor was connected before, so re-use the existing
// monitor object to preserve its address and user pointer

@ -174,6 +174,11 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
return monitors;
}
GLboolean _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second)
{
return wcscmp(first->win32.name, second->win32.name);
}
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
{
DEVMODE settings;

@ -224,6 +224,11 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* found)
return monitors;
}
GLboolean _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second)
{
return first->x11.crtc == second->x11.crtc;
}
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
{
if (_glfw.x11.randr.available)

Loading…
Cancel
Save