[Spice-devel] [PATCH win-agent 9/9] Resize to arbitrary resolution
Alon Levy
alevy at redhat.com
Sun May 13 02:32:34 PDT 2012
On Fri, May 11, 2012 at 06:39:18PM +0200, Marc-André Lureau wrote:
> Use QXL_ESCAPE_SET_CUSTOM_DISPLAY to update custom mode,
> and switch to it.
> ---
> vdagent/desktop_layout.cpp | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
> index 6e255fc..7564cf6 100644
> --- a/vdagent/desktop_layout.cpp
> +++ b/vdagent/desktop_layout.cpp
> @@ -15,6 +15,7 @@
> along with this program. If not, see <http://www.gnu.org/licenses/>.
> */
>
> +#include <spice/qxl_windows.h>
> #include "desktop_layout.h"
> #include "vdlog.h"
>
> @@ -240,6 +241,8 @@ bool DesktopLayout::init_dev_mode(LPCTSTR dev_name, DEVMODE* dev_mode, DisplayMo
> {
> DWORD closest_diff = -1;
> DWORD best = -1;
> + QXLEscapeSetCustomDisplay custom;
> + HDC hdc = NULL;
>
> ZeroMemory(dev_mode, sizeof(DEVMODE));
> dev_mode->dmSize = sizeof(DEVMODE);
> @@ -248,6 +251,29 @@ bool DesktopLayout::init_dev_mode(LPCTSTR dev_name, DEVMODE* dev_mode, DisplayMo
> dev_mode->dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION;
> return true;
> }
> +
> + // Update custom resolution
> + custom.xres = mode->_width;
> + custom.yres = mode->_height;
> + custom.bpp = mode->_depth;
> + hdc = CreateDC(dev_name, NULL, NULL, NULL);
> + if (!hdc) {
> + vd_printf("failed to create DC: %s", dev_name);
> + } else {
> + int err = ExtEscape(hdc, QXL_ESCAPE_SET_CUSTOM_DISPLAY,
> + sizeof(QXLEscapeSetCustomDisplay), (LPCSTR)&custom, 0, NULL);
> + if (err <= 0) {
> + vd_printf("can't set custom display, perhaps an old driver");
> + }
> + DeleteDC(hdc);
> + }
> +
> + // force refresh mode table
> + DEVMODE tempDevMode;
> + ZeroMemory(&tempDevMode, sizeof (tempDevMode));
> + tempDevMode.dmSize = sizeof(DEVMODE);
> + EnumDisplaySettings(dev_name, 0xffffff, &tempDevMode);
Missing comment for 0xffffff (you mention this is used to refresh the
modes list earlier).
> +
> //Find the closest size which will fit within the monitor
> for (DWORD i = 0; EnumDisplaySettings(dev_name, i, dev_mode); i++) {
> if (dev_mode->dmPelsWidth > mode->_width ||
> --
> 1.7.10.1
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list