@@ -560,6 +560,10 @@ void Window::PrivateData::startModal() | |||||
modal.parent->show(); | modal.parent->show(); | ||||
show(); | show(); | ||||
#ifdef DISTRHO_OS_MAC | |||||
puglMacOSAddChildWindow(modal.parent->view, view); | |||||
#endif | |||||
DGL_DBG("Ok\n"); | DGL_DBG("Ok\n"); | ||||
} | } | ||||
@@ -576,6 +580,10 @@ void Window::PrivateData::stopModal() | |||||
if (modal.parent->modal.child != this) | if (modal.parent->modal.child != this) | ||||
return; | return; | ||||
#ifdef DISTRHO_OS_MAC | |||||
puglMacOSRemoveChildWindow(modal.parent->view, view); | |||||
#endif | |||||
// stop parent from giving focus to us, so it behaves like normal | // stop parent from giving focus to us, so it behaves like normal | ||||
modal.parent->modal.child = nullptr; | modal.parent->modal.child = nullptr; | ||||
@@ -407,6 +407,46 @@ void puglMacOSActivateApp() | |||||
[NSApp activateIgnoringOtherApps:YES]; | [NSApp activateIgnoringOtherApps:YES]; | ||||
} | } | ||||
// -------------------------------------------------------------------------------------------------------------------- | |||||
// macOS specific, add another view's window as child | |||||
PuglStatus | |||||
puglMacOSAddChildWindow(PuglView* const view, PuglView* const child) | |||||
{ | |||||
if (NSWindow* const viewWindow = view->impl->window ? view->impl->window | |||||
: [view->impl->wrapperView window]) | |||||
{ | |||||
if (NSWindow* const childWindow = child->impl->window ? child->impl->window | |||||
: [child->impl->wrapperView window]) | |||||
{ | |||||
[viewWindow addChildWindow:childWindow ordered:NSWindowAbove]; | |||||
return PUGL_SUCCESS; | |||||
} | |||||
} | |||||
return PUGL_FAILURE; | |||||
} | |||||
// -------------------------------------------------------------------------------------------------------------------- | |||||
// macOS specific, remove another view's window as child | |||||
PuglStatus | |||||
puglMacOSRemoveChildWindow(PuglView* const view, PuglView* const child) | |||||
{ | |||||
if (NSWindow* const viewWindow = view->impl->window ? view->impl->window | |||||
: [view->impl->wrapperView window]) | |||||
{ | |||||
if (NSWindow* const childWindow = child->impl->window ? child->impl->window | |||||
: [child->impl->wrapperView window]) | |||||
{ | |||||
[viewWindow removeChildWindow:childWindow]; | |||||
return PUGL_SUCCESS; | |||||
} | |||||
} | |||||
return PUGL_FAILURE; | |||||
} | |||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
// macOS specific, setup file browser dialog | // macOS specific, setup file browser dialog | ||||
@@ -100,6 +100,14 @@ puglFallbackOnResize(PuglView* view); | |||||
PUGL_API void | PUGL_API void | ||||
puglMacOSActivateApp(); | puglMacOSActivateApp(); | ||||
// macOS specific, add another view's window as child | |||||
PUGL_API PuglStatus | |||||
puglMacOSAddChildWindow(PuglView* view, PuglView* child); | |||||
// macOS specific, remove another view's window as child | |||||
PUGL_API PuglStatus | |||||
puglMacOSRemoveChildWindow(PuglView* view, PuglView* child); | |||||
// macOS specific, setup file browser dialog | // macOS specific, setup file browser dialog | ||||
typedef void (*openPanelCallback)(PuglView* view, const char* path); | typedef void (*openPanelCallback)(PuglView* view, const char* path); | ||||
bool puglMacOSFilePanelOpen(PuglView* view, const char* startDir, const char* title, uint flags, openPanelCallback callback); | bool puglMacOSFilePanelOpen(PuglView* view, const char* startDir, const char* title, uint flags, openPanelCallback callback); | ||||