mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 10:48:51 -05:00
X11: Fix queries crashing if monitor disconnected
Merged from downstream kovidgoyal/glfw. First of many. Related to #1602.
This commit is contained in:
parent
65cfe743af
commit
a5e5b782c7
|
@ -322,12 +322,16 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||||
XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
||||||
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
||||||
|
|
||||||
|
if (ci)
|
||||||
|
{
|
||||||
if (xpos)
|
if (xpos)
|
||||||
*xpos = ci->x;
|
*xpos = ci->x;
|
||||||
if (ypos)
|
if (ypos)
|
||||||
*ypos = ci->y;
|
*ypos = ci->y;
|
||||||
|
|
||||||
XRRFreeCrtcInfo(ci);
|
XRRFreeCrtcInfo(ci);
|
||||||
|
}
|
||||||
|
|
||||||
XRRFreeScreenResources(sr);
|
XRRFreeScreenResources(sr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -493,9 +497,15 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||||
XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
|
||||||
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
||||||
|
|
||||||
*mode = vidmodeFromModeInfo(getModeInfo(sr, ci->mode), ci);
|
if (ci)
|
||||||
|
{
|
||||||
|
const XRRModeInfo* mi = getModeInfo(sr, ci->mode);
|
||||||
|
if (mi) // mi can be NULL if the monitor has been disconnected
|
||||||
|
*mode = vidmodeFromModeInfo(mi, ci);
|
||||||
|
|
||||||
XRRFreeCrtcInfo(ci);
|
XRRFreeCrtcInfo(ci);
|
||||||
|
}
|
||||||
|
|
||||||
XRRFreeScreenResources(sr);
|
XRRFreeScreenResources(sr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user