[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 2/6] ui/gtk-gl-area: Don't forget to calculate the scaling fac
From: |
Vivek Kasireddy |
Subject: |
[PATCH v2 2/6] ui/gtk-gl-area: Don't forget to calculate the scaling factors in draw |
Date: |
Thu, 17 Nov 2022 17:44:22 -0800 |
Just like it is done in gtk-egl.c, we need to ensure that the scaling
factors are correctly calculated in draw callback. Otherwise, they
would just be set to 1.0. And, use gtk_widget_get_allocated_width/height
variants to determine width and height in the Wayland case similar to
how it is done in draw.
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Dongwon Kim <dongwon.kim@intel.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
---
ui/gtk-gl-area.c | 5 +++++
ui/gtk.c | 9 +++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c
index 682638a197..6799805f8e 100644
--- a/ui/gtk-gl-area.c
+++ b/ui/gtk-gl-area.c
@@ -81,6 +81,9 @@ void gd_gl_area_draw(VirtualConsole *vc)
egl_dmabuf_create_sync(dmabuf);
}
#endif
+ vc->gfx.scale_x = (double)ww / vc->gfx.w;
+ vc->gfx.scale_y = (double)wh / vc->gfx.h;
+
glFlush();
#ifdef CONFIG_GBM
if (dmabuf) {
@@ -100,6 +103,8 @@ void gd_gl_area_draw(VirtualConsole *vc)
surface_gl_setup_viewport(vc->gfx.gls, vc->gfx.ds, ww, wh);
surface_gl_render_texture(vc->gfx.gls, vc->gfx.ds);
+ vc->gfx.scale_x = (double)ww / vc->gfx.w;
+ vc->gfx.scale_y = (double)wh / vc->gfx.h;
}
}
diff --git a/ui/gtk.c b/ui/gtk.c
index 6c23903173..9d0c27c9e7 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -883,9 +883,14 @@ static gboolean gd_motion_event(GtkWidget *widget,
GdkEventMotion *motion,
fbh = surface_height(vc->gfx.ds) * vc->gfx.scale_y;
window = gtk_widget_get_window(vc->gfx.drawing_area);
- ww = gdk_window_get_width(window);
- wh = gdk_window_get_height(window);
ws = gdk_window_get_scale_factor(window);
+ if (GDK_IS_WAYLAND_DISPLAY(dpy)) {
+ ww = gtk_widget_get_allocated_width(vc->gfx.drawing_area);
+ wh = gtk_widget_get_allocated_height(vc->gfx.drawing_area);
+ } else {
+ ww = gdk_window_get_width(window);
+ wh = gdk_window_get_height(window);
+ }
mx = my = 0;
if (ww > fbw) {
--
2.37.2
- [PATCH v2 0/6] ui/gtk: Add a new parameter to assign connectors/monitors (v2), Vivek Kasireddy, 2022/11/17
- [PATCH v2 1/6] ui/gtk: Consider the scaling factor when getting the root coordinates, Vivek Kasireddy, 2022/11/17
- [PATCH v2 2/6] ui/gtk-gl-area: Don't forget to calculate the scaling factors in draw,
Vivek Kasireddy <=
- [PATCH v2 4/6] ui/gtk: Disable the scanout when a detached tab is closed, Vivek Kasireddy, 2022/11/17
- [PATCH v2 3/6] ui/gtk: Handle relative mode events correctly with Wayland compositors, Vivek Kasireddy, 2022/11/17
- [PATCH v2 5/6] ui/gtk: Factor out tab window creation into a separate function, Vivek Kasireddy, 2022/11/17
- [PATCH v2 6/6] ui/gtk: Add a new parameter to assign connectors/monitors to GFX VCs (v2), Vivek Kasireddy, 2022/11/17