-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -16,19 +16,106 @@ | |||
|
||||
#include "DistrhoUIPrivateData.hpp" | ||||
#include "src/WindowPrivateData.hpp" | ||||
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI | ||||
#if DISTRHO_PLUGIN_HAS_EXTERNAL_UI | ||||
# if defined(DISTRHO_OS_HAIKU) | ||||
# elif defined(DISTRHO_OS_MAC) | ||||
# define Point CocoaPoint | ||||
# define Size CocoaSize | ||||
# import <Cocoa/Cocoa.h> | ||||
# undef Point | ||||
# undef Size | ||||
# elif defined(DISTRHO_OS_WINDOWS) | ||||
# define WIN32_LEAN_AND_MEAN | ||||
# include <windows.h> | ||||
# else | ||||
# include <X11/Xresource.h> | ||||
# endif | ||||
#else | ||||
# include "src/TopLevelWidgetPrivateData.hpp" | ||||
#endif | ||||
|
||||
START_NAMESPACE_DISTRHO | ||||
|
||||
#if DISTRHO_PLUGIN_HAS_EXTERNAL_UI | ||||
/* ------------------------------------------------------------------------------------------------------------ | ||||
* Static data, see DistrhoUIInternal.hpp */ | ||||
|
||||
#if DISTRHO_PLUGIN_HAS_EXTERNAL_UI | ||||
uintptr_t g_nextWindowId = 0; | ||||
double g_nextScaleFactor = 1.0; | ||||
const char* g_nextBundlePath = nullptr; | ||||
|
||||
/* ------------------------------------------------------------------------------------------------------------ | ||||
* get global scale factor */ | ||||
|
||||
static double getDesktopScaleFactor() | ||||
{ | ||||
// allow custom scale for testing | ||||
if (const char* const scale = getenv("DPF_SCALE_FACTOR")) | ||||
return std::max(1.0, std::atof(scale)); | ||||
|
||||
#if defined(DISTRHO_OS_MAC) | ||||
return [NSScreen mainScreen].backingScaleFactor; | ||||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
falkTX
Author
Contributor
|
? MonitorFromWindow((HWND)parentWindowHandle, MONITOR_DEFAULTTOPRIMARY) |
So far I haven't found resizing issues on any host/platform but testing has been always performed on a single monitor setup tbh.
I don't think it is possible to write Objective-C code in a file with .cpp extension, unless clang is instructed to compile Objective-C++ by changing the extension to .mm . The EmbedExternalUI example builds but my plugin unsurprisingly does not, because the compiler thinks [NSScreen mainScreen] is a C++ capture list. Really don't know why EmbedExternalUI builds, it has to be some coincidence.
Also if you agree I would add a uintptr_t argument to getDesktopScaleFactor() so it is called with the native view handle. In macOS this is useful to query the backing scale factor for that particular view, instead of assuming the view belongs to the main screen. Similarly for Windows to avoid assuming the plugin is visible on the primary monitor.