@samitouri / QOSamiQemu / commits / 9bc23833be

ui/spice: switch LED handling to Notifier-based input API

Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Marc-André Lureau committed Jun 9, 2026 at 01:19 UTC 9bc23833be2f42fab1b724ba9589fd246313d253
1 file changed +10 -6
ui/spice-input.c
+10 -6
@@ -33,6 +33,7 @@ typedef struct QemuSpiceKbd {
33 int ledstate;
34 bool emul0;
35 size_t pauseseq;
36 + Notifier led_notifier;
37 } QemuSpiceKbd;
38
39 static void kbd_push_key(SpiceKbdInstance *sin, uint8_t frag);
@@ -86,18 +87,20 @@ static uint8_t kbd_get_leds(SpiceKbdInstance *sin)
87 return kbd->ledstate;
88 }
89
89 -static void kbd_leds(void *opaque, int ledstate)
90 +static void kbd_leds(Notifier *notifier, void *data)
91 {
91 - QemuSpiceKbd *kbd = opaque;
92 + QemuSpiceKbd *kbd = container_of(notifier, QemuSpiceKbd, led_notifier);
93 + /* spice has no associated console support */
94 + uint32_t leds_mask = qemu_input_get_leds_mask(NULL);
95
96 kbd->ledstate = 0;
94 - if (ledstate & QEMU_SCROLL_LOCK_LED) {
97 + if (leds_mask & QEMU_SCROLL_LOCK_LED) {
98 kbd->ledstate |= SPICE_KEYBOARD_MODIFIER_FLAGS_SCROLL_LOCK;
99 }
97 - if (ledstate & QEMU_NUM_LOCK_LED) {
100 + if (leds_mask & QEMU_NUM_LOCK_LED) {
101 kbd->ledstate |= SPICE_KEYBOARD_MODIFIER_FLAGS_NUM_LOCK;
102 }
100 - if (ledstate & QEMU_CAPS_LOCK_LED) {
103 + if (leds_mask & QEMU_CAPS_LOCK_LED) {
104 kbd->ledstate |= SPICE_KEYBOARD_MODIFIER_FLAGS_CAPS_LOCK;
105 }
106 spice_server_kbd_leds(&kbd->sin, kbd->ledstate);
@@ -247,7 +250,8 @@ void qemu_spice_input_init(void)
250 kbd = g_malloc0(sizeof(*kbd));
251 kbd->sin.base.sif = &kbd_interface.base;
252 qemu_spice.add_interface(&kbd->sin.base);
250 - qemu_add_led_event_handler(kbd_leds, kbd);
253 + kbd->led_notifier.notify = kbd_leds;
254 + qemu_input_led_notifier_add(&kbd->led_notifier);
255
256 pointer = g_malloc0(sizeof(*pointer));
257 pointer->mouse.base.sif = &mouse_interface.base;