Changes SetWindowMonitor() to no longer force fullscreen (#3209)
* Changes SetWindowMonitor() to no longer force fullscreen * Readds fullscreen support
This commit is contained in:
parent
5d28bad0ad
commit
962030e70a
2 changed files with 29 additions and 5 deletions
|
@ -954,7 +954,7 @@ RLAPI void SetWindowIcon(Image image); // Set icon fo
|
||||||
RLAPI void SetWindowIcons(Image *images, int count); // Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
|
RLAPI void SetWindowIcons(Image *images, int count); // Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
|
||||||
RLAPI void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP)
|
RLAPI void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP)
|
||||||
RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP)
|
RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP)
|
||||||
RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode)
|
RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window
|
||||||
RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
|
RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE)
|
||||||
RLAPI void SetWindowSize(int width, int height); // Set window dimensions
|
RLAPI void SetWindowSize(int width, int height); // Set window dimensions
|
||||||
RLAPI void SetWindowOpacity(float opacity); // Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
|
RLAPI void SetWindowOpacity(float opacity); // Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
|
||||||
|
|
26
src/rcore.c
26
src/rcore.c
|
@ -1661,7 +1661,7 @@ void SetWindowPosition(int x, int y)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set monitor for the current window (fullscreen mode)
|
// Set monitor for the current window
|
||||||
void SetWindowMonitor(int monitor)
|
void SetWindowMonitor(int monitor)
|
||||||
{
|
{
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
@ -1669,12 +1669,36 @@ void SetWindowMonitor(int monitor)
|
||||||
GLFWmonitor **monitors = glfwGetMonitors(&monitorCount);
|
GLFWmonitor **monitors = glfwGetMonitors(&monitorCount);
|
||||||
|
|
||||||
if ((monitor >= 0) && (monitor < monitorCount))
|
if ((monitor >= 0) && (monitor < monitorCount))
|
||||||
|
{
|
||||||
|
if (CORE.Window.fullscreen)
|
||||||
{
|
{
|
||||||
TRACELOG(LOG_INFO, "GLFW: Selected fullscreen monitor: [%i] %s", monitor, glfwGetMonitorName(monitors[monitor]));
|
TRACELOG(LOG_INFO, "GLFW: Selected fullscreen monitor: [%i] %s", monitor, glfwGetMonitorName(monitors[monitor]));
|
||||||
|
|
||||||
const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
|
const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
|
||||||
glfwSetWindowMonitor(CORE.Window.handle, monitors[monitor], 0, 0, mode->width, mode->height, mode->refreshRate);
|
glfwSetWindowMonitor(CORE.Window.handle, monitors[monitor], 0, 0, mode->width, mode->height, mode->refreshRate);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TRACELOG(LOG_INFO, "GLFW: Selected monitor: [%i] %s", monitor, glfwGetMonitorName(monitors[monitor]));
|
||||||
|
|
||||||
|
const int screenWidth = CORE.Window.screen.width;
|
||||||
|
const int screenHeight = CORE.Window.screen.height;
|
||||||
|
int monitorWorkareaX = 0;
|
||||||
|
int monitorWorkareaY = 0;
|
||||||
|
int monitorWorkareaWidth = 0;
|
||||||
|
int monitorWorkareaHeight = 0;
|
||||||
|
glfwGetMonitorWorkarea(monitors[monitor], &monitorWorkareaX, &monitorWorkareaY, &monitorWorkareaWidth, &monitorWorkareaHeight);
|
||||||
|
|
||||||
|
// If the screen size is larger than the monitor workarea, anchor it on the top left corner, otherwise, center it
|
||||||
|
if ((screenWidth >= monitorWorkareaWidth) || (screenHeight >= monitorWorkareaHeight)) glfwSetWindowPos(CORE.Window.handle, monitorWorkareaX, monitorWorkareaY);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const int x = monitorWorkareaX + (monitorWorkareaWidth*0.5f) - (screenWidth*0.5f);
|
||||||
|
const int y = monitorWorkareaY + (monitorWorkareaHeight*0.5f) - (screenHeight*0.5f);
|
||||||
|
glfwSetWindowPos(CORE.Window.handle, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
|
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue