aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/detail/implementation.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-08-04 20:19:01 +0200
committerDavid Robillard <d@drobilla.net>2019-09-03 08:34:39 +0200
commitb0ac6dcb492b68404d800fe8ed0c7393d487fa4b (patch)
tree41d0050ef6d33bfe9f2186195168e36f8a8b8f3a /pugl/detail/implementation.c
parent075c5c5927e511dd03d9608a285ed58ef395120b (diff)
downloadpugl-b0ac6dcb492b68404d800fe8ed0c7393d487fa4b.tar.gz
pugl-b0ac6dcb492b68404d800fe8ed0c7393d487fa4b.tar.bz2
pugl-b0ac6dcb492b68404d800fe8ed0c7393d487fa4b.zip
Add puglSetClassName()
Diffstat (limited to 'pugl/detail/implementation.c')
-rw-r--r--pugl/detail/implementation.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/pugl/detail/implementation.c b/pugl/detail/implementation.c
index a64e6fd..1f027a9 100644
--- a/pugl/detail/implementation.c
+++ b/pugl/detail/implementation.c
@@ -26,6 +26,15 @@
#include <string.h>
static void
+puglSetString(char** dest, const char* string)
+{
+ const size_t len = strlen(string);
+
+ *dest = (char*)realloc(*dest, len + 1);
+ strncpy(*dest, string, len + 1);
+}
+
+static void
puglSetDefaultHints(PuglHints hints)
{
hints[PUGL_USE_COMPAT_PROFILE] = PUGL_TRUE;
@@ -54,6 +63,7 @@ puglNewWorld(void)
}
world->startTime = puglGetTime(world);
+ puglSetString(&world->className, "Pugl");
return world;
}
@@ -62,10 +72,18 @@ void
puglFreeWorld(PuglWorld* const world)
{
puglFreeWorldInternals(world);
+ free(world->className);
free(world->views);
free(world);
}
+PuglStatus
+puglSetClassName(PuglWorld* const world, const char* const name)
+{
+ puglSetString(&world->className, name);
+ return PUGL_SUCCESS;
+}
+
PuglView*
puglNewView(PuglWorld* const world)
{
@@ -109,7 +127,6 @@ puglFreeView(PuglView* view)
}
puglFreeViewInternals(view);
- free(view->windowClass);
free(view);
}
@@ -128,16 +145,6 @@ puglInitWindowHint(PuglView* view, PuglWindowHint hint, int value)
}
void
-puglInitWindowClass(PuglView* view, const char* name)
-{
- const size_t len = strlen(name);
-
- free(view->windowClass);
- view->windowClass = (char*)calloc(1, len + 1);
- memcpy(view->windowClass, name, len);
-}
-
-void
puglInitWindowParent(PuglView* view, PuglNativeWindow parent)
{
view->parent = parent;