From 60d8d59858a30cc45518652414f6bf683c822f9d Mon Sep 17 00:00:00 2001 From: Kyle Hipke Date: Sun, 1 Mar 2026 18:18:27 -0800 Subject: [PATCH 1/6] clap support on linux: pickup where we left off --- src/format/clap/gui.rs | 141 ++++++++++++++++++++++++++++++++++-- src/format/clap/instance.rs | 54 +++++++++++++- 2 files changed, 186 insertions(+), 9 deletions(-) diff --git a/src/format/clap/gui.rs b/src/format/clap/gui.rs index a76b63fc..e81ea2c4 100644 --- a/src/format/clap/gui.rs +++ b/src/format/clap/gui.rs @@ -1,22 +1,33 @@ +use std::cell::RefCell; use std::collections::HashMap; use std::ffi::{c_char, CStr}; +use std::future::Future; +use std::os::raw::c_int; use std::rc::Rc; use std::sync::Arc; -use clap_sys::ext::{gui::*, params::*}; -use clap_sys::{host::*, plugin::*}; - use super::instance::Instance; use crate::params::{ParamId, ParamValue}; use crate::plugin::Plugin; use crate::sync::param_gestures::ParamGestures; use crate::view::{ParentWindow, RawParent, View, ViewHost, ViewHostInner}; +use clap_sys::ext::posix_fd_support::{ + clap_plugin_posix_fd_support, clap_posix_fd_flags, CLAP_POSIX_FD_READ, +}; +use clap_sys::ext::timer_support::clap_plugin_timer_support; +use clap_sys::ext::{gui::*, params::*}; +use clap_sys::id::{clap_id, CLAP_INVALID_ID}; +use clap_sys::{host::*, plugin::*}; -struct ClapViewHost { +pub struct ClapViewHost { host: *const clap_host, host_params: Option<*const clap_host_params>, param_map: Arc>, param_gestures: Arc, + #[cfg_attr(not(target_os = "linux"), allow(unused))] + timer_id: Option, + #[cfg_attr(not(target_os = "linux"), allow(unused))] + fd: Option, } impl ViewHostInner for ClapViewHost { @@ -73,6 +84,17 @@ impl Instance

{ #[cfg(target_os = "linux")] const API: &'static CStr = CLAP_WINDOW_API_X11; + #[cfg(target_os = "linux")] + pub(crate) const TIMER_SUPPORT: clap_plugin_timer_support = clap_plugin_timer_support { + on_timer: Some(Self::timer_support_on_timer), + }; + + #[cfg(target_os = "linux")] + pub(crate) const POSIX_FD_SUPPORT: clap_plugin_posix_fd_support = + clap_plugin_posix_fd_support { + on_fd: Some(Self::posix_fd_support_on_fd), + }; + unsafe extern "C" fn gui_is_api_supported( _plugin: *const clap_plugin, api: *const c_char, @@ -113,6 +135,12 @@ impl Instance

{ let instance = &*(plugin as *const Self); let main_thread_state = &mut *instance.main_thread_state.get(); + if let Some(posix_fd_support) = (*instance.host_extensions.get()).posix_fd_support { + if let Some(fd) = main_thread_state.view_host.as_ref().unwrap().fd { + (*posix_fd_support).unregister_fd.unwrap_unchecked()(instance.host, fd); + } + } + main_thread_state.view = None; } @@ -189,14 +217,80 @@ impl Instance

{ let instance = &*(plugin as *const Self); let main_thread_state = &mut *instance.main_thread_state.get(); - let host = ViewHost::from_inner(Rc::new(ClapViewHost { + // TODO: note as we need an fd, we can't set it until after we get the .view from the plugin. + // Is there a way we could simply have an FD external to the plugin, in coupler itself? + main_thread_state.view_host = Some(Rc::new(ClapViewHost { host: instance.host, host_params: main_thread_state.host_params, param_map: Arc::clone(&instance.param_map), param_gestures: Arc::clone(&instance.param_gestures), + // todo: cannot populate this until AFTER we get the plugin view + #[cfg_attr(not(target_os = "linux"), allow(unused))] + timer_id: None, + #[cfg_attr(not(target_os = "linux"), allow(unused))] + fd: None, })); + let view_host = ViewHost::from_inner(main_thread_state.view_host.as_ref().unwrap().clone()); let parent = ParentWindow::from_raw(raw_parent); - let view = main_thread_state.plugin.view(host, &parent); + let view = main_thread_state.plugin.view(view_host, &parent); + + // todo: seems absurdly stupid, could we implement clone for ClapViewHot + // set timer / timer_id + #[cfg(target_os = "linux")] + { + // todo: is there a way to avoid the repetitive de-referencing? + let host_extensions = instance.host_extensions.get(); + if (*host_extensions).timer_support.is_none() + || (*host_extensions).posix_fd_support.is_none() + { + dbg!("missing timer support"); + return false; + } + let timer_support = (*host_extensions).timer_support.unwrap(); + let posix_fd_support = (*host_extensions).posix_fd_support.unwrap(); + + // todo: what's even the point of saving the timer_id / fd? do we really need to? + const TIMER_PERIOD_MS: u32 = 16; + let mut timer_id = CLAP_INVALID_ID; + if !(*timer_support).register_timer.unwrap_unchecked()( + instance.host, + TIMER_PERIOD_MS, + &mut timer_id, + ) { + dbg!("Failed to register timer"); + return false; + } + + let final_fd = if let Some(fd) = view.file_descriptor() { + if !(*posix_fd_support).register_fd.unwrap_unchecked()( + instance.host, + fd, + CLAP_POSIX_FD_READ, + ) { + dbg!("Failed to register fd"); + return false; + } + Some(fd) + } else { + None + }; + + // todo: sketchy - now this view_host doesn't exactly match the view_host that + // was passed to the plugin's view function - the fd / timer_id will be different + // I tend to assumed that will be okay since the plugin shouldn't care about the fd / + // timer_id in the first place (but then why put it in the view_host at all?) + main_thread_state.view_host = Some(Rc::new(ClapViewHost { + host: instance.host, + host_params: main_thread_state.host_params, + param_map: Arc::clone(&instance.param_map), + param_gestures: Arc::clone(&instance.param_gestures), + #[cfg_attr(not(target_os = "linux"), allow(unused))] + timer_id: Some(timer_id), + #[cfg_attr(not(target_os = "linux"), allow(unused))] + fd: final_fd, + })); + } + main_thread_state.view = Some(view); true @@ -218,4 +312,39 @@ impl Instance

{ unsafe extern "C" fn gui_hide(_plugin: *const clap_plugin) -> bool { false } + + #[cfg(target_os = "linux")] + unsafe extern "C" fn timer_support_on_timer(plugin: *const clap_plugin, timer_id: clap_id) { + let instance = &*(plugin as *const Self); + let main_thread_state = unsafe { &mut *instance.main_thread_state.get() }; + + main_thread_state.view_host.as_ref().unwrap().timer_id; + + if let Some(view_host) = &mut main_thread_state.view_host { + if let Some(id) = view_host.timer_id { + if id == timer_id { + if let Some(view) = &mut main_thread_state.view { + view.poll(); + } + } + } + } + } + + #[cfg(target_os = "linux")] + pub unsafe extern "C" fn posix_fd_support_on_fd( + plugin: *const clap_plugin, + fd: i32, + _flags: clap_posix_fd_flags, + ) { + let instance = &*(plugin as *const Self); + let main_thread_state = unsafe { &mut *instance.main_thread_state.get() }; + if let Some(view) = &mut main_thread_state.view { + if let Some(fd) = view.file_descriptor() { + if fd == fd { + view.poll(); + } + } + } + } } diff --git a/src/format/clap/instance.rs b/src/format/clap/instance.rs index 09f2d686..cc17eb19 100644 --- a/src/format/clap/instance.rs +++ b/src/format/clap/instance.rs @@ -5,15 +5,17 @@ use std::iter::zip; use std::ptr::NonNull; use std::sync::Arc; use std::{io, mem, ptr, slice}; - -use clap_sys::ext::{audio_ports::*, audio_ports_config::*, gui::*, params::*, state::*}; +use std::rc::Rc; +use clap_sys::ext::{audio_ports::*, audio_ports_config::*, gui::*, params::*, posix_fd_support, state::*}; use clap_sys::{events::*, host::*, id::*, plugin::*, process::*, stream::*}; - +use clap_sys::ext::posix_fd_support::{clap_host_posix_fd_support, clap_plugin_posix_fd_support, CLAP_EXT_POSIX_FD_SUPPORT}; +use clap_sys::ext::timer_support::{clap_host_timer_support, clap_plugin_timer_support, CLAP_EXT_TIMER_SUPPORT}; use super::host::ClapHost; use crate::buffers::{BufferData, BufferType, Buffers}; use crate::bus::{BusDir, Format}; use crate::engine::{Config, Engine}; use crate::events::{Data, Event, Events}; +use crate::format::clap::gui::ClapViewHost; use crate::host::Host; use crate::params::{ParamId, ParamInfo, ParamValue}; use crate::plugin::{Plugin, PluginInfo}; @@ -50,6 +52,8 @@ pub struct MainThreadState { pub layout_index: usize, pub plugin: P, pub view: Option, + // todo: unused - remove probably + pub view_host: Option>, } pub struct ProcessState { @@ -60,11 +64,19 @@ pub struct ProcessState { engine: Option, } +pub struct HostExtensions { + pub timer_support: Option<*const clap_host_timer_support>, + pub posix_fd_support: Option<*const clap_host_posix_fd_support>, +} + #[repr(C)] pub struct Instance { #[allow(unused)] pub clap_plugin: clap_plugin, pub host: *const clap_host, + // todo: is below comment still correct? + // Safety: We only form an &mut in init(), which must be called before any other methods + pub host_extensions: UnsafeCell, pub info: Arc, pub input_bus_map: Vec, pub output_bus_map: Vec, @@ -120,6 +132,10 @@ impl Instance

{ on_main_thread: Some(Self::on_main_thread), }, host, + host_extensions: UnsafeCell::new(HostExtensions { + timer_support: None, + posix_fd_support: None, + }), info: info.clone(), input_bus_map, output_bus_map, @@ -132,6 +148,7 @@ impl Instance

{ layout_index: 0, plugin: P::new(Host::from_inner(Arc::new(ClapHost {}))), view: None, + view_host: None, }), process_state: UnsafeCell::new(ProcessState { gesture_states: GestureStates::with_count(info.params.len()), @@ -311,6 +328,25 @@ impl Instance

{ if !host_params.is_null() { main_thread_state.host_params = Some(host_params as *const clap_host_params); } + let host_extensions = instance.host_extensions.get(); + + let timer_support = (*instance.host).get_extension.unwrap_unchecked()( + instance.host, + CLAP_EXT_TIMER_SUPPORT.as_ptr(), + ); + if !timer_support.is_null() { + // todo: dereferencing seems odd - is this okay? + (*host_extensions).timer_support = Some(timer_support as *const clap_host_timer_support); + } + + let posix_fd_support = (*instance.host).get_extension.unwrap_unchecked()( + instance.host, + CLAP_EXT_POSIX_FD_SUPPORT.as_ptr(), + ); + if !posix_fd_support.is_null() { + // todo: dereferencing seems odd - is this okay? + (*host_extensions).posix_fd_support = Some(posix_fd_support as *const clap_host_posix_fd_support); + } true } @@ -524,6 +560,18 @@ impl Instance

{ } } + // todo: adding this required making below constants public - is there + // a better way? + #[cfg(target_os = "linux")] + if id == CLAP_EXT_TIMER_SUPPORT { + return &Self::TIMER_SUPPORT as *const _ as *const c_void; + } + + #[cfg(target_os = "linux")] + if id == CLAP_EXT_POSIX_FD_SUPPORT { + return &Self::POSIX_FD_SUPPORT as *const _ as *const c_void; + } + ptr::null() } From 49e9c34c182f6af806f213403f46a4b75fd51d9a Mon Sep 17 00:00:00 2001 From: Kyle Hipke Date: Sun, 1 Mar 2026 18:24:08 -0800 Subject: [PATCH 2/6] clap support on linux: pickup where we left off --- src/format/clap/gui.rs | 1 + src/format/clap/instance.rs | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/format/clap/gui.rs b/src/format/clap/gui.rs index e81ea2c4..34c079bd 100644 --- a/src/format/clap/gui.rs +++ b/src/format/clap/gui.rs @@ -140,6 +140,7 @@ impl Instance

{ (*posix_fd_support).unregister_fd.unwrap_unchecked()(instance.host, fd); } } + // todo: don't we also need to unregister the timer? main_thread_state.view = None; } diff --git a/src/format/clap/instance.rs b/src/format/clap/instance.rs index cc17eb19..72e9eaf5 100644 --- a/src/format/clap/instance.rs +++ b/src/format/clap/instance.rs @@ -52,7 +52,6 @@ pub struct MainThreadState { pub layout_index: usize, pub plugin: P, pub view: Option, - // todo: unused - remove probably pub view_host: Option>, } From 5a857494824de2fab3efbec90099e2893ad1700e Mon Sep 17 00:00:00 2001 From: Kyle Hipke Date: Tue, 3 Mar 2026 21:37:12 -0800 Subject: [PATCH 3/6] refactor clap support approach --- src/format/clap/gui.rs | 88 ++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 51 deletions(-) diff --git a/src/format/clap/gui.rs b/src/format/clap/gui.rs index 34c079bd..3fb2a7c1 100644 --- a/src/format/clap/gui.rs +++ b/src/format/clap/gui.rs @@ -6,7 +6,7 @@ use std::os::raw::c_int; use std::rc::Rc; use std::sync::Arc; -use super::instance::Instance; +use super::instance::{Instance, MainThreadState}; use crate::params::{ParamId, ParamValue}; use crate::plugin::Plugin; use crate::sync::param_gestures::ParamGestures; @@ -26,8 +26,6 @@ pub struct ClapViewHost { param_gestures: Arc, #[cfg_attr(not(target_os = "linux"), allow(unused))] timer_id: Option, - #[cfg_attr(not(target_os = "linux"), allow(unused))] - fd: Option, } impl ViewHostInner for ClapViewHost { @@ -136,11 +134,16 @@ impl Instance

{ let main_thread_state = &mut *instance.main_thread_state.get(); if let Some(posix_fd_support) = (*instance.host_extensions.get()).posix_fd_support { - if let Some(fd) = main_thread_state.view_host.as_ref().unwrap().fd { + if let Some(fd) = main_thread_state.view.as_ref().unwrap().file_descriptor() { (*posix_fd_support).unregister_fd.unwrap_unchecked()(instance.host, fd); } } - // todo: don't we also need to unregister the timer? + + if let Some(timer_support) = (*instance.host_extensions.get()).timer_support { + (*timer_support).unregister_timer.unwrap_unchecked()( + instance.host, main_thread_state.view_host.as_ref().unwrap().timer_id.unwrap() + ); + } main_thread_state.view = None; } @@ -218,51 +221,52 @@ impl Instance

{ let instance = &*(plugin as *const Self); let main_thread_state = &mut *instance.main_thread_state.get(); - // TODO: note as we need an fd, we can't set it until after we get the .view from the plugin. - // Is there a way we could simply have an FD external to the plugin, in coupler itself? - main_thread_state.view_host = Some(Rc::new(ClapViewHost { - host: instance.host, - host_params: main_thread_state.host_params, - param_map: Arc::clone(&instance.param_map), - param_gestures: Arc::clone(&instance.param_gestures), - // todo: cannot populate this until AFTER we get the plugin view - #[cfg_attr(not(target_os = "linux"), allow(unused))] - timer_id: None, - #[cfg_attr(not(target_os = "linux"), allow(unused))] - fd: None, - })); - let view_host = ViewHost::from_inner(main_thread_state.view_host.as_ref().unwrap().clone()); - let parent = ParentWindow::from_raw(raw_parent); - let view = main_thread_state.plugin.view(view_host, &parent); - - // todo: seems absurdly stupid, could we implement clone for ClapViewHot - // set timer / timer_id + let mut timer_id: Option = None; #[cfg(target_os = "linux")] { - // todo: is there a way to avoid the repetitive de-referencing? let host_extensions = instance.host_extensions.get(); if (*host_extensions).timer_support.is_none() - || (*host_extensions).posix_fd_support.is_none() { dbg!("missing timer support"); return false; } let timer_support = (*host_extensions).timer_support.unwrap(); - let posix_fd_support = (*host_extensions).posix_fd_support.unwrap(); - - // todo: what's even the point of saving the timer_id / fd? do we really need to? const TIMER_PERIOD_MS: u32 = 16; - let mut timer_id = CLAP_INVALID_ID; + let mut maybe_timer_id = CLAP_INVALID_ID; if !(*timer_support).register_timer.unwrap_unchecked()( instance.host, TIMER_PERIOD_MS, - &mut timer_id, + &mut maybe_timer_id, ) { dbg!("Failed to register timer"); return false; } + timer_id = Some(maybe_timer_id); + } + + let view_host = Rc::new(ClapViewHost { + host: instance.host, + host_params: main_thread_state.host_params, + param_map: Arc::clone(&instance.param_map), + param_gestures: Arc::clone(&instance.param_gestures), + timer_id, + }); + main_thread_state.view_host = Some(view_host); + let view_host = ViewHost::from_inner(main_thread_state.view_host.as_ref().unwrap().clone()); + let parent = ParentWindow::from_raw(raw_parent); + let view = main_thread_state.plugin.view(view_host, &parent); + + #[cfg(target_os = "linux")] + { + let host_extensions = instance.host_extensions.get(); + if (*host_extensions).posix_fd_support.is_none() + { + dbg!("missing fd support"); + return false; + } + let posix_fd_support = (*host_extensions).posix_fd_support.unwrap(); - let final_fd = if let Some(fd) = view.file_descriptor() { + if let Some(fd) = view.file_descriptor() { if !(*posix_fd_support).register_fd.unwrap_unchecked()( instance.host, fd, @@ -271,25 +275,7 @@ impl Instance

{ dbg!("Failed to register fd"); return false; } - Some(fd) - } else { - None - }; - - // todo: sketchy - now this view_host doesn't exactly match the view_host that - // was passed to the plugin's view function - the fd / timer_id will be different - // I tend to assumed that will be okay since the plugin shouldn't care about the fd / - // timer_id in the first place (but then why put it in the view_host at all?) - main_thread_state.view_host = Some(Rc::new(ClapViewHost { - host: instance.host, - host_params: main_thread_state.host_params, - param_map: Arc::clone(&instance.param_map), - param_gestures: Arc::clone(&instance.param_gestures), - #[cfg_attr(not(target_os = "linux"), allow(unused))] - timer_id: Some(timer_id), - #[cfg_attr(not(target_os = "linux"), allow(unused))] - fd: final_fd, - })); + } } main_thread_state.view = Some(view); From d4631a49cbd29f306760a5d59f17743c151da73f Mon Sep 17 00:00:00 2001 From: Kyle Hipke Date: Thu, 5 Mar 2026 18:10:35 -0800 Subject: [PATCH 4/6] wip - refactoring size to live on plugin --- examples/gain/src/lib.rs | 5 +++++ src/format/clap/gui.rs | 1 + src/format/clap/tests.rs | 4 ++++ src/plugin.rs | 7 ++++++- src/view.rs | 1 + 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/examples/gain/src/lib.rs b/examples/gain/src/lib.rs index a6b6f1f8..60da0a73 100644 --- a/examples/gain/src/lib.rs +++ b/examples/gain/src/lib.rs @@ -58,6 +58,10 @@ impl Plugin for Gain { ], params: GainParams::params(), has_view: true, + size: Size { + width: 256.0, + height: 256.0 + } } } @@ -339,6 +343,7 @@ impl View for GainView { fn size(&self) -> Size { let size = self.task.with(|state, _| state.window.as_ref().unwrap().size()); + dbg!("size {} {}", size.width, size.height); Size { width: size.width, height: size.height, diff --git a/src/format/clap/gui.rs b/src/format/clap/gui.rs index 3fb2a7c1..4b7ddc3d 100644 --- a/src/format/clap/gui.rs +++ b/src/format/clap/gui.rs @@ -160,6 +160,7 @@ impl Instance

{ let instance = &*(plugin as *const Self); let main_thread_state = &mut *instance.main_thread_state.get(); + // todo: failing on x11 - view is not present by the time this is called if let Some(view) = &main_thread_state.view { let size = view.size(); diff --git a/src/format/clap/tests.rs b/src/format/clap/tests.rs index d5328afc..a6607722 100644 --- a/src/format/clap/tests.rs +++ b/src/format/clap/tests.rs @@ -40,6 +40,10 @@ impl Plugin for TestPlugin { layouts: vec![], params: Vec::new(), has_view: false, + size: Size { + height: 0., + width: 0., + } } } fn new(_host: Host) -> Self { diff --git a/src/plugin.rs b/src/plugin.rs index cb6998fa..c8c89c02 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -5,7 +5,7 @@ use crate::bus::{BusInfo, Layout}; use crate::engine::{Config, Engine}; use crate::host::Host; use crate::params::{ParamId, ParamInfo, ParamValue}; -use crate::view::{ParentWindow, View, ViewHost}; +use crate::view::{ParentWindow, Size, View, ViewHost}; pub struct PluginInfo { pub name: String, @@ -17,6 +17,7 @@ pub struct PluginInfo { pub layouts: Vec, pub params: Vec, pub has_view: bool, + pub size: Size, } #[allow(clippy::derivable_impls)] @@ -32,6 +33,10 @@ impl Default for PluginInfo { layouts: Vec::new(), params: Vec::new(), has_view: false, + size: Size { + width: 0.0, + height: 0.0 + } } } } diff --git a/src/view.rs b/src/view.rs index d9240d8d..9f66999e 100644 --- a/src/view.rs +++ b/src/view.rs @@ -66,6 +66,7 @@ pub struct Size { } pub trait View: Sized + 'static { + /// todo: remove fn size(&self) -> Size; fn param_changed(&mut self, id: ParamId, value: ParamValue); #[cfg(target_os = "linux")] From 5a724df87ee0bb65f0f518a539c6b458a08dcdee Mon Sep 17 00:00:00 2001 From: Kyle Hipke Date: Sun, 8 Mar 2026 14:53:56 -0700 Subject: [PATCH 5/6] CLAP X11 size working --- src/format/clap/gui.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/format/clap/gui.rs b/src/format/clap/gui.rs index 4b7ddc3d..00faa760 100644 --- a/src/format/clap/gui.rs +++ b/src/format/clap/gui.rs @@ -158,19 +158,11 @@ impl Instance

{ height: *mut u32, ) -> bool { let instance = &*(plugin as *const Self); - let main_thread_state = &mut *instance.main_thread_state.get(); - - // todo: failing on x11 - view is not present by the time this is called - if let Some(view) = &main_thread_state.view { - let size = view.size(); + let size = &instance.info.size; + *width = size.width as u32; + *height = size.height as u32; - *width = size.width.round() as u32; - *height = size.height.round() as u32; - - return true; - } - - false + true } unsafe extern "C" fn gui_can_resize(_plugin: *const clap_plugin) -> bool { From f3a44a9588592f1d0dcc826d88d4fc37f74a7753 Mon Sep 17 00:00:00 2001 From: Kyle Hipke Date: Sun, 8 Mar 2026 15:03:35 -0700 Subject: [PATCH 6/6] refactor size for vst3 as well --- examples/gain/src/lib.rs | 12 +----------- src/format/clap/gui.rs | 3 +-- src/format/vst3/view.rs | 20 +++++++------------- src/view.rs | 9 --------- 4 files changed, 9 insertions(+), 35 deletions(-) diff --git a/examples/gain/src/lib.rs b/examples/gain/src/lib.rs index 60da0a73..113276d2 100644 --- a/examples/gain/src/lib.rs +++ b/examples/gain/src/lib.rs @@ -60,7 +60,7 @@ impl Plugin for Gain { has_view: true, size: Size { width: 256.0, - height: 256.0 + height: 256.0 } } } @@ -340,16 +340,6 @@ impl GainView { } impl View for GainView { - fn size(&self) -> Size { - let size = self.task.with(|state, _| state.window.as_ref().unwrap().size()); - - dbg!("size {} {}", size.width, size.height); - Size { - width: size.width, - height: size.height, - } - } - fn param_changed(&mut self, id: ParamId, value: ParamValue) { self.task.with(|state, _| { state.params.set_param(id, value); diff --git a/src/format/clap/gui.rs b/src/format/clap/gui.rs index 00faa760..f37bb228 100644 --- a/src/format/clap/gui.rs +++ b/src/format/clap/gui.rs @@ -157,8 +157,7 @@ impl Instance

{ width: *mut u32, height: *mut u32, ) -> bool { - let instance = &*(plugin as *const Self); - let size = &instance.info.size; + let size = P::info().size; *width = size.width as u32; *height = size.height as u32; diff --git a/src/format/vst3/view.rs b/src/format/vst3/view.rs index 70c77c3c..93a80c92 100644 --- a/src/format/vst3/view.rs +++ b/src/format/vst3/view.rs @@ -228,21 +228,15 @@ impl IPlugViewTrait for PlugView

{ return kResultFalse; } - let main_thread_state = &*self.main_thread_state.get(); + let plugin_size = P::info().size; - if let Some(view) = &main_thread_state.view { - let view_size = view.size(); + let rect = &mut *size; + rect.left = 0; + rect.top = 0; + rect.right = plugin_size.width.round() as int32; + rect.bottom = plugin_size.height.round() as int32; - let rect = &mut *size; - rect.left = 0; - rect.top = 0; - rect.right = view_size.width.round() as int32; - rect.bottom = view_size.height.round() as int32; - - return kResultOk; - } - - kResultFalse + kResultOk } unsafe fn onSize(&self, _newSize: *mut ViewRect) -> tresult { diff --git a/src/view.rs b/src/view.rs index 9f66999e..26a83809 100644 --- a/src/view.rs +++ b/src/view.rs @@ -66,8 +66,6 @@ pub struct Size { } pub trait View: Sized + 'static { - /// todo: remove - fn size(&self) -> Size; fn param_changed(&mut self, id: ParamId, value: ParamValue); #[cfg(target_os = "linux")] fn file_descriptor(&self) -> Option; @@ -78,13 +76,6 @@ pub trait View: Sized + 'static { pub struct NoView; impl View for NoView { - fn size(&self) -> Size { - Size { - width: 0.0, - height: 0.0, - } - } - fn param_changed(&mut self, _id: ParamId, _value: ParamValue) {} fn file_descriptor(&self) -> Option {