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

Sandy Stutsman sstutsma at redhat.com
Mon Jun 29 06:09:37 PDT 2015


Works for me.

----- Original Message -----
> From: "Christophe Fergeau" <cfergeau at redhat.com>
> To: "Sandy Stutsman" <sstutsma at redhat.com>
> Cc: spice-devel at lists.freedesktop.org
> Sent: Monday, June 29, 2015 8:56:18 AM
> Subject: Re: [Spice-devel] [vd_agent PATCH V3] Add monitors_config driver escape.
> 
> On Wed, Jun 24, 2015 at 02:36:21PM -0400, Sandy Stutsman wrote:
> > 
> > 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
> > ---
> > Changes for v2
> >    Removed call to set_display in  wnd_proc WM_DISPLAYCHANGE switch
> >    Replaced driver specific escape structure with existing QXLHead
> > ---
> >  vdagent/desktop_layout.cpp | 32 ++++++++++++++++++++++++++++++--
> >  vdagent/desktop_layout.h   |  2 +-
> >  2 files changed, 31 insertions(+), 3 deletions(-)
> > 
> > diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
> > index f71abd0..0be5077 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 MonitorConfig;
> 
> monitor_config instead? I'd tend to squash that in:
> 
> 
> diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
> index 0be5077..7a34f7f 100644
> --- a/vdagent/desktop_layout.cpp
> +++ b/vdagent/desktop_layout.cpp
> @@ -360,21 +360,21 @@ bool DesktopLayout::init_dev_mode(LPCTSTR dev_name,
> DEVMODE* dev_mode, DisplayMo
> 
>  bool DesktopLayout::update_monitor_config(LPCTSTR dev_name, DisplayMode*
>  mode)
>  {
> -    QXLHead MonitorConfig;
> +    QXLHead monitor_config;
> 
>      if (!mode || !mode->get_attached())
>          return false;
> 
>      HDC hdc = CreateDC(dev_name, NULL, NULL, NULL);
> 
> -    memset(&MonitorConfig, 0, sizeof(MonitorConfig));
> -    MonitorConfig.x = mode->_pos_x;
> -    MonitorConfig.y = mode->_pos_y;
> -    MonitorConfig.width = mode->_width;
> -    MonitorConfig.height = mode->_height;
> +    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) &MonitorConfig, 0, NULL);
> +        sizeof(QXLHead), (LPCSTR) &monitor_config, 0, NULL);
> 
>      if (err < 0){
>          vd_printf("can't update monitor config, may have an older driver");
> 
> 
> 
> > +
> > +    if (!mode || !mode->get_attached())
> > +        return false;
> > +
> > +    HDC hdc = CreateDC(dev_name, NULL, NULL, NULL);
> > +
> > +    memset(&MonitorConfig, 0, sizeof(MonitorConfig));
> > +    MonitorConfig.x = mode->_pos_x;
> > +    MonitorConfig.y = mode->_pos_y;
> > +    MonitorConfig.width = mode->_width;
> > +    MonitorConfig.height = mode->_height;
> > +
> > +    int err = ExtEscape(hdc, QXL_ESCAPE_MONITOR_CONFIG,
> > +        sizeof(QXLHead), (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
> > 
> > _______________________________________________
> > 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