Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.2KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. // A few utils declared in DistrhoUI.cpp but defined here because they use Obj-C
  17. #include "DistrhoDetails.hpp"
  18. #include "src/DistrhoPluginChecks.h"
  19. #include "src/DistrhoDefines.h"
  20. #define Point CocoaPoint
  21. #define Size CocoaSize
  22. #import <Cocoa/Cocoa.h>
  23. #undef Point
  24. #undef Size
  25. #if DISTRHO_UI_FILE_BROWSER
  26. # define DISTRHO_FILE_BROWSER_DIALOG_HPP_INCLUDED
  27. # define FILE_BROWSER_DIALOG_NAMESPACE DISTRHO_NAMESPACE
  28. # define FILE_BROWSER_DIALOG_DISTRHO_NAMESPACE
  29. START_NAMESPACE_DISTRHO
  30. # include "extra/FileBrowserDialogImpl.hpp"
  31. END_NAMESPACE_DISTRHO
  32. # include "extra/FileBrowserDialogImpl.cpp"
  33. #endif
  34. #if DISTRHO_UI_WEB_VIEW
  35. # define DISTRHO_WEB_VIEW_HPP_INCLUDED
  36. # define WEB_VIEW_NAMESPACE DISTRHO_NAMESPACE
  37. # define WEB_VIEW_DISTRHO_NAMESPACE
  38. START_NAMESPACE_DISTRHO
  39. # include "extra/WebViewImpl.hpp"
  40. END_NAMESPACE_DISTRHO
  41. # include "extra/WebViewImpl.cpp"
  42. #endif
  43. #include <algorithm>
  44. #include <cmath>
  45. START_NAMESPACE_DISTRHO
  46. double getDesktopScaleFactor(const uintptr_t parentWindowHandle)
  47. {
  48. // allow custom scale for testing
  49. if (const char* const scale = getenv("DPF_SCALE_FACTOR"))
  50. return std::max(1.0, std::atof(scale));
  51. if (NSView* const parentView = (NSView*)parentWindowHandle)
  52. if (NSWindow* const parentWindow = [parentView window])
  53. return [parentWindow screen].backingScaleFactor;
  54. return [NSScreen mainScreen].backingScaleFactor;
  55. }
  56. END_NAMESPACE_DISTRHO