mirror of
https://github.com/glfw/glfw.git
synced 2025-06-07 08:14:57 +00:00
glfwGetWindowTitle initial draft
This commit is contained in:
parent
00e86d4b73
commit
ceca17f56c
@ -3241,6 +3241,26 @@ GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
|
||||
*/
|
||||
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
|
||||
|
||||
/*! @brief Retrieves the title of the specified window.
|
||||
*
|
||||
* This function gets the window title, encoded as UTF-8, of the specified
|
||||
* window.
|
||||
*
|
||||
* @param[in] window The window to query.
|
||||
* @return A copy of the UTF-8 encoded window title, as set by glfwCreateWindow
|
||||
* or glfwSetWindowTitle, or NULL if there is an error.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
*
|
||||
* @sa @ref window_title
|
||||
* @sa @ref glfwSetWindowTitle
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* window);
|
||||
|
||||
/*! @brief Sets the title of the specified window.
|
||||
*
|
||||
* This function sets the window title, encoded as UTF-8, of the specified
|
||||
|
@ -531,6 +531,7 @@ struct _GLFWwindow
|
||||
GLFWvidmode videoMode;
|
||||
_GLFWmonitor* monitor;
|
||||
_GLFWcursor* cursor;
|
||||
char* title;
|
||||
|
||||
int minwidth, minheight;
|
||||
int maxwidth, maxheight;
|
||||
|
24
src/window.c
24
src/window.c
@ -173,6 +173,15 @@ void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor)
|
||||
window->monitor = monitor;
|
||||
}
|
||||
|
||||
// Notifies shared code that a window has new title
|
||||
//
|
||||
void _glfwInputWindowTitle(_GLFWwindow* window, const char* title)
|
||||
{
|
||||
size_t size = strlen( title ) + 1;
|
||||
window->title = _glfw_realloc(window->title, size);
|
||||
memcpy( window->title, title, size );
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW public API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -242,6 +251,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
||||
window->maxheight = GLFW_DONT_CARE;
|
||||
window->numer = GLFW_DONT_CARE;
|
||||
window->denom = GLFW_DONT_CARE;
|
||||
_glfwInputWindowTitle(window, title);
|
||||
|
||||
if (!_glfw.platform.createWindow(window, &wndconfig, &ctxconfig, &fbconfig))
|
||||
{
|
||||
@ -491,7 +501,7 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
|
||||
|
||||
*prev = window->next;
|
||||
}
|
||||
|
||||
_glfw_free(window->title);
|
||||
_glfw_free(window);
|
||||
}
|
||||
|
||||
@ -513,6 +523,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;
|
||||
@ -520,6 +540,8 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
|
||||
assert(title != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_glfwInputWindowTitle(window, title);
|
||||
_glfw.platform.setWindowTitle(window, title);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user