From 874bbbe17a7f93c2d66b7ae48cb2ba2658bb8d05 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Fri, 26 Oct 2012 17:08:01 +0200 Subject: [PATCH] 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 Signed-off-by: David Herrmann --- src/uterm_input.c | 11 +---------- src/uterm_input.h | 2 +- src/uterm_input_uxkb.c | 26 ++------------------------ 3 files changed, 4 insertions(+), 35 deletions(-) diff --git a/src/uterm_input.c b/src/uterm_input.c index 23d034e..bd487a7 100644 --- a/src/uterm_input.c +++ b/src/uterm_input.c @@ -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, diff --git a/src/uterm_input.h b/src/uterm_input.h index e9c1916..dc824f7 100644 --- a/src/uterm_input.h +++ b/src/uterm_input.h @@ -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 */ diff --git a/src/uterm_input_uxkb.c b/src/uterm_input_uxkb.c index dc7489e..9c93b5d 100644 --- a/src/uterm_input_uxkb.c +++ b/src/uterm_input_uxkb.c @@ -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); - */ - } }