[Spice-devel] Spice-devel][vd_agent PATCH V2] Add monitors_config driver escape.

Sandy Stutsman sstutsma at redhat.com
Mon Jun 22 16:41:40 PDT 2015


When a Windows guest uses the "Set Resolution" applet to change
resolutions and/or monitor positions, this escape sends the new monitor
configurations to the client via a new QXL driver escape.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1202419
---
Change from v1:
* Add call to update_monitor_config to get_displays
  *Remove call to set_displays in wnd_proc WM_DISPLAYCHANGE case switch
This should reduce the opportunity for contending changes between the 
guest and the client
---

vdagent/desktop_layout.cpp | 30 ++++++++++++++++++++++++++++--
vdagent/desktop_layout.h | 2 +-
2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
index f71abd0..a126978 100644
--- a/vdagent/desktop_layout.cpp
+++ b/vdagent/desktop_layout.cpp
@@ -85,6 +85,7 @@ void DesktopLayout::get_displays()
_displays[display_id] = new DisplayMode(mode.dmPosition.x, 
mode.dmPosition.y,
mode.dmPelsWidth, mode.dmPelsHeight,
mode.dmBitsPerPel, attached);
+ update_monitor_config(dev_info.DeviceName, _displays[display_id]);
}
normalize_displays_pos();
unlock();
@@ -142,8 +143,8 @@ void DesktopLayout::set_displays()
vd_printf("display_id %lu out of range, #displays %zu" , display_id, 
_displays.size());
break;
}
- if (!init_dev_mode(dev_info.DeviceName, &dev_mode, 
_displays.at(display_id),
- normal_x, normal_y, true)) {
+ DisplayMode * mode(_displays.at(display_id));
+ if (!init_dev_mode(dev_info.DeviceName, &dev_mode, mode, normal_x, 
normal_y, true)) {
vd_printf("No suitable mode found for display %S", dev_info.DeviceName);
break;
}
@@ -152,6 +153,7 @@ void DesktopLayout::set_displays()
CDS_UPDATEREGISTRY | CDS_NORESET, NULL);
if (ret == DISP_CHANGE_SUCCESSFUL) {
dev_sets++;
+ update_monitor_config(dev_info.DeviceName, mode);
}
if (!is_qxl) {
display_id++;
@@ -355,3 +357,27 @@ bool DesktopLayout::init_dev_mode(LPCTSTR dev_name, 
DEVMODE* dev_mode, DisplayMo
return true;
}

+bool DesktopLayout::update_monitor_config(LPCTSTR dev_name, 
DisplayMode* mode)
+{
+ QXLEscapeMonitorConfig MonitorConfig;
+
+ if (!mode || !mode->get_attached())
+ return false;
+
+ HDC hdc = CreateDC(dev_name, NULL, NULL, NULL);
+
+ MonitorConfig.xpos = mode->_pos_x;
+ MonitorConfig.ypos = mode->_pos_y;
+ MonitorConfig.xres = mode->_width;
+ MonitorConfig.yres = mode->_height;
+
+ int err = ExtEscape(hdc, QXL_ESCAPE_MONITOR_CONFIG,
+ sizeof(QXLEscapeMonitorConfig), (LPCSTR) &MonitorConfig, 0, NULL);
+
+ if (err < 0){
+ vd_printf("can't update monitor config, may have an older driver");
+ }
+
+ DeleteDC(hdc);
+ return (err >= 0);
+}
diff --git a/vdagent/desktop_layout.h b/vdagent/desktop_layout.h
index 4f6a042..0e310e3 100644
--- a/vdagent/desktop_layout.h
+++ b/vdagent/desktop_layout.h
@@ -83,7 +83,7 @@ private:
static bool get_qxl_device_id(WCHAR* device_key, DWORD* device_id);
static bool init_dev_mode(LPCTSTR dev_name, DEVMODE* dev_mode, 
DisplayMode* mode,
LONG normal_x, LONG normal_y, bool set_pos);
-
+ static bool update_monitor_config(LPCTSTR dev_name, DisplayMode* mode);
private:
mutex_t _mutex;
Displays _displays;
-- 
1.9.5.msysgit.0



More information about the Spice-devel mailing list