[Spice-commits] vdagent/desktop_layout.cpp vdagent/desktop_layout.h

Christophe Fergau teuf at kemper.freedesktop.org
Tue Jun 30 07:47:43 PDT 2015


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

New commits:
commit 6023630562fd129433aef1eaddcf6fbee3f03e50
Author: Sandy Stutsman <sstutsma at redhat.com>
Date:   Wed Jun 24 14:36:21 2015 -0400

    Add monitors_config driver escape.
    
    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

diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
index f71abd0..7a34f7f 100644
--- a/vdagent/desktop_layout.cpp
+++ b/vdagent/desktop_layout.cpp
@@ -16,6 +16,7 @@
 */
 
 #include <spice/qxl_windows.h>
+#include <spice/qxl_dev.h>
 #include "desktop_layout.h"
 #include "vdlog.h"
 
@@ -85,6 +86,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 +144,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 +154,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 +358,28 @@ bool DesktopLayout::init_dev_mode(LPCTSTR dev_name, DEVMODE* dev_mode, DisplayMo
     return true;
 }
 
+bool DesktopLayout::update_monitor_config(LPCTSTR dev_name, DisplayMode* mode)
+{
+    QXLHead monitor_config;
+
+    if (!mode || !mode->get_attached())
+        return false;
+
+    HDC hdc = CreateDC(dev_name, NULL, NULL, NULL);
+
+    memset(&monitor_config, 0, sizeof(monitor_config));
+    monitor_config.x = mode->_pos_x;
+    monitor_config.y = mode->_pos_y;
+    monitor_config.width = mode->_width;
+    monitor_config.height = mode->_height;
+
+    int err = ExtEscape(hdc, QXL_ESCAPE_MONITOR_CONFIG,
+        sizeof(QXLHead), (LPCSTR) &monitor_config, 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;


More information about the Spice-commits mailing list