commit e30f18fec10257c47293c9a77bbc1c76af2b8af4
parent 69934915096502f2d5f49739d10c719e0847ab04
Author: Raymond Li <hi@raymond.li>
Date: Wed, 10 Jun 2020 10:27:32 -0400
Merge pull request #167 from andremarcais/fix_key_group
Fix key group
Diffstat:
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/i3lock.c b/i3lock.c
@@ -894,6 +894,8 @@ static void process_xkb_event(xcb_generic_event_t *gevent) {
event->state_notify.baseGroup,
event->state_notify.latchedGroup,
event->state_notify.lockedGroup);
+ layout_text = get_keylayoutname(keylayout_mode, conn);
+ redraw_screen();
break;
}
}
diff --git a/xcb.c b/xcb.c
@@ -537,6 +537,17 @@ static char * get_atom_name(xcb_connection_t* conn, xcb_atom_t atom) {
}
+uint8_t xcb_get_key_group_index(xcb_connection_t *conn) {
+ xcb_xkb_get_state_cookie_t cookie;
+ xcb_xkb_get_state_reply_t* reply = NULL;
+ cookie = xcb_xkb_get_state(conn, XCB_XKB_ID_USE_CORE_KBD);
+ reply = xcb_xkb_get_state_reply(conn, cookie, NULL);
+ uint8_t ans = reply->group;
+ free(reply);
+ return ans;
+}
+
+
char* xcb_get_key_group_names(xcb_connection_t *conn) {
uint8_t xkb_base_event;
uint8_t xkb_base_error;
@@ -585,15 +596,17 @@ char* xcb_get_key_group_names(xcb_connection_t *conn) {
int length;
xcb_atom_t *iter;
+ uint8_t index;
char* answer = NULL;
length = xcb_xkb_get_names_value_list_groups_length(reply, &list);
iter = xcb_xkb_get_names_value_list_groups(&list);
+ index = xcb_get_key_group_index(conn);
for (int i = 0; i < length; i++) {
xcb_atom_t group_name = *iter;
char* name = get_atom_name(conn, group_name);
DEBUG("group_name %d: %s\n", i, name);
- if (i == 0) {
+ if (i == index) {
answer = name;
} else {
free(name);