Signed-off-by: falkTX <falktx@falktx.com>tags/v2.4.0
@@ -304,6 +304,8 @@ CARLA_EXPORT void carla_set_process_name(const char* name); | |||||
/* -------------------------------------------------------------------------------------------------------------------- | /* -------------------------------------------------------------------------------------------------------------------- | ||||
* window control */ | * window control */ | ||||
CARLA_EXPORT double carla_get_desktop_scale_factor(); | |||||
CARLA_EXPORT int carla_cocoa_get_window(void* nsViewPtr); | CARLA_EXPORT int carla_cocoa_get_window(void* nsViewPtr); | ||||
CARLA_EXPORT void carla_cocoa_set_transient_window_for(void* nsViewChild, void* nsViewParent); | CARLA_EXPORT void carla_cocoa_set_transient_window_for(void* nsViewChild, void* nsViewParent); | ||||
@@ -31,6 +31,22 @@ namespace CB = CarlaBackend; | |||||
// ------------------------------------------------------------------------------------------------------------------- | // ------------------------------------------------------------------------------------------------------------------- | ||||
double carla_get_desktop_scale_factor() | |||||
{ | |||||
// allow custom scale for testing | |||||
if (const char* const scale = getenv("DPF_SCALE_FACTOR")) | |||||
return std::max(1.0, std::atof(scale)); | |||||
// Qt env var for the same | |||||
if (const char* const scale = getenv("QT_SCALE_FACTOR")) | |||||
return std::max(1.0, std::atof(scale)); | |||||
#if defined(CARLA_OS_MAC) && !defined(CARLA_PLUGIN_EXPORT) | |||||
return [NSScreen mainScreen].backingScaleFactor; | |||||
#endif | |||||
return 1.0; | |||||
} | |||||
int carla_cocoa_get_window(void* nsViewPtr) | int carla_cocoa_get_window(void* nsViewPtr) | ||||
{ | { | ||||
CARLA_SAFE_ASSERT_RETURN(nsViewPtr != nullptr, 0); | CARLA_SAFE_ASSERT_RETURN(nsViewPtr != nullptr, 0); | ||||
@@ -327,6 +327,9 @@ class CarlaUtils(): | |||||
self.lib.carla_juce_cleanup.argtypes = None | self.lib.carla_juce_cleanup.argtypes = None | ||||
self.lib.carla_juce_cleanup.restype = None | self.lib.carla_juce_cleanup.restype = None | ||||
self.lib.carla_get_desktop_scale_factor.argtypes = None | |||||
self.lib.carla_get_desktop_scale_factor.restype = c_double | |||||
self.lib.carla_cocoa_get_window.argtypes = [c_uintptr] | self.lib.carla_cocoa_get_window.argtypes = [c_uintptr] | ||||
self.lib.carla_cocoa_get_window.restype = c_int | self.lib.carla_cocoa_get_window.restype = c_int | ||||
@@ -480,6 +483,9 @@ class CarlaUtils(): | |||||
def juce_cleanup(self): | def juce_cleanup(self): | ||||
self.lib.carla_juce_cleanup() | self.lib.carla_juce_cleanup() | ||||
def get_desktop_scale_factor(self): | |||||
return float(self.lib.carla_get_desktop_scale_factor()) | |||||
def cocoa_get_window(self, winId): | def cocoa_get_window(self, winId): | ||||
return self.lib.carla_cocoa_get_window(winId) | return self.lib.carla_cocoa_get_window(winId) | ||||