[RFC PATCH spice-server v3 20/20] stream-device: Implement mouse movement

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

 



Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/stream-device.c | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/server/stream-device.c b/server/stream-device.c
index e28111d9..aad111f4 100644
--- a/server/stream-device.c
+++ b/server/stream-device.c
@@ -64,7 +64,7 @@ G_DEFINE_TYPE(StreamDevice, stream_device, RED_TYPE_CHAR_DEVICE)
 typedef void StreamMsgHandler(StreamDevice *dev, SpiceCharDeviceInstance *sin);
 
 static StreamMsgHandler handle_msg_format, handle_msg_data, handle_msg_invalid,
-    handle_msg_cursor_set;
+    handle_msg_cursor_set, handle_msg_cursor_move;
 
 static RedPipeItem *
 stream_device_read_msg_from_dev(RedCharDevice *self, SpiceCharDeviceInstance *sin)
@@ -111,6 +111,13 @@ stream_device_read_msg_from_dev(RedCharDevice *self, SpiceCharDeviceInstance *si
     case STREAM_TYPE_CURSOR_SET:
         handle_msg_cursor_set(dev, sin);
         break;
+    case STREAM_TYPE_CURSOR_MOVE:
+        if (dev->hdr.size != sizeof(StreamMsgCursorMove)) {
+            handle_msg_invalid(dev, sin);
+        } else {
+            handle_msg_cursor_move(dev, sin);
+        }
+        break;
     case STREAM_TYPE_CAPABILITIES:
         /* FIXME */
     default:
@@ -294,6 +301,32 @@ handle_msg_cursor_set(StreamDevice *dev, SpiceCharDeviceInstance *sin)
 }
 
 static void
+handle_msg_cursor_move(StreamDevice *dev, SpiceCharDeviceInstance *sin)
+{
+    StreamMsgCursorMove move;
+    SpiceCharDeviceInterface *sif = spice_char_device_get_interface(sin);
+    int n = sif->read(sin, (uint8_t *) &move, sizeof(move));
+    if (n == 0) {
+        return;
+    }
+    if (n != sizeof(move)) {
+        handle_msg_invalid(dev, sin);
+        return;
+    }
+    move.x = GINT32_FROM_LE(move.x);
+    move.y = GINT32_FROM_LE(move.y);
+
+    RedCursorCmd *cmd = spice_new0(RedCursorCmd, 1);
+    cmd->type = QXL_CURSOR_MOVE;
+    cmd->u.position.x = move.x;
+    cmd->u.position.y = move.y;
+
+    cursor_channel_process_cmd(dev->cursor_channel, cmd);
+
+    dev->hdr_pos = 0;
+}
+
+static void
 stream_device_send_msg_to_client(RedCharDevice *self, RedPipeItem *msg, RedClient *client)
 {
 }
-- 
2.13.5

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]