From 3cc5539d1c85e5044e6f893b3173cd1392bd8fc8 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 6 Jun 2022 22:41:41 -0400 Subject: Use consistent terminology for native views On MacOS in particular, views and windows are entirely different concepts, so confusing them... confuses things. This was the last holdover in the API that used the old "native window". --- bindings/cpp/include/pugl/pugl.hpp | 4 ++-- doc/c/view.rst | 4 ++-- examples/pugl_embed_demo.c | 2 +- examples/pugl_window_demo.c | 2 +- include/pugl/pugl.h | 13 +++++++++++-- src/mac.m | 2 +- src/win.c | 2 +- src/x11.c | 2 +- test/test_view.c | 4 ++-- 9 files changed, 22 insertions(+), 13 deletions(-) diff --git a/bindings/cpp/include/pugl/pugl.hpp b/bindings/cpp/include/pugl/pugl.hpp index 6dd5042..e80408c 100644 --- a/bindings/cpp/include/pugl/pugl.hpp +++ b/bindings/cpp/include/pugl/pugl.hpp @@ -518,8 +518,8 @@ public: /// @copydoc puglGetVisible bool visible() const noexcept { return puglGetVisible(cobj()); } - /// @copydoc puglGetNativeWindow - NativeView nativeWindow() noexcept { return puglGetNativeWindow(cobj()); } + /// @copydoc puglGetNativeView + NativeView nativeView() noexcept { return puglGetNativeView(cobj()); } /** @} diff --git a/doc/c/view.rst b/doc/c/view.rst index 016c4e3..634b736 100644 --- a/doc/c/view.rst +++ b/doc/c/view.rst @@ -52,12 +52,12 @@ To embed the view in another window, you will need to somehow get the :type:`native view handle ` for the parent, then set it with :func:`puglSetParentWindow`. If the parent is a Pugl view, -the native handle can be accessed with :func:`puglGetNativeWindow`. +the native handle can be accessed with :func:`puglGetNativeView`. For example: .. code-block:: c - puglSetParentWindow(view, puglGetNativeWindow(parent)); + puglSetParentWindow(view, puglGetNativeView(parent)); ************************ Setting an Event Handler diff --git a/examples/pugl_embed_demo.c b/examples/pugl_embed_demo.c index f7e4676..9f93287 100644 --- a/examples/pugl_embed_demo.c +++ b/examples/pugl_embed_demo.c @@ -289,7 +289,7 @@ main(int argc, char** argv) } puglSetFrame(app.child, getChildFrame(parentFrame)); - puglSetParentWindow(app.child, puglGetNativeWindow(app.parent)); + puglSetParentWindow(app.child, puglGetNativeView(app.parent)); puglSetViewHint(app.child, PUGL_USE_DEBUG_CONTEXT, opts.errorChecking); puglSetViewHint(app.child, PUGL_SAMPLES, opts.samples); diff --git a/examples/pugl_window_demo.c b/examples/pugl_window_demo.c index 3b8da31..b3deb0d 100644 --- a/examples/pugl_window_demo.c +++ b/examples/pugl_window_demo.c @@ -206,7 +206,7 @@ main(int argc, char** argv) if (i == 1) { puglSetTransientParent(app.cubes[1].view, - puglGetNativeWindow(app.cubes[0].view)); + puglGetNativeView(app.cubes[0].view)); } if ((st = puglRealize(view))) { diff --git a/include/pugl/pugl.h b/include/pugl/pugl.h index dc9c010..397d25e 100644 --- a/include/pugl/pugl.h +++ b/include/pugl/pugl.h @@ -1157,7 +1157,7 @@ puglGetTransientParent(const PuglView* view); Realize a view by creating a corresponding system view or window. After this call, the (initially invisible) underlying system view exists and - can be accessed with puglGetNativeWindow(). There is currently no + can be accessed with puglGetNativeView(). There is currently no corresponding unrealize function, the system view will be destroyed along with the view when puglFreeView() is called. @@ -1194,7 +1194,7 @@ puglGetVisible(const PuglView* view); /// Return the native window handle PUGL_API PuglNativeView -puglGetNativeWindow(PuglView* view); +puglGetNativeView(PuglView* view); /** @} @@ -1536,6 +1536,7 @@ typedef PuglLoopLeaveEvent PuglEventLoopLeave; Windows: This is a `HWND`. */ +PUGL_DEPRECATED_BY("PuglNativeView") typedef uintptr_t PuglNativeWindow; /** @@ -1914,6 +1915,14 @@ puglSetAspectRatio(PuglView* view, int minX, int minY, int maxX, int maxY) return st0 ? st0 : st1; } +/// Return the native window handle +static inline PUGL_DEPRECATED_BY("puglGetNativeView") +PuglNativeView +puglGetNativeWindow(PuglView* view) +{ + return puglGetNativeView(view); +} + #endif // PUGL_DISABLE_DEPRECATED /** diff --git a/src/mac.m b/src/mac.m index ce156f5..fafade3 100644 --- a/src/mac.m +++ b/src/mac.m @@ -1421,7 +1421,7 @@ puglPostRedisplayRect(PuglView* view, const PuglRect rect) } PuglNativeView -puglGetNativeWindow(PuglView* view) +puglGetNativeView(PuglView* view) { return (PuglNativeView)view->impl->wrapperView; } diff --git a/src/win.c b/src/win.c index ea64fdc..0150d67 100644 --- a/src/win.c +++ b/src/win.c @@ -1002,7 +1002,7 @@ puglPostRedisplayRect(PuglView* view, const PuglRect rect) } PuglNativeView -puglGetNativeWindow(PuglView* view) +puglGetNativeView(PuglView* view) { return (PuglNativeView)view->impl->hwnd; } diff --git a/src/x11.c b/src/x11.c index 582b6f7..ac81ca8 100644 --- a/src/x11.c +++ b/src/x11.c @@ -1547,7 +1547,7 @@ puglPostRedisplayRect(PuglView* const view, const PuglRect rect) } PuglNativeView -puglGetNativeWindow(PuglView* const view) +puglGetNativeView(PuglView* const view) { return (PuglNativeView)view->impl->win; } diff --git a/test/test_view.c b/test/test_view.c index e9a954c..f8b0cb5 100644 --- a/test/test_view.c +++ b/test/test_view.c @@ -79,8 +79,8 @@ main(int argc, char** argv) assert(!puglUpdate(test.world, -1.0)); } - // Check that puglGetNativeWindow() returns something - assert(puglGetNativeWindow(test.view)); + // Check that puglGetNativeView() returns something + assert(puglGetNativeView(test.view)); // Tear down puglFreeView(test.view); -- cgit v1.2.1