@@ -15,7 +15,7 @@ use gtk::CompositeTemplate;
1515use gtk:: TemplateChild ;
1616use log:: { debug, error, info} ;
1717use once_cell:: sync:: Lazy ;
18- use std:: cell:: RefCell ;
18+ use std:: cell:: { Cell , RefCell } ;
1919use std:: collections:: HashMap ;
2020use std:: marker:: PhantomData ;
2121use std:: pin:: Pin ;
@@ -42,6 +42,7 @@ pub struct HistoryStatus {
4242 pub ( crate ) current : usize ,
4343 pub ( crate ) available : usize ,
4444}
45+
4546pub mod imp {
4647
4748 pub use super :: * ;
@@ -223,30 +224,32 @@ impl Tab {
223224 Ok ( ( ) )
224225 }
225226 fn handle_motion ( & self , x : f64 , y : f64 ) -> Result < ( ) > {
227+ // May need some debounce?
228+
226229 let imp = self . imp ( ) ;
227230 let gemini_text_ext = imp. gemini_text_ext . borrow ( ) ;
228231 let gemini_text_ext = gemini_text_ext. as_ref ( ) . unwrap ( ) ;
229232 let links = imp. links . borrow ( ) ;
230233 let entry = Self :: extract_linkhandler ( & * links, gemini_text_ext, x, y) ;
231234
232235 let link_ref = entry. as_ref ( ) . map ( |x| x. 1 ) . unwrap_or ( "" ) ;
236+ if link_ref == & * imp. hover_url . borrow ( ) {
237+ return Ok ( ( ) ) ;
238+ }
233239
234- // May need optimization. Comparing two strings for each motion event is expensive
235- if * imp. hover_url . borrow ( ) != link_ref {
236- match link_ref {
237- "" => {
238- gemini_text_ext. text_view . set_cursor_from_name ( Some ( "text" ) ) ;
239- }
240- _ => {
241- gemini_text_ext
242- . text_view
243- . set_cursor_from_name ( Some ( "pointer" ) ) ;
244- }
240+ match link_ref {
241+ "" => {
242+ gemini_text_ext. text_view . set_cursor_from_name ( Some ( "text" ) ) ;
245243 }
246- imp. hover_url . replace ( link_ref. to_owned ( ) ) ;
247- self . notify ( "hover-url" ) ;
248- }
244+ _ => {
245+ gemini_text_ext
246+ . text_view
247+ . set_cursor_from_name ( Some ( "pointer" ) ) ;
248+ }
249+ } ;
249250
251+ imp. hover_url . replace ( link_ref. to_owned ( ) ) ;
252+ self . notify ( "hover-url" ) ;
250253 Ok ( ( ) )
251254 }
252255 pub fn spawn_open_url ( & self , url : Url ) {
0 commit comments