1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

Compose stuff

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
This commit is contained in:
Quentin Glidic 2016-02-21 15:31:13 +01:00
parent e1f87a67b4
commit 5d6f2ee1ab
3 changed files with 35 additions and 1 deletions

View file

@ -2,6 +2,7 @@
#define ROFI_XKB_INTERNAL_H #define ROFI_XKB_INTERNAL_H
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>
#include <xkbcommon/xkbcommon-compose.h>
struct xkb_stuff { struct xkb_stuff {
xcb_connection_t *xcb_connection; xcb_connection_t *xcb_connection;
@ -10,6 +11,10 @@ struct xkb_stuff {
int32_t device_id; int32_t device_id;
struct xkb_keymap *keymap; struct xkb_keymap *keymap;
struct xkb_state *state; struct xkb_state *state;
struct {
struct xkb_compose_table *table;
struct xkb_compose_state * state;
} compose;
}; };
#endif #endif

View file

@ -38,6 +38,7 @@
#include <xcb/xcb_aux.h> #include <xcb/xcb_aux.h>
#include <xcb/xkb.h> #include <xcb/xkb.h>
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>
#include <xkbcommon/xkbcommon-compose.h>
#include <xkbcommon/xkbcommon-x11.h> #include <xkbcommon/xkbcommon-x11.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
@ -868,6 +869,9 @@ int main ( int argc, char *argv[] )
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 ); xkb.state = xkb_x11_state_new_from_device ( xkb.keymap, xcb_connection, xkb.device_id );
xkb.compose.table = xkb_compose_table_new_from_locale ( xkb.context, setlocale ( LC_CTYPE, NULL ), 0 );
xkb.compose.state = xkb_compose_state_new ( xkb.compose.table, 0 );
main_loop = g_main_loop_new ( NULL, FALSE ); main_loop = g_main_loop_new ( NULL, FALSE );
TICK_N ( "Setup mainloop" ); TICK_N ( "Setup mainloop" );

View file

@ -1310,7 +1310,32 @@ static void rofi_view_mainloop_iter ( RofiViewState *state, xcb_generic_event_t
int len = 0; int len = 0;
key = xkb_state_key_get_one_sym ( xkb->state, xkpe->detail ); key = xkb_state_key_get_one_sym ( xkb->state, xkpe->detail );
len = xkb_state_key_get_utf8 ( xkb->state, xkpe->detail, pad, sizeof ( pad ) );
if ( ( key != XKB_KEY_NoSymbol ) && ( xkb_compose_state_feed ( xkb->compose.state, key ) == XKB_COMPOSE_FEED_ACCEPTED ) ) {
switch ( xkb_compose_state_get_status ( xkb->compose.state ) )
{
case XKB_COMPOSE_COMPOSING:
g_debug ( "[COMPOSE] composing" );
key = XKB_KEY_NoSymbol;
break;
case XKB_COMPOSE_COMPOSED:
g_debug ( "[COMPOSE] composed" );
key = xkb_compose_state_get_one_sym ( xkb->compose.state );
len = xkb_compose_state_get_utf8 ( xkb->compose.state, pad, sizeof ( pad ) );
break;
case XKB_COMPOSE_CANCELLED:
g_debug ( "[COMPOSE] cancelled" );
case XKB_COMPOSE_NOTHING:
break;
}
if ( key == XKB_KEY_NoSymbol ) {
break;
}
}
if ( len == 0 ) {
len = xkb_state_key_get_utf8 ( xkb->state, xkpe->detail, pad, sizeof ( pad ) );
}
if ( key != XKB_KEY_NoSymbol ) { if ( key != XKB_KEY_NoSymbol ) {
// Handling of paste // Handling of paste