diff options
author | Daniel Stone <daniel@fooishbar.org> | 2012-05-30 16:31:45 +0100 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-05-31 15:38:50 -0400 |
commit | 8c8164faeb68e4c460a1d45085128ffce8cd5a57 (patch) | |
tree | 0f5f8aa4fd3460002725bf3a124dec056984342a | |
parent | e3f15edc2f7a760c898a3bcafc775f52f33e2d9b (diff) |
Add core LED handling
Similar to how we deal with modifiers, also add LED handling to the core
input code, with a callout into the backends to update them when they
change.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
-rw-r--r-- | src/compositor.c | 22 | ||||
-rw-r--r-- | src/compositor.h | 12 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/compositor.c b/src/compositor.c index b76cd39..eb3d474 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -1733,6 +1733,7 @@ update_modifier_state(struct weston_seat *seat, uint32_t key, uint32_t state) { uint32_t mods_depressed, mods_latched, mods_locked, group; uint32_t mods_lookup; + enum weston_led leds = 0; int ret = 0; /* First update the XKB state object with the keypress. */ @@ -1771,6 +1772,20 @@ update_modifier_state(struct weston_seat *seat, uint32_t key, uint32_t state) if ((mods_lookup & seat->compositor->xkb_info.super_mod)) seat->modifier_state |= MODIFIER_SUPER; + /* Finally, notify the compositor that LEDs have changed. */ + if (xkb_state_led_index_is_active(seat->xkb_state.state, + seat->compositor->xkb_info.num_led)) + leds |= LED_NUM_LOCK; + if (xkb_state_led_index_is_active(seat->xkb_state.state, + seat->compositor->xkb_info.caps_led)) + leds |= LED_CAPS_LOCK; + if (xkb_state_led_index_is_active(seat->xkb_state.state, + seat->compositor->xkb_info.scroll_led)) + leds |= LED_SCROLL_LOCK; + if (leds != seat->xkb_state.leds && seat->led_update) + seat->led_update(seat, seat->xkb_state.leds); + seat->xkb_state.leds = leds; + return ret; } @@ -2237,6 +2252,13 @@ static int weston_compositor_xkb_init(struct weston_compositor *ec, ec->xkb_info.super_mod = xkb_map_mod_get_index(ec->xkb_info.keymap, XKB_MOD_NAME_LOGO); + ec->xkb_info.num_led = xkb_map_led_get_index(ec->xkb_info.keymap, + XKB_LED_NAME_NUM); + ec->xkb_info.caps_led = xkb_map_led_get_index(ec->xkb_info.keymap, + XKB_LED_NAME_CAPS); + ec->xkb_info.scroll_led = xkb_map_led_get_index(ec->xkb_info.keymap, + XKB_LED_NAME_SCROLL); + return 0; } diff --git a/src/compositor.h b/src/compositor.h index 4c037c9..08dcd77 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -54,6 +54,12 @@ enum weston_keyboard_modifier { MODIFIER_SUPER = (1 << 2), }; +enum weston_led { + LED_NUM_LOCK = (1 << 0), + LED_CAPS_LOCK = (1 << 1), + LED_SCROLL_LOCK = (1 << 2), +}; + struct weston_mode { uint32_t flags; int32_t width, height; @@ -180,12 +186,15 @@ struct weston_seat { struct wl_listener new_drag_icon_listener; + void (*led_update)(struct weston_seat *ws, enum weston_led leds); + struct { struct xkb_state *state; uint32_t mods_depressed; uint32_t mods_latched; uint32_t mods_locked; uint32_t group; + enum weston_led leds; } xkb_state; }; @@ -308,6 +317,9 @@ struct weston_compositor { xkb_mod_index_t ctrl_mod; xkb_mod_index_t alt_mod; xkb_mod_index_t super_mod; + xkb_led_index_t num_led; + xkb_led_index_t caps_led; + xkb_led_index_t scroll_led; } xkb_info; }; |