From 024fb88cd1bfcf3dfc77eacc852032f4e706eb01 Mon Sep 17 00:00:00 2001 From: Tsuki Date: Wed, 6 Mar 2024 12:13:21 +0800 Subject: [PATCH] change: drag dpi --- src/widgets/render/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/widgets/render/mod.rs b/src/widgets/render/mod.rs index aa194a4..6dab846 100644 --- a/src/widgets/render/mod.rs +++ b/src/widgets/render/mod.rs @@ -48,8 +48,8 @@ impl Render { let pointer_location_detecture = gtk::EventControllerMotion::new(); pointer_location_detecture.connect_motion( clone!( @weak this as r => move |_context, x, y| { + let dpi = r.scale_factor(); r.update_status(|s| { - let dpi = r.scale_factor(); let (_,h) = s.window_size.unwrap(); s.pointer_location = (x as f32 * dpi as f32, h as f32 - y as f32 * dpi as f32); }); @@ -73,8 +73,9 @@ impl Render { drag_detecture.connect_drag_update(clone!( @weak this as r => move |this, _, _| { let (ox, oy) = this.offset().unwrap_or((0.0,0.0)); + let dpi = r.scale_factor() as f32; r.update_status(|s| { - s.translate = Some((-ox as f32 * 1.35, oy as f32 * 1.35)); + s.translate = Some((-ox as f32 * dpi , oy as f32 * dpi)); s.motion = RenderMotion::Translate; }); r.queue_render();