Add glfwGetWindowTitle

This adds a function for querying the current title of a window.  This
currently returns a copy of the last title set via GLFW.

Fixes #1448
Closes #1909
Closes #2482
This commit is contained in:
Doug Binks
2024-02-07 19:26:52 +00:00
committed by Camilla Löwy
parent bafece4cf7
commit 95d464bb4b
8 changed files with 81 additions and 2 deletions
+1
View File
@@ -532,6 +532,7 @@ struct _GLFWwindow
GLFWvidmode videoMode;
_GLFWmonitor* monitor;
_GLFWcursor* cursor;
char* title;
int minwidth, minheight;
int maxwidth, maxheight;
+17 -1
View File
@@ -242,6 +242,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
window->maxheight = GLFW_DONT_CARE;
window->numer = GLFW_DONT_CARE;
window->denom = GLFW_DONT_CARE;
window->title = _glfw_strdup(title);
if (!_glfw.platform.createWindow(window, &wndconfig, &ctxconfig, &fbconfig))
{
@@ -493,7 +494,7 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
*prev = window->next;
}
_glfw_free(window->title);
_glfw_free(window);
}
@@ -515,6 +516,16 @@ GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value)
window->shouldClose = value;
}
GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return window->title;
}
GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
@@ -522,7 +533,12 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
assert(title != NULL);
_GLFW_REQUIRE_INIT();
char* prev = window->title;
window->title = _glfw_strdup(title);
_glfw.platform.setWindowTitle(window, title);
_glfw_free(prev);
}
GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle,