diff --git a/distrho/DistrhoUI.hpp b/distrho/DistrhoUI.hpp index a84c54de..10bc7c3e 100644 --- a/distrho/DistrhoUI.hpp +++ b/distrho/DistrhoUI.hpp @@ -72,6 +72,11 @@ class PluginWindow; class UI : public UIWidget { public: + enum InternalScalingMode { + kNoInternalScaling, + kInternalScalingMatchingHost, + }; + /** UI class constructor. The UI should be initialized to a default state that matches the plugin side. @@ -82,7 +87,7 @@ public: @see getScaleFactor @see setGeometryConstraints */ - UI(uint width = 0, uint height = 0); + UI(uint width = 0, uint height = 0, InternalScalingMode internalScalingMode = kNoInternalScaling); #if DGL_ALLOW_DEPRECATED_METHODS /** DEPRECATED DO NOT USE. diff --git a/distrho/src/DistrhoUI.cpp b/distrho/src/DistrhoUI.cpp index e2ccf46c..3ab474c9 100644 --- a/distrho/src/DistrhoUI.cpp +++ b/distrho/src/DistrhoUI.cpp @@ -180,7 +180,7 @@ PluginWindow& UI::PrivateData::createNextWindow(UI* const ui, uint width, uint h UI::PrivateData* const uiData = s_nextPrivateData; const double scaleFactor = d_isNotZero(uiData->scaleFactor) ? uiData->scaleFactor : getDesktopScaleFactor(uiData->winId); - if (d_isNotZero(scaleFactor) && d_isNotEqual(scaleFactor, 1.0)) + if (d_isNotEqual(scaleFactor, 1.0)) { width *= scaleFactor; height *= scaleFactor; @@ -322,7 +322,7 @@ void UI::PrivateData::webViewMessageCallback(void* const arg, char* const msg) /* ------------------------------------------------------------------------------------------------------------ * UI */ -UI::UI(const uint width, const uint height) +UI::UI(const uint width, const uint height, const InternalScalingMode internalScalingMode) : UIWidget(UI::PrivateData::createNextWindow(this, // width #ifdef DISTRHO_UI_DEFAULT_WIDTH @@ -339,14 +339,15 @@ UI::UI(const uint width, const uint height) { if (width != 0 && height != 0) { - Widget::setSize(width, height); - } - #ifdef DISTRHO_UI_DEFAULT_WIDTH - else - { - Widget::setSize(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT); + if (internalScalingMode == kInternalScalingMatchingHost) + { + d_stdout("enableInternalScalingWithSize %u %u", width, height); + getWindow().enableInternalScalingWithSize(width, height, true); + return; + } } - #endif + + Widget::setSize(getWindow().getSize()); } #if DGL_ALLOW_DEPRECATED_METHODS