summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2009-07-29 12:43:30 +0100
committerDaniel P. Berrange <berrange@redhat.com>2009-07-29 12:43:30 +0100
commit0f20335a4f92f1d38a11ba65588955f1310ebfeb (patch)
tree638085c21984b7a1459fd544a06b0c9c5c3bb8fc /src
parent831411aacbccb111a87d5425e32515ef1824a1d3 (diff)
downloadvirt-viewer-0f20335a4f92f1d38a11ba65588955f1310ebfeb.tar.gz
virt-viewer-0f20335a4f92f1d38a11ba65588955f1310ebfeb.tar.xz
virt-viewer-0f20335a4f92f1d38a11ba65588955f1310ebfeb.zip
Ensure VNC display is centered if being scaled
Diffstat (limited to 'src')
-rw-r--r--src/viewer.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/viewer.c b/src/viewer.c
index 606be3f..6f3b294 100644
--- a/src/viewer.c
+++ b/src/viewer.c
@@ -213,6 +213,7 @@ static gboolean viewer_resize_align(GtkWidget *widget,
double scrollAspect = (double)alloc->width / (double)alloc->height;
int height, width;
GtkAllocation child;
+ int dx = 0, dy = 0;
if (!viewer->active) {
DEBUG_LOG("Skipping inactive resize");
@@ -221,10 +222,12 @@ static gboolean viewer_resize_align(GtkWidget *widget,
if (scrollAspect > desktopAspect) {
width = alloc->height * desktopAspect;
+ dx = (alloc->width - width) / 2;
height = alloc->height;
} else {
width = alloc->width;
height = alloc->width / desktopAspect;
+ dy = (alloc->height - height) / 2;
}
DEBUG_LOG("Align widget=%p is %dx%d, desktop is %dx%d, setting VNC to %dx%d",
@@ -233,8 +236,8 @@ static gboolean viewer_resize_align(GtkWidget *widget,
viewer->desktopWidth, viewer->desktopHeight,
width, height);
- child.x = alloc->x;
- child.y = alloc->y;
+ child.x = alloc->x + dx;
+ child.y = alloc->y + dy;
child.width = width;
child.height = height;
gtk_widget_size_allocate(viewer->vnc, &child);