[virt-tools-list] [PATCH virt-viewer] Remove 'map' handler for VirtViewerDisplay

Fabiano Fidêncio fidencio at redhat.com
Fri Dec 12 23:13:26 UTC 2014


Jonathon,

On Fri, 2014-12-12 at 17:05 -0600, Jonathon Jongsma wrote:
> In order to solve several problems with sizing and resizing displays, a
> 'map' handler was added to VirtViewerDisplay. The first time the map
> handler runs, its queues a resize to attempt to ensure that the window
> gets created at its desired size. Subsequent map events generate a call
> to _make_resizable(), which was an attempt to ensure that the window was
> always 'shrinkable' on the Microsoft Windows platform. Recent testing
> suggests that this _make_resizable() is not actually necessary on
> Windows anymore, since it is possible to shrink the display even when
> this call is removed.
> 
> In addition, the call to _queue_resize() is a bit of an indirect
> solution to the problem of ensuring the proper size at startup. What we
> really want is to guarantee that the very first size request negotiation
> returns the desired size rather than the minimum size. In order to do
> this, we've added a flag to determine whether we've ever received a size
> request, and if not, we return our desired size, even if 'dirty' is not
> set.
> ---
> 
> NOTE: I've tested this on Fedora 20, RHEL 6, and Windows XP (built on Fedora
> 20). I've been attempting to test a windows build that was built on RHEL6 as
> well (to ensure that the behavior is the same when bundled with e.g. RHEL6
> versions of gtk2, etc), but I've not succeeded yet. It turns out that it's not
> straightforward to make a windows build of git master on RHEL6. So that's a bit
> of an open question yet...

I've been following this work and I consider wait for someone's else ACK
apart from mine. (Marc-André? Christophe?)

> 
>  src/virt-viewer-display.c | 22 +++-------------------
>  1 file changed, 3 insertions(+), 19 deletions(-)
> 
> diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
> index e6bc108..9c9c796 100644
> --- a/src/virt-viewer-display.c
> +++ b/src/virt-viewer-display.c
> @@ -38,7 +38,7 @@ struct _VirtViewerDisplayPrivate
>  {
>  #if !GTK_CHECK_VERSION(3, 0, 0)
>      gboolean dirty;
> -    gboolean mapped_once;
> +    gboolean size_request_once;
>  #endif
>      guint desktopWidth;
>      guint desktopHeight;
> @@ -54,7 +54,6 @@ struct _VirtViewerDisplayPrivate
>  #if !GTK_CHECK_VERSION(3, 0, 0)
>  static void virt_viewer_display_size_request(GtkWidget *widget,
>                                               GtkRequisition *requisition);
> -static void virt_viewer_display_map(GtkWidget *widget);
>  #else
>  static void virt_viewer_display_get_preferred_width(GtkWidget *widget,
>                                                      int *minwidth,
> @@ -106,7 +105,6 @@ virt_viewer_display_class_init(VirtViewerDisplayClass *class)
>      widget_class->get_preferred_height = virt_viewer_display_get_preferred_height;
>  #else
>      widget_class->size_request = virt_viewer_display_size_request;
> -    widget_class->map = virt_viewer_display_map;
>  #endif
>      widget_class->size_allocate = virt_viewer_display_size_allocate;
>      widget_class->grab_focus = virt_viewer_display_grab_focus;
> @@ -423,13 +421,14 @@ virt_viewer_display_size_request(GtkWidget *widget,
>      VirtViewerDisplay *display = VIRT_VIEWER_DISPLAY(widget);
>      VirtViewerDisplayPrivate *priv = display->priv;
>  
> -    if (priv->dirty) {
> +    if (priv->dirty || !priv->size_request_once) {
>          virt_viewer_display_get_preferred_size(display, requisition);
>      } else {
>          requisition->width = 50;
>          requisition->height = 50;
>      }
>  
> +    priv->size_request_once = TRUE;
>      g_debug("Display size request %dx%d (desktop %dx%d)",
>                requisition->width, requisition->height,
>                priv->desktopWidth, priv->desktopHeight);
> @@ -450,21 +449,6 @@ virt_viewer_display_make_resizable(VirtViewerDisplay *self)
>      }
>  }
>  
> -static void
> -virt_viewer_display_map(GtkWidget *widget)
> -{
> -    VirtViewerDisplay* self = VIRT_VIEWER_DISPLAY(widget);
> -
> -    GTK_WIDGET_CLASS(virt_viewer_display_parent_class)->map(widget);
> -
> -    if (!self->priv->mapped_once)
> -        virt_viewer_display_queue_resize(self);
> -    else
> -        virt_viewer_display_make_resizable(self);
> -
> -    self->priv->mapped_once = TRUE;
> -}
> -
>  #else
>  
>  static void virt_viewer_display_get_preferred_width(GtkWidget *widget,

Please, initialize the priv->size_request_once as FALSE in
virt_viewer_display_init().
ACK from my side.




More information about the virt-tools-list mailing list