@@ -373,7 +373,7 @@ impl WebGl2Backend {
373373 ( None , None )
374374 } ;
375375
376- let mut backend = Self {
376+ Ok ( Self {
377377 beamterm,
378378 cursor_position : None ,
379379 options,
@@ -384,12 +384,7 @@ impl WebGl2Backend {
384384 hyperlink_state,
385385 _user_mouse_handler : None ,
386386 _user_key_handler : None ,
387- } ;
388-
389- // Convert handler metrics from physical pixels to CSS pixels
390- backend. update_mouse_handler_metrics ( ) ;
391-
392- Ok ( backend)
387+ } )
393388 }
394389
395390 /// Returns the options objects used to create this backend.
@@ -422,8 +417,6 @@ impl WebGl2Backend {
422417 // Reset hyperlink cursor state when canvas is resized
423418 self . cursor_over_hyperlink = false ;
424419
425- self . update_mouse_handler_metrics ( ) ;
426-
427420 Ok ( ( ) )
428421 }
429422
@@ -444,32 +437,9 @@ impl WebGl2Backend {
444437 pub fn set_size ( & mut self , width : u32 , height : u32 ) -> Result < ( ) , Error > {
445438 self . beamterm . resize ( width as i32 , height as i32 ) ?;
446439 self . cursor_over_hyperlink = false ;
447- self . update_mouse_handler_metrics ( ) ;
448440 Ok ( ( ) )
449441 }
450442
451- /// Updates metrics on externally-managed mouse handlers after resize or DPR changes.
452- ///
453- /// Beamterm's `Terminal::resize()` only updates its own internal mouse handler.
454- /// The user and hyperlink handlers created by ratzilla need their metrics updated
455- /// separately.
456- fn update_mouse_handler_metrics ( & mut self ) {
457- let ( cols, rows) = self . beamterm . terminal_size ( ) ;
458- let ( phys_w, phys_h) = self . beamterm . cell_size ( ) ;
459- let dpr = window ( )
460- . map ( |w| w. device_pixel_ratio ( ) as f32 )
461- . unwrap_or ( 1.0 ) ;
462- let cell_width = phys_w as f32 / dpr;
463- let cell_height = phys_h as f32 / dpr;
464-
465- if let Some ( handler) = & mut self . _user_mouse_handler {
466- handler. update_metrics ( cols, rows, cell_width, cell_height) ;
467- }
468- if let Some ( handler) = & mut self . _hyperlink_mouse_handler {
469- handler. update_metrics ( cols, rows, cell_width, cell_height) ;
470- }
471- }
472-
473443 /// Checks if the canvas size matches the display size and resizes it if necessary.
474444 fn check_canvas_resize ( & mut self ) -> Result < ( ) , Error > {
475445 // Compare CSS display size against beamterm's stored logical size.
@@ -924,10 +894,6 @@ impl WebEventHandler for WebGl2Backend {
924894
925895 self . _user_mouse_handler = Some ( mouse_handler) ;
926896
927- // TerminalMouseHandler is constructed with physical pixel metrics;
928- // convert to CSS pixels so coordinate translation is correct on HiDPI.
929- self . update_mouse_handler_metrics ( ) ;
930-
931897 Ok ( ( ) )
932898 }
933899
0 commit comments