aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/detail
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-03-15 18:14:19 +0100
committerDavid Robillard <d@drobilla.net>2020-03-15 20:53:37 +0100
commit87351f2a8aaaad988b44e985ac5240af43d331e3 (patch)
tree3631d55d2fbf5e8a4e2fe97d4dd3845400d93ddb /pugl/detail
parent9f1467c2173c487e35522139abc54d583a4078e9 (diff)
downloadpugl-87351f2a8aaaad988b44e985ac5240af43d331e3.tar.gz
pugl-87351f2a8aaaad988b44e985ac5240af43d331e3.tar.bz2
pugl-87351f2a8aaaad988b44e985ac5240af43d331e3.zip
Add type and flags to world
Unfortunately this is an API break, but there's no reasonable way to deprecate the old function and this is required for things to work correctly. The type will be used in following commits to tick the main loop and dispatch events correctly for either case.
Diffstat (limited to 'pugl/detail')
-rw-r--r--pugl/detail/implementation.c4
-rw-r--r--pugl/detail/implementation.h3
-rw-r--r--pugl/detail/mac.m3
-rw-r--r--pugl/detail/win.c3
-rw-r--r--pugl/detail/x11.c6
5 files changed, 13 insertions, 6 deletions
diff --git a/pugl/detail/implementation.c b/pugl/detail/implementation.c
index 17cc6fd..b2306c6 100644
--- a/pugl/detail/implementation.c
+++ b/pugl/detail/implementation.c
@@ -115,10 +115,10 @@ puglSetDefaultHints(PuglHints hints)
}
PuglWorld*
-puglNewWorld(void)
+puglNewWorld(PuglWorldType type, PuglWorldFlags flags)
{
PuglWorld* world = (PuglWorld*)calloc(1, sizeof(PuglWorld));
- if (!world || !(world->impl = puglInitWorldInternals())) {
+ if (!world || !(world->impl = puglInitWorldInternals(type, flags))) {
free(world);
return NULL;
}
diff --git a/pugl/detail/implementation.h b/pugl/detail/implementation.h
index f363a30..2ad3f65 100644
--- a/pugl/detail/implementation.h
+++ b/pugl/detail/implementation.h
@@ -36,7 +36,8 @@ void puglSetBlob(PuglBlob* dest, const void* data, size_t len);
void puglSetString(char** dest, const char* string);
/** Allocate and initialise world internals (implemented once per platform) */
-PuglWorldInternals* puglInitWorldInternals(void);
+PuglWorldInternals*
+puglInitWorldInternals(PuglWorldType type, PuglWorldFlags flags);
/** Destroy and free world internals (implemented once per platform) */
void puglFreeWorldInternals(PuglWorld* world);
diff --git a/pugl/detail/mac.m b/pugl/detail/mac.m
index 2920675..ab59b99 100644
--- a/pugl/detail/mac.m
+++ b/pugl/detail/mac.m
@@ -695,7 +695,8 @@ handleCrossing(PuglWrapperView* view, NSEvent* event, const PuglEventType type)
@end
PuglWorldInternals*
-puglInitWorldInternals(void)
+puglInitWorldInternals(PuglWorldType PUGL_UNUSED(type),
+ PuglWorldFlags PUGL_UNUSED(flags))
{
PuglWorldInternals* impl = (PuglWorldInternals*)calloc(
1, sizeof(PuglWorldInternals));
diff --git a/pugl/detail/win.c b/pugl/detail/win.c
index 290a658..bbaa872 100644
--- a/pugl/detail/win.c
+++ b/pugl/detail/win.c
@@ -105,7 +105,8 @@ puglRegisterWindowClass(const char* name)
}
PuglWorldInternals*
-puglInitWorldInternals(void)
+puglInitWorldInternals(PuglWorldType PUGL_UNUSED(type),
+ PuglWorldFlags PUGL_UNUSED(flags))
{
PuglWorldInternals* impl = (PuglWorldInternals*)calloc(
1, sizeof(PuglWorldInternals));
diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c
index 10ae0bb..7edc1ed 100644
--- a/pugl/detail/x11.c
+++ b/pugl/detail/x11.c
@@ -66,8 +66,12 @@ static const long eventMask =
ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask);
PuglWorldInternals*
-puglInitWorldInternals(void)
+puglInitWorldInternals(PuglWorldType type, PuglWorldFlags flags)
{
+ if (type == PUGL_PROGRAM && (flags & PUGL_WORLD_THREADS)) {
+ XInitThreads();
+ }
+
Display* display = XOpenDisplay(NULL);
if (!display) {
return NULL;