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>
dev
Daniel Stone 13 years ago committed by Kristian Høgsberg
parent e3f15edc2f
commit 8c8164faeb
  1. 22
      src/compositor.c
  2. 12
      src/compositor.h

@ -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;
}

@ -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;
};

Loading…
Cancel
Save