[Spice-devel] [PATCH 1/4] move cursor_connect to CursorChannel

Frediano Ziglio fziglio at redhat.com
Fri May 13 09:16:31 UTC 2016


This function was handling mainly CursorChannel state

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/cursor-channel.c | 23 +++++++++++++++++++++++
 server/cursor-channel.h |  5 +++++
 server/red-worker.c     | 32 ++++----------------------------
 3 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index 444d89b..c67c88f 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -569,3 +569,26 @@ void cursor_channel_set_mouse_mode(CursorChannel *cursor, uint32_t mode)
 
     cursor->mouse_mode = mode;
 }
+
+void cursor_channel_connect(CursorChannel *cursor, RedClient *client, RedsStream *stream,
+                            int migrate,
+                            uint32_t *common_caps, int num_common_caps,
+                            uint32_t *caps, int num_caps)
+{
+    CursorChannelClient *ccc;
+
+    spice_return_if_fail(cursor != NULL);
+
+    spice_info("add cursor channel client");
+    ccc = cursor_channel_client_new(cursor, client, stream,
+                                    migrate,
+                                    common_caps, num_common_caps,
+                                    caps, num_caps);
+    spice_return_if_fail(ccc != NULL);
+
+    RedChannelClient *rcc = RED_CHANNEL_CLIENT(ccc);
+    red_channel_client_ack_zero_messages_window(rcc);
+    red_channel_client_push_set_ack(rcc);
+
+    cursor_channel_init(cursor, ccc);
+}
diff --git a/server/cursor-channel.h b/server/cursor-channel.h
index 4dad4b6..ecb20a4 100644
--- a/server/cursor-channel.h
+++ b/server/cursor-channel.h
@@ -34,6 +34,11 @@ void                 cursor_channel_reset       (CursorChannel *cursor);
 void                 cursor_channel_init        (CursorChannel *cursor, CursorChannelClient* client);
 void                 cursor_channel_process_cmd (CursorChannel *cursor, RedCursorCmd *cursor_cmd);
 void                 cursor_channel_set_mouse_mode(CursorChannel *cursor, uint32_t mode);
+void                 cursor_channel_connect     (CursorChannel *cursor, RedClient *client, 
+                                                 RedsStream *stream,
+                                                 int migrate,
+                                                 uint32_t *common_caps, int num_common_caps,
+                                                 uint32_t *caps, int num_caps);
 
 CursorChannelClient* cursor_channel_client_new(CursorChannel *cursor,
                                                RedClient *client, RedsStream *stream,
diff --git a/server/red-worker.c b/server/red-worker.c
index 8d8073e..f6d626b 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -544,30 +544,6 @@ static void guest_set_client_capabilities(RedWorker *worker)
     }
 }
 
-static void cursor_connect(RedWorker *worker, RedClient *client, RedsStream *stream,
-                           int migrate,
-                           uint32_t *common_caps, int num_common_caps,
-                           uint32_t *caps, int num_caps)
-{
-    CursorChannel *channel = worker->cursor_channel;
-    CursorChannelClient *ccc;
-
-    spice_return_if_fail(channel != NULL);
-
-    spice_info("add cursor channel client");
-    ccc = cursor_channel_client_new(channel, client, stream,
-                                    migrate,
-                                    common_caps, num_common_caps,
-                                    caps, num_caps);
-    spice_return_if_fail(ccc != NULL);
-
-    RedChannelClient *rcc = RED_CHANNEL_CLIENT(ccc);
-    red_channel_client_ack_zero_messages_window(rcc);
-    red_channel_client_push_set_ack(rcc);
-
-    cursor_channel_init(channel, ccc);
-}
-
 static void handle_dev_update_async(void *opaque, void *payload)
 {
     RedWorker *worker = opaque;
@@ -1000,10 +976,10 @@ static void handle_dev_cursor_connect(void *opaque, void *payload)
     RedWorker *worker = opaque;
 
     spice_info("cursor connect");
-    cursor_connect(worker,
-                   msg->client, msg->stream, msg->migration,
-                   msg->common_caps, msg->num_common_caps,
-                   msg->caps, msg->num_caps);
+    cursor_channel_connect(worker->cursor_channel,
+                           msg->client, msg->stream, msg->migration,
+                           msg->common_caps, msg->num_common_caps,
+                           msg->caps, msg->num_caps);
     free(msg->caps);
     free(msg->common_caps);
 }
-- 
2.7.4



More information about the Spice-devel mailing list