[virt-tools-list] [PATCH virt-viewer 3/3] display-spice: Do not ignore change of position
Pavel Grunt
pgrunt at redhat.com
Sun Apr 5 13:45:02 UTC 2015
Positions of displays can be changed by guest, it is important to
react to this change by rearranging client's windows otherwise
mouse actions can be assigned to a wrong window.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1206216
---
I implemented in virt-viewer-display-spice.[ch] because the problem is spice and multimonitor specific.
I don't mind to move the implementation to virt-viewer-display.[ch] if you prefer.
---
src/virt-viewer-display-spice.c | 27 +++++++++++++++++++++++++++
src/virt-viewer-display-spice.h | 2 ++
src/virt-viewer-session-spice.c | 5 +++--
3 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/src/virt-viewer-display-spice.c b/src/virt-viewer-display-spice.c
index 6cd8394..399c207 100644
--- a/src/virt-viewer-display-spice.c
+++ b/src/virt-viewer-display-spice.c
@@ -45,6 +45,8 @@ struct _VirtViewerDisplaySpicePrivate {
SpiceChannel *channel; /* weak reference */
SpiceDisplay *display;
AutoResizeState auto_resize;
+ guint x;
+ guint y;
};
#define VIRT_VIEWER_DISPLAY_SPICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_DISPLAY_SPICE, VirtViewerDisplaySpicePrivate))
@@ -343,6 +345,31 @@ virt_viewer_display_spice_selectable(VirtViewerDisplay *self)
return agent_connected;
}
+void
+virt_viewer_display_spice_set_desktop(VirtViewerDisplay *display,
+ guint x, guint y,
+ guint width, guint height)
+{
+ VirtViewerDisplaySpicePrivate *priv;
+ guint desktopWidth, desktopHeight;
+
+ g_return_if_fail(VIRT_VIEWER_IS_DISPLAY_SPICE(display));
+
+ virt_viewer_display_get_desktop_size(display, &desktopWidth, &desktopHeight);
+
+ priv = VIRT_VIEWER_DISPLAY_SPICE(display)->priv;
+
+ if (desktopWidth == width && desktopHeight == height && priv->x == x && priv->y == y)
+ return;
+
+ g_object_set(G_OBJECT(display), "desktop-width", width, "desktop-height", height, NULL);
+ priv->x = x;
+ priv->y = y;
+
+ virt_viewer_display_queue_resize(display);
+
+ g_signal_emit_by_name(display, "display-desktop-resize");
+}
/*
* Local variables:
diff --git a/src/virt-viewer-display-spice.h b/src/virt-viewer-display-spice.h
index c2013ec..3c30270 100644
--- a/src/virt-viewer-display-spice.h
+++ b/src/virt-viewer-display-spice.h
@@ -68,6 +68,8 @@ GType virt_viewer_display_spice_get_type(void);
GtkWidget* virt_viewer_display_spice_new(VirtViewerSessionSpice *session, SpiceChannel *channel, gint monitorid);
+void virt_viewer_display_spice_set_desktop(VirtViewerDisplay *display, guint x, guint y,
+ guint width, guint height);
G_END_DECLS
#endif /* _VIRT_VIEWER_DISPLAY_SPICE_H */
diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index 921e613..e2645ca 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -741,8 +741,9 @@ virt_viewer_session_spice_display_monitors(SpiceChannel *channel,
continue;
virt_viewer_display_set_enabled(VIRT_VIEWER_DISPLAY(display), TRUE);
- virt_viewer_display_set_desktop_size(VIRT_VIEWER_DISPLAY(display),
- monitor->width, monitor->height);
+ virt_viewer_display_spice_set_desktop(VIRT_VIEWER_DISPLAY(display),
+ monitor->x, monitor->y,
+ monitor->width, monitor->height);
}
g_clear_pointer(&monitors, g_array_unref);
--
2.3.4
More information about the virt-tools-list
mailing list