From a7cb0cb1506792d6893556bc976822e254a89106 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 9 Mar 2020 21:49:53 +0100 Subject: Add create, destroy, map, and unmap events These can be used to do things when a view is created or destroyed, in particular set up the GL context in a more controlled way. Map and unmap events are also added for when views are shown and hidden so application can react to this as well. Towards the deprecation of puglEnterContext() and puglLeaveContext(), which are prone to abuse. squash! Remove client event stuff --- pugl/detail/x11.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'pugl/detail/x11.c') diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c index cc77f29..d3e4195 100644 --- a/pugl/detail/x11.c +++ b/pugl/detail/x11.c @@ -254,6 +254,9 @@ puglCreateWindow(PuglView* view, const char* title) fprintf(stderr, "warning: XCreateIC failed\n"); } + const PuglEvent createEvent = {{PUGL_CREATE, 0}}; + puglDispatchEvent(view, &createEvent); + return PUGL_SUCCESS; } @@ -425,17 +428,11 @@ translateEvent(PuglView* view, XEvent xevent) case VisibilityNotify: view->visible = xevent.xvisibility.state != VisibilityFullyObscured; break; - case MapNotify: { - XWindowAttributes attrs = {0}; - XGetWindowAttributes(view->impl->display, view->impl->win, &attrs); - event.type = PUGL_CONFIGURE; - event.configure.x = attrs.x; - event.configure.y = attrs.y; - event.configure.width = attrs.width; - event.configure.height = attrs.height; + case MapNotify: + event.type = PUGL_MAP; break; - } case UnmapNotify: + event.type = PUGL_UNMAP; view->visible = false; break; case ConfigureNotify: -- cgit v1.2.1