[Spice-devel] [win32/vd_agent v2 2/3] introduce turn_monitor_off method of WDDM interface

Yuri Benditovich yuri.benditovich at daynix.com
Fri Mar 8 09:15:50 UTC 2019


Adding method 'turn_monitor_off' to WDDM interface.
It sends QXL_ESCAPE_MONITOR_CONFIG escape with zeroed
display size to qxl-wddm-dod driver.

Signed-off-by: Yuri Benditovich <yuri.benditovich at daynix.com>
---
 vdagent/display_configuration.cpp | 18 ++++++++++++++++++
 vdagent/display_configuration.h   |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/vdagent/display_configuration.cpp b/vdagent/display_configuration.cpp
index bb2fb80..420836b 100644
--- a/vdagent/display_configuration.cpp
+++ b/vdagent/display_configuration.cpp
@@ -488,6 +488,24 @@ bool WDDMInterface::update_monitor_config(LPCTSTR device_name, DisplayMode* disp
 
 }
 
+bool WDDMInterface::turn_monitor_off(LPCTSTR device_name)
+{
+    vd_printf("for %S", device_name);
+    if (!_send_monitors_config)
+    {
+        vd_printf("do nothing as _send_monitors_config is off");
+        return false;
+    }
+
+    WDDMMonitorConfigEscape wddm_escape(NULL);
+    if (escape(device_name, &wddm_escape, sizeof(wddm_escape))) {
+        return true;
+    }
+
+    vd_printf("%S failed", device_name);
+    return false;
+}
+
 LONG WDDMInterface::update_display_settings()
 {
     LONG error(0);
diff --git a/vdagent/display_configuration.h b/vdagent/display_configuration.h
index 7b5578e..8f3b93a 100644
--- a/vdagent/display_configuration.h
+++ b/vdagent/display_configuration.h
@@ -150,7 +150,6 @@ public:
     bool update_monitor_config(LPCTSTR device_name, DisplayMode* mode, DEVMODE* dev_mode);
     bool update_dev_mode_position(LPCTSTR device_name, DEVMODE * dev_mode, LONG x, LONG y);
     void update_config_path();
-
 private:
     bool init_d3d_api();
     D3D_HANDLE adapter_handle(LPCTSTR device_name);
@@ -160,6 +159,7 @@ private:
 
     void close_adapter(D3D_HANDLE handle);
     bool escape(LPCTSTR device_name, void* data, UINT sizeData);
+    bool turn_monitor_off(LPCTSTR device_name);
 
     //GDI Function pointers
     PFND3DKMT_OPENADAPTERFROMHDC _pfnOpen_adapter_hdc;
-- 
2.16.1.windows.4



More information about the Spice-devel mailing list