[virt-tools-list] [PATCH virt-viewer 2/2] fullscreen-auto-conf: Use display id according to monitor-mapping

Pavel Grunt pgrunt at redhat.com
Wed Jun 3 14:48:47 UTC 2015


On Wed, 2015-06-03 at 09:29 -0500, Jonathon Jongsma wrote:
> On Wed, 2015-06-03 at 14:44 +0200, Pavel Grunt wrote:
> > ---
> >  src/virt-viewer-session-spice.c | 12 ++++++++----
> >  1 file changed, 8 insertions(+), 4 deletions(-)
> > 
> > diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session
> > -spice.c
> > index 9c72245..2a036b7 100644
> > --- a/src/virt-viewer-session-spice.c
> > +++ b/src/virt-viewer-session-spice.c
> > @@ -836,6 +836,7 @@ 
> > virt_viewer_session_spice_fullscreen_auto_conf(VirtViewerSessionSpice *self)
> >      gint i;
> >      GList *initial_displays, *l;
> >      guint ndisplays;
> > +    gint *display_ids;
> >  
> >      /* only do auto-conf once at startup. Avoid repeating auto-conf later 
> > due to
> >       * agent disconnection/re-connection, etc */
> > @@ -869,10 +870,12 @@ 
> > virt_viewer_session_spice_fullscreen_auto_conf(VirtViewerSessionSpice *self)
> >      ndisplays = g_list_length(initial_displays);
> >      g_debug("Performing full screen auto-conf, %u host monitors", 
> > ndisplays);
> >      displays = g_new0(GdkRectangle, ndisplays);
> > +    display_ids = g_new0(gint, ndisplays);
> >  
> >      for (ndisplays = 0, l = initial_displays; l != NULL; l = l->next) {
> >          GdkRectangle* rect = &displays[ndisplays];
> > -        gint j = virt_viewer_app_get_initial_monitor_for_display(app, 
> > GPOINTER_TO_INT(l->data));
> > +        display_ids[ndisplays] = GPOINTER_TO_INT(l->data);
> > +        gint j = virt_viewer_app_get_initial_monitor_for_display(app, 
> > display_ids[ndisplays]);
> >          if (j == -1)
> >              continue;
> >  
> > @@ -886,12 +889,13 @@ 
> > virt_viewer_session_spice_fullscreen_auto_conf(VirtViewerSessionSpice *self)
> >      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);
> > +        spice_main_set_display(cmain, display_ids[i], rect->x, rect->y, 
> > rect->width, rect->height);
> > +        spice_main_set_display_enabled(cmain, display_ids[i], TRUE);
> >          g_debug("Set SPICE display %d to (%d,%d)-(%dx%d)",
> > -                  i, rect->x, rect->y, rect->width, rect->height);
> > +                display_ids[i], rect->x, rect->y, rect->width, rect
> > ->height);
> >      }
> >      g_free(displays);
> > +    g_free(display_ids);
> >  
> >      spice_main_send_monitor_config(cmain);
> >      self->priv->did_auto_conf = TRUE;
> 
> 
> This looks like it will work fine, but I'm starting to wonder whether it
> wouldn't be simpler and easier to understand if we used a e.g.
> GHashTable<int, GdkRectangle*> instead of using an array of ints and a
> separate array of GdkRectangles...
> 

Ok, I will change it. Probably I would need to rewrite
virt_viewer_shift_monitors_to_origin to work with GList.

Pavel





More information about the virt-tools-list mailing list