aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2019-08-23 22:22:22 +0200
committerGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2019-08-23 22:22:22 +0200
commit706cbf912c41986ce81e3335900d93b49b7ffa6d (patch)
treef6d9f04867e20239286a77f11e766978c441c4b6
parent6ab5c633f53d941118aff72684c174e0db6cce3f (diff)
downloadd2tk-706cbf912c41986ce81e3335900d93b49b7ffa6d.zip
d2tk-706cbf912c41986ce81e3335900d93b49b7ffa6d.tar.gz
d2tk-706cbf912c41986ce81e3335900d93b49b7ffa6d.tar.bz2
d2tk-706cbf912c41986ce81e3335900d93b49b7ffa6d.tar.xz
pugl: various fixes for upstream pugl:app branchHEADmaster
-rw-r--r--VERSION2
-rw-r--r--src/frontend_pugl.c74
2 files changed, 51 insertions, 25 deletions
diff --git a/VERSION b/VERSION
index 1968b2f..379ebc9 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.805
+0.1.811
diff --git a/src/frontend_pugl.c b/src/frontend_pugl.c
index 2a13988..84a10b8 100644
--- a/src/frontend_pugl.c
+++ b/src/frontend_pugl.c
@@ -42,6 +42,7 @@
struct _d2tk_pugl_t {
const d2tk_pugl_config_t *config;
bool done;
+ PuglWorld *world;
PuglView *view;
d2tk_base_t *base;
void *ctx;
@@ -84,7 +85,7 @@ _d2tk_pugl_modifiers(d2tk_pugl_t *dpugl, unsigned state)
d2tk_base_set_alt(base, state & PUGL_MOD_ALT ? true : false);
}
-static void
+static PuglStatus
_d2tk_pugl_event_func(PuglView *view, const PuglEvent *e)
{
d2tk_pugl_t *dpugl = puglGetHandle(view);
@@ -314,12 +315,14 @@ _d2tk_pugl_event_func(PuglView *view, const PuglEvent *e)
// nothing
} break;
}
+
+ return PUGL_SUCCESS;
}
D2TK_API int
d2tk_pugl_step(d2tk_pugl_t *dpugl)
{
- const PuglStatus stat = puglProcessEvents(dpugl->view);
+ const PuglStatus stat = puglDispatchEvents(dpugl->world);
(void)stat;
return dpugl->done;
@@ -376,13 +379,17 @@ d2tk_pugl_free(d2tk_pugl_t *dpugl)
puglLeaveContext(dpugl->view, false);
}
- if(dpugl->view)
+ if(dpugl->world)
{
- if(puglGetVisible(dpugl->view))
+ if(dpugl->view)
{
- puglHideWindow(dpugl->view);
+ if(puglGetVisible(dpugl->view))
+ {
+ puglHideWindow(dpugl->view);
+ }
+ puglFreeView(dpugl->view);
}
- puglDestroy(dpugl->view);
+ puglFreeWorld(dpugl->world);
}
free(dpugl);
@@ -447,37 +454,52 @@ d2tk_pugl_new(const d2tk_pugl_config_t *config, uintptr_t *widget)
dpugl->config = config;
- dpugl->view = puglInit(NULL, NULL);
+ dpugl->world = puglNewWorld();
+ if(!dpugl->world)
+ {
+ fprintf(stderr, "puglNewWorld failed\n");
+ goto fail;
+ }
+
+ puglSetClassName(dpugl->world, "d2tk");
+
+ dpugl->view = puglNewView(dpugl->world);
if(!dpugl->view)
{
- fprintf(stderr, "puglInit failed\n");
+ fprintf(stderr, "puglNewView failed\n");
goto fail;
}
- puglInitWindowClass(dpugl->view, "d2tk");
- puglInitWindowSize(dpugl->view, config->w, config->h);
+ const PuglRect frame = {
+ .x = 0,
+ .y = 0,
+ .width = config->w,
+ .height = config->h
+ };
+
+ puglSetFrame(dpugl->view, frame);
if(config->min_w && config->min_h)
{
- puglInitWindowMinSize(dpugl->view, config->min_w, config->min_h);
+ puglSetMinSize(dpugl->view, config->min_w, config->min_h);
}
if(config->parent)
{
- puglInitWindowParent(dpugl->view, config->parent);
- puglInitTransientFor(dpugl->view, config->parent);
+ puglSetParentWindow(dpugl->view, config->parent);
+ puglSetTransientFor(dpugl->view, config->parent);
}
if(config->fixed_aspect)
{
- puglInitWindowAspectRatio(dpugl->view, config->w, config->h,
+ puglSetAspectRatio(dpugl->view, config->w, config->h,
config->w, config->h);
}
- puglInitWindowHint(dpugl->view, PUGL_RESIZABLE, !config->fixed_size);
+ puglSetViewHint(dpugl->view, PUGL_RESIZABLE, !config->fixed_size);
puglSetHandle(dpugl->view, dpugl);
puglSetEventFunc(dpugl->view, _d2tk_pugl_event_func);
#if defined(PUGL_HAVE_CAIRO)
- puglInitBackend(dpugl->view, puglCairoBackend());
+ puglSetBackend(dpugl->view, puglCairoBackend());
#else
- puglInitBackend(dpugl->view, puglGlBackend());
+ puglSetBackend(dpugl->view, puglGlBackend());
#endif
const int stat = puglCreateWindow(dpugl->view, "d2tk");
@@ -516,16 +538,20 @@ d2tk_pugl_new(const d2tk_pugl_config_t *config, uintptr_t *widget)
fail:
if(dpugl)
{
- if(dpugl->view)
+ if(dpugl->world)
{
- if(dpugl->ctx)
+ if(dpugl->view)
{
- puglEnterContext(dpugl->view, false);
- d2tk_core_driver.free(dpugl->ctx);
- puglLeaveContext(dpugl->view, false);
- }
+ if(dpugl->ctx)
+ {
+ puglEnterContext(dpugl->view, false);
+ d2tk_core_driver.free(dpugl->ctx);
+ puglLeaveContext(dpugl->view, false);
+ }
- puglDestroy(dpugl->view);
+ puglFreeView(dpugl->view);
+ }
+ puglFreeWorld(dpugl->world);
}
free(dpugl);