diff options
Diffstat (limited to 'pugl/detail')
-rw-r--r-- | pugl/detail/mac.m | 17 | ||||
-rw-r--r-- | pugl/detail/win.c | 17 | ||||
-rw-r--r-- | pugl/detail/win.h | 5 |
3 files changed, 38 insertions, 1 deletions
diff --git a/pugl/detail/mac.m b/pugl/detail/mac.m index 501be02..480253e 100644 --- a/pugl/detail/mac.m +++ b/pugl/detail/mac.m @@ -1154,6 +1154,23 @@ puglSetAspectRatio(PuglView* const view, return PUGL_SUCCESS; } +PuglStatus +puglSetTransientFor(PuglView* view, PuglNativeView parent) +{ + view->transientParent = parent; + + if (view->impl->window) { + NSWindow* parentWindow = [(NSView*)parent window]; + if (parentWindow) { + [parentWindow addChildWindow:view->impl->window + ordered:NSWindowAbove]; + return PUGL_SUCCESS; + } + } + + return PUGL_FAILURE; +} + const void* puglGetClipboard(PuglView* const view, const char** const type, diff --git a/pugl/detail/win.c b/pugl/detail/win.c index 44ba6cd..cb9a69c 100644 --- a/pugl/detail/win.c +++ b/pugl/detail/win.c @@ -979,6 +979,23 @@ puglSetAspectRatio(PuglView* const view, return PUGL_SUCCESS; } +PuglStatus +puglSetTransientFor(PuglView* view, PuglNativeView parent) +{ + if (view->parent) { + return PUGL_FAILURE; + } + + view->transientParent = parent; + + if (view->impl->hwnd) { + SetWindowLongPtr(view->impl->hwnd, GWLP_HWNDPARENT, (LONG_PTR)parent); + return GetLastError() == NO_ERROR ? PUGL_SUCCESS : PUGL_FAILURE; + } + + return PUGL_SUCCESS; +} + const void* puglGetClipboard(PuglView* const view, const char** const type, diff --git a/pugl/detail/win.h b/pugl/detail/win.h index 949fa90..241ea24 100644 --- a/pugl/detail/win.h +++ b/pugl/detail/win.h @@ -96,6 +96,9 @@ puglWinCreateWindow(const PuglView* const view, const unsigned winFlags = puglWinGetWindowFlags(view); const unsigned winExFlags = puglWinGetWindowExFlags(view); + // The meaning of "parent" depends on the window type (WS_CHILD) + PuglNativeView parent = view->parent ? view->parent : view->transientParent; + // Calculate total window size to accommodate requested view size RECT wr = { (long)view->frame.x, (long)view->frame.y, (long)view->frame.width, (long)view->frame.height }; @@ -105,7 +108,7 @@ puglWinCreateWindow(const PuglView* const view, if (!(*hwnd = CreateWindowEx(winExFlags, className, title, winFlags, CW_USEDEFAULT, CW_USEDEFAULT, wr.right-wr.left, wr.bottom-wr.top, - (HWND)view->parent, NULL, NULL, NULL))) { + (HWND)parent, NULL, NULL, NULL))) { return PUGL_REALIZE_FAILED; } else if (!(*hdc = GetDC(*hwnd))) { DestroyWindow(*hwnd); |