devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=8fdb4e0d8deaa8fe0802047d642ca20e8ef90abb

commit 8fdb4e0d8deaa8fe0802047d642ca20e8ef90abb
Author: Chris Michael <cp.mich...@samsung.com>
Date:   Mon Jul 10 14:14:06 2017 -0400

    elput: Fix support for setting keyboard led(s)
    
    Small patch to update keyboard led(s) when caps, numlock, etc are
    pressed. This patch adds some fields to internal (non-API exposed)
    structures inside our private header (of a BETA-API library) and thus
    should still be ok during freeze.
    
    Fixes T5655
    
    @fix
    
    Signed-off-by: Chris Michael <cp.mich...@samsung.com>
---
 src/lib/elput/elput_evdev.c   | 43 +++++++++++++++++++++++++++++++++++++++++++
 src/lib/elput/elput_private.h | 18 +++++++++++++++++-
 2 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/src/lib/elput/elput_evdev.c b/src/lib/elput/elput_evdev.c
index 222c5087a2..b041bb6785 100644
--- a/src/lib/elput/elput_evdev.c
+++ b/src/lib/elput/elput_evdev.c
@@ -38,9 +38,25 @@ _seat_frame_send(Elput_Seat *seat)
 }
 
 static void
+_evdev_leds_update(Elput_Device *edev, Elput_Leds leds)
+{
+   enum libinput_led input_leds = 0;
+
+   if (leds & ELPUT_LED_NUM)
+     input_leds |= LIBINPUT_LED_NUM_LOCK;
+   if (leds & ELPUT_LED_CAPS)
+     input_leds |= LIBINPUT_LED_CAPS_LOCK;
+   if (leds & ELPUT_LED_SCROLL)
+     input_leds |= LIBINPUT_LED_SCROLL_LOCK;
+
+   libinput_device_led_update(edev->device, input_leds);
+}
+
+static void
 _keyboard_modifiers_update(Elput_Keyboard *kbd, Elput_Seat *seat)
 {
    xkb_mod_mask_t mask;
+   Elput_Leds leds = 0;
 
    kbd->mods.depressed =
      xkb_state_serialize_mods(kbd->state, XKB_STATE_DEPRESSED);
@@ -64,6 +80,26 @@ _keyboard_modifiers_update(Elput_Keyboard *kbd, Elput_Seat 
*seat)
      seat->modifiers |= ECORE_EVENT_MODIFIER_WIN;
    if (mask & kbd->info->mods.altgr)
      seat->modifiers |= ECORE_EVENT_MODIFIER_ALTGR;
+
+   if (xkb_state_led_index_is_active(kbd->state, kbd->info->leds.num))
+     leds |= ELPUT_LED_NUM;
+
+   if (xkb_state_led_index_is_active(kbd->state, kbd->info->leds.caps))
+     leds |= ELPUT_LED_CAPS;
+
+   if (xkb_state_led_index_is_active(kbd->state, kbd->info->leds.scroll))
+     leds |= ELPUT_LED_SCROLL;
+
+   if (kbd->leds != leds)
+     {
+        Eina_List *l;
+        Elput_Device *edev;
+
+        EINA_LIST_FOREACH(seat->devices, l, edev)
+          _evdev_leds_update(edev, leds);
+
+        kbd->leds = leds;
+     }
 }
 
 static Elput_Keyboard_Info *
@@ -90,6 +126,13 @@ _keyboard_info_create(struct xkb_keymap *keymap)
    info->mods.altgr =
      1 << xkb_keymap_mod_get_index(info->keymap.map, "ISO_Level3_Shift");
 
+   info->leds.num =
+     xkb_keymap_led_get_index(info->keymap.map, XKB_LED_NAME_NUM);
+   info->leds.caps =
+     xkb_keymap_led_get_index(info->keymap.map, XKB_LED_NAME_CAPS);
+   info->leds.scroll =
+     xkb_keymap_led_get_index(info->keymap.map, XKB_LED_NAME_SCROLL);
+
    return info;
 }
 
diff --git a/src/lib/elput/elput_private.h b/src/lib/elput/elput_private.h
index 54ef2c2ba0..5b38c14ab6 100644
--- a/src/lib/elput/elput_private.h
+++ b/src/lib/elput/elput_private.h
@@ -86,6 +86,13 @@ typedef struct _Elput_Input
    Eina_Bool suspended : 1;
 } Elput_Input;
 
+typedef enum _Elput_Leds
+{
+   ELPUT_LED_NUM = (1 << 0),
+   ELPUT_LED_CAPS = (1 << 1),
+   ELPUT_LED_SCROLL = (1 << 2)
+} Elput_Leds;
+
 typedef struct _Elput_Keyboard_Info
 {
    int refs;
@@ -104,6 +111,13 @@ typedef struct _Elput_Keyboard_Info
         xkb_mod_index_t altgr;
         xkb_mod_index_t super;
      } mods;
+
+   struct
+     {
+        xkb_led_index_t num;
+        xkb_led_index_t caps;
+        xkb_led_index_t scroll;
+     } leds;
 } Elput_Keyboard_Info;
 
 struct _Elput_Keyboard
@@ -132,6 +146,8 @@ struct _Elput_Keyboard
    struct xkb_compose_table *compose_table;
    struct xkb_compose_state *compose_state;
 
+   Elput_Leds leds;
+
    Elput_Seat *seat;
 
    Eina_Bool pending_keymap : 1;
@@ -295,6 +311,6 @@ extern Elput_Interface _logind_interface;
 void _keyboard_keymap_update(Elput_Seat *seat);
 void _keyboard_group_update(Elput_Seat *seat);
 
-
 void _udev_seat_destroy(Elput_Seat *eseat);
+
 #endif

-- 


Reply via email to