]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
ply-input-device: Ensure that the LED state is updated on the keyboard of which the...
authorn3rdopolis <bluescreen_avenger@verizon.net>
Mon, 2 Jan 2023 16:57:21 +0000 (11:57 -0500)
committerRay Strode <rstrode@redhat.com>
Mon, 2 Jan 2023 17:20:44 +0000 (12:20 -0500)
When a lock modifier is pressed, plymouth goes through some gymnastics
to ensure the LEDs on all attached keyboards are appropriately updated.

Unfortunately, an optimization in the code used to avoid redundant
updates of keyboards that already have the correct state is actually
preventing the initiating keyboard from getting its LEDs turned on.

This is because the initiating keyboard gets its state updated at
key press time before the LED handling code runs, thus making it
seem like that run is redundant.

This commit introduces a new state variable `leds_state_invalid`
on the input device to mark this situation and updates the optimization
check to also check the new variable.

Some contributions by Ray Strode.

src/libply-splash-core/ply-input-device.c

index be473fc55ea838d0c4e1b2e6bb8e2c64dfc02ef7..fc92de561ead70535bbb10af11351e252abbe513 100644 (file)
@@ -61,6 +61,8 @@ struct _ply_input_device
         struct xkb_compose_state *compose_state;
 
         struct libevdev          *dev;
+
+        uint32_t                  leds_state_invalid : 1;
 };
 
 static bool
@@ -204,8 +206,10 @@ on_input (ply_input_device_t *input_device)
 
                 updated_state = xkb_state_update_key (input_device->keyboard_state, keycode, xkb_key_direction);
 
-                if ((updated_state & XKB_STATE_LEDS) != 0)
+                if ((updated_state & XKB_STATE_LEDS) != 0) {
+                        input_device->leds_state_invalid = true;
                         ply_trigger_pull (input_device->leds_changed_trigger, input_device);
+                }
 
                 /* If the key is repeating, or is being pressed down */
                 if (key_state == PLY_KEY_HELD || key_state == PLY_KEY_DOWN)
@@ -384,7 +388,8 @@ ply_input_device_set_state (ply_input_device_t       *input_device,
         if (mods_depressed == xkb_state->mods_depressed &&
             mods_latched == xkb_state->mods_latched &&
             mods_locked == xkb_state->mods_locked &&
-            group == xkb_state->group)
+            group == xkb_state->group &&
+            !input_device->leds_state_invalid)
                 return;
 
         mods_depressed = xkb_state->mods_depressed;
@@ -414,6 +419,7 @@ ply_input_device_set_state (ply_input_device_t       *input_device,
         ev[i].code = SYN_REPORT;
 
         ply_write (input_device->fd, ev, sizeof(ev));
+        input_device->leds_state_invalid = false;
 }
 
 ply_xkb_keyboard_state_t