diff options
author | David Robillard <d@drobilla.net> | 2020-03-09 21:49:53 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-03-09 21:49:53 +0100 |
commit | a7cb0cb1506792d6893556bc976822e254a89106 (patch) | |
tree | c6ea552a3fb0fbf711ecbfafc699030eda3f8158 /pugl/detail/win.c | |
parent | ed301f0548438692269481096e6ef51c3ead01dc (diff) | |
download | pugl-a7cb0cb1506792d6893556bc976822e254a89106.tar.gz pugl-a7cb0cb1506792d6893556bc976822e254a89106.tar.bz2 pugl-a7cb0cb1506792d6893556bc976822e254a89106.zip |
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
Diffstat (limited to 'pugl/detail/win.c')
-rw-r--r-- | pugl/detail/win.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/pugl/detail/win.c b/pugl/detail/win.c index b7f03a3..2e0cd96 100644 --- a/pugl/detail/win.c +++ b/pugl/detail/win.c @@ -193,6 +193,9 @@ puglCreateWindow(PuglView* view, const char* title) puglSetFrame(view, view->frame); SetWindowLongPtr(impl->hwnd, GWLP_USERDATA, (LONG_PTR)view); + const PuglEvent createEvent = {{PUGL_CREATE, 0}}; + view->eventFunc(view, &createEvent); + return PUGL_SUCCESS; } @@ -203,7 +206,6 @@ puglShowWindow(PuglView* view) ShowWindow(impl->hwnd, SW_SHOWNORMAL); SetFocus(impl->hwnd); - view->visible = true; return PUGL_SUCCESS; } @@ -213,7 +215,6 @@ puglHideWindow(PuglView* view) PuglInternals* impl = view->impl; ShowWindow(impl->hwnd, SW_HIDE); - view->visible = false; return PUGL_SUCCESS; } @@ -554,9 +555,17 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam) case WM_SHOWWINDOW: if (wParam) { handleConfigure(view, &event); + puglDispatchEvent(view, &event); + event.type = PUGL_NOTHING; + RedrawWindow(view->impl->hwnd, NULL, NULL, RDW_INVALIDATE|RDW_ALLCHILDREN|RDW_INTERNALPAINT); } + + if ((bool)wParam != view->visible) { + view->visible = wParam; + event.any.type = wParam ? PUGL_MAP : PUGL_UNMAP; + } break; case WM_SIZE: handleConfigure(view, &event); |