[PATCH] server: input_channel: fix input on BE machines

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

 



The following patch fixes the input between SPICE
server on BE machine and LE client

Signed-off-by: Denis Kirjanov <kda@xxxxxxxxxxx>
---
 server/inputs_channel.c |   23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/server/inputs_channel.c b/server/inputs_channel.c
index b0ba1d6..6f19492 100644
--- a/server/inputs_channel.c
+++ b/server/inputs_channel.c
@@ -28,6 +28,7 @@
 #include <spice/vd_agent.h>
 #include <spice/protocol.h>
 #include <stdbool.h>
+#include <glib.h>
 
 #include "common/marshaller.h"
 #include "common/messages.h"
@@ -326,21 +327,24 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
     InputsChannel *inputs_channel = (InputsChannel *)rcc->channel;
     InputsChannelClient *icc = (InputsChannelClient *)rcc;
     uint32_t i;
+    uint32_t key_code;
 
     spice_assert(g_inputs_channel == inputs_channel);
     switch (type) {
     case SPICE_MSGC_INPUTS_KEY_DOWN: {
         SpiceMsgcKeyDown *key_down = message;
-        if (key_down->code == CAPS_LOCK_SCAN_CODE ||
-            key_down->code == NUM_LOCK_SCAN_CODE ||
-            key_down->code == SCROLL_LOCK_SCAN_CODE) {
+               key_code = GUINT32_FROM_LE(key_down->code);
+        if (key_code == CAPS_LOCK_SCAN_CODE ||
+            key_code == NUM_LOCK_SCAN_CODE ||
+            key_code == SCROLL_LOCK_SCAN_CODE) {
             activate_modifiers_watch();
         }
     }
     case SPICE_MSGC_INPUTS_KEY_UP: {
         SpiceMsgcKeyUp *key_up = message;
+               key_code = GUINT32_FROM_LE(key_up->code);
         for (i = 0; i < 4; i++) {
-            uint8_t code = (key_up->code >> (i * 8)) & 0xff;
+            uint8_t code = (key_code >> (i * 8)) & 0xff;
             if (code == 0) {
                 break;
             }
@@ -357,6 +361,9 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
     }
     case SPICE_MSGC_INPUTS_MOUSE_MOTION: {
         SpiceMsgcMouseMotion *mouse_motion = message;
+               mouse_motion->dx = GUINT32_FROM_LE(mouse_motion->dx);
+               mouse_motion->dy = GUINT32_FROM_LE(mouse_motion->dy);
+               mouse_motion->buttons_state = GUINT32_FROM_LE(mouse_motion->buttons_state);
 
         if (++icc->motion_count % SPICE_INPUT_MOTION_ACK_BUNCH == 0 &&
             !g_inputs_channel->src_during_migrate) {
@@ -374,6 +381,10 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
     }
     case SPICE_MSGC_INPUTS_MOUSE_POSITION: {
         SpiceMsgcMousePosition *pos = message;
+               pos->x = GUINT32_FROM_LE(pos->x);
+               pos->y = GUINT32_FROM_LE(pos->y);
+               pos->buttons_state = GUINT32_FROM_LE(pos->buttons_state);
+               pos->display_id = GUINT32_FROM_LE(pos->display_id);
 
         if (++icc->motion_count % SPICE_INPUT_MOTION_ACK_BUNCH == 0 &&
             !g_inputs_channel->src_during_migrate) {
@@ -400,6 +411,8 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
     }
     case SPICE_MSGC_INPUTS_MOUSE_PRESS: {
         SpiceMsgcMousePress *mouse_press = message;
+               mouse_press->buttons_state = GINT16_FROM_LE(mouse_press->buttons_state);
+
         int dz = 0;
         if (mouse_press->button == SPICE_MOUSE_BUTTON_UP) {
             dz = -1;
@@ -428,6 +441,8 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
     }
     case SPICE_MSGC_INPUTS_MOUSE_RELEASE: {
         SpiceMsgcMouseRelease *mouse_release = message;
+               mouse_release->buttons_state = GUINT32_FROM_LE(mouse_release->buttons_state);
+
         if (reds_get_mouse_mode() == SPICE_MOUSE_MODE_CLIENT) {
             if (reds_get_agent_mouse() && reds_has_vdagent()) {
                 inputs_channel->mouse_state.buttons =
-- 
1.7.10.4

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://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]