diff options
author | Jonathon Jongsma <jjongsma@redhat.com> | 2014-09-30 11:24:18 -0500 |
---|---|---|
committer | Jonathon Jongsma <jjongsma@redhat.com> | 2014-10-27 10:37:31 -0500 |
commit | 8fa5e004ec7e66ab0ca6e8443271e09425e4a1a1 (patch) | |
tree | f95a3cfb4b7dfa550039e335c2505712de440927 /src/virt-viewer-session-spice.c | |
parent | 221d5f5cd44b73fe1fc3c28a944744bd791af631 (diff) | |
download | virt-viewer-8fa5e004ec7e66ab0ca6e8443271e09425e4a1a1.tar.gz virt-viewer-8fa5e004ec7e66ab0ca6e8443271e09425e4a1a1.tar.xz virt-viewer-8fa5e004ec7e66ab0ca6e8443271e09425e4a1a1.zip |
Shift top-left display to origin
When using a custom fullscreen display configuration, it's possible to
specify that e.g. a single screen should be fullscreen on client
monitor #4. Since we send down absolute positions and disable alignment
when all windows are in fullscreen, we can send configurations with a
very large offset to the top-left corner. This could result in the guest
trying to create a screen that was much larger than necessary. For
example when sending a configuration of 1280x1024+4240+0, the guest
would need to allocate a screen of size 5520x1024, which might fail if
video memory was too low. To avoid this issue, we shift all displays
so that the minimum X coordinate for all screens is at x=0, and the
minimum y coordinate is at y=0.
Diffstat (limited to 'src/virt-viewer-session-spice.c')
-rw-r--r-- | src/virt-viewer-session-spice.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c index 4cd2ac8..271467a 100644 --- a/src/virt-viewer-session-spice.c +++ b/src/virt-viewer-session-spice.c @@ -804,7 +804,7 @@ virt_viewer_session_spice_fullscreen_auto_conf(VirtViewerSessionSpice *self) GdkScreen *screen = gdk_screen_get_default(); SpiceMainChannel* cmain = virt_viewer_session_spice_get_main_channel(self); VirtViewerApp *app = NULL; - GdkRectangle dest; + GdkRectangle *displays; gboolean agent_connected; gint i; gsize ndisplays = 0; @@ -838,18 +838,28 @@ virt_viewer_session_spice_fullscreen_auto_conf(VirtViewerSessionSpice *self) ndisplays = virt_viewer_app_get_n_initial_displays(app); g_debug("Performing full screen auto-conf, %" G_GSIZE_FORMAT " host monitors", ndisplays); + displays = g_new0(GdkRectangle, ndisplays); for (i = 0; i < ndisplays; i++) { + GdkRectangle* rect = &displays[i]; gint j = virt_viewer_app_get_initial_monitor_for_display(app, i); if (j == -1) continue; - gdk_screen_get_monitor_geometry(screen, j, &dest); - g_debug("Set SPICE display %d to (%d,%d)-(%dx%d)", - i, dest.x, dest.y, dest.width, dest.height); - spice_main_set_display(cmain, i, dest.x, dest.y, dest.width, dest.height); + gdk_screen_get_monitor_geometry(screen, j, rect); + } + + virt_viewer_shift_monitors_to_origin(displays, ndisplays); + + for (i = 0; i < ndisplays; i++) { + GdkRectangle *rect = &displays[i]; + + spice_main_set_display(cmain, i, rect->x, rect->y, rect->width, rect->height); spice_main_set_display_enabled(cmain, i, TRUE); + g_debug("Set SPICE display %d to (%d,%d)-(%dx%d)", + i, rect->x, rect->y, rect->width, rect->height); } + g_free(displays); spice_main_send_monitor_config(cmain); self->priv->did_auto_conf = TRUE; |