[Spice-devel] [vdagent-linux v5 3/3] Move mouse-specific handling out of virtio_port_read_complete
Victor Toso
victortoso at redhat.com
Fri Jan 20 15:56:50 UTC 2017
From: Michal Suchanek <msuchanek at suse.de>
Move some mouse-specific code from the start of
virtio_port_read_complete to a separate helper
as is the case with other message types.
Signed-off-by: Michal Suchanek <msuchanek at suse.de>
---
src/vdagentd/vdagentd.c | 43 ++++++++++++++++++++++++-------------------
1 file changed, 24 insertions(+), 19 deletions(-)
diff --git a/src/vdagentd/vdagentd.c b/src/vdagentd/vdagentd.c
index 7ab8b2e..0e78084 100644
--- a/src/vdagentd/vdagentd.c
+++ b/src/vdagentd/vdagentd.c
@@ -166,6 +166,29 @@ static void do_client_disconnect(void)
}
}
+void do_client_mouse(struct vdagentd_uinput **uinputp, VDAgentMouseState *mouse)
+{
+ vdagentd_uinput_do_mouse(uinputp, mouse);
+ if (!*uinputp) {
+ /* Try to re-open the tablet */
+ struct agent_data *agent_data =
+ udscs_get_user_data(active_session_conn);
+ if (agent_data)
+ *uinputp = vdagentd_uinput_create(uinput_device,
+ agent_data->width,
+ agent_data->height,
+ agent_data->screen_info,
+ agent_data->screen_count,
+ debug > 1,
+ uinput_fake);
+ if (!*uinputp) {
+ syslog(LOG_CRIT, "Fatal uinput error");
+ retval = 1;
+ quit = 1;
+ }
+ }
+}
+
static void do_client_monitors(struct vdagent_virtio_port *vport, int port_nr,
VDAgentMessage *message_header, VDAgentMonitorsConfig *new_monitors)
{
@@ -434,25 +457,7 @@ static int virtio_port_read_complete(
switch (message_header->type) {
case VD_AGENT_MOUSE_STATE:
virtio_msg_uint32_from_le(data, message_header->size, 0);
- vdagentd_uinput_do_mouse(&uinput, (VDAgentMouseState *)data);
- if (!uinput) {
- /* Try to re-open the tablet */
- struct agent_data *agent_data =
- udscs_get_user_data(active_session_conn);
- if (agent_data)
- uinput = vdagentd_uinput_create(uinput_device,
- agent_data->width,
- agent_data->height,
- agent_data->screen_info,
- agent_data->screen_count,
- debug > 1,
- uinput_fake);
- if (!uinput) {
- syslog(LOG_CRIT, "Fatal uinput error");
- retval = 1;
- quit = 1;
- }
- }
+ do_client_mouse(&uinput, (VDAgentMouseState *)data);
break;
case VD_AGENT_MONITORS_CONFIG:
virtio_msg_uint32_from_le(data, message_header->size, 0);
--
2.9.3
More information about the Spice-devel
mailing list