diff options
author | Alexander Larsson <alexl@redhat.com> | 2012-08-30 19:27:28 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2012-08-30 22:11:03 +0200 |
commit | d0bc4f9194c0b8d6a001883344ab2689ea13c6b4 (patch) | |
tree | 70b73f42151de7ddc2529b5126a8dcf90c832873 /gtk/spice-widget-x11.c | |
parent | 8fa2996a51757086a00eafc23ad3650ea223e79d (diff) |
Centralize scaling handling
This moves all the handling of scaling calculations and
positioning of the display inside the widget into one place.
This makes it easier to later change how scaling works.
Also, the new scaling only support aspect-ratio-keeping
scaling.
https://bugs.freedesktop.org/show_bug.cgi?id=54277
Diffstat (limited to 'gtk/spice-widget-x11.c')
-rw-r--r-- | gtk/spice-widget-x11.c | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/gtk/spice-widget-x11.c b/gtk/spice-widget-x11.c index 7fc99ff..178dc98 100644 --- a/gtk/spice-widget-x11.c +++ b/gtk/spice-widget-x11.c @@ -219,33 +219,36 @@ void spicex_expose_event(SpiceDisplay *display, GdkEventExpose *expose) { GdkDrawable *window = gtk_widget_get_window(GTK_WIDGET(display)); SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display); + int x, y, w, h; - if (expose->area.x >= d->mx && - expose->area.y >= d->my && - expose->area.x + expose->area.width <= d->mx + d->area.width && - expose->area.y + expose->area.height <= d->my + d->area.height) { + spice_display_get_scaling(display, NULL, &x, &y, &w, &h); + + if (expose->area.x >= x && + expose->area.y >= y && + expose->area.x + expose->area.width <= x + w && + expose->area.y + expose->area.height <= y + h) { /* area is completely inside the guest screen -- blit it */ if (d->have_mitshm && d->shminfo) { XShmPutImage(d->dpy, gdk_x11_drawable_get_xid(window), d->gc, d->ximage, - d->area.x + expose->area.x - d->mx, d->area.y + expose->area.y - d->my, + d->area.x + expose->area.x - x, d->area.y + expose->area.y - y, expose->area.x, expose->area.y, expose->area.width, expose->area.height, true); } else { XPutImage(d->dpy, gdk_x11_drawable_get_xid(window), d->gc, d->ximage, - d->area.x + expose->area.x - d->mx, d->area.y + expose->area.y - d->my, - expose->area.x expose->area.y, + d->area.x + expose->area.x - x, d->area.y + expose->area.y - y, + expose->area.x, expose->area.y, expose->area.width, expose->area.height); } } else { /* complete window update */ if (d->ww > d->area.width || d->wh > d->area.height) { - int x1 = d->mx; - int x2 = d->mx + d->area.width; - int y1 = d->my; - int y2 = d->my + d->area.height; + int x1 = x; + int x2 = x + w; + int y1 = y; + int y2 = y + h; XFillRectangle(d->dpy, gdk_x11_drawable_get_xid(window), d->gc, 0, 0, x1, d->wh); XFillRectangle(d->dpy, gdk_x11_drawable_get_xid(window), @@ -258,27 +261,17 @@ void spicex_expose_event(SpiceDisplay *display, GdkEventExpose *expose) if (d->have_mitshm && d->shminfo) { XShmPutImage(d->dpy, gdk_x11_drawable_get_xid(window), d->gc, d->ximage, - d->area.x, d->area.y, d->mx, d->my, d->area.width, d->area.height, + d->area.x, d->area.y, x, y, w, h, true); } else { XPutImage(d->dpy, gdk_x11_drawable_get_xid(window), d->gc, d->ximage, - d->area.x, d->area.y, d->mx, d->my, d->area.width, d->area.height); + d->area.x, d->area.y, x, y, w, h); } } } G_GNUC_INTERNAL -void spicex_image_invalidate (SpiceDisplay *display, - gint *x, gint *y, gint *w, gint *h) -{ - SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display); - /* Offset the Spice region to produce expose region */ - *x += d->mx; - *y += d->my; -} - -G_GNUC_INTERNAL gboolean spicex_is_scaled(SpiceDisplay *display) { return FALSE; /* backend doesn't support scaling yet */ |