[virt-tools-list] [PATCH virt-viewer 2/2] RFC: resize: simplify and isolate fullscreen aspect logic
Marc-André Lureau
marcandre.lureau at gmail.com
Tue Mar 11 15:38:46 UTC 2014
From: Marc-André Lureau <marcandre.lureau at redhat.com>
Tbh, I don't understand the purpose of this code (both spice and vnc
widgets keep the aspect ration), I would welcome some comments. I am not
sure why we check fullscreen display resolution in window mode either,
so I moved the code in if (priv->fullscreen)
If it's possible, this code should be removed (surrouding with if 0
doesn't seem to change anything here with spice or vnc). Please help me
to understand that logic.
---
src/virt-viewer-window.c | 63 +++++++++++++++++++++++-------------------------
1 file changed, 30 insertions(+), 33 deletions(-)
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 08cacd5..d5d9b87 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -406,11 +406,7 @@ virt_viewer_window_queue_resize(VirtViewerWindow *self)
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;
@@ -426,40 +422,41 @@ 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 = desktopHeight;
+ width = desktopWidth;
+ height = desktopHeight;
+
+ if (priv->fullscreen) {
+ GdkRectangle fullscreen;
+ GdkScreen *screen;
+ double desktopAspect;
+ double screenAspect;
+
+ 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);
+
+ 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 = desktopHeight;
}
- DEBUG_LOG("Decided todo %dx%d (desktop is %dx%d, fullscreen is %dx%d",
- width, height, desktopWidth, desktopHeight,
- fullscreen.width, fullscreen.height);
+ DEBUG_LOG("Decided todo %dx%d (desktop is %dx%d)",
+ width, height, desktopWidth, desktopHeight);
virt_viewer_display_set_desktop_size(VIRT_VIEWER_DISPLAY(priv->display),
width, height);
--
1.8.5.3
More information about the virt-tools-list
mailing list