From 523bea1b0516fa6f8f982ef117d80ed9695b1fa1 Mon Sep 17 00:00:00 2001 From: Stuart Hayhurst Date: Wed, 27 Dec 2023 22:13:49 +0000 Subject: [PATCH] Allow modifying window geometry --- src/ammonite/window.cpp | 21 +++++++++++++++++++++ src/ammonite/window.hpp | 3 +++ 2 files changed, 24 insertions(+) diff --git a/src/ammonite/window.cpp b/src/ammonite/window.cpp index 95964a7..017f92d 100644 --- a/src/ammonite/window.cpp +++ b/src/ammonite/window.cpp @@ -236,6 +236,27 @@ namespace ammonite { useIcons(iconPaths, pngFiles.size()); } + void setWindowGeometry(int width, int height, int xPos, int yPos) { + //Don't allow setting window geometry for fullscreen windows + if (isFullscreen) { + return; + } + + //Update the geometry of the window + glfwSetWindowPos(windowPtr, xPos, yPos); + glfwSetWindowSize(windowPtr, width, height); + } + + void getWindowGeometry(int* width, int* height, int* xPos, int* yPos) { + //Don't allow querying window geometry for fullscreen windows + if (isFullscreen) { + return; + } + + glfwGetWindowSize(windowPtr, width, height); + glfwGetWindowPos(windowPtr, xPos, yPos); + } + bool getFullscreen() { return isFullscreen; } diff --git a/src/ammonite/window.hpp b/src/ammonite/window.hpp index 7b22562..ee2ebb1 100644 --- a/src/ammonite/window.hpp +++ b/src/ammonite/window.hpp @@ -20,6 +20,9 @@ namespace ammonite { void useIcon(const char* iconPath); void useIconDir(const char* iconDirPath); + void setWindowGeometry(int width, int height, int xPos, int yPos); + void getWindowGeometry(int* width, int* height, int* xPos, int* yPos); + bool getFullscreen(); GLFWmonitor* getFullscreenMonitor(); int getMonitors(GLFWmonitor*** monitorsPtr);