[virt-tools-list] [PATCH virt-viewer 2/2] display: Move variable definitions to block where are used
Pavel Grunt
pgrunt at redhat.com
Wed Jan 27 17:03:20 UTC 2016
---
src/virt-viewer-display.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index 72ec56a..d1b088e 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -501,11 +501,6 @@ virt_viewer_display_size_allocate(GtkWidget *widget,
GtkBin *bin = GTK_BIN(widget);
VirtViewerDisplay *display = VIRT_VIEWER_DISPLAY(widget);
VirtViewerDisplayPrivate *priv = display->priv;
- GtkAllocation child_allocation;
- gint width, height;
- gint border_width;
- double desktopAspect;
- double actualAspect;
GtkWidget *child = gtk_bin_get_child(bin);
g_debug("Allocated %dx%d", allocation->width, allocation->height);
@@ -519,14 +514,15 @@ virt_viewer_display_size_allocate(GtkWidget *widget,
return;
#endif
- desktopAspect = (double)priv->desktopWidth / (double)priv->desktopHeight;
-
if (child && gtk_widget_get_visible(child)) {
- border_width = gtk_container_get_border_width(GTK_CONTAINER(display));
+ GtkAllocation child_allocation;
+ gint border_width = gtk_container_get_border_width(GTK_CONTAINER(display));
+
+ gint width = MAX(1, allocation->width - 2 * border_width);
+ gint height = MAX(1, allocation->height - 2 * border_width);
- width = MAX(1, allocation->width - 2 * border_width);
- height = MAX(1, allocation->height - 2 * border_width);
- actualAspect = (double)width / (double)height;
+ double desktopAspect = (double) priv->desktopWidth / (double) priv->desktopHeight;
+ double actualAspect = (double) width / (double) height;
if (actualAspect > desktopAspect) {
child_allocation.width = round(height * desktopAspect);
--
2.5.0
More information about the virt-tools-list
mailing list