[Spice-devel] [PATCH 05/11] Add InputsChannelClientPrivate struct

Jonathon Jongsma jjongsma at redhat.com
Tue Aug 9 15:32:59 UTC 2016


Encapsulate private data and prepare for port to GObject.
---
 server/inputs-channel-client.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/server/inputs-channel-client.c b/server/inputs-channel-client.c
index 547ca43..8a4b4dd 100644
--- a/server/inputs-channel-client.c
+++ b/server/inputs-channel-client.c
@@ -23,8 +23,16 @@
 #include "migration-protocol.h"
 #include "red-channel-client-private.h"
 
-struct InputsChannelClient {
+typedef struct InputsChannelClientPrivate InputsChannelClientPrivate;
+struct InputsChannelClient
+{
     RedChannelClient base;
+
+    InputsChannelClientPrivate *priv;
+};
+
+struct InputsChannelClientPrivate
+{
     uint16_t motion_count;
 };
 
@@ -45,8 +53,10 @@ RedChannelClient* inputs_channel_client_create(RedChannel *channel,
                                                         num_common_caps,
                                                         common_caps, num_caps,
                                                         caps);
-    if (icc)
-        icc->motion_count = 0;
+    if (icc) {
+        icc->priv = g_new0(InputsChannelClientPrivate, 1);
+        icc->priv->motion_count = 0;
+    }
     return &icc->base;
 }
 
@@ -60,16 +70,16 @@ void inputs_channel_client_send_migrate_data(RedChannelClient *rcc,
 
     spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_INPUTS_MAGIC);
     spice_marshaller_add_uint32(m, SPICE_MIGRATE_DATA_INPUTS_VERSION);
-    spice_marshaller_add_uint16(m, icc->motion_count);
+    spice_marshaller_add_uint16(m, icc->priv->motion_count);
 }
 
 void inputs_channel_client_handle_migrate_data(InputsChannelClient *icc,
                                                uint16_t motion_count)
 {
-    icc->motion_count = motion_count;
+    icc->priv->motion_count = motion_count;
 
-    for (; icc->motion_count >= SPICE_INPUT_MOTION_ACK_BUNCH;
-           icc->motion_count -= SPICE_INPUT_MOTION_ACK_BUNCH) {
+    for (; icc->priv->motion_count >= SPICE_INPUT_MOTION_ACK_BUNCH;
+           icc->priv->motion_count -= SPICE_INPUT_MOTION_ACK_BUNCH) {
         red_channel_client_pipe_add_type(&icc->base, RED_PIPE_ITEM_MOUSE_MOTION_ACK);
     }
 }
@@ -78,9 +88,9 @@ void inputs_channel_client_on_mouse_motion(InputsChannelClient *icc)
 {
     InputsChannel *inputs_channel = (InputsChannel *)icc->base.channel;
 
-    if (++icc->motion_count % SPICE_INPUT_MOTION_ACK_BUNCH == 0 &&
+    if (++icc->priv->motion_count % SPICE_INPUT_MOTION_ACK_BUNCH == 0 &&
         !inputs_channel_is_src_during_migrate(inputs_channel)) {
         red_channel_client_pipe_add_type(&icc->base, RED_PIPE_ITEM_MOUSE_MOTION_ACK);
-        icc->motion_count = 0;
+        icc->priv->motion_count = 0;
     }
 }
-- 
2.7.4



More information about the Spice-devel mailing list