Browse Source

Set scale factor for carla-bridge-*/carla-single standalone usage

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.4.0
falkTX 3 years ago
parent
commit
9abf745694
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
5 changed files with 34 additions and 14 deletions
  1. +8
    -9
      source/backend/CarlaStandalone.cpp
  2. +5
    -2
      source/backend/CarlaUtils.h
  3. +5
    -1
      source/backend/utils/Information.cpp
  4. +4
    -2
      source/backend/utils/Windows.cpp
  5. +12
    -0
      source/bridges-plugin/CarlaBridgePlugin.cpp

+ 8
- 9
source/backend/CarlaStandalone.cpp View File

@@ -43,18 +43,16 @@

// --------------------------------------------------------------------------------------------------------------------

#ifdef USING_JUCE
static void carla_standalone_juce_init(void);
static void carla_standalone_juce_idle(void);
static void carla_standalone_juce_cleanup(void);
# define carla_juce_init carla_standalone_juce_init
# define carla_juce_idle carla_standalone_juce_idle
# define carla_juce_cleanup carla_standalone_juce_cleanup
# include "utils/JUCE.cpp"
# undef carla_juce_init
# undef carla_juce_idle
# undef carla_juce_cleanup
#endif
#define carla_juce_init carla_standalone_juce_init
#define carla_juce_idle carla_standalone_juce_idle
#define carla_juce_cleanup carla_standalone_juce_cleanup
#include "utils/JUCE.cpp"
#undef carla_juce_init
#undef carla_juce_idle
#undef carla_juce_cleanup

// -------------------------------------------------------------------------------------------------------------------
// Always return a valid string ptr for standalone functions
@@ -2375,6 +2373,7 @@ const char* carla_get_host_osc_url_udp(CarlaHostHandle handle)
# include "CarlaProcessUtils.cpp"
# include "CarlaStateUtils.cpp"
# include "utils/Information.cpp"
# include "utils/Windows.cpp"
#endif /* CARLA_PLUGIN_EXPORT */

// --------------------------------------------------------------------------------------------------------------------

+ 5
- 2
source/backend/CarlaUtils.h View File

@@ -1,6 +1,6 @@
/*
* Carla Plugin Host
* Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2021 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -304,7 +304,10 @@ CARLA_EXPORT void carla_set_process_name(const char* name);
/* --------------------------------------------------------------------------------------------------------------------
* window control */

CARLA_EXPORT double carla_get_desktop_scale_factor();
/*!
* Get the global/desktop scale factor.
*/
CARLA_EXPORT double carla_get_desktop_scale_factor(void);

CARLA_EXPORT int carla_cocoa_get_window(void* nsViewPtr);
CARLA_EXPORT void carla_cocoa_set_transient_window_for(void* nsViewChild, void* nsViewParent);


+ 5
- 1
source/backend/utils/Information.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla Plugin Host
* Copyright (C) 2011-2020 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2021 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -45,6 +45,10 @@
# pragma GCC diagnostic pop
#endif

#ifdef CARLA_OS_MAC
# import <AppKit/AppKit.h>
#endif

#include "water/files/File.h"

// -------------------------------------------------------------------------------------------------------------------


+ 4
- 2
source/backend/utils/Windows.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla Plugin Host
* Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2021 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -40,13 +40,15 @@ double carla_get_desktop_scale_factor()
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)
#ifdef CARLA_OS_MAC
return [NSScreen mainScreen].backingScaleFactor;
#endif

return 1.0;
}

// -------------------------------------------------------------------------------------------------------------------

int carla_cocoa_get_window(void* nsViewPtr)
{
CARLA_SAFE_ASSERT_RETURN(nsViewPtr != nullptr, 0);


+ 12
- 0
source/bridges-plugin/CarlaBridgePlugin.cpp View File

@@ -21,6 +21,7 @@

#include "CarlaEngine.hpp"
#include "CarlaHost.h"
#include "CarlaUtils.h"

#include "CarlaBackendUtils.hpp"
#include "CarlaJuceUtils.hpp"
@@ -657,6 +658,17 @@ int main(int argc, char* argv[])
return 1;
}

if (! useBridge && ! testing)
{
#ifdef HAVE_X11
if (std::getenv("DISPLAY") != nullptr)
#endif
carla_set_engine_option(gHostHandle,
CarlaBackend::ENGINE_OPTION_FRONTEND_UI_SCALE,
static_cast<int>(carla_get_desktop_scale_factor()*1000+0.5),
nullptr);
}

// -----------------------------------------------------------------
// Init plugin



Loading…
Cancel
Save