Less reloading of keymap, fixes from psychon comments

Response to psychon comments in PR#227 -
https://github.com/awesomeWM/awesome/pull/227

With this commit, we don't reload keymap, when we are not
notified about its change.
This commit is contained in:
Peter Junos 2015-05-21 21:21:34 +02:00
parent 9be4a0368b
commit e2562227ab
4 changed files with 22 additions and 12 deletions

View File

@ -20,8 +20,6 @@
*/
#include <unistd.h>
#include <stdio.h>
#include <stdint.h>
#include <xkbcommon/xkbcommon.h>
#include <xkbcommon/xkbcommon-x11.h>

View File

@ -26,6 +26,7 @@
/* XStringToKeysym() and XKeysymToString */
#include <X11/Xlib.h>
#include <xkbcommon/xkbcommon.h>
static void
luaA_keystore(lua_State *L, int ud, const char *str, ssize_t len)

23
xkb.c
View File

@ -172,7 +172,8 @@ xkb_free_keymap(void)
}
/** Rereads the state of keyboard from X.
* This call should be used after changing keyboard layouts or using dead keys
* This call should be used after receiving NewKeyboardNotify or MapNotify,
* as written in http://xkbcommon.org/doc/current/group__x11.html
*/
static void
xkb_reload_keymap(void)
@ -189,9 +190,6 @@ event_handle_xkb_notify(xcb_generic_event_t* event)
{
lua_State *L = globalconf_get_lua_State();
/* something has changed, reload keymap in case someone pressed dead key */
xkb_reload_keymap();
/* The pad0 field of xcb_generic_event_t contains the event sub-type,
* unfortunately xkb doesn't provide a usable struct for getting this in a
* nicer way*/
@ -200,11 +198,18 @@ event_handle_xkb_notify(xcb_generic_event_t* event)
case XCB_XKB_NEW_KEYBOARD_NOTIFY:
{
xcb_xkb_new_keyboard_notify_event_t *new_keyboard_event = (void*)event;
xkb_reload_keymap();
if (new_keyboard_event->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
{
signal_object_emit(L, &global_signals, "xkb::map_changed", 0);
}
break;
}
case XCB_XKB_MAP_NOTIFY:
{
xkb_reload_keymap();
break;
}
case XCB_XKB_NAMES_NOTIFY:
@ -216,6 +221,14 @@ event_handle_xkb_notify(xcb_generic_event_t* event)
{
xcb_xkb_state_notify_event_t *state_notify_event = (void*)event;
xkb_state_update_mask(globalconf.xkb_state,
state_notify_event->baseMods,
state_notify_event->latchedMods,
state_notify_event->lockedMods,
state_notify_event->baseGroup,
state_notify_event->latchedGroup,
state_notify_event->lockedGroup);
if (state_notify_event->changed & XCB_XKB_STATE_PART_GROUP_STATE)
{
lua_pushnumber(L, state_notify_event->group);

2
xkb.h
View File

@ -23,8 +23,6 @@
#define AWESOME_XKB_H
#include <xcb/xcb.h>
#include <xkbcommon/xkbcommon.h>
#include <xkbcommon/xkbcommon-x11.h>
#include <lua.h>
void event_handle_xkb_notify(xcb_generic_event_t* event);