From ced718c264cbd760928a88289ddbc50b1cfce574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 29 Mar 2021 14:48:08 +0400 Subject: [PATCH] gtk: scale cursor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc-André Lureau --- qemu-gtk4/src/console.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qemu-gtk4/src/console.rs b/qemu-gtk4/src/console.rs index ee61287..9d56642 100644 --- a/qemu-gtk4/src/console.rs +++ b/qemu-gtk4/src/console.rs @@ -279,9 +279,11 @@ mod imp { priv_.label.set_label("Console disconnected!"); } Event::CursorDefine { width, height, hot_x, hot_y, data }=> { - let bytes = glib::Bytes::from(&data); - let tex = gdk::MemoryTexture::new(width, height, gdk::MemoryFormat::B8g8r8a8, &bytes, width as usize * 4); - let cur = gdk::Cursor::from_texture(&tex, hot_x, hot_y, None); + let scale = priv_.area.get_scale_factor(); + let pb = gdk::gdk_pixbuf::Pixbuf::from_mut_slice(data, gdk::gdk_pixbuf::Colorspace::Rgb, true, 8, width, height, width * 4); + let pb = pb.scale_simple(width * scale, height * scale, gdk::gdk_pixbuf::InterpType::Bilinear).unwrap(); + let tex = gdk::Texture::new_for_pixbuf(&pb); + let cur = gdk::Cursor::from_texture(&tex, hot_x * scale, hot_y * scale, None); priv_.area.set_cursor(Some(&cur)); } _t => { }