summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPavel Grunt <pgrunt@redhat.com>2016-01-27 17:42:59 +0100
committerPavel Grunt <pgrunt@redhat.com>2016-02-03 15:25:09 +0100
commit045174f4830c87054f8ddf3840fc76df6f2617b1 (patch)
treecd8ee655faee652fff9169a49523d1b589af2beb /src
parentc2f6412e7a055473e6e124ede5b4ddb229c255b1 (diff)
downloadvirt-viewer-045174f4830c87054f8ddf3840fc76df6f2617b1.tar.gz
virt-viewer-045174f4830c87054f8ddf3840fc76df6f2617b1.tar.xz
virt-viewer-045174f4830c87054f8ddf3840fc76df6f2617b1.zip
display: Return early and remove a block
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/virt-viewer-display.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index 72ec56a..4bfa29b 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -511,37 +511,34 @@ virt_viewer_display_size_allocate(GtkWidget *widget,
g_debug("Allocated %dx%d", allocation->width, allocation->height);
gtk_widget_set_allocation(widget, allocation);
- if (priv->desktopWidth == 0 ||
- priv->desktopHeight == 0)
+ if (priv->desktopWidth == 0 || priv->desktopHeight == 0 ||
+ child == NULL || !gtk_widget_get_visible(child))
#if !GTK_CHECK_VERSION(3, 0, 0)
goto end;
#else
return;
#endif
+ border_width = gtk_container_get_border_width(GTK_CONTAINER(display));
- desktopAspect = (double)priv->desktopWidth / (double)priv->desktopHeight;
+ width = MAX(1, allocation->width - 2 * border_width);
+ height = MAX(1, allocation->height - 2 * border_width);
- if (child && gtk_widget_get_visible(child)) {
- border_width = gtk_container_get_border_width(GTK_CONTAINER(display));
-
- width = MAX(1, allocation->width - 2 * border_width);
- height = MAX(1, allocation->height - 2 * border_width);
- actualAspect = (double)width / (double)height;
+ desktopAspect = (double) priv->desktopWidth / (double) priv->desktopHeight;
+ actualAspect = (double) width / (double) height;
- if (actualAspect > desktopAspect) {
- child_allocation.width = round(height * desktopAspect);
- child_allocation.height = height;
- } else {
- child_allocation.width = width;
- child_allocation.height = round(width / desktopAspect);
- }
+ if (actualAspect > desktopAspect) {
+ child_allocation.width = round(height * desktopAspect);
+ child_allocation.height = height;
+ } else {
+ child_allocation.width = width;
+ child_allocation.height = round(width / desktopAspect);
+ }
- child_allocation.x = 0.5 * (width - child_allocation.width) + allocation->x + border_width;
- child_allocation.y = 0.5 * (height - child_allocation.height) + allocation->y + border_width;
+ child_allocation.x = 0.5 * (width - child_allocation.width) + allocation->x + border_width;
+ child_allocation.y = 0.5 * (height - child_allocation.height) + allocation->y + border_width;
- g_debug("Child allocate %dx%d", child_allocation.width, child_allocation.height);
- gtk_widget_size_allocate(child, &child_allocation);
- }
+ g_debug("Child allocate %dx%d", child_allocation.width, child_allocation.height);
+ gtk_widget_size_allocate(child, &child_allocation);
#if !GTK_CHECK_VERSION(3, 0, 0)
end: