@@ -71,7 +71,9 @@ impl PluginGuiImpl for ExamplePluginMainThread<'_> {
7171 return None ;
7272 } ;
7373
74- Some ( window_size_to_gui_size ( gui. handle . size ( ) ) )
74+ let size = gui. handle . size ( ) . to_native_size ( ) ;
75+
76+ Some ( GuiSize { width : size. width , height : size. height } )
7577 }
7678
7779 fn can_resize ( & mut self ) -> bool {
@@ -96,13 +98,13 @@ impl PluginGuiImpl for ExamplePluginMainThread<'_> {
9698 let scale_factor = gui. handle . size ( ) . scale_factor ;
9799
98100 if let Some ( max_size) = gui. handle . max_size ( ) {
99- let max_size = size_to_gui_size ( max_size, scale_factor) ;
101+ let max_size = NativeSize :: from_size ( max_size, scale_factor) ;
100102 size. width = size. width . min ( max_size. width ) ;
101103 size. height = size. height . min ( max_size. height ) ;
102104 }
103105
104106 if let Some ( min_size) = gui. handle . min_size ( ) {
105- let min_size = size_to_gui_size ( min_size, scale_factor) ;
107+ let min_size = NativeSize :: from_size ( min_size, scale_factor) ;
106108 size. width = size. width . max ( min_size. width ) ;
107109 size. height = size. height . max ( min_size. height ) ;
108110 }
@@ -115,8 +117,7 @@ impl PluginGuiImpl for ExamplePluginMainThread<'_> {
115117 return Err ( PluginError :: Message ( "set_size called without a GUI active" ) ) ;
116118 } ;
117119
118- let size = gui_size_to_window_size ( size) ;
119- gui. handle . resize ( size) ?;
120+ gui. handle . resize ( NativeSize { width : size. width , height : size. height } ) ?;
120121
121122 Ok ( ( ) )
122123 }
@@ -162,45 +163,6 @@ impl PluginGuiImpl for ExamplePluginMainThread<'_> {
162163 }
163164}
164165
165- fn size_to_gui_size ( size : Size , scale_factor : f64 ) -> GuiSize {
166- #[ cfg( target_os = "macos" ) ]
167- {
168- let size = size. to_logical ( scale_factor) ;
169- GuiSize { width : size. width , height : size. height }
170- }
171-
172- #[ cfg( not( target_os = "macos" ) ) ]
173- {
174- let size = size. to_physical ( scale_factor) ;
175- GuiSize { width : size. width , height : size. height }
176- }
177- }
178-
179- fn window_size_to_gui_size ( size : WindowSize ) -> GuiSize {
180- #[ cfg( target_os = "macos" ) ]
181- {
182- let size = size. logical . cast ( ) ;
183- GuiSize { width : size. width , height : size. height }
184- }
185-
186- #[ cfg( not( target_os = "macos" ) ) ]
187- {
188- let size = size. physical . cast ( ) ;
189- GuiSize { width : size. width , height : size. height }
190- }
191- }
192-
193- fn gui_size_to_window_size ( size : GuiSize ) -> Size {
194- #[ cfg( target_os = "macos" ) ]
195- {
196- Size :: Logical ( LogicalSize :: new ( size. width , size. height ) . cast ( ) )
197- }
198- #[ cfg( not( target_os = "macos" ) ) ]
199- {
200- Size :: Physical ( PhysicalSize :: new ( size. width , size. height ) )
201- }
202- }
203-
204166struct MainThreadHandler {
205167 host : HostSharedHandle < ' static > ,
206168}
@@ -218,8 +180,8 @@ struct HostGuiCallbacks {
218180
219181impl HostCallbacks for HostGuiCallbacks {
220182 fn request_resize ( & mut self , new_size : WindowSize ) -> Result < ( ) , HandlerError > {
221- let size = window_size_to_gui_size ( new_size) ;
222- self . ext . request_resize ( & self . host , size . width , size . height ) ?;
183+ let new_size = new_size. to_native_size ( ) ;
184+ self . ext . request_resize ( & self . host , new_size . width , new_size . height ) ?;
223185 Ok ( ( ) )
224186 }
225187
0 commit comments