diff options
| author | Jeffery Myers <[email protected]> | 2020-12-30 08:29:39 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-12-30 17:29:39 +0100 |
| commit | 4c8bebc0d785cb9445ef8ea34a9b2d813c4a6153 (patch) | |
| tree | d04fb17e5ac530889cd541c4b286c10298afa2f3 /src | |
| parent | 24b6dcf29ff3ce8765da5e24a8ad4ae6df63bcaa (diff) | |
| download | raylib-4c8bebc0d785cb9445ef8ea34a9b2d813c4a6153.tar.gz raylib-4c8bebc0d785cb9445ef8ea34a9b2d813c4a6153.zip | |
Add a current monitor function for window mode windows. (#1492)
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.c | 37 |
1 files changed, 33 insertions, 4 deletions
@@ -1458,12 +1458,41 @@ int GetCurrentMonitor(void) #if defined(PLATFORM_DESKTOP) int monitorCount; GLFWmonitor** monitors = glfwGetMonitors(&monitorCount); + GLFWmonitor* monitor = NULL; - GLFWmonitor* monitor = glfwGetWindowMonitor(CORE.Window.handle); - for (int i = 0; i < monitorCount; i++) + if (monitorCount == 1) // easy out + return 0; + + if (IsWindowFullscreen()) + { + monitor = glfwGetWindowMonitor(CORE.Window.handle); + for (int i = 0; i < monitorCount; i++) + { + if (monitors[i] == monitor) + return i; + } + return 0; + } + else { - if (monitors[i] == monitor) - return i; + int x = 0; + int y = 0; + + glfwGetWindowPos(CORE.Window.handle, &x, &y); + + for (int i = 0; i < monitorCount; i++) + { + int mx = 0; + int my = 0; + + int width = 0; + int height = 0; + + monitor = monitors[i]; + glfwGetMonitorWorkarea(monitor, &mx, &my, &width, &height); + if (x >= mx && x <= (mx + width) && y >= my && y <= (my + height)) + return i; + } } return 0; #else |
