Made glfwGetMonitorPos immediate.
This commit is contained in:
parent
a591cdeba6
commit
7b3783abe2
@ -231,11 +231,9 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
for (i = 0; i < monitorCount; i++)
|
||||
{
|
||||
const CGSize size = CGDisplayScreenSize(displays[i]);
|
||||
const CGRect bounds = CGDisplayBounds(displays[i]);
|
||||
|
||||
monitors[found] = _glfwCreateMonitor(getDisplayName(displays[i]),
|
||||
size.width, size.height,
|
||||
bounds.origin.x, bounds.origin.y);
|
||||
size.width, size.height);
|
||||
|
||||
monitors[found]->ns.displayID = displays[i];
|
||||
found++;
|
||||
@ -258,6 +256,16 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
return monitors;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
{
|
||||
const CGRect bounds = CGDisplayBounds(monitor->ns.displayID);
|
||||
|
||||
if (xpos)
|
||||
*xpos = (int) bounds.origin.x;
|
||||
if (ypos)
|
||||
*ypos = (int) bounds.origin.y;
|
||||
}
|
||||
|
||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
||||
{
|
||||
CFArrayRef modes;
|
||||
|
@ -273,8 +273,6 @@ struct _GLFWmonitor
|
||||
|
||||
// Physical dimensions in millimeters.
|
||||
int widthMM, heightMM;
|
||||
// Logical orientation of the screen on the desktop
|
||||
int positionX, positionY;
|
||||
|
||||
GLFWvidmode* modes;
|
||||
int modeCount;
|
||||
@ -363,6 +361,11 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode);
|
||||
*/
|
||||
_GLFWmonitor** _glfwPlatformGetMonitors(int* count);
|
||||
|
||||
/*! @copydoc glfwGetMonitorPos
|
||||
* @ingroup platform
|
||||
*/
|
||||
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos);
|
||||
|
||||
/*! @copydoc glfwGetVideoModes
|
||||
* @ingroup platform
|
||||
*/
|
||||
@ -693,9 +696,7 @@ GLboolean _glfwIsValidContext(_GLFWwndconfig* wndconfig);
|
||||
|
||||
/*! @ingroup utility
|
||||
*/
|
||||
_GLFWmonitor* _glfwCreateMonitor(const char* name,
|
||||
int widthMM, int heightMM,
|
||||
int x, int y);
|
||||
_GLFWmonitor* _glfwCreateMonitor(const char* name, int widthMM, int heightMM);
|
||||
|
||||
/*! @ingroup utility
|
||||
*/
|
||||
|
@ -155,9 +155,7 @@ void _glfwInputMonitorChange(void)
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
_GLFWmonitor* _glfwCreateMonitor(const char* name,
|
||||
int widthMM, int heightMM,
|
||||
int x, int y)
|
||||
_GLFWmonitor* _glfwCreateMonitor(const char* name, int widthMM, int heightMM)
|
||||
{
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) calloc(1, sizeof(_GLFWmonitor));
|
||||
if (!monitor)
|
||||
@ -169,8 +167,6 @@ _GLFWmonitor* _glfwCreateMonitor(const char* name,
|
||||
monitor->name = strdup(name);
|
||||
monitor->widthMM = widthMM;
|
||||
monitor->heightMM = heightMM;
|
||||
monitor->positionX = x;
|
||||
monitor->positionY = y;
|
||||
|
||||
return monitor;
|
||||
}
|
||||
@ -281,10 +277,7 @@ GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
if (xpos)
|
||||
*xpos = monitor->positionX;
|
||||
if (ypos)
|
||||
*ypos = monitor->positionY;
|
||||
_glfwPlatformGetMonitorPos(monitor, xpos, ypos);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* width, int* height)
|
||||
|
@ -109,7 +109,6 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
// Enumerate display adapters
|
||||
|
||||
DISPLAY_DEVICE adapter, display;
|
||||
DEVMODE settings;
|
||||
char* name;
|
||||
HDC dc;
|
||||
|
||||
@ -127,14 +126,6 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
continue;
|
||||
}
|
||||
|
||||
ZeroMemory(&settings, sizeof(DEVMODE));
|
||||
settings.dmSize = sizeof(DEVMODE);
|
||||
|
||||
EnumDisplaySettingsEx(adapter.DeviceName,
|
||||
ENUM_CURRENT_SETTINGS,
|
||||
&settings,
|
||||
EDS_ROTATEDMODE);
|
||||
|
||||
if (found == size)
|
||||
{
|
||||
if (size)
|
||||
@ -168,9 +159,7 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
|
||||
monitors[found] = _glfwCreateMonitor(name,
|
||||
GetDeviceCaps(dc, HORZSIZE),
|
||||
GetDeviceCaps(dc, VERTSIZE),
|
||||
settings.dmPosition.x,
|
||||
settings.dmPosition.y);
|
||||
GetDeviceCaps(dc, VERTSIZE));
|
||||
|
||||
free(name);
|
||||
DeleteDC(dc);
|
||||
@ -196,6 +185,23 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
return monitors;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
{
|
||||
DEVMODE settings;
|
||||
ZeroMemory(&settings, sizeof(DEVMODE));
|
||||
settings.dmSize = sizeof(DEVMODE);
|
||||
|
||||
EnumDisplaySettingsEx(monitor->win32.name,
|
||||
ENUM_CURRENT_SETTINGS,
|
||||
&settings,
|
||||
EDS_ROTATEDMODE);
|
||||
|
||||
if (xpos)
|
||||
*xpos = settings.dmPosition.x;
|
||||
if (ypos)
|
||||
*ypos = settings.dmPosition.y;
|
||||
}
|
||||
|
||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
||||
{
|
||||
int modeIndex = 0, count = 0;
|
||||
|
@ -691,7 +691,7 @@ static int createWindow(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
int positionX, positionY, fullWidth, fullHeight;
|
||||
int xpos, ypos, fullWidth, fullHeight;
|
||||
POINT cursorPos;
|
||||
WCHAR* wideTitle;
|
||||
|
||||
@ -702,8 +702,7 @@ static int createWindow(_GLFWwindow* window,
|
||||
{
|
||||
window->win32.dwStyle |= WS_POPUP;
|
||||
|
||||
positionX = wndconfig->monitor->positionX;
|
||||
positionY = wndconfig->monitor->positionY;
|
||||
_glfwPlatformGetMonitorPos(wndconfig->monitor, &xpos, &ypos);
|
||||
|
||||
fullWidth = wndconfig->width;
|
||||
fullHeight = wndconfig->height;
|
||||
@ -719,8 +718,8 @@ static int createWindow(_GLFWwindow* window,
|
||||
window->win32.dwExStyle |= WS_EX_WINDOWEDGE;
|
||||
}
|
||||
|
||||
positionX = CW_USEDEFAULT;
|
||||
positionY = CW_USEDEFAULT;
|
||||
xpos = CW_USEDEFAULT;
|
||||
ypos = CW_USEDEFAULT;
|
||||
|
||||
getFullWindowSize(window,
|
||||
wndconfig->width, wndconfig->height,
|
||||
@ -739,7 +738,7 @@ static int createWindow(_GLFWwindow* window,
|
||||
_GLFW_WNDCLASSNAME,
|
||||
wideTitle,
|
||||
window->win32.dwStyle,
|
||||
positionX, positionY,
|
||||
xpos, ypos,
|
||||
fullWidth, fullHeight,
|
||||
NULL, // No parent window
|
||||
NULL, // No window menu
|
||||
|
@ -193,8 +193,7 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* found)
|
||||
}
|
||||
|
||||
monitors[*found] = _glfwCreateMonitor(oi->name,
|
||||
oi->mm_width, oi->mm_height,
|
||||
ci->x, ci->y);
|
||||
oi->mm_width, oi->mm_height);
|
||||
|
||||
monitors[*found]->x11.output = output;
|
||||
monitors[*found]->x11.crtc = oi->crtc;
|
||||
@ -220,8 +219,6 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* found)
|
||||
}
|
||||
else
|
||||
{
|
||||
int widthMM, heightMM;
|
||||
|
||||
monitors = (_GLFWmonitor**) calloc(1, sizeof(_GLFWmonitor*));
|
||||
if (!monitors)
|
||||
{
|
||||
@ -229,16 +226,44 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* found)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
widthMM = DisplayWidthMM(_glfw.x11.display, _glfw.x11.screen);
|
||||
heightMM = DisplayHeightMM(_glfw.x11.display, _glfw.x11.screen);
|
||||
|
||||
monitors[0] = _glfwCreateMonitor("Display", widthMM, heightMM, 0, 0);
|
||||
monitors[0] = _glfwCreateMonitor("Display",
|
||||
DisplayWidthMM(_glfw.x11.display,
|
||||
_glfw.x11.screen),
|
||||
DisplayHeightMM(_glfw.x11.display,
|
||||
_glfw.x11.screen));
|
||||
*found = 1;
|
||||
}
|
||||
|
||||
return monitors;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
{
|
||||
if (_glfw.x11.randr.available)
|
||||
{
|
||||
XRRScreenResources* sr;
|
||||
XRRCrtcInfo* ci;
|
||||
|
||||
sr = XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);
|
||||
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
|
||||
|
||||
if (xpos)
|
||||
*xpos = ci->x;
|
||||
if (ypos)
|
||||
*ypos = ci->y;
|
||||
|
||||
XRRFreeCrtcInfo(ci);
|
||||
XRRFreeScreenResources(sr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (xpos)
|
||||
*xpos = 0;
|
||||
if (ypos)
|
||||
*ypos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
||||
{
|
||||
GLFWvidmode* result;
|
||||
|
@ -199,8 +199,7 @@ static GLboolean createWindow(_GLFWwindow* window,
|
||||
if (wndconfig->monitor)
|
||||
{
|
||||
hints->flags |= PPosition;
|
||||
hints->x = wndconfig->monitor->positionX;
|
||||
hints->y = wndconfig->monitor->positionY;
|
||||
_glfwPlatformGetMonitorPos(wndconfig->monitor, &hints->x, &hints->y);
|
||||
}
|
||||
|
||||
if (!wndconfig->resizable)
|
||||
|
Loading…
Reference in New Issue
Block a user