Skip to contentSkip to conversation

vnc: Make ledstate comparison before modifiers updated

PATCH Applied Lei Li 3 participants 3 messages May 15, 2013 – May 16, 2013

lore
Share & tools
lore

Lei Li

author
#0 lore raw

PATCH 1/1 vnc: Make ledstate comparison before modifiers updated

The ledstate should be compared before modifiers updated, otherwise the ledstate would be the same as current_led_state.

---
 ui/vnc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
ui/vnc.c +2 -1
index 89108de..dfc7459 100644
@@ -1601,6 +1601,7 @@ static void kbd_leds(void *opaque, int ledstate)
 {
     VncState *vs = opaque;
     int caps, num, scr;
+    bool has_changed = (ledstate != current_led_state(vs));
 
     caps = ledstate & QEMU_CAPS_LOCK_LED ? 1 : 0;
     num  = ledstate & QEMU_NUM_LOCK_LED  ? 1 : 0;
@@ -1617,7 +1618,7 @@ static void kbd_leds(void *opaque, int ledstate)
     }
 
     /* Sending the current led state message to the client */
-    if (ledstate != current_led_state(vs)) {
+    if (has_changed) {
         vnc_led_state_change(vs);
     }
 }
Signature · 1 line
1.7.7.6
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Lei Li

The ledstate should be compared before modifiers updated, otherwise the ledstate would be the same as current_led_state.

---
 ui/vnc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
ui/vnc.c +1 -0
index 89108de..dfc7459 100644
@@ -1601,6 +1601,7 @@ static void kbd_leds(void *opaque, int ledstate)
 {
     VncState *vs = opaque;
     int caps, num, scr;
+    bool has_changed = (ledstate != current_led_state(vs));
 
     caps = ledstate & QEMU_CAPS_LOCK_LED ? 1 : 0;
     num  = ledstate & QEMU_NUM_LOCK_LED  ? 1 : 0;

ui/vnc.c static void kbd_leds(void *opaque, int ledstate) · line 1624

Quoted 8 lines
ui/vnc.c +1 -1
@@ -1617,7 +1618,7 @@ static void kbd_leds(void *opaque, int ledstate)
     }
 
     /* Sending the current led state message to the client */
-    if (ledstate != current_led_state(vs)) {
+    if (has_changed) {
         vnc_led_state_change(vs);
     }
 }

Looks good to me.