I am testing multi-monitor support for my GLFW application and I have come across a bug. The code I am using works 100% fine with 2 monitors, if one monitor is 1920x1080 and the second is 1920x1200, but if the second monitor is a 4K monitor then a lot weird stuff starts happening.
If I choose a window size of 1536x864 on the second monitor, a 3840x2160 window is created, with the entire area black and the1536x864 area of content in the bottom left corner!
If I choose a window size of 2560x1440 on the second monitor, this time the window is created with the correct size, but the mouse co-ordinates are wrong - they are offset 50 pixels downwards.
This is the code I am using:
int numMonitors;
GLFWmonitor** monitors = glfwGetMonitors(&numMonitors);
int xPos;
int yPos;
int widthWorkArea;
int heightWorkArea;
glfwGetMonitorWorkarea(monitors[m_ixMonitorCurr], &xPos, &yPos, &widthWorkArea, &heightWorkArea);
if (m_posWindow.m_x < xPos || m_posWindow.m_x >= xPos+widthWorkArea) m_posWindow.m_x = xPos;
if (m_posWindow.m_y < yPos || m_posWindow.m_y >= yPos+heightWorkArea) m_posWindow.m_y = yPos;
glfwWindowHint(GLFW_DECORATED, GL_FALSE);
g_pWindow = glfwCreateWindow(pMonitorSettings->GetScreenWidth(),
pMonitorSettings->GetScreenHeight(), "Merc Tactics", NULL, NULL);
glfwSetWindowPos(g_pWindow, m_posWindow.m_x,
m_posWindow.m_y);