XKB update: Use an idle source
Instead of updating the keyboard state at the end of the current main loop iteration, this now uses a GLib idle source with a very low priority. This increases the chance of batching multiple refreshes together. Also, this means that awesome_refresh() does less work. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
a22479c97b
commit
fb147cf856
4
event.h
4
event.h
|
@ -39,13 +39,9 @@ void client_refresh(void);
|
||||||
void client_focus_refresh(void);
|
void client_focus_refresh(void);
|
||||||
void client_destroy_later(void);
|
void client_destroy_later(void);
|
||||||
|
|
||||||
/* xkb.c */
|
|
||||||
void xkb_refresh(void);
|
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
awesome_refresh(void)
|
awesome_refresh(void)
|
||||||
{
|
{
|
||||||
xkb_refresh();
|
|
||||||
luaA_emit_refresh();
|
luaA_emit_refresh();
|
||||||
drawin_refresh();
|
drawin_refresh();
|
||||||
client_refresh();
|
client_refresh();
|
||||||
|
|
|
@ -189,6 +189,8 @@ typedef struct
|
||||||
struct xkb_context *xkb_ctx;
|
struct xkb_context *xkb_ctx;
|
||||||
/* xkb state of dead keys on keyboard */
|
/* xkb state of dead keys on keyboard */
|
||||||
struct xkb_state *xkb_state;
|
struct xkb_state *xkb_state;
|
||||||
|
/* Do we have a pending xkb update call? */
|
||||||
|
bool xkb_update_pending;
|
||||||
/* Do we have a pending reload? */
|
/* Do we have a pending reload? */
|
||||||
bool xkb_reload_keymap;
|
bool xkb_reload_keymap;
|
||||||
/* Do we have a pending map change? */
|
/* Do we have a pending map change? */
|
||||||
|
|
22
xkb.c
22
xkb.c
|
@ -297,11 +297,12 @@ xkb_reload_keymap(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static gboolean
|
||||||
xkb_refresh(void)
|
xkb_refresh(gpointer unused)
|
||||||
{
|
{
|
||||||
lua_State *L = globalconf_get_lua_State();
|
lua_State *L = globalconf_get_lua_State();
|
||||||
|
|
||||||
|
globalconf.xkb_update_pending = false;
|
||||||
if (globalconf.xkb_reload_keymap)
|
if (globalconf.xkb_reload_keymap)
|
||||||
xkb_reload_keymap();
|
xkb_reload_keymap();
|
||||||
if (globalconf.xkb_map_changed)
|
if (globalconf.xkb_map_changed)
|
||||||
|
@ -312,6 +313,17 @@ xkb_refresh(void)
|
||||||
globalconf.xkb_reload_keymap = false;
|
globalconf.xkb_reload_keymap = false;
|
||||||
globalconf.xkb_map_changed = false;
|
globalconf.xkb_map_changed = false;
|
||||||
globalconf.xkb_group_changed = false;
|
globalconf.xkb_group_changed = false;
|
||||||
|
|
||||||
|
return G_SOURCE_REMOVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xkb_schedule_refresh(void)
|
||||||
|
{
|
||||||
|
if (globalconf.xkb_update_pending)
|
||||||
|
return;
|
||||||
|
globalconf.xkb_update_pending = true;
|
||||||
|
g_idle_add_full(G_PRIORITY_LOW, xkb_refresh, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The xkb notify event handler.
|
/** The xkb notify event handler.
|
||||||
|
@ -335,12 +347,14 @@ event_handle_xkb_notify(xcb_generic_event_t* event)
|
||||||
|
|
||||||
if (new_keyboard_event->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
|
if (new_keyboard_event->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
|
||||||
globalconf.xkb_map_changed = true;
|
globalconf.xkb_map_changed = true;
|
||||||
|
xkb_schedule_refresh();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case XCB_XKB_MAP_NOTIFY:
|
case XCB_XKB_MAP_NOTIFY:
|
||||||
{
|
{
|
||||||
globalconf.xkb_reload_keymap = true;
|
globalconf.xkb_reload_keymap = true;
|
||||||
globalconf.xkb_map_changed = true;
|
globalconf.xkb_map_changed = true;
|
||||||
|
xkb_schedule_refresh();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case XCB_XKB_STATE_NOTIFY:
|
case XCB_XKB_STATE_NOTIFY:
|
||||||
|
@ -356,7 +370,10 @@ event_handle_xkb_notify(xcb_generic_event_t* event)
|
||||||
state_notify_event->lockedGroup);
|
state_notify_event->lockedGroup);
|
||||||
|
|
||||||
if (state_notify_event->changed & XCB_XKB_STATE_PART_GROUP_STATE)
|
if (state_notify_event->changed & XCB_XKB_STATE_PART_GROUP_STATE)
|
||||||
|
{
|
||||||
globalconf.xkb_group_changed = true;
|
globalconf.xkb_group_changed = true;
|
||||||
|
xkb_schedule_refresh();
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -369,6 +386,7 @@ event_handle_xkb_notify(xcb_generic_event_t* event)
|
||||||
void
|
void
|
||||||
xkb_init(void)
|
xkb_init(void)
|
||||||
{
|
{
|
||||||
|
globalconf.xkb_update_pending = false;
|
||||||
globalconf.xkb_reload_keymap = false;
|
globalconf.xkb_reload_keymap = false;
|
||||||
globalconf.xkb_map_changed = false;
|
globalconf.xkb_map_changed = false;
|
||||||
globalconf.xkb_group_changed = false;
|
globalconf.xkb_group_changed = false;
|
||||||
|
|
Loading…
Reference in New Issue