[Spice-devel] [PATCH 23/39] MouseInterface: redesign
Gerd Hoffmann
kraxel at redhat.com
Tue May 18 08:43:00 PDT 2010
Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>
---
server/reds.c | 30 ++++++++++++++++++++----------
server/reds.h | 4 ++++
server/vd_interface.h | 25 ++++++++++++++++---------
3 files changed, 40 insertions(+), 19 deletions(-)
diff --git a/server/reds.c b/server/reds.c
index 1eee21d..8d6e14d 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -57,7 +57,7 @@
SpiceCoreInterface *core = NULL;
static MigrationInterface *mig = NULL;
static SpiceKbdInstance *keyboard = NULL;
-static MouseInterface *mouse = NULL;
+static SpiceMouseInstance *mouse = NULL;
static TabletInterface *tablet = NULL;
static VDIPortInterface *vdagent = NULL;
@@ -2163,8 +2163,11 @@ static void inputs_handle_input(void *opaque, SpiceDataHeader *header)
}
}
if (mouse && reds->mouse_mode == SPICE_MOUSE_MODE_SERVER) {
- mouse->moution(mouse, mouse_motion->dx, mouse_motion->dy, 0,
- RED_MOUSE_STATE_TO_LOCAL(mouse_motion->buttons_state));
+ SpiceMouseInterface *sif;
+ sif = SPICE_CONTAINEROF(mouse->base.sif, SpiceMouseInterface, base);
+ sif->motion(mouse,
+ mouse_motion->dx, mouse_motion->dy, 0,
+ RED_MOUSE_STATE_TO_LOCAL(mouse_motion->buttons_state));
}
break;
}
@@ -2219,7 +2222,10 @@ static void inputs_handle_input(void *opaque, SpiceDataHeader *header)
tablet->wheel(tablet, dz, RED_MOUSE_STATE_TO_LOCAL(mouse_press->buttons_state));
}
} else if (mouse) {
- mouse->moution(mouse, 0, 0, dz, RED_MOUSE_STATE_TO_LOCAL(mouse_press->buttons_state));
+ SpiceMouseInterface *sif;
+ sif = SPICE_CONTAINEROF(mouse->base.sif, SpiceMouseInterface, base);
+ sif->motion(mouse, 0, 0, dz,
+ RED_MOUSE_STATE_TO_LOCAL(mouse_press->buttons_state));
}
break;
}
@@ -2234,7 +2240,10 @@ static void inputs_handle_input(void *opaque, SpiceDataHeader *header)
tablet->buttons(tablet, RED_MOUSE_STATE_TO_LOCAL(mouse_release->buttons_state));
}
} else if (mouse) {
- mouse->buttons(mouse, RED_MOUSE_STATE_TO_LOCAL(mouse_release->buttons_state));
+ SpiceMouseInterface *sif;
+ sif = SPICE_CONTAINEROF(mouse->base.sif, SpiceMouseInterface, base);
+ sif->buttons(mouse,
+ RED_MOUSE_STATE_TO_LOCAL(mouse_release->buttons_state));
}
break;
}
@@ -4041,18 +4050,19 @@ __visible__ int spice_server_add_interface(SpiceServer *s,
keyboard = SPICE_CONTAINEROF(sin, SpiceKbdInstance, base);
keyboard->st = spice_new0(SpiceKbdState, 1);
- } else if (strcmp(interface->type, VD_INTERFACE_MOUSE) == 0) {
- red_printf("VD_INTERFACE_MOUSE");
+ } else if (strcmp(interface->type, SPICE_INTERFACE_MOUSE) == 0) {
+ red_printf("SPICE_INTERFACE_MOUSE");
if (mouse) {
red_printf("already have mouse");
return -1;
}
- if (interface->major_version != VD_INTERFACE_MOUSE_MAJOR ||
- interface->minor_version < VD_INTERFACE_MOUSE_MINOR) {
+ if (interface->major_version != SPICE_INTERFACE_MOUSE_MAJOR ||
+ interface->minor_version < SPICE_INTERFACE_MOUSE_MINOR) {
red_printf("unsuported mouse interface");
return -1;
}
- mouse = (MouseInterface *)interface;
+ mouse = SPICE_CONTAINEROF(sin, SpiceMouseInstance, base);
+ mouse->st = spice_new0(SpiceMouseState, 1);
} else if (strcmp(interface->type, VD_INTERFACE_MIGRATION) == 0) {
red_printf("VD_INTERFACE_MIGRATION");
diff --git a/server/reds.h b/server/reds.h
index 2ba7398..68359ae 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -62,6 +62,10 @@ struct SpiceKbdState {
int dummy;
};
+struct SpiceMouseState {
+ int dummy;
+};
+
void reds_desable_mm_timer();
void reds_enable_mm_timer();
void reds_update_mm_timer(uint32_t mm_time);
diff --git a/server/vd_interface.h b/server/vd_interface.h
index e2e5d26..1567b12 100644
--- a/server/vd_interface.h
+++ b/server/vd_interface.h
@@ -219,17 +219,24 @@ struct SpiceKbdInstance {
SpiceKbdState *st;
};
-#define VD_INTERFACE_MOUSE "mouse"
-#define VD_INTERFACE_MOUSE_MAJOR 1
-#define VD_INTERFACE_MOUSE_MINOR 1
-typedef struct MouseInterface MouseInterface;
-
-struct MouseInterface {
+#define SPICE_INTERFACE_MOUSE "mouse"
+#define SPICE_INTERFACE_MOUSE_MAJOR 1
+#define SPICE_INTERFACE_MOUSE_MINOR 1
+typedef struct SpiceMouseInterface SpiceMouseInterface;
+typedef struct SpiceMouseInstance SpiceMouseInstance;
+typedef struct SpiceMouseState SpiceMouseState;
+
+struct SpiceMouseInterface {
SpiceBaseInterface base;
- void (*moution)(MouseInterface* mouse, int dx, int dy, int dz,
- uint32_t buttons_state);
- void (*buttons)(MouseInterface* mouse, uint32_t buttons_state);
+ void (*motion)(SpiceMouseInstance *sin, int dx, int dy, int dz,
+ uint32_t buttons_state);
+ void (*buttons)(SpiceMouseInstance *sin, uint32_t buttons_state);
+};
+
+struct SpiceMouseInstance {
+ SpiceBaseInstance base;
+ SpiceMouseState *st;
};
#define VD_INTERFACE_TABLET "tablet"
--
1.6.6.1
More information about the Spice-devel
mailing list