Signed-off-by: falkTX <falktx@falktx.com>pull/272/head
@@ -67,6 +67,7 @@ public: | |||||
Window& getWindow() const noexcept; | Window& getWindow() const noexcept; | ||||
// TODO group stuff after here, convenience functions present in Window class | // TODO group stuff after here, convenience functions present in Window class | ||||
double getScaleFactor() const noexcept; | |||||
void repaint() noexcept; | void repaint() noexcept; | ||||
void repaint(const Rectangle<uint>& rect) noexcept; | void repaint(const Rectangle<uint>& rect) noexcept; | ||||
void setGeometryConstraints(uint minimumWidth, | void setGeometryConstraints(uint minimumWidth, | ||||
@@ -61,7 +61,7 @@ public: | |||||
*/ | */ | ||||
explicit Window(Application& app, | explicit Window(Application& app, | ||||
uintptr_t parentWindowHandle, | uintptr_t parentWindowHandle, | ||||
double scaling, | |||||
double scaleFactor, | |||||
bool resizable); | bool resizable); | ||||
/** | /** | ||||
@@ -72,7 +72,7 @@ public: | |||||
uintptr_t parentWindowHandle, | uintptr_t parentWindowHandle, | ||||
uint width, | uint width, | ||||
uint height, | uint height, | ||||
double scaling, | |||||
double scaleFactor, | |||||
bool resizable); | bool resizable); | ||||
/** | /** | ||||
@@ -40,6 +40,11 @@ Window& TopLevelWidget::getWindow() const noexcept | |||||
return pData->window; | return pData->window; | ||||
} | } | ||||
double TopLevelWidget::getScaleFactor() const noexcept | |||||
{ | |||||
return pData->window.getScaleFactor(); | |||||
} | |||||
void TopLevelWidget::repaint() noexcept | void TopLevelWidget::repaint() noexcept | ||||
{ | { | ||||
pData->window.repaint(); | pData->window.repaint(); | ||||
@@ -31,17 +31,17 @@ Window::Window(Application& app) | |||||
Window::Window(Application& app, | Window::Window(Application& app, | ||||
const uintptr_t parentWindowHandle, | const uintptr_t parentWindowHandle, | ||||
const double scaling, | |||||
const double scaleFactor, | |||||
const bool resizable) | const bool resizable) | ||||
: pData(new PrivateData(app, this, parentWindowHandle, scaling, resizable)) {} | |||||
: pData(new PrivateData(app, this, parentWindowHandle, scaleFactor, resizable)) {} | |||||
Window::Window(Application& app, | Window::Window(Application& app, | ||||
const uintptr_t parentWindowHandle, | const uintptr_t parentWindowHandle, | ||||
const uint width, | const uint width, | ||||
const uint height, | const uint height, | ||||
const double scaling, | |||||
const double scaleFactor, | |||||
const bool resizable) | const bool resizable) | ||||
: pData(new PrivateData(app, this, parentWindowHandle, width, height, scaling, resizable)) {} | |||||
: pData(new PrivateData(app, this, parentWindowHandle, width, height, scaleFactor, resizable)) {} | |||||
Window::~Window() | Window::~Window() | ||||
{ | { | ||||
@@ -40,6 +40,16 @@ START_NAMESPACE_DGL | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
static double getDesktopScaleFactor() | |||||
{ | |||||
if (const char* const scale = getenv("DPF_SCALE_FACTOR")) | |||||
return std::max(1.0, std::atof(scale)); | |||||
return 1.0; | |||||
} | |||||
// ----------------------------------------------------------------------- | |||||
Window::PrivateData::PrivateData(Application& a, Window* const s) | Window::PrivateData::PrivateData(Application& a, Window* const s) | ||||
: app(a), | : app(a), | ||||
appData(a.pData), | appData(a.pData), | ||||
@@ -49,7 +59,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s) | |||||
isClosed(true), | isClosed(true), | ||||
isVisible(false), | isVisible(false), | ||||
isEmbed(false), | isEmbed(false), | ||||
scaleFactor(1.0), | |||||
scaleFactor(getDesktopScaleFactor()), | |||||
autoScaling(false), | autoScaling(false), | ||||
autoScaleFactor(1.0), | autoScaleFactor(1.0), | ||||
minWidth(0), | minWidth(0), | ||||
@@ -68,7 +78,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, Window& transi | |||||
isClosed(true), | isClosed(true), | ||||
isVisible(false), | isVisible(false), | ||||
isEmbed(false), | isEmbed(false), | ||||
scaleFactor(1.0), | |||||
scaleFactor(getDesktopScaleFactor()), | |||||
autoScaling(false), | autoScaling(false), | ||||
autoScaleFactor(1.0), | autoScaleFactor(1.0), | ||||
minWidth(0), | minWidth(0), | ||||
@@ -91,7 +101,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, | |||||
isClosed(parentWindowHandle == 0), | isClosed(parentWindowHandle == 0), | ||||
isVisible(parentWindowHandle != 0), | isVisible(parentWindowHandle != 0), | ||||
isEmbed(parentWindowHandle != 0), | isEmbed(parentWindowHandle != 0), | ||||
scaleFactor(scale), | |||||
scaleFactor(scale != 0.0 ? scale : getDesktopScaleFactor()), | |||||
autoScaling(false), | autoScaling(false), | ||||
autoScaleFactor(1.0), | autoScaleFactor(1.0), | ||||
minWidth(0), | minWidth(0), | ||||
@@ -125,7 +135,7 @@ Window::PrivateData::PrivateData(Application& a, Window* const s, | |||||
isClosed(parentWindowHandle == 0), | isClosed(parentWindowHandle == 0), | ||||
isVisible(parentWindowHandle != 0), | isVisible(parentWindowHandle != 0), | ||||
isEmbed(parentWindowHandle != 0), | isEmbed(parentWindowHandle != 0), | ||||
scaleFactor(scale), | |||||
scaleFactor(scale != 0.0 ? scale : getDesktopScaleFactor()), | |||||
autoScaling(false), | autoScaling(false), | ||||
autoScaleFactor(1.0), | autoScaleFactor(1.0), | ||||
minWidth(0), | minWidth(0), | ||||
@@ -82,16 +82,6 @@ static void initSignalHandler() | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
// TODO | |||||
static double getDesktopScaleFactor() noexcept | |||||
{ | |||||
return 1.0; | |||||
} | |||||
#endif | |||||
// ----------------------------------------------------------------------- | |||||
#if DISTRHO_PLUGIN_HAS_UI | #if DISTRHO_PLUGIN_HAS_UI | ||||
class PluginJack : public IdleCallback | class PluginJack : public IdleCallback | ||||
#else | #else | ||||
@@ -111,7 +101,7 @@ public: | |||||
nullptr, // file request | nullptr, // file request | ||||
nullptr, // bundle | nullptr, // bundle | ||||
fPlugin.getInstancePointer(), | fPlugin.getInstancePointer(), | ||||
getDesktopScaleFactor()), | |||||
0.0), | |||||
#endif | #endif | ||||
fClient(client) | fClient(client) | ||||
{ | { | ||||
@@ -137,7 +137,7 @@ public: | |||||
const fileRequestFunc fileRequestCall, | const fileRequestFunc fileRequestCall, | ||||
const char* const bundlePath = nullptr, | const char* const bundlePath = nullptr, | ||||
void* const dspPtr = nullptr, | void* const dspPtr = nullptr, | ||||
const float scaleFactor = 1.0f, | |||||
const double scaleFactor = 1.0, | |||||
const uint32_t bgColor = 0, | const uint32_t bgColor = 0, | ||||
const uint32_t fgColor = 0xffffffff) | const uint32_t fgColor = 0xffffffff) | ||||
#if DISTRHO_PLUGIN_HAS_EXTERNAL_UI | #if DISTRHO_PLUGIN_HAS_EXTERNAL_UI | ||||