[PATCH weston 07/31] Add core LED handling
Daniel Stone
daniel at fooishbar.org
Wed May 30 08:31:45 PDT 2012
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 at fooishbar.org>
---
src/compositor.c | 22 ++++++++++++++++++++++
src/compositor.h | 12 ++++++++++++
2 files changed, 34 insertions(+)
diff --git a/src/compositor.c b/src/compositor.c
index e310ceb..d00a25c 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1735,6 +1735,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. */
@@ -1773,6 +1774,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;
}
@@ -2239,6 +2254,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 57a49de..12ee49d 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;
@@ -175,12 +181,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;
};
@@ -303,6 +312,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;
};
--
1.7.10
More information about the wayland-devel
mailing list