[retro-gtk] retro-gl-display: Correctly translate coords on hidpi
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk] retro-gl-display: Correctly translate coords on hidpi
- Date: Sat, 11 Jan 2020 07:56:43 +0000 (UTC)
commit d8bfd4e4cd25be1c8db14fa180d90f49b66d2c2b
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sat Jan 11 02:15:22 2020 +0500
retro-gl-display: Correctly translate coords on hidpi
Fixes https://gitlab.gnome.org/GNOME/retro-gtk/issues/27
retro-gtk/retro-gl-display.c | 5 +++++
1 file changed, 5 insertions(+)
---
diff --git a/retro-gtk/retro-gl-display.c b/retro-gtk/retro-gl-display.c
index d8f563d..ea4c1e5 100644
--- a/retro-gtk/retro-gl-display.c
+++ b/retro-gtk/retro-gl-display.c
@@ -561,6 +561,7 @@ retro_gl_display_get_coordinates_on_display (RetroGLDisplay *self,
gdouble h = 0.0;
gdouble x = 0.0;
gdouble y = 0.0;
+ gint scale_factor;
g_return_val_if_fail (RETRO_IS_GL_DISPLAY (self), FALSE);
g_return_val_if_fail (display_x != NULL, FALSE);
@@ -568,6 +569,10 @@ retro_gl_display_get_coordinates_on_display (RetroGLDisplay *self,
retro_gl_display_get_video_box (self, &w, &h, &x, &y);
+ scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (self));
+ widget_x *= scale_factor;
+ widget_y *= scale_factor;
+
// Return coordinates as a [-1.0, 1.0] scale, (0.0, 0.0) is the center.
*display_x = ((widget_x - x) * 2.0 - w) / w;
*display_y = ((widget_y - y) * 2.0 - h) / h;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]