qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/4] console: a few cleanups


From: Anthony Liguori
Subject: [Qemu-devel] [PATCH 1/4] console: a few cleanups
Date: Mon, 16 Jan 2012 16:36:34 -0600

We don't do anything with the list of registered DisplayState so get rid of it.
That's one less list to deal with down the road.

Also pass DisplayState to the callbacks in DisplayState so users can avoid
global state references.

Signed-off-by: Anthony Liguori <address@hidden>
---
 console.c          |    9 +++------
 console.h          |    6 ++----
 hw/vmware_vga.c    |    4 ++--
 ui/sdl.c           |    4 ++--
 ui/spice-display.c |    4 ++--
 ui/vnc.c           |    4 ++--
 6 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/console.c b/console.c
index 135394f..1085b07 100644
--- a/console.c
+++ b/console.c
@@ -1363,12 +1363,9 @@ static void dumb_display_init(void)
 
 void register_displaystate(DisplayState *ds)
 {
-    DisplayState **s;
-    s = &display_state;
-    while (*s != NULL)
-        s = &(*s)->next;
-    ds->next = NULL;
-    *s = ds;
+    if (display_state == NULL) {
+        display_state = ds;
+    }
 }
 
 DisplayState *get_displaystate(void)
diff --git a/console.h b/console.h
index 9466886..e78b359 100644
--- a/console.h
+++ b/console.h
@@ -179,10 +179,8 @@ struct DisplayState {
     struct DisplayAllocator* allocator;
     struct DisplayChangeListener* listeners;
 
-    void (*mouse_set)(int x, int y, int on);
-    void (*cursor_define)(QEMUCursor *cursor);
-
-    struct DisplayState *next;
+    void (*mouse_set)(DisplayState *ds, int x, int y, int on);
+    void (*cursor_define)(DisplayState *ds, QEMUCursor *cursor);
 };
 
 void register_displaystate(DisplayState *ds);
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index b1885c3..c379d72 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -480,7 +480,7 @@ static inline void vmsvga_cursor_define(struct 
vmsvga_state_s *s,
     }
 
     if (s->vga.ds->cursor_define)
-        s->vga.ds->cursor_define(qc);
+        s->vga.ds->cursor_define(s->vga.ds, qc);
     cursor_put(qc);
 }
 #endif
@@ -905,7 +905,7 @@ static void vmsvga_value_write(void *opaque, uint32_t 
address, uint32_t value)
         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);
+            s->vga.ds->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 8cafc44..0040ad2 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;
diff --git a/ui/spice-display.c b/ui/spice-display.c
index 6c302a3..3d1d5b0 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -328,12 +328,12 @@ void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd)
         ssd->notify++;
     }
     if (ssd->cursor) {
-        ssd->ds->cursor_define(ssd->cursor);
+        ssd->ds->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);
+        ssd->ds->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 1869a7a..3f3d8c3 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -779,7 +779,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 ??? */
 }
@@ -806,7 +806,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;
-- 
1.7.4.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]