[Spice-devel] [PATCH win-vdagent] Adding ioctl operation to update Vdagent state

Victor Toso lists at victortoso.com
Thu Aug 4 13:44:54 UTC 2016


Hi,

On Thu, Aug 04, 2016 at 06:34:14AM -0700, Dmitry Fleytman wrote:
> Hi Victor,
>
> How do we configure server mouse with VDAgent running?

You mean the host/VM configuration? What I mean by my question is that
we can send a SpiceMsgcMainMouseModeRequest from client to change mouse
mode and I would like to know if that would still be possible with this
patch.

Check:
https://cgit.freedesktop.org/spice/spice-gtk/commit/?id=5f89a4df037f6a1f2

> 
> Thanks,
> Dmitry
> 
> 
> On Thu, Aug 4, 2016 at 6:30 AM, Victor Toso <lists at victortoso.com> wrote:
> 
> > Hi,
> >
> > On Wed, Aug 03, 2016 at 06:45:29PM +0300, Sameeh Jubran wrote:
> > > This patch adds new ioctl operation to Vdagent in order to update
> > > the driver on Vdagent state. This allows the driver to know
> > > when Vdagent is running and when it is off.
> > >
> > > Spice supports two mouse modes: server and client. The server mouse
> > > mode pointer should be enabled when vdagent is off and the client
> > > mouse mode should be enabled  when it is on. The mouse mode
> > > is updated by the driver and thus this patch is needed.
> >
> > Just to be sure. I can still have mouse in server mode when VDAgent is
> > running?
> >
> >   toso
> >
> > >
> > > Signed-off-by: Sameeh Jubran <sameeh at daynix.com>
> > > ---
> > >  vdagent/desktop_layout.cpp        | 21 +++++++++++++++++++++
> > >  vdagent/desktop_layout.h          |  1 +
> > >  vdagent/display_configuration.cpp | 16 ++++++++++++++++
> > >  vdagent/display_configuration.h   |  3 ++-
> > >  4 files changed, 40 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
> > > index 9c3e873..4d183e1 100644
> > > --- a/vdagent/desktop_layout.cpp
> > > +++ b/vdagent/desktop_layout.cpp
> > > @@ -45,6 +45,7 @@ DesktopLayout::DesktopLayout()
> > >
> > >  DesktopLayout::~DesktopLayout()
> > >  {
> > > +    set_vdagent_running_for_displays(false);
> > >      clean_displays();
> > >      delete _display_config;
> > >  }
> > > @@ -121,6 +122,8 @@ void DesktopLayout::set_displays()
> > >      DWORD display_id = 0;
> > >      int dev_sets = 0;
> > >
> > > +    set_vdagent_running_for_displays(true);
> > > +
> > >      lock();
> > >      if (!consistent_displays()) {
> > >          unlock();
> > > @@ -275,6 +278,22 @@ bool DesktopLayout::get_qxl_device_id(WCHAR*
> > device_key, DWORD* device_id)
> > >      return key_found;
> > >  }
> > >
> > > +void DesktopLayout::set_vdagent_running_for_displays(bool running)
> > > +{
> > > +    DISPLAY_DEVICE dev_info;
> > > +    DWORD dev_id = 0;
> > > +    lock();
> > > +    ZeroMemory(&dev_info, sizeof(dev_info));
> > > +    dev_info.cb = sizeof(dev_info);
> > > +    while (EnumDisplayDevices(NULL, dev_id, &dev_info, 0)) {
> > > +        dev_id++;
> > > +        if (!(dev_info.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER)
> > && wcsstr(dev_info.DeviceString, L"QXL")) {
> > > +            _display_config->set_vdagent_running(dev_info.DeviceName,
> > running);
> > > +        }
> > > +    }
> > > +    unlock();
> > > +}
> > > +
> > >  bool DesktopLayout::init_dev_mode(LPCTSTR dev_name, DEVMODE* dev_mode,
> > DisplayMode* mode)
> > >  {
> > >      ZeroMemory(dev_mode, sizeof(DEVMODE));
> > > @@ -298,6 +317,8 @@ bool DesktopLayout::init_dev_mode(LPCTSTR dev_name,
> > DEVMODE* dev_mode, DisplayMo
> > >      // update current DisplayMode (so mouse scaling works properly)
> > >      mode->_width = dev_mode->dmPelsWidth;
> > >      mode->_height = dev_mode->dmPelsHeight;
> > > +
> > > +    set_vdagent_running_for_displays(true);
> > >      return true;
> > >
> > >  }
> > > diff --git a/vdagent/desktop_layout.h b/vdagent/desktop_layout.h
> > > index fd6af76..da5a40b 100644
> > > --- a/vdagent/desktop_layout.h
> > > +++ b/vdagent/desktop_layout.h
> > > @@ -83,6 +83,7 @@ private:
> > >      static bool consistent_displays();
> > >      static bool is_attached(LPCTSTR dev_name);
> > >      static bool get_qxl_device_id(WCHAR* device_key, DWORD* device_id);
> > > +    void set_vdagent_running_for_displays(bool enable_pointer);
> > >  private:
> > >      mutex_t _mutex;
> > >      Displays _displays;
> > > diff --git a/vdagent/display_configuration.cpp b/vdagent/display_
> > configuration.cpp
> > > index 4565b15..7e617b6 100755
> > > --- a/vdagent/display_configuration.cpp
> > > +++ b/vdagent/display_configuration.cpp
> > > @@ -248,6 +248,16 @@ struct WDDMMonitorConfigEscape {
> > >      QXLHead     _head;
> > >  };
> > >
> > > +struct WDDMVDAgentRunningEscape {
> > > +    WDDMVDAgentRunningEscape(bool running)
> > > +    {
> > > +        _ioctl = QXL_ESCAPE_VDAGENT_RUNNING;
> > > +        _vdagent_state.running = running;
> > > +    }
> > > +    int                        _ioctl;
> > > +    QXLEscapeVDAgentRunning    _vdagent_state;
> > > +};
> > > +
> > >  DisplayConfig* DisplayConfig::create_config()
> > >  {
> > >      DisplayConfig* new_interface;
> > > @@ -690,6 +700,12 @@ bool WDDMInterface::escape(LPCTSTR device_name,
> > void* data, UINT size_data)
> > >      return NT_SUCCESS(status);
> > >  }
> > >
> > > +bool WDDMInterface::set_vdagent_running(LPCTSTR device_name, bool
> > running)
> > > +{
> > > +    WDDMVDAgentRunningEscape wddm_escape(running);
> > > +    return escape(device_name, &wddm_escape, sizeof(wddm_escape));
> > > +}
> > > +
> > >  CCD::CCD()
> > >      :_NumPathElements(0)
> > >      ,_NumModeElements(0)
> > > diff --git a/vdagent/display_configuration.h b/vdagent/display_
> > configuration.h
> > > index b3d0198..e8ba2f0 100755
> > > --- a/vdagent/display_configuration.h
> > > +++ b/vdagent/display_configuration.h
> > > @@ -107,7 +107,7 @@ public:
> > >      virtual bool update_dev_mode_position(LPCTSTR dev_name, DEVMODE*
> > dev_mode, LONG x, LONG y) = 0;
> > >      void set_monitors_config(bool flag) { _send_monitors_config = flag;
> > }
> > >      virtual void update_config_path() {};
> > > -
> > > +    virtual bool set_vdagent_running(LPCTSTR device_name, bool running)
> > { return false; };
> > >  protected:
> > >      bool _send_monitors_config;
> > >  };
> > > @@ -162,6 +162,7 @@ private:
> > >
> > >      void close_adapter(D3D_HANDLE handle);
> > >      bool escape(LPCTSTR device_name, void* data, UINT sizeData);
> > > +    bool set_vdagent_running(LPCTSTR device_name, bool running);
> > >
> > >      //GDI Function pointers
> > >      PFND3DKMT_OPENADAPTERFROMHDC _pfnOpen_adapter_hdc;
> > > --
> > > 2.5.5
> > >
> > > _______________________________________________
> > > Spice-devel mailing list
> > > Spice-devel at lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/spice-devel
> > _______________________________________________
> > Spice-devel mailing list
> > Spice-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/spice-devel
> >


More information about the Spice-devel mailing list