Merge pull request #167 from andremarcais/fix_key_group

Fix key group
This commit is contained in:
Raymond Li 2020-06-10 10:27:32 -04:00 committed by GitHub
commit e30f18fec1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

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

15
xcb.c
View File

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