[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 2/2] ui/gtk: Include the position info while setting the ui in
From: |
Vivek Kasireddy |
Subject: |
[PATCH v1 2/2] ui/gtk: Include the position info while setting the ui info |
Date: |
Thu, 17 Nov 2022 17:37:23 -0800 |
In situtations where the Guest uses multiple displays/outputs, this
position info is useful for aligning the Guest's outputs with that of
the Host's.
Cc: Dongwon Kim <dongwon.kim@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
---
ui/gtk.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/ui/gtk.c b/ui/gtk.c
index 92daaa6a6e..12b3bc6481 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -714,12 +714,31 @@ static gboolean gd_window_close(GtkWidget *widget,
GdkEvent *event,
return TRUE;
}
+static void gd_set_ui_window_position(VirtualConsole *vc, QemuUIInfo *info)
+{
+ GdkDisplay *dpy = gtk_widget_get_display(vc->gfx.drawing_area);
+ GdkWindow *window;
+ GdkMonitor *monitor;
+ GdkRectangle geometry;
+
+ if (!gtk_widget_get_realized(vc->gfx.drawing_area)) {
+ return;
+ }
+
+ window = gtk_widget_get_window(vc->gfx.drawing_area);
+ monitor = gdk_display_get_monitor_at_window(dpy, window);
+ gdk_monitor_get_geometry(monitor, &geometry);
+ info->xoff = geometry.x;
+ info->yoff = geometry.y;
+}
+
static void gd_set_ui_refresh_rate(VirtualConsole *vc, int refresh_rate)
{
QemuUIInfo info;
info = *dpy_get_ui_info(vc->gfx.dcl.con);
info.refresh_rate = refresh_rate;
+ gd_set_ui_window_position(vc, &info);
dpy_set_ui_info(vc->gfx.dcl.con, &info, true);
}
@@ -730,6 +749,7 @@ static void gd_set_ui_size(VirtualConsole *vc, gint width,
gint height)
info = *dpy_get_ui_info(vc->gfx.dcl.con);
info.width = width;
info.height = height;
+ gd_set_ui_window_position(vc, &info);
dpy_set_ui_info(vc->gfx.dcl.con, &info, true);
}
--
2.37.2