diff --git a/dgl/src/Window.cpp b/dgl/src/Window.cpp index 0902ffdc..9d3c7441 100644 --- a/dgl/src/Window.cpp +++ b/dgl/src/Window.cpp @@ -67,6 +67,9 @@ struct Window::PrivateData { fVisible(false), fResizable(true), fUsingEmbed(false), + fWidth(1), + fHeight(1), + fModal(), #if defined(DISTRHO_OS_WINDOWS) hwnd(0), #elif defined(DISTRHO_OS_LINUX) @@ -90,6 +93,8 @@ struct Window::PrivateData { fVisible(false), fResizable(true), fUsingEmbed(false), + fWidth(1), + fHeight(1), fModal(parent.pData), #if defined(DISTRHO_OS_WINDOWS) hwnd(0), @@ -120,6 +125,9 @@ struct Window::PrivateData { fVisible(parentId != 0), fResizable(parentId == 0), fUsingEmbed(parentId != 0), + fWidth(1), + fHeight(1), + fModal(), #if defined(DISTRHO_OS_WINDOWS) hwnd(0), #elif defined(DISTRHO_OS_LINUX) @@ -161,6 +169,7 @@ struct Window::PrivateData { } puglInitResizable(fView, fResizable); + puglInitWindowSize(fView, fWidth, fHeight); puglSetHandle(fView, this); puglSetDisplayFunc(fView, onDisplayCallback); @@ -358,7 +367,7 @@ struct Window::PrivateData { fVisible = yesNo; if (yesNo && fFirstInit) - setSize(static_cast(fView->width), static_cast(fView->height), true); + setSize(fWidth, fHeight, true); #if defined(DISTRHO_OS_WINDOWS) if (yesNo) @@ -412,7 +421,7 @@ struct Window::PrivateData { fResizable = yesNo; - setSize(static_cast(fView->width), static_cast(fView->height), true); + setSize(fWidth, fHeight, true); } // ------------------------------------------------------------------- @@ -425,14 +434,14 @@ struct Window::PrivateData { return; } - if (fView->width == static_cast(width) && fView->height == static_cast(height) && ! forced) + if (fWidth == width && fHeight == height && ! forced) { DBGp("Window setSize matches current size, ignoring request (%i %i)\n", width, height); return; } - fView->width = static_cast(width); - fView->height = static_cast(height); + fWidth = width; + fHeight = height; DBGp("Window setSize called %s, size %i %i\n", forced ? "(forced)" : "(not forced)", width, height); @@ -580,15 +589,15 @@ struct Window::PrivateData { // reset color glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - if (widget->fNeedsFullViewport || (widget->fAbsolutePos.isZero() && widget->fSize == Size(fView->width, fView->height))) + if (widget->fNeedsFullViewport || (widget->fAbsolutePos.isZero() && widget->fSize == Size(fWidth, fHeight))) { // full viewport size - glViewport(0, 0, fView->width, fView->height); + glViewport(0, 0, fWidth, fHeight); } else if (! widget->fNeedsScaling) { // only set viewport pos - glViewport(widget->getAbsoluteX(), /*fView->height - widget->getHeight()*/ - widget->getAbsoluteY(), fView->width, fView->height); + glViewport(widget->getAbsoluteX(), /*fView->height - widget->getHeight()*/ - widget->getAbsoluteY(), fWidth, fHeight); // then cut the outer bounds glScissor(widget->getAbsoluteX(), fView->height - widget->getHeight() - widget->getAbsoluteY(), widget->getWidth(), widget->getHeight()); @@ -732,6 +741,12 @@ struct Window::PrivateData { { DBGp("PUGL: onReshape : %i %i\n", width, height); + if (width == 1 && height == 1) + return; + + fWidth = width; + fHeight = height; + fSelf->onReshape(width, height); FOR_EACH_WIDGET(it) @@ -768,6 +783,8 @@ struct Window::PrivateData { bool fVisible; bool fResizable; bool fUsingEmbed; + uint fWidth; + uint fHeight; std::list fWidgets; struct Modal { @@ -921,23 +938,17 @@ void Window::setResizable(bool yesNo) uint Window::getWidth() const noexcept { - DISTRHO_SAFE_ASSERT_RETURN(pData->fView->width >= 0, 0); - - return pData->fView->width; + return pData->fWidth; } uint Window::getHeight() const noexcept { - DISTRHO_SAFE_ASSERT_RETURN(pData->fView->height >= 0, 0); - - return pData->fView->height; + return pData->fHeight; } Size Window::getSize() const noexcept { - DISTRHO_SAFE_ASSERT_RETURN(pData->fView->width >= 0 && pData->fView->height >= 0, Size(0, 0)); - - return Size(pData->fView->width, pData->fView->height); + return Size(pData->fWidth, pData->fHeight); } void Window::setSize(uint width, uint height) diff --git a/distrho/src/DistrhoUIInternal.hpp b/distrho/src/DistrhoUIInternal.hpp index 141b51a3..e5b53762 100644 --- a/distrho/src/DistrhoUIInternal.hpp +++ b/distrho/src/DistrhoUIInternal.hpp @@ -298,6 +298,8 @@ public: { if (glWindow.isReady()) fUI->d_uiIdle(); + + fChangingSize = false; } bool idle() @@ -309,6 +311,8 @@ public: if (glWindow.isReady()) fUI->d_uiIdle(); + fChangingSize = false; + return ! glApp.isQuiting(); } @@ -333,11 +337,6 @@ public: fUI->setSize(width, height); glWindow.setSize(width, height); - glWindow.onReshape(width, height); // FIXME - - glApp.idle(); - - fChangingSize = false; } void setWindowTitle(const char* const uiTitle)