@@ -2,7 +2,7 @@ use crate::window_handler::OpenWindowExample;
22use crate :: ExamplePluginMainThread ;
33use baseview:: dpi:: PhysicalSize ;
44use baseview:: gl:: GlConfig ;
5- use baseview:: { WindowHandle , WindowOpenOptions } ;
5+ use baseview:: { WindowHandle , WindowOpenOptions , WindowSize } ;
66use clack_extensions:: gui:: {
77 GuiApiType , GuiConfiguration , GuiResizeHints , GuiSize , PluginGuiImpl , Window as ClapWindow ,
88} ;
@@ -45,8 +45,7 @@ impl PluginGuiImpl for ExamplePluginMainThread {
4545 }
4646
4747 fn get_size ( & mut self ) -> Option < GuiSize > {
48- // Unsupported
49- Some ( GuiSize { width : 400 , height : 200 } )
48+ Some ( window_size_to_gui_size ( self . gui . as_ref ( ) ?. handle . size ( ) ) )
5049 }
5150
5251 fn can_resize ( & mut self ) -> bool {
@@ -98,3 +97,17 @@ impl PluginGuiImpl for ExamplePluginMainThread {
9897 Ok ( ( ) ) // Not supported yet
9998 }
10099}
100+
101+ fn window_size_to_gui_size ( size : WindowSize ) -> GuiSize {
102+ #[ cfg( target_os = "macos" ) ]
103+ {
104+ let size = size. logical . cast ( ) ;
105+ GuiSize { width : size. width , height : size. height }
106+ }
107+
108+ #[ cfg( not( target_os = "macos" ) ) ]
109+ {
110+ let size = size. physical . cast ( ) ;
111+ GuiSize { width : size. width , height : size. height }
112+ }
113+ }
0 commit comments