uterm_input: remove supporting code for updating LED state
Before we transitioned to xkbcommon, we had some code that, upon returning from a VT-switch, looked at the evdev led state and updated the keyboard modifier state accordingly. So if we returned and NumLock was on, we adjusted ourselves to that. That was pretty cute. xkbcommon however doesn't support updating the state by LEDs like that. Normally, the state of the LEDs is derived from the modifiers; going the other way is tricky, error-prone and not used much. What we should be doing is updating the LEDs according to *our* state. This commit does the part of removing the unused dead code. Signed-off-by: Ran Benita <ran234@gmail.com> Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
1 parent
2843c80c5b
commit
874bbbe17a
3 files changed
+4
-35
No files matched your search
+1
-10
@@ -105,7 +105,6 @@ static void input_data_dev(struct ev_fd *fd, int mask, void *data)
|
||||
static int input_wake_up_dev(struct uterm_input_dev *dev)
|
||||
{
|
||||
int ret;
|
||||
unsigned long ledbits[NLONGS(LED_CNT)] = { 0 };
|
||||
|
||||
if (dev->rfd >= 0)
|
||||
return 0;
|
||||
@@ -117,16 +116,8 @@ static int input_wake_up_dev(struct uterm_input_dev *dev)
|
||||
}
|
||||
|
||||
if (dev->features & FEATURE_HAS_KEYS) {
|
||||
if (dev->features & FEATURE_HAS_LEDS) {
|
||||
ret = ioctl(dev->rfd, EVIOCGLED(sizeof(ledbits)),
|
||||
&ledbits);
|
||||
if (ret == -1)
|
||||
log_warn("cannot read LED state of %s (%d): %m",
|
||||
dev->node, errno);
|
||||
}
|
||||
|
||||
/* rediscover the keyboard state if sth changed during sleep */
|
||||
uxkb_dev_reset(dev, ledbits);
|
||||
uxkb_dev_reset(dev);
|
||||
|
||||
ret = ev_eloop_new_fd(dev->input->eloop, &dev->fd,
|
||||
dev->rfd, EV_READABLE,
|
||||
|
||||
+1
-1
@@ -85,6 +85,6 @@ void uxkb_dev_destroy(struct uterm_input_dev *dev);
|
||||
int uxkb_dev_process(struct uterm_input_dev *dev,
|
||||
uint16_t key_state,
|
||||
uint16_t code);
|
||||
void uxkb_dev_reset(struct uterm_input_dev *dev, const unsigned long *ledbits);
|
||||
void uxkb_dev_reset(struct uterm_input_dev *dev);
|
||||
|
||||
#endif /* UTERM_INPUT_H */
|
||||
+2
-24
@@ -304,21 +304,11 @@ int uxkb_dev_process(struct uterm_input_dev *dev,
|
||||
|
||||
/*
|
||||
* Call this when we regain control of the keyboard after losing it.
|
||||
* We don't reset the locked group, this should survive a VT switch, etc. The
|
||||
* locked modifiers are reset according to the keyboard LEDs.
|
||||
* We don't reset the locked group, this should survive a VT switch, etc.
|
||||
*/
|
||||
void uxkb_dev_reset(struct uterm_input_dev *dev, const unsigned long *ledbits)
|
||||
void uxkb_dev_reset(struct uterm_input_dev *dev)
|
||||
{
|
||||
unsigned int i;
|
||||
struct xkb_state *state;
|
||||
static const struct {
|
||||
int led;
|
||||
const char *name;
|
||||
} led_names[] = {
|
||||
{ LED_NUML, XKB_LED_NAME_NUM },
|
||||
{ LED_CAPSL, XKB_LED_NAME_CAPS },
|
||||
{ LED_SCROLLL, XKB_LED_NAME_SCROLL },
|
||||
};
|
||||
|
||||
/* TODO: Urghs, while the input device was closed we might have missed
|
||||
* some events that affect internal state. As xkbcommon does not provide
|
||||
@@ -334,16 +324,4 @@ void uxkb_dev_reset(struct uterm_input_dev *dev, const unsigned long *ledbits)
|
||||
}
|
||||
xkb_state_unref(dev->state);
|
||||
dev->state = state;
|
||||
|
||||
for (i = 0; i < sizeof(led_names) / sizeof(*led_names); i++) {
|
||||
if (!input_bit_is_set(ledbits, led_names[i].led))
|
||||
continue;
|
||||
|
||||
/*
|
||||
* TODO: Add support in xkbcommon for setting the led state,
|
||||
* and updating the modifier state accordingly. E.g., something
|
||||
* like this:
|
||||
* xkb_state_led_name_set_active(state, led_names[i].led);
|
||||
*/
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user