@@ -274,28 +274,27 @@ void Window::setSize(uint width, uint height)
274274
275275 if (pData->isEmbed )
276276 {
277- uint minWidth = pData->minWidth ;
278- uint minHeight = pData->minHeight ;
277+ PuglArea area = puglGetSizeHint (pData->view , PUGL_FIXED_ASPECT);
279278
280279 if (pData->autoScaling && d_isNotEqual (scaleFactor, 1.0 ))
281280 {
282- minWidth = d_roundToUnsignedInt (minWidth * scaleFactor);
283- minHeight = d_roundToUnsignedInt (minHeight * scaleFactor);
281+ area. width = d_roundToUnsignedInt (area. width * scaleFactor);
282+ area. height = d_roundToUnsignedInt (area. height * scaleFactor);
284283 width = d_roundToUnsignedInt (width * scaleFactor);
285284 height = d_roundToUnsignedInt (height * scaleFactor);
286285 }
287286
288287 // handle geometry constraints here
289- if (width < minWidth )
290- width = minWidth ;
288+ if (width < area. width )
289+ width = area. width ;
291290
292- if (height < minHeight )
293- height = minHeight ;
291+ if (height < area. height )
292+ height = area. height ;
294293
295- if (pData-> keepAspectRatio )
294+ if (area. width != 0 && area. height != 0 )
296295 {
297- const double ratio = static_cast <double >(pData-> minWidth )
298- / static_cast <double >(pData-> minHeight );
296+ const double ratio = static_cast <double >(area. width )
297+ / static_cast <double >(area. height );
299298 const double reqRatio = static_cast <double >(width)
300299 / static_cast <double >(height);
301300
@@ -432,11 +431,10 @@ void Window::enableInternalScalingWithSize(uint baseWidth, uint baseHeight, cons
432431 const double scaleHorizontal = size.getWidth () / static_cast <double >(baseWidth);
433432 const double scaleVertical = size.getHeight () / static_cast <double >(baseHeight);
434433
435- pData->minWidth = baseWidth;
436- pData->minHeight = baseHeight;
434+ pData->baseWidth = baseWidth;
435+ pData->baseHeight = baseHeight;
437436 pData->autoScaling = true ;
438437 pData->autoScaleFactor = scaleHorizontal < scaleVertical ? scaleHorizontal : scaleVertical;
439- pData->keepAspectRatio = keepAspectRatio;
440438
441439 if (pData->view == nullptr )
442440 return ;
@@ -527,19 +525,16 @@ void Window::runAsModal(bool blockWait)
527525
528526Size<uint> Window::getGeometryConstraints (bool & keepAspectRatio)
529527{
530- keepAspectRatio = pData->keepAspectRatio ;
531- return Size<uint>(pData->minWidth , pData->minHeight );
528+ const PuglArea area = puglGetSizeHint (pData->view , PUGL_FIXED_ASPECT);
529+ keepAspectRatio = area.width != 0 && area.height != 0 ;
530+ return Size<uint>(area.width , area.height );
532531}
533532
534533void Window::setGeometryConstraints (const uint minimumWidth, const uint minimumHeight, const bool keepAspectRatio)
535534{
536535 DISTRHO_SAFE_ASSERT_RETURN (minimumWidth > 0 ,);
537536 DISTRHO_SAFE_ASSERT_RETURN (minimumHeight > 0 ,);
538537
539- pData->minWidth = minimumWidth;
540- pData->minHeight = minimumHeight;
541- pData->keepAspectRatio = keepAspectRatio;
542-
543538 if (pData->view != nullptr )
544539 puglSetGeometryConstraints (pData->view , minimumWidth, minimumHeight, keepAspectRatio);
545540}
@@ -558,10 +553,18 @@ void Window::setGeometryConstraints(uint minimumWidth,
558553 if (resizeNowIfAutoScaling && automaticallyScale && pData->autoScaling == automaticallyScale)
559554 resizeNowIfAutoScaling = false ;
560555
561- pData->minWidth = minimumWidth;
562- pData->minHeight = minimumHeight;
563- pData->autoScaling = automaticallyScale;
564- pData->keepAspectRatio = keepAspectRatio;
556+ if (automaticallyScale)
557+ {
558+ pData->autoScaling = true ;
559+ pData->baseWidth = minimumWidth;
560+ pData->baseHeight = minimumHeight;
561+ }
562+ else
563+ {
564+ pData->autoScaling = false ;
565+ pData->baseWidth = 0 ;
566+ pData->baseHeight = 0 ;
567+ }
565568
566569 if (pData->view == nullptr )
567570 return ;
0 commit comments