Browse Source

Fix macOS hosts providing windowless views on init

Like FLStudio VST3 hosting
pull/321/head
falkTX 7 months ago
parent
commit
90b8d2d271
2 changed files with 16 additions and 4 deletions
  1. +14
    -4
      dgl/src/pugl.cpp
  2. +2
    -0
      distrho/src/DistrhoUIVST3.cpp

+ 14
- 4
dgl/src/pugl.cpp View File

@@ -237,10 +237,20 @@ double puglGetScaleFactorFromParent(const PuglView* const view)
{
const PuglNativeView parent = view->parent ? view->parent : view->transientParent ? view->transientParent : 0;
#if defined(DISTRHO_OS_MAC)
NSWindow* const window = parent != 0 ? [(NSView*)parent window]
: view->impl->window ? view->impl->window : [view->impl->wrapperView window];
NSScreen* const screen = window != nullptr ? [window screen] : [NSScreen mainScreen];
return [screen backingScaleFactor];
// some of these can return 0 as backingScaleFactor, pick the most relevant valid one
const NSWindow* possibleWindows[] = {
parent != 0 ? [(NSView*)parent window] : nullptr,
view->impl->window,
[view->impl->wrapperView window]
};
for (size_t i=0; i<ARRAY_SIZE(possibleWindows); ++i)
{
if (possibleWindows[i] == nullptr)
continue;
if (const double scaleFactor = [[possibleWindows[i] screen] backingScaleFactor])
return scaleFactor;
}
return [[NSScreen mainScreen] backingScaleFactor];
#elif defined(DISTRHO_OS_WINDOWS)
const HWND hwnd = parent != 0 ? (HWND)parent : view->impl->hwnd;
return puglWinGetViewScaleFactor(hwnd);


+ 2
- 0
distrho/src/DistrhoUIVST3.cpp View File

@@ -306,6 +306,7 @@ public:
}
else if (fNeedsResizeFromPlugin)
{
d_stdout("postInit forcely sets size from plugin as %u %u", fUI.getWidth(), fUI.getHeight());
setSize(fUI.getWidth(), fUI.getHeight());
}

@@ -1478,6 +1479,7 @@ struct dpf_plugin_view : v3_plugin_view_cpp {
return uivst3->getSize(rect);

d_stdout("dpf_plugin_view::get_size => %p | V3_NOT_INITIALIZED", self);
std::memset(rect, 0, sizeof(v3_view_rect));
view->sizeRequestedBeforeBeingAttached = true;
return V3_NOT_INITIALIZED;
}


Loading…
Cancel
Save