From 075c5c5927e511dd03d9608a285ed58ef395120b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 4 Aug 2019 19:51:49 +0200 Subject: Replace puglInitTransientFor() with puglSetTransientFor() --- pugl/detail/implementation.c | 6 ------ pugl/detail/x11.c | 13 +++++++++++++ pugl/pugl.h | 30 +++++++++++++++++++++--------- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/pugl/detail/implementation.c b/pugl/detail/implementation.c index f971284..a64e6fd 100644 --- a/pugl/detail/implementation.c +++ b/pugl/detail/implementation.c @@ -143,12 +143,6 @@ puglInitWindowParent(PuglView* view, PuglNativeWindow parent) view->parent = parent; } -void -puglInitTransientFor(PuglView* view, uintptr_t parent) -{ - view->transientParent = parent; -} - int puglInitBackend(PuglView* view, const PuglBackend* backend) { diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c index d7b7677..ea8367c 100644 --- a/pugl/detail/x11.c +++ b/pugl/detail/x11.c @@ -761,3 +761,16 @@ puglSetAspectRatio(PuglView* const view, return PUGL_SUCCESS; } + +void +puglSetTransientFor(PuglView* view, PuglNativeWindow parent) +{ + Display* display = view->world->impl->display; + + view->transientParent = parent; + + if (view->impl->win) { + XSetTransientForHint(display, view->impl->win, + (Window)view->transientParent); + } +} diff --git a/pugl/pugl.h b/pugl/pugl.h index 26593f2..017338c 100644 --- a/pugl/pugl.h +++ b/pugl/pugl.h @@ -534,15 +534,6 @@ puglInitWindowClass(PuglView* view, const char* name); PUGL_API void puglInitWindowParent(PuglView* view, PuglNativeWindow parent); -/** - Set transient parent before creating a window. - - On X11, parent must be a Window. - On OSX, parent must be an NSView*. -*/ -PUGL_API void -puglInitTransientFor(PuglView* view, uintptr_t parent); - /** Set the graphics backend to use. @@ -645,6 +636,15 @@ puglSetMinSize(PuglView* view, int width, int height); PUGL_API PuglStatus puglSetAspectRatio(PuglView* view, int minX, int minY, int maxX, int maxY); +/** + Set the transient parent of the window. + + This is used for things like dialogs, to have them associated with the + window they are a transient child of properly. +*/ +PUGL_API void +puglSetTransientFor(PuglView* view, PuglNativeWindow parent); + /** @name Context Functions for accessing the drawing context. @@ -841,6 +841,18 @@ puglInitWindowAspectRatio(PuglView* view, puglSetAspectRatio(view, minX, minY, maxX, maxY); } +/** + Set transient parent before creating a window. + + On X11, parent must be a Window. + On OSX, parent must be an NSView*. +*/ +static inline PUGL_DEPRECATED_BY("puglSetTransientFor") void +puglInitTransientFor(PuglView* view, uintptr_t parent) +{ + puglSetTransientFor(view, (PuglNativeWindow)parent); +} + /** Enable or disable resizing before creating a window. -- cgit v1.2.1