1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Move keymap updating into right x11 event loop handler.

This commit is contained in:
Dave Davenport 2016-03-04 08:15:12 +01:00
parent 9d7d8a9aeb
commit fd707acac5
2 changed files with 57 additions and 49 deletions

View file

@ -446,6 +446,31 @@ static inline void load_configuration_dynamic ( )
*/
static gboolean main_loop_x11_event_handler ( xcb_generic_event_t *ev, G_GNUC_UNUSED gpointer data )
{
uint8_t type = ev->response_type & ~0x80;
if ( type == xkb.first_event ) {
switch ( ev->pad0 )
{
case XCB_XKB_MAP_NOTIFY:
xkb_state_unref ( xkb.state );
xkb_keymap_unref ( xkb.keymap );
xkb.keymap = xkb_x11_keymap_new_from_device ( xkb.context, xcb->connection, xkb.device_id, 0 );
xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id );
break;
case XCB_XKB_STATE_NOTIFY:
{
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
xkb_state_update_mask ( xkb.state,
ksne->baseMods,
ksne->latchedMods,
ksne->lockedMods,
ksne->baseGroup,
ksne->latchedGroup,
ksne->lockedGroup );
break;
}
}
return G_SOURCE_CONTINUE;
}
RofiViewState *state = rofi_view_get_active ();
if ( xcb->sndisplay != NULL ) {
sn_xcb_display_process_event ( xcb->sndisplay, ev );
@ -696,7 +721,15 @@ int main ( int argc, char *argv[] )
&details );
xkb.keymap = xkb_x11_keymap_new_from_device ( xkb.context, xcb->connection, xkb.device_id, XKB_KEYMAP_COMPILE_NO_FLAGS );
if ( xkb.keymap == NULL ) {
fprintf ( stderr, "Failed to get Keymap for current keyboard device.\n" );
return EXIT_FAILURE;
}
xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id );
if ( xkb.state == NULL ) {
fprintf ( stderr, "Failed to get state object for current keyboard device.\n" );
return EXIT_FAILURE;
}
xkb.compose.table = xkb_compose_table_new_from_locale ( xkb.context, setlocale ( LC_CTYPE, NULL ), 0 );
if ( xkb.compose.table != NULL ) {

View file

@ -368,30 +368,6 @@ static void rofi_view_resize ( RofiViewState *state )
void rofi_view_itterrate ( RofiViewState *state, xcb_generic_event_t *event, xkb_stuff *xkb )
{
uint8_t type = event->response_type & ~0x80;
if ( type == xkb->first_event ) {
switch ( event->pad0 )
{
case XCB_XKB_MAP_NOTIFY:
xkb_state_unref ( xkb->state );
xkb_keymap_unref ( xkb->keymap );
xkb->keymap = xkb_x11_keymap_new_from_device ( xkb->context, xcb->connection, xkb->device_id, 0 );
xkb->state = xkb_x11_state_new_from_device ( xkb->keymap, xcb->connection, xkb->device_id );
break;
case XCB_XKB_STATE_NOTIFY:
{
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) event;
xkb_state_update_mask ( xkb->state,
ksne->baseMods,
ksne->latchedMods,
ksne->lockedMods,
ksne->baseGroup,
ksne->latchedGroup,
ksne->lockedGroup );
break;
}
}
}
else{
switch ( type )
{
case XCB_EXPOSE:
@ -418,7 +394,6 @@ void rofi_view_itterrate ( RofiViewState *state, xcb_generic_event_t *event, xkb
default:
state->x11_event_loop ( state, event, xkb );
}
}
rofi_view_update ( state );
}