From 90dbca5ce38633b4eaea2a2b093c17aa96c5c909 Mon Sep 17 00:00:00 2001 From: YuraIz <7516890@gmail.com> Date: Tue, 4 Jul 2023 15:55:18 +0300 Subject: [PATCH] fix(inline-emojis): Fix scaling issues --- src/components/label_with_widgets.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/components/label_with_widgets.rs b/src/components/label_with_widgets.rs index 2514f3c30..d00d01570 100644 --- a/src/components/label_with_widgets.rs +++ b/src/components/label_with_widgets.rs @@ -129,23 +129,30 @@ mod imp { if self.widgets.borrow().is_empty() { self.parent_snapshot(snapshot) } else { - let (texture, bounds) = { - let snapshot = gtk::Snapshot::new(); + let widget = self.obj(); + + let width = widget.width(); + let heigth = widget.height(); + + let bounds = gtk::graphene::Rect::new(1.0, 0.0, width as f32, heigth as f32); + + let texture = { + let s = widget.scale_factor() as f32; + + let bounds = bounds.scale(s, s); + let snapshot = gtk::Snapshot::new(); + snapshot.scale(s, s); self.parent_snapshot(&snapshot); let node = snapshot.to_node().unwrap(); - let bounds = node.bounds(); let renderer = gsk::CairoRenderer::new(); - renderer.realize(None).unwrap(); - let texture = renderer.render_texture(node, Some(&bounds)); - renderer.unrealize(); - (texture, bounds) + texture }; snapshot.append_texture(&texture, &bounds)