Added GetCurrentMonitor() function to Get the monitor that contains the greater window area
This commit is contained in:
parent
7b4831f1b7
commit
6a30b4a2a7
43
src/core.c
43
src/core.c
|
|
@ -938,6 +938,47 @@ int GetMonitorCount(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GetCurrentMonitor(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
int bestmonitor = 0;
|
||||||
|
|
||||||
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
|
||||||
|
int nmonitors, i;
|
||||||
|
int wx, wy, ww, wh;
|
||||||
|
int mx, my, mw, mh;
|
||||||
|
int overlap, bestoverlap;
|
||||||
|
GLFWmonitor **monitors;
|
||||||
|
const GLFWvidmode *mode;
|
||||||
|
|
||||||
|
bestoverlap = 0;
|
||||||
|
|
||||||
|
glfwGetWindowPos(window, &wx, &wy);
|
||||||
|
glfwGetWindowSize(window, &ww, &wh);
|
||||||
|
monitors = glfwGetMonitors(&nmonitors);
|
||||||
|
|
||||||
|
for (i = 0; i < nmonitors; i++) {
|
||||||
|
mode = glfwGetVideoMode(monitors[i]);
|
||||||
|
glfwGetMonitorPos(monitors[i], &mx, &my);
|
||||||
|
mw = mode->width;
|
||||||
|
mh = mode->height;
|
||||||
|
|
||||||
|
overlap =
|
||||||
|
maxi(0, mini(wx + ww, mx + mw) - maxi(wx, mx)) *
|
||||||
|
maxi(0, mini(wy + wh, my + mh) - maxi(wy, my));
|
||||||
|
|
||||||
|
if (bestoverlap < overlap) {
|
||||||
|
bestoverlap = overlap;
|
||||||
|
bestmonitor = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return bestmonitor;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get primary monitor width
|
// Get primary monitor width
|
||||||
int GetMonitorWidth(int monitor)
|
int GetMonitorWidth(int monitor)
|
||||||
{
|
{
|
||||||
|
|
@ -4991,4 +5032,4 @@ static void LogoAnimation(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
showLogo = false; // Prevent for repeating when reloading window (Android)
|
showLogo = false; // Prevent for repeating when reloading window (Android)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -878,6 +878,7 @@ RLAPI void *GetWindowHandle(void); // Get native
|
||||||
RLAPI int GetScreenWidth(void); // Get current screen width
|
RLAPI int GetScreenWidth(void); // Get current screen width
|
||||||
RLAPI int GetScreenHeight(void); // Get current screen height
|
RLAPI int GetScreenHeight(void); // Get current screen height
|
||||||
RLAPI int GetMonitorCount(void); // Get number of connected monitors
|
RLAPI int GetMonitorCount(void); // Get number of connected monitors
|
||||||
|
RLAPI int GetCurrentMonitor(void); // Get the monitor that contains the greater window area.
|
||||||
RLAPI int GetMonitorWidth(int monitor); // Get primary monitor width
|
RLAPI int GetMonitorWidth(int monitor); // Get primary monitor width
|
||||||
RLAPI int GetMonitorHeight(int monitor); // Get primary monitor height
|
RLAPI int GetMonitorHeight(int monitor); // Get primary monitor height
|
||||||
RLAPI int GetMonitorPhysicalWidth(int monitor); // Get primary monitor physical width in millimetres
|
RLAPI int GetMonitorPhysicalWidth(int monitor); // Get primary monitor physical width in millimetres
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user