@@ -13,7 +13,7 @@ use processing_core::error::Result;
1313use processing_input:: {
1414 input_cursor_grab_mode, input_cursor_visible, input_flush, input_set_char,
1515 input_set_cursor_enter, input_set_cursor_leave, input_set_focus, input_set_key,
16- input_set_mouse_button, input_set_mouse_move, input_set_scroll,
16+ input_set_mouse_button, input_set_mouse_move, input_set_scroll, input_window_resize ,
1717} ;
1818use processing_render:: surface:: { MonitorWorkarea , WindowControls } ;
1919
@@ -256,6 +256,7 @@ impl GlfwContext {
256256 }
257257 } ;
258258
259+ let mut pending_resize: Option < ( i32 , i32 ) > = None ;
259260 for ( _, event) in glfw:: flush_messages ( & self . events ) {
260261 match event {
261262 WindowEvent :: Close => {
@@ -301,8 +302,8 @@ impl GlfwContext {
301302 input_set_focus ( surface, focused) . unwrap ( ) ;
302303 }
303304 WindowEvent :: Size ( width, height) => {
304- processing_render :: surface_resize ( surface , width as u32 , height as u32 )
305- . unwrap ( ) ;
305+ // A drag delivers many Size events per poll; keep only the last and apply it once after the loop.
306+ pending_resize = Some ( ( width , height ) ) ;
306307 }
307308 _ => { }
308309 }
@@ -313,6 +314,12 @@ impl GlfwContext {
313314 return false ;
314315 }
315316
317+ // Apply the coalesced resize once, the WindowResized message and Window change are processed this poll.
318+ if let Some ( ( width, height) ) = pending_resize {
319+ input_window_resize ( surface, width as f32 , height as f32 ) . unwrap ( ) ;
320+ processing_render:: surface_resize ( surface, width as u32 , height as u32 ) . unwrap ( ) ;
321+ }
322+
316323 let Ok ( _) = input_flush ( ) else {
317324 return false ;
318325 } ;
0 commit comments