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 ) 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 (); RofiViewState *state = rofi_view_get_active ();
if ( xcb->sndisplay != NULL ) { if ( xcb->sndisplay != NULL ) {
sn_xcb_display_process_event ( xcb->sndisplay, ev ); sn_xcb_display_process_event ( xcb->sndisplay, ev );
@ -696,7 +721,15 @@ int main ( int argc, char *argv[] )
&details ); &details );
xkb.keymap = xkb_x11_keymap_new_from_device ( xkb.context, xcb->connection, xkb.device_id, XKB_KEYMAP_COMPILE_NO_FLAGS ); xkb.keymap = xkb_x11_keymap_new_from_device ( xkb.context, xcb->connection, xkb.device_id, XKB_KEYMAP_COMPILE_NO_FLAGS );
xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb->connection, xkb.device_id ); 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 ); xkb.compose.table = xkb_compose_table_new_from_locale ( xkb.context, setlocale ( LC_CTYPE, NULL ), 0 );
if ( xkb.compose.table != NULL ) { if ( xkb.compose.table != NULL ) {

View file

@ -368,56 +368,31 @@ static void rofi_view_resize ( RofiViewState *state )
void rofi_view_itterrate ( RofiViewState *state, xcb_generic_event_t *event, xkb_stuff *xkb ) void rofi_view_itterrate ( RofiViewState *state, xcb_generic_event_t *event, xkb_stuff *xkb )
{ {
uint8_t type = event->response_type & ~0x80; uint8_t type = event->response_type & ~0x80;
if ( type == xkb->first_event ) { switch ( type )
switch ( event->pad0 ) {
{ case XCB_EXPOSE:
case XCB_XKB_MAP_NOTIFY: state->update = TRUE;
xkb_state_unref ( xkb->state ); break;
xkb_keymap_unref ( xkb->keymap ); case XCB_CONFIGURE_NOTIFY:
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 ); xcb_configure_notify_event_t *xce = (xcb_configure_notify_event_t *) event;
break; if ( xce->window == state->window ) {
case XCB_XKB_STATE_NOTIFY: if ( state->x != xce->x || state->y != xce->y ) {
{ state->x = xce->x;
xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) event; state->y = xce->y;
xkb_state_update_mask ( xkb->state, state->update = TRUE;
ksne->baseMods, }
ksne->latchedMods, if ( state->w != xce->width || state->h != xce->height ) {
ksne->lockedMods, state->w = xce->width;
ksne->baseGroup, state->h = xce->height;
ksne->latchedGroup, cairo_xcb_surface_set_size ( surface, state->w, state->h );
ksne->lockedGroup ); rofi_view_resize ( state );
break;
}
}
}
else{
switch ( type )
{
case XCB_EXPOSE:
state->update = TRUE;
break;
case XCB_CONFIGURE_NOTIFY:
{
xcb_configure_notify_event_t *xce = (xcb_configure_notify_event_t *) event;
if ( xce->window == state->window ) {
if ( state->x != xce->x || state->y != xce->y ) {
state->x = xce->x;
state->y = xce->y;
state->update = TRUE;
}
if ( state->w != xce->width || state->h != xce->height ) {
state->w = xce->width;
state->h = xce->height;
cairo_xcb_surface_set_size ( surface, state->w, state->h );
rofi_view_resize ( state );
}
} }
break;
}
default:
state->x11_event_loop ( state, event, xkb );
} }
break;
}
default:
state->x11_event_loop ( state, event, xkb );
} }
rofi_view_update ( state ); rofi_view_update ( state );
} }