hi-dpi support for Boxes
Submitted by Owen Taylor
I did some testing of Boxes on a hi-dpi screen, and it basically works, not perfectly.
In guest resizing mode only half the resolution is exposed to the guest, and then the guest contents are upscaled by a factor of 2 using bilinear scaling, resulting in a blurry appearance.
This is better than just exposing the full screen resolution to unsuspecting guests and having everything tiny - but generally a hi-dpi laptop screen is not going to have enough screen real estate to make the guest resizing resizing work well - my 2560x1440 laptop screen is 1280x720 when halved. A window that's smaller than that is not going to have much vertical real estate, and would be better scaled down.
Improvements that make sense to me:
- If spice-gtk is rendering at an integer scale factor, it should set the filter to nearest-neighbour.
I added to spice-widget-cairo.c:
cairo_set_source_surface(cr, d->ximage, 0, 0);
if ((int)s == s)
cairo_pattern_set_filter (cairo_get_source (cr),
- There should be support for guests that have hi-dpi support themselves - this would be a new toggle in settings. In this case, guest resizing would give the guest a size that is exactly the pixel size of the window (use gtk_widget_get_scale_factor()) and a physical size would be exposed to the guest that corresponds to a dpi of 96dpi * scale factor. [Rounding down the physical dimensions to so that the result is strictly >= than 192dpi for a scale of two.]
Beyond that, I'm not sure what is needed to facilitate using non-hdpi guests at scales of 1 < scale < 2 (or hi-dpi guests at scales of 0.5 < scale < 1) which is a natural thing to do on a screen with high resolution but limited real estate.
Ideas I had:
Nothing - you just have to turn off guest resizing and set the resolution of the guest in the guest's hardware settings.
Expose resolution setting in the box properties - this would be more convenient if you need to change it frequently. If guest resizing is reliable enough, then setting the resolution from within Boxes should be reliable enough.
Some sort of floating point scale slider within the Boxes properties that affects the result of guest resizing so that the user could set a scale of 0.75 and a 600x400 window would result in a guest size of 800x533.
Some sort of smart resizing algorithm that would pick an appropriate guest size based on a) scaling-factor b) window size c) considerations of what's going create a maximally usable guest - balancing having enough screen real estate without making things too tiny.
The third option seems against the minimalist spirit of Boxes preferences. I think the fourth could work, though the algorithm takes some thinking.