From 79ab0cd7ed389e1b9cbad26e4666ad217159df79 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 5 Mar 2022 16:01:58 +0100 Subject: [PATCH] Add the special win32-dpi-aware feature on Windows --- src/plugin.rs | 5 ++--- src/wrapper/clap/descriptor.rs | 11 ++++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/plugin.rs b/src/plugin.rs index 1ef0ff50..4bb54cf8 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -137,9 +137,8 @@ pub trait ClapPlugin: Plugin { const CLAP_DESCRIPTION: &'static str; /// Arbitrary keywords describing the plugin. See the CLAP specification for examples: /// . - // - // TODO: CLAP mentions that `win32-dpi-aware` is a special keyword that informs the host that - // the plugin is DPI aware, can and should we have special handling for this? + /// + /// On windows `win32-dpi-aware` is automatically added. const CLAP_FEATURES: &'static [&'static str]; /// A URL to the plugin's manual, CLAP does not specify what to do when there is none. // diff --git a/src/wrapper/clap/descriptor.rs b/src/wrapper/clap/descriptor.rs index 025e7b9e..db027574 100644 --- a/src/wrapper/clap/descriptor.rs +++ b/src/wrapper/clap/descriptor.rs @@ -60,7 +60,16 @@ impl Default for PluginDescriptor

{ _phantom: PhantomData, }; - // The keyword list is an environ-like list of char pointers terminated by a null pointer + // The keyword list is an environ-like list of char pointers terminated by a null pointer. + // On Windows `win32-dpi-aware` is a special value informing the host that the plugin is + // DPI-aware. + // TODO: Is this actually what we want? What happens if we don't add it? If this means that + // we need to do our own DPI handling instead of the host passing a scale then we + // don't want that of course. + #[cfg(target_os = "windows")] + descriptor + .clap_features + .push(CString::new("win32-dpi-aware").unwrap()); let mut clap_features_ptrs: Vec<*const c_char> = descriptor .clap_features .iter()