[virt-tools-list] [PATCH virt-viewer v2] session-spice: Disable extra displays in fullscreen mode
Pavel Grunt
pgrunt at redhat.com
Wed Apr 29 14:56:05 UTC 2015
self NACK, I am sending a better version
Pavel
On Wed, 2015-04-29 at 15:46 +0200, Pavel Grunt wrote:
> When running in fullscreen it is possible to end up in a situation
> where we have more displays enabled than monitors. This can happen
> if displays that were enabled in the previous connection to the guest
> doesn't match displays requested when entering the fullscreen mode.
>
> This commit solves the problem by disabling displays that should not
> enabled in the fullscreen mode.
>
> Resolves: rhbz#1212802
> ---
> v1: https://www.redhat.com/archives/virt-tools-list/2015
> -April/msg00184.html
> v2: - nth is not used to determine which display should be enabled,
> but the list of fullscreen displays is used
> - the extra display is disabled instead of being ignored
> ---
> src/virt-viewer-session-spice.c | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer
> -session-spice.c
> index b69faa6..fe1fde1 100644
> --- a/src/virt-viewer-session-spice.c
> +++ b/src/virt-viewer-session-spice.c
> @@ -58,6 +58,7 @@ struct _VirtViewerSessionSpicePrivate {
> gboolean has_sw_smartcard_reader;
> guint pass_try;
> gboolean did_auto_conf;
> + GList *fullscreen_displays;
> };
>
> #define VIRT_VIEWER_SESSION_SPICE_GET_PRIVATE(o)
> (G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_SESSION_SPICE,
> VirtViewerSessionSpicePrivate))
> @@ -146,6 +147,7 @@ virt_viewer_session_spice_dispose(GObject *obj)
> spice->priv->audio = NULL;
>
> g_clear_object(&spice->priv->main_window);
> + g_list_free(spice->priv->fullscreen_displays);
>
> G_OBJECT_CLASS(virt_viewer_session_spice_parent_class)
> ->dispose(obj);
> }
> @@ -693,6 +695,15 @@ destroy_display(gpointer data)
> g_object_unref(display);
> }
>
> +static gboolean
> +display_is_in_fullscreen_mode(VirtViewerSessionSpice *self,
> + VirtViewerDisplay *display)
> +{
> + gconstpointer nth =
> GINT_TO_POINTER(virt_viewer_display_get_nth(display));
> +
> + return g_list_index(self->priv->fullscreen_displays, nth) != -1;
> +}
> +
> static void
> virt_viewer_session_spice_display_monitors(SpiceChannel *channel,
> GParamSpec *pspec
> G_GNUC_UNUSED,
> @@ -702,6 +713,9 @@
> virt_viewer_session_spice_display_monitors(SpiceChannel *channel,
> GPtrArray *displays = NULL;
> GtkWidget *display;
> guint i, monitors_max;
> + gboolean fullscreen_mode =
> +
> virt_viewer_app_get_fullscreen(virt_viewer_session_get_app(VIRT_VIEW
> ER_SESSION(self)));
> + gboolean disable_display = FALSE;
>
> g_object_get(channel,
> "monitors", &monitors,
> @@ -739,12 +753,26 @@
> virt_viewer_session_spice_display_monitors(SpiceChannel *channel,
> if (monitor->width == 0 || monitor->height == 0)
> continue;
>
> + if (fullscreen_mode && !display_is_in_fullscreen_mode(self,
> VIRT_VIEWER_DISPLAY(display))) {
> + g_debug("display %d should not be enabled, disabling",
> +
> virt_viewer_display_get_nth(VIRT_VIEWER_DISPLAY(display)));
> +
> spice_main_set_display_enabled(virt_viewer_session_spice_get_main_ch
> annel(self),
> +
> virt_viewer_display_get_nth(VIRT_VIEWER_DISPLAY(display)),
> + FALSE);
> + disable_display = TRUE;
> + continue;
> + }
> +
>
> virt_viewer_display_set_enabled(VIRT_VIEWER_DISPLAY(display), TRUE);
>
> virt_viewer_display_spice_set_desktop(VIRT_VIEWER_DISPLAY(display),
> monitor->x, monitor
> ->y,
> monitor->width,
> monitor->height);
> }
>
> + if (disable_display) {
> +
> spice_main_send_monitor_config(virt_viewer_session_spice_get_main_ch
> annel(self));
> + }
> +
> g_clear_pointer(&monitors, g_array_unref);
>
> }
> @@ -879,6 +907,8 @@
> virt_viewer_session_spice_fullscreen_auto_conf(VirtViewerSessionSpice
> *self)
>
> for (i = 0; i < ndisplays; i++) {
> GdkRectangle *rect = &displays[i];
> + self->priv->fullscreen_displays = g_list_append(self->priv
> ->fullscreen_displays,
> +
> GINT_TO_POINTER(i));
>
> spice_main_set_display(cmain, i, rect->x, rect->y, rect
> ->width, rect->height);
> spice_main_set_display_enabled(cmain, i, TRUE);
More information about the virt-tools-list
mailing list