The if () { if () x; else y; } else z; block this commit removes, is a nop: The z block does: width = desktopWidth; height = desktopHeight; The x block does: width = desktopHeight * desktopAspect; height = desktopHeight; Where the width = ... can also be written as: width = desktopHeight * desktopWidth / desktopHeight; Which can be simplified to: width = desktopWidth; Like wise the height setting in the y block can be simplified to: height = desktopHeight; too. So all 3 branches do the same, and the entire block of code can be removed. Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx> --- src/virt-viewer-window.c | 47 +---------------------------------------------- 1 file changed, 1 insertion(+), 46 deletions(-) diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c index 0fcd53e..4273975 100644 --- a/src/virt-viewer-window.c +++ b/src/virt-viewer-window.c @@ -397,20 +397,9 @@ virt_viewer_window_queue_resize(VirtViewerWindow *self) #endif } -/* - * This code attempts to resize the top level window to be large enough - * to contain the entire display desktop at 1:1 ratio. If the local desktop - * isn't large enough that it goes as large as possible and lets the display - * scale down to fit, maintaining aspect ratio - */ static void virt_viewer_window_resize(VirtViewerWindow *self, gboolean keep_win_size) { - GdkRectangle fullscreen; - GdkScreen *screen; - int width, height; - double desktopAspect; - double screenAspect; guint desktopWidth; guint desktopHeight; VirtViewerWindowPrivate *priv = self->priv; @@ -427,42 +416,8 @@ virt_viewer_window_resize(VirtViewerWindow *self, gboolean keep_win_size) virt_viewer_display_get_desktop_size(VIRT_VIEWER_DISPLAY(priv->display), &desktopWidth, &desktopHeight); - screen = gtk_widget_get_screen(priv->window); - gdk_screen_get_monitor_geometry(screen, - gdk_screen_get_monitor_at_window - (screen, gtk_widget_get_window(priv->window)), - &fullscreen); - - g_return_if_fail(fullscreen.height > 128); - g_return_if_fail(fullscreen.width > 128); - g_return_if_fail(desktopWidth > 0); - g_return_if_fail(desktopHeight > 0); - - desktopAspect = (double)desktopWidth / (double)desktopHeight; - screenAspect = (double)(fullscreen.width - 128) / (double)(fullscreen.height - 128); - - if ((desktopWidth > (fullscreen.width - 128)) || - (desktopHeight > (fullscreen.height - 128))) { - /* Doesn't fit native res, so go as large as possible - maintaining aspect ratio */ - if (screenAspect > desktopAspect) { - width = desktopHeight * desktopAspect; - height = desktopHeight; - } else { - width = desktopWidth; - height = desktopWidth / desktopAspect; - } - } else { - width = desktopWidth; - height = desktopHeight; - } - - DEBUG_LOG("Decided todo %dx%d (desktop is %dx%d, fullscreen is %dx%d", - width, height, desktopWidth, desktopHeight, - fullscreen.width, fullscreen.height); - virt_viewer_display_set_desktop_size(VIRT_VIEWER_DISPLAY(priv->display), - width, height); + desktopWidth, desktopHeight); if (!keep_win_size) virt_viewer_window_queue_resize(self); -- 1.8.3.1 _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list