[Spice-devel] [PATCH] Update monitor state when it is detached

Sameeh Jubran sameeh at daynix.com
Mon Aug 15 12:30:19 UTC 2016


The monitor detached state is being set but not updated, in order to update it
we should call ChangeDisplaySettingsEx after setting the appropriate
flags along with width and height that are set to 0.

Signed-off-by: Sameeh Jubran <sameeh at daynix.com>
---
 vdagent/desktop_layout.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
index a7666ca..c0632cc 100644
--- a/vdagent/desktop_layout.cpp
+++ b/vdagent/desktop_layout.cpp
@@ -279,7 +279,10 @@ bool DesktopLayout::init_dev_mode(LPCTSTR dev_name, DEVMODE* dev_mode, DisplayMo
     if (!mode || !mode->_attached) {
         //Detach monitor
         dev_mode->dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION;
-        return true;
+        dev_mode->dmPelsWidth = 0;
+        dev_mode->dmPelsHeight = 0;
+        ret = ChangeDisplaySettingsEx(dev_name, dev_mode, NULL, CDS_UPDATEREGISTRY, NULL);
+        return (ret == DISP_CHANGE_SUCCESSFUL);
     }
 
     hdc = CreateDC(dev_name, NULL, NULL, NULL);
-- 
2.7.4



More information about the Spice-devel mailing list