diff options
author | Chris Michael <cp.michael@samsung.com> | 2017-07-10 14:14:06 -0400 |
---|---|---|
committer | Chris Michael <cp.michael@samsung.com> | 2017-07-10 14:14:06 -0400 |
commit | 8fdb4e0d8deaa8fe0802047d642ca20e8ef90abb (patch) | |
tree | 73dc6df98d7c4a47b6250f990d030b118ab76ce2 /src/lib/elput/elput_evdev.c | |
parent | 4052923ed087087e1b9b8f8145d2c6362ff55dec (diff) |
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.michael@samsung.com>
Diffstat (limited to '')
-rw-r--r-- | src/lib/elput/elput_evdev.c | 43 |
1 files changed, 43 insertions, 0 deletions
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) | |||
38 | } | 38 | } |
39 | 39 | ||
40 | static void | 40 | static void |
41 | _evdev_leds_update(Elput_Device *edev, Elput_Leds leds) | ||
42 | { | ||
43 | enum libinput_led input_leds = 0; | ||
44 | |||
45 | if (leds & ELPUT_LED_NUM) | ||
46 | input_leds |= LIBINPUT_LED_NUM_LOCK; | ||
47 | if (leds & ELPUT_LED_CAPS) | ||
48 | input_leds |= LIBINPUT_LED_CAPS_LOCK; | ||
49 | if (leds & ELPUT_LED_SCROLL) | ||
50 | input_leds |= LIBINPUT_LED_SCROLL_LOCK; | ||
51 | |||
52 | libinput_device_led_update(edev->device, input_leds); | ||
53 | } | ||
54 | |||
55 | static void | ||
41 | _keyboard_modifiers_update(Elput_Keyboard *kbd, Elput_Seat *seat) | 56 | _keyboard_modifiers_update(Elput_Keyboard *kbd, Elput_Seat *seat) |
42 | { | 57 | { |
43 | xkb_mod_mask_t mask; | 58 | xkb_mod_mask_t mask; |
59 | Elput_Leds leds = 0; | ||
44 | 60 | ||
45 | kbd->mods.depressed = | 61 | kbd->mods.depressed = |
46 | xkb_state_serialize_mods(kbd->state, XKB_STATE_DEPRESSED); | 62 | xkb_state_serialize_mods(kbd->state, XKB_STATE_DEPRESSED); |
@@ -64,6 +80,26 @@ _keyboard_modifiers_update(Elput_Keyboard *kbd, Elput_Seat *seat) | |||
64 | seat->modifiers |= ECORE_EVENT_MODIFIER_WIN; | 80 | seat->modifiers |= ECORE_EVENT_MODIFIER_WIN; |
65 | if (mask & kbd->info->mods.altgr) | 81 | if (mask & kbd->info->mods.altgr) |
66 | seat->modifiers |= ECORE_EVENT_MODIFIER_ALTGR; | 82 | seat->modifiers |= ECORE_EVENT_MODIFIER_ALTGR; |
83 | |||
84 | if (xkb_state_led_index_is_active(kbd->state, kbd->info->leds.num)) | ||
85 | leds |= ELPUT_LED_NUM; | ||
86 | |||
87 | if (xkb_state_led_index_is_active(kbd->state, kbd->info->leds.caps)) | ||
88 | leds |= ELPUT_LED_CAPS; | ||
89 | |||
90 | if (xkb_state_led_index_is_active(kbd->state, kbd->info->leds.scroll)) | ||
91 | leds |= ELPUT_LED_SCROLL; | ||
92 | |||
93 | if (kbd->leds != leds) | ||
94 | { | ||
95 | Eina_List *l; | ||
96 | Elput_Device *edev; | ||
97 | |||
98 | EINA_LIST_FOREACH(seat->devices, l, edev) | ||
99 | _evdev_leds_update(edev, leds); | ||
100 | |||
101 | kbd->leds = leds; | ||
102 | } | ||
67 | } | 103 | } |
68 | 104 | ||
69 | static Elput_Keyboard_Info * | 105 | static Elput_Keyboard_Info * |
@@ -90,6 +126,13 @@ _keyboard_info_create(struct xkb_keymap *keymap) | |||
90 | info->mods.altgr = | 126 | info->mods.altgr = |
91 | 1 << xkb_keymap_mod_get_index(info->keymap.map, "ISO_Level3_Shift"); | 127 | 1 << xkb_keymap_mod_get_index(info->keymap.map, "ISO_Level3_Shift"); |
92 | 128 | ||
129 | info->leds.num = | ||
130 | xkb_keymap_led_get_index(info->keymap.map, XKB_LED_NAME_NUM); | ||
131 | info->leds.caps = | ||
132 | xkb_keymap_led_get_index(info->keymap.map, XKB_LED_NAME_CAPS); | ||
133 | info->leds.scroll = | ||
134 | xkb_keymap_led_get_index(info->keymap.map, XKB_LED_NAME_SCROLL); | ||
135 | |||
93 | return info; | 136 | return info; |
94 | } | 137 | } |
95 | 138 | ||