Patchwork [3/9] move set_mouse + cursor_define callbacks

login
register
mail settings
Submitter Gerd Hoffmann
Date Sept. 18, 2012, 7:17 a.m.
Message ID <1347952634-12286-4-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/184639/
State New
Headers show

Comments

Gerd Hoffmann - Sept. 18, 2012, 7:17 a.m.
When adding DisplayChangeListeners the set_mouse and cursor_define
callbacks have been left in DisplayState for some reason.  Fix it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 console.c          |    2 +-
 console.h          |   39 +++++++++++++++++++++++++++++++++++----
 hw/jazz_led.c      |    2 +-
 hw/qxl-render.c    |    2 +-
 hw/vga.c           |   10 +++++-----
 hw/vmware_vga.c    |   11 ++++++-----
 ui/sdl.c           |    8 ++++----
 ui/spice-display.c |    4 ++--
 ui/vnc.c           |    8 ++++----
 9 files changed, 59 insertions(+), 27 deletions(-)
Stefano Stabellini - Sept. 18, 2012, 2:10 p.m.
On Tue, 18 Sep 2012, Gerd Hoffmann wrote:
> When adding DisplayChangeListeners the set_mouse and cursor_define
> callbacks have been left in DisplayState for some reason.  Fix it.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

This patch is good.
The one thing I don't like is dpy_cursor_define_supported, because it
enforces the idea that we cannot register/deregister
DisplayChangeListeners at run time. Theoretically a new
DisplayChangeListener that support cursor_define could show up at any
time.
Is dpy_cursor_define_supported really necessary?


>  console.c          |    2 +-
>  console.h          |   39 +++++++++++++++++++++++++++++++++++----
>  hw/jazz_led.c      |    2 +-
>  hw/qxl-render.c    |    2 +-
>  hw/vga.c           |   10 +++++-----
>  hw/vmware_vga.c    |   11 ++++++-----
>  ui/sdl.c           |    8 ++++----
>  ui/spice-display.c |    4 ++--
>  ui/vnc.c           |    8 ++++----
>  9 files changed, 59 insertions(+), 27 deletions(-)
> 
> diff --git a/console.c b/console.c
> index a8bcc42..cc0479b 100644
> --- a/console.c
> +++ b/console.c
> @@ -1239,7 +1239,7 @@ static void text_console_update(void *opaque, console_ch_t *chardata)
>          s->text_y[1] = 0;
>      }
>      if (s->cursor_invalidate) {
> -        dpy_cursor(s->ds, s->x, s->y);
> +        dpy_text_cursor(s->ds, s->x, s->y);
>          s->cursor_invalidate = 0;
>      }
>  }
> diff --git a/console.h b/console.h
> index 48fef22..bef2d2d 100644
> --- a/console.h
> +++ b/console.h
> @@ -164,6 +164,9 @@ struct DisplayChangeListener {
>                       int w, int h, uint32_t c);
>      void (*dpy_text_cursor)(struct DisplayState *s, int x, int y);
>  
> +    void (*dpy_mouse_set)(struct DisplayState *s, int x, int y, int on);
> +    void (*dpy_cursor_define)(struct DisplayState *s, QEMUCursor *cursor);
> +
>      QLIST_ENTRY(DisplayChangeListener) next;
>  };
>  
> @@ -181,9 +184,6 @@ struct DisplayState {
>      struct DisplayAllocator* allocator;
>      QLIST_HEAD(, DisplayChangeListener) listeners;
>  
> -    void (*mouse_set)(int x, int y, int on);
> -    void (*cursor_define)(QEMUCursor *cursor);
> -
>      struct DisplayState *next;
>  };
>  
> @@ -304,7 +304,7 @@ static inline void dpy_fill(struct DisplayState *s, int x, int y,
>      }
>  }
>  
> -static inline void dpy_cursor(struct DisplayState *s, int x, int y)
> +static inline void dpy_text_cursor(struct DisplayState *s, int x, int y)
>  {
>      struct DisplayChangeListener *dcl;
>      QLIST_FOREACH(dcl, &s->listeners, next) {
> @@ -314,6 +314,37 @@ static inline void dpy_cursor(struct DisplayState *s, int x, int y)
>      }
>  }
>  
> +static inline void dpy_mouse_set(struct DisplayState *s, int x, int y, int on)
> +{
> +    struct DisplayChangeListener *dcl;
> +    QLIST_FOREACH(dcl, &s->listeners, next) {
> +        if (dcl->dpy_mouse_set) {
> +            dcl->dpy_mouse_set(s, x, y, on);
> +        }
> +    }
> +}
> +
> +static inline void dpy_cursor_define(struct DisplayState *s, QEMUCursor *cursor)
> +{
> +    struct DisplayChangeListener *dcl;
> +    QLIST_FOREACH(dcl, &s->listeners, next) {
> +        if (dcl->dpy_cursor_define) {
> +            dcl->dpy_cursor_define(s, cursor);
> +        }
> +    }
> +}
> +
> +static inline bool dpy_cursor_define_supported(struct DisplayState *s)
> +{
> +    struct DisplayChangeListener *dcl;
> +    QLIST_FOREACH(dcl, &s->listeners, next) {
> +        if (dcl->dpy_cursor_define) {
> +            return true;
> +        }
> +    }
> +    return false;
> +}
> +
>  static inline int ds_get_linesize(DisplayState *ds)
>  {
>      return ds->surface->linesize;
> diff --git a/hw/jazz_led.c b/hw/jazz_led.c
> index 6486523..c4d54e2 100644
> --- a/hw/jazz_led.c
> +++ b/hw/jazz_led.c
> @@ -210,7 +210,7 @@ static void jazz_led_text_update(void *opaque, console_ch_t *chardata)
>      LedState *s = opaque;
>      char buf[2];
>  
> -    dpy_cursor(s->ds, -1, -1);
> +    dpy_text_cursor(s->ds, -1, -1);
>      qemu_console_resize(s->ds, 2, 1);
>  
>      /* TODO: draw the segments */
> diff --git a/hw/qxl-render.c b/hw/qxl-render.c
> index e2e3fe2..085a090 100644
> --- a/hw/qxl-render.c
> +++ b/hw/qxl-render.c
> @@ -238,7 +238,7 @@ int qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext)
>          return 1;
>      }
>  
> -    if (!qxl->ssd.ds->mouse_set || !qxl->ssd.ds->cursor_define) {
> +    if (!dpy_cursor_define_supported(qxl->ssd.ds)) {
>          return 0;
>      }
>  
> diff --git a/hw/vga.c b/hw/vga.c
> index afaef0d..ec4f0c5 100644
> --- a/hw/vga.c
> +++ b/hw/vga.c
> @@ -2081,11 +2081,11 @@ static void vga_update_text(void *opaque, console_ch_t *chardata)
>              s->cr[VGA_CRTC_CURSOR_END] != s->cursor_end || full_update) {
>              cursor_visible = !(s->cr[VGA_CRTC_CURSOR_START] & 0x20);
>              if (cursor_visible && cursor_offset < size && cursor_offset >= 0)
> -                dpy_cursor(s->ds,
> -                           TEXTMODE_X(cursor_offset),
> -                           TEXTMODE_Y(cursor_offset));
> +                dpy_text_cursor(s->ds,
> +                                TEXTMODE_X(cursor_offset),
> +                                TEXTMODE_Y(cursor_offset));
>              else
> -                dpy_cursor(s->ds, -1, -1);
> +                dpy_text_cursor(s->ds, -1, -1);
>              s->cursor_offset = cursor_offset;
>              s->cursor_start = s->cr[VGA_CRTC_CURSOR_START];
>              s->cursor_end = s->cr[VGA_CRTC_CURSOR_END];
> @@ -2146,7 +2146,7 @@ static void vga_update_text(void *opaque, console_ch_t *chardata)
>      /* Display a message */
>      s->last_width = 60;
>      s->last_height = height = 3;
> -    dpy_cursor(s->ds, -1, -1);
> +    dpy_text_cursor(s->ds, -1, -1);
>      s->ds->surface->width = s->last_width;
>      s->ds->surface->height = height;
>      dpy_resize(s->ds);
> diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
> index e815a04..e105b5a 100644
> --- a/hw/vmware_vga.c
> +++ b/hw/vmware_vga.c
> @@ -479,8 +479,7 @@ static inline void vmsvga_cursor_define(struct vmsvga_state_s *s,
>          qc = cursor_builtin_left_ptr();
>      }
>  
> -    if (s->vga.ds->cursor_define)
> -        s->vga.ds->cursor_define(qc);
> +    dpy_cursor_define(s->vga.ds, qc);
>      cursor_put(qc);
>  }
>  #endif
> @@ -755,9 +754,10 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address)
>          caps |= SVGA_CAP_RECT_FILL;
>  #endif
>  #ifdef HW_MOUSE_ACCEL
> -        if (s->vga.ds->mouse_set)
> +        if (dpy_cursor_define_supported(s->vga.ds)) {
>              caps |= SVGA_CAP_CURSOR | SVGA_CAP_CURSOR_BYPASS_2 |
>                      SVGA_CAP_CURSOR_BYPASS;
> +        }
>  #endif
>          return caps;
>  
> @@ -904,8 +904,9 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
>          s->cursor.on |= (value == SVGA_CURSOR_ON_SHOW);
>          s->cursor.on &= (value != SVGA_CURSOR_ON_HIDE);
>  #ifdef HW_MOUSE_ACCEL
> -        if (s->vga.ds->mouse_set && value <= SVGA_CURSOR_ON_SHOW)
> -            s->vga.ds->mouse_set(s->cursor.x, s->cursor.y, s->cursor.on);
> +        if (value <= SVGA_CURSOR_ON_SHOW) {
> +            dpy_mouse_set(s->vga.ds, s->cursor.x, s->cursor.y, s->cursor.on);
> +        }
>  #endif
>          break;
>  
> diff --git a/ui/sdl.c b/ui/sdl.c
> index f6f711c..f8ead93 100644
> --- a/ui/sdl.c
> +++ b/ui/sdl.c
> @@ -905,7 +905,7 @@ static void sdl_fill(DisplayState *ds, int x, int y, int w, int h, uint32_t c)
>      SDL_FillRect(real_screen, &dst, c);
>  }
>  
> -static void sdl_mouse_warp(int x, int y, int on)
> +static void sdl_mouse_warp(DisplayState *ds, int x, int y, int on)
>  {
>      if (on) {
>          if (!guest_cursor)
> @@ -921,7 +921,7 @@ static void sdl_mouse_warp(int x, int y, int on)
>      guest_x = x, guest_y = y;
>  }
>  
> -static void sdl_mouse_define(QEMUCursor *c)
> +static void sdl_mouse_define(DisplayState *ds, QEMUCursor *c)
>  {
>      uint8_t *image, *mask;
>      int bpl;
> @@ -1025,8 +1025,8 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
>      dcl->dpy_refresh = sdl_refresh;
>      dcl->dpy_setdata = sdl_setdata;
>      dcl->dpy_fill = sdl_fill;
> -    ds->mouse_set = sdl_mouse_warp;
> -    ds->cursor_define = sdl_mouse_define;
> +    dcl->dpy_mouse_set = sdl_mouse_warp;
> +    dcl->dpy_cursor_define = sdl_mouse_define;
>      register_displaychangelistener(ds, dcl);
>  
>      da = g_malloc0(sizeof(DisplayAllocator));
> diff --git a/ui/spice-display.c b/ui/spice-display.c
> index 50fbefb..5180428 100644
> --- a/ui/spice-display.c
> +++ b/ui/spice-display.c
> @@ -441,12 +441,12 @@ void qemu_spice_display_resize(SimpleSpiceDisplay *ssd)
>  void qemu_spice_cursor_refresh_unlocked(SimpleSpiceDisplay *ssd)
>  {
>      if (ssd->cursor) {
> -        ssd->ds->cursor_define(ssd->cursor);
> +        dpy_cursor_define(ssd->ds, ssd->cursor);
>          cursor_put(ssd->cursor);
>          ssd->cursor = NULL;
>      }
>      if (ssd->mouse_x != -1 && ssd->mouse_y != -1) {
> -        ssd->ds->mouse_set(ssd->mouse_x, ssd->mouse_y, 1);
> +        dpy_mouse_set(ssd->ds, ssd->mouse_x, ssd->mouse_y, 1);
>          ssd->mouse_x = -1;
>          ssd->mouse_y = -1;
>      }
> diff --git a/ui/vnc.c b/ui/vnc.c
> index 385e345..f8f058d 100644
> --- a/ui/vnc.c
> +++ b/ui/vnc.c
> @@ -798,7 +798,7 @@ static void vnc_dpy_copy(DisplayState *ds, int src_x, int src_y, int dst_x, int
>      }
>  }
>  
> -static void vnc_mouse_set(int x, int y, int visible)
> +static void vnc_mouse_set(DisplayState *ds, int x, int y, int visible)
>  {
>      /* can we ask the client(s) to move the pointer ??? */
>  }
> @@ -825,7 +825,7 @@ static int vnc_cursor_define(VncState *vs)
>      return -1;
>  }
>  
> -static void vnc_dpy_cursor_define(QEMUCursor *c)
> +static void vnc_dpy_cursor_define(DisplayState *ds, QEMUCursor *c)
>  {
>      VncDisplay *vd = vnc_display;
>      VncState *vs;
> @@ -2751,9 +2751,9 @@ void vnc_display_init(DisplayState *ds)
>      dcl->dpy_update = vnc_dpy_update;
>      dcl->dpy_resize = vnc_dpy_resize;
>      dcl->dpy_setdata = vnc_dpy_setdata;
> +    dcl->dpy_mouse_set = vnc_mouse_set;
> +    dcl->dpy_cursor_define = vnc_dpy_cursor_define;
>      register_displaychangelistener(ds, dcl);
> -    ds->mouse_set = vnc_mouse_set;
> -    ds->cursor_define = vnc_dpy_cursor_define;
>  }
>  
>  
> -- 
> 1.7.1
> 
>
Gerd Hoffmann - Sept. 18, 2012, 4:31 p.m.
On 09/18/12 16:10, Stefano Stabellini wrote:
> On Tue, 18 Sep 2012, Gerd Hoffmann wrote:
>> When adding DisplayChangeListeners the set_mouse and cursor_define
>> callbacks have been left in DisplayState for some reason.  Fix it.
>>
>> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> 
> This patch is good.
> The one thing I don't like is dpy_cursor_define_supported, because it
> enforces the idea that we cannot register/deregister
> DisplayChangeListeners at run time. Theoretically a new
> DisplayChangeListener that support cursor_define could show up at any
> time.

Depends on how it is used.

qxl is fine, it uses dpy_cursor_define_supported only to skip some work
in case nobody cares anyway.

vmware_vga uses it to signal the capability to the guest, which
obviously doesn't fly with displaysurfaces coming & going ...

cheers,
  Gerd
Stefano Stabellini - Sept. 18, 2012, 4:44 p.m.
On Tue, 18 Sep 2012, Gerd Hoffmann wrote:
> On 09/18/12 16:10, Stefano Stabellini wrote:
> > On Tue, 18 Sep 2012, Gerd Hoffmann wrote:
> >> When adding DisplayChangeListeners the set_mouse and cursor_define
> >> callbacks have been left in DisplayState for some reason.  Fix it.
> >>
> >> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > 
> > This patch is good.
> > The one thing I don't like is dpy_cursor_define_supported, because it
> > enforces the idea that we cannot register/deregister
> > DisplayChangeListeners at run time. Theoretically a new
> > DisplayChangeListener that support cursor_define could show up at any
> > time.
> 
> Depends on how it is used.
> 
> qxl is fine, it uses dpy_cursor_define_supported only to skip some work
> in case nobody cares anyway.
> 
> vmware_vga uses it to signal the capability to the guest, which
> obviously doesn't fly with displaysurfaces coming & going ...

yeah.. that is what I am talking about. Maybe adding a comment on top
the "offending code" in vmware_vga could suffice for now.

Patch

diff --git a/console.c b/console.c
index a8bcc42..cc0479b 100644
--- a/console.c
+++ b/console.c
@@ -1239,7 +1239,7 @@  static void text_console_update(void *opaque, console_ch_t *chardata)
         s->text_y[1] = 0;
     }
     if (s->cursor_invalidate) {
-        dpy_cursor(s->ds, s->x, s->y);
+        dpy_text_cursor(s->ds, s->x, s->y);
         s->cursor_invalidate = 0;
     }
 }
diff --git a/console.h b/console.h
index 48fef22..bef2d2d 100644
--- a/console.h
+++ b/console.h
@@ -164,6 +164,9 @@  struct DisplayChangeListener {
                      int w, int h, uint32_t c);
     void (*dpy_text_cursor)(struct DisplayState *s, int x, int y);
 
+    void (*dpy_mouse_set)(struct DisplayState *s, int x, int y, int on);
+    void (*dpy_cursor_define)(struct DisplayState *s, QEMUCursor *cursor);
+
     QLIST_ENTRY(DisplayChangeListener) next;
 };
 
@@ -181,9 +184,6 @@  struct DisplayState {
     struct DisplayAllocator* allocator;
     QLIST_HEAD(, DisplayChangeListener) listeners;
 
-    void (*mouse_set)(int x, int y, int on);
-    void (*cursor_define)(QEMUCursor *cursor);
-
     struct DisplayState *next;
 };
 
@@ -304,7 +304,7 @@  static inline void dpy_fill(struct DisplayState *s, int x, int y,
     }
 }
 
-static inline void dpy_cursor(struct DisplayState *s, int x, int y)
+static inline void dpy_text_cursor(struct DisplayState *s, int x, int y)
 {
     struct DisplayChangeListener *dcl;
     QLIST_FOREACH(dcl, &s->listeners, next) {
@@ -314,6 +314,37 @@  static inline void dpy_cursor(struct DisplayState *s, int x, int y)
     }
 }
 
+static inline void dpy_mouse_set(struct DisplayState *s, int x, int y, int on)
+{
+    struct DisplayChangeListener *dcl;
+    QLIST_FOREACH(dcl, &s->listeners, next) {
+        if (dcl->dpy_mouse_set) {
+            dcl->dpy_mouse_set(s, x, y, on);
+        }
+    }
+}
+
+static inline void dpy_cursor_define(struct DisplayState *s, QEMUCursor *cursor)
+{
+    struct DisplayChangeListener *dcl;
+    QLIST_FOREACH(dcl, &s->listeners, next) {
+        if (dcl->dpy_cursor_define) {
+            dcl->dpy_cursor_define(s, cursor);
+        }
+    }
+}
+
+static inline bool dpy_cursor_define_supported(struct DisplayState *s)
+{
+    struct DisplayChangeListener *dcl;
+    QLIST_FOREACH(dcl, &s->listeners, next) {
+        if (dcl->dpy_cursor_define) {
+            return true;
+        }
+    }
+    return false;
+}
+
 static inline int ds_get_linesize(DisplayState *ds)
 {
     return ds->surface->linesize;
diff --git a/hw/jazz_led.c b/hw/jazz_led.c
index 6486523..c4d54e2 100644
--- a/hw/jazz_led.c
+++ b/hw/jazz_led.c
@@ -210,7 +210,7 @@  static void jazz_led_text_update(void *opaque, console_ch_t *chardata)
     LedState *s = opaque;
     char buf[2];
 
-    dpy_cursor(s->ds, -1, -1);
+    dpy_text_cursor(s->ds, -1, -1);
     qemu_console_resize(s->ds, 2, 1);
 
     /* TODO: draw the segments */
diff --git a/hw/qxl-render.c b/hw/qxl-render.c
index e2e3fe2..085a090 100644
--- a/hw/qxl-render.c
+++ b/hw/qxl-render.c
@@ -238,7 +238,7 @@  int qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext)
         return 1;
     }
 
-    if (!qxl->ssd.ds->mouse_set || !qxl->ssd.ds->cursor_define) {
+    if (!dpy_cursor_define_supported(qxl->ssd.ds)) {
         return 0;
     }
 
diff --git a/hw/vga.c b/hw/vga.c
index afaef0d..ec4f0c5 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -2081,11 +2081,11 @@  static void vga_update_text(void *opaque, console_ch_t *chardata)
             s->cr[VGA_CRTC_CURSOR_END] != s->cursor_end || full_update) {
             cursor_visible = !(s->cr[VGA_CRTC_CURSOR_START] & 0x20);
             if (cursor_visible && cursor_offset < size && cursor_offset >= 0)
-                dpy_cursor(s->ds,
-                           TEXTMODE_X(cursor_offset),
-                           TEXTMODE_Y(cursor_offset));
+                dpy_text_cursor(s->ds,
+                                TEXTMODE_X(cursor_offset),
+                                TEXTMODE_Y(cursor_offset));
             else
-                dpy_cursor(s->ds, -1, -1);
+                dpy_text_cursor(s->ds, -1, -1);
             s->cursor_offset = cursor_offset;
             s->cursor_start = s->cr[VGA_CRTC_CURSOR_START];
             s->cursor_end = s->cr[VGA_CRTC_CURSOR_END];
@@ -2146,7 +2146,7 @@  static void vga_update_text(void *opaque, console_ch_t *chardata)
     /* Display a message */
     s->last_width = 60;
     s->last_height = height = 3;
-    dpy_cursor(s->ds, -1, -1);
+    dpy_text_cursor(s->ds, -1, -1);
     s->ds->surface->width = s->last_width;
     s->ds->surface->height = height;
     dpy_resize(s->ds);
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index e815a04..e105b5a 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -479,8 +479,7 @@  static inline void vmsvga_cursor_define(struct vmsvga_state_s *s,
         qc = cursor_builtin_left_ptr();
     }
 
-    if (s->vga.ds->cursor_define)
-        s->vga.ds->cursor_define(qc);
+    dpy_cursor_define(s->vga.ds, qc);
     cursor_put(qc);
 }
 #endif
@@ -755,9 +754,10 @@  static uint32_t vmsvga_value_read(void *opaque, uint32_t address)
         caps |= SVGA_CAP_RECT_FILL;
 #endif
 #ifdef HW_MOUSE_ACCEL
-        if (s->vga.ds->mouse_set)
+        if (dpy_cursor_define_supported(s->vga.ds)) {
             caps |= SVGA_CAP_CURSOR | SVGA_CAP_CURSOR_BYPASS_2 |
                     SVGA_CAP_CURSOR_BYPASS;
+        }
 #endif
         return caps;
 
@@ -904,8 +904,9 @@  static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
         s->cursor.on |= (value == SVGA_CURSOR_ON_SHOW);
         s->cursor.on &= (value != SVGA_CURSOR_ON_HIDE);
 #ifdef HW_MOUSE_ACCEL
-        if (s->vga.ds->mouse_set && value <= SVGA_CURSOR_ON_SHOW)
-            s->vga.ds->mouse_set(s->cursor.x, s->cursor.y, s->cursor.on);
+        if (value <= SVGA_CURSOR_ON_SHOW) {
+            dpy_mouse_set(s->vga.ds, s->cursor.x, s->cursor.y, s->cursor.on);
+        }
 #endif
         break;
 
diff --git a/ui/sdl.c b/ui/sdl.c
index f6f711c..f8ead93 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -905,7 +905,7 @@  static void sdl_fill(DisplayState *ds, int x, int y, int w, int h, uint32_t c)
     SDL_FillRect(real_screen, &dst, c);
 }
 
-static void sdl_mouse_warp(int x, int y, int on)
+static void sdl_mouse_warp(DisplayState *ds, int x, int y, int on)
 {
     if (on) {
         if (!guest_cursor)
@@ -921,7 +921,7 @@  static void sdl_mouse_warp(int x, int y, int on)
     guest_x = x, guest_y = y;
 }
 
-static void sdl_mouse_define(QEMUCursor *c)
+static void sdl_mouse_define(DisplayState *ds, QEMUCursor *c)
 {
     uint8_t *image, *mask;
     int bpl;
@@ -1025,8 +1025,8 @@  void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
     dcl->dpy_refresh = sdl_refresh;
     dcl->dpy_setdata = sdl_setdata;
     dcl->dpy_fill = sdl_fill;
-    ds->mouse_set = sdl_mouse_warp;
-    ds->cursor_define = sdl_mouse_define;
+    dcl->dpy_mouse_set = sdl_mouse_warp;
+    dcl->dpy_cursor_define = sdl_mouse_define;
     register_displaychangelistener(ds, dcl);
 
     da = g_malloc0(sizeof(DisplayAllocator));
diff --git a/ui/spice-display.c b/ui/spice-display.c
index 50fbefb..5180428 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -441,12 +441,12 @@  void qemu_spice_display_resize(SimpleSpiceDisplay *ssd)
 void qemu_spice_cursor_refresh_unlocked(SimpleSpiceDisplay *ssd)
 {
     if (ssd->cursor) {
-        ssd->ds->cursor_define(ssd->cursor);
+        dpy_cursor_define(ssd->ds, ssd->cursor);
         cursor_put(ssd->cursor);
         ssd->cursor = NULL;
     }
     if (ssd->mouse_x != -1 && ssd->mouse_y != -1) {
-        ssd->ds->mouse_set(ssd->mouse_x, ssd->mouse_y, 1);
+        dpy_mouse_set(ssd->ds, ssd->mouse_x, ssd->mouse_y, 1);
         ssd->mouse_x = -1;
         ssd->mouse_y = -1;
     }
diff --git a/ui/vnc.c b/ui/vnc.c
index 385e345..f8f058d 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -798,7 +798,7 @@  static void vnc_dpy_copy(DisplayState *ds, int src_x, int src_y, int dst_x, int
     }
 }
 
-static void vnc_mouse_set(int x, int y, int visible)
+static void vnc_mouse_set(DisplayState *ds, int x, int y, int visible)
 {
     /* can we ask the client(s) to move the pointer ??? */
 }
@@ -825,7 +825,7 @@  static int vnc_cursor_define(VncState *vs)
     return -1;
 }
 
-static void vnc_dpy_cursor_define(QEMUCursor *c)
+static void vnc_dpy_cursor_define(DisplayState *ds, QEMUCursor *c)
 {
     VncDisplay *vd = vnc_display;
     VncState *vs;
@@ -2751,9 +2751,9 @@  void vnc_display_init(DisplayState *ds)
     dcl->dpy_update = vnc_dpy_update;
     dcl->dpy_resize = vnc_dpy_resize;
     dcl->dpy_setdata = vnc_dpy_setdata;
+    dcl->dpy_mouse_set = vnc_mouse_set;
+    dcl->dpy_cursor_define = vnc_dpy_cursor_define;
     register_displaychangelistener(ds, dcl);
-    ds->mouse_set = vnc_mouse_set;
-    ds->cursor_define = vnc_dpy_cursor_define;
 }