summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorQuentin Glidic <sardemff7+git@sardemff7.net>2016-02-21 15:31:13 +0100
committerQuentin Glidic <sardemff7+git@sardemff7.net>2016-02-21 16:04:53 +0100
commit5d6f2ee1ab78764f50c490063cf3b104fefebe27 (patch)
tree823ff756d0734d7509e57d7310a99c25a61ab42d /source
parente1f87a67b4352ad60b4fc0291a121515fe7f15d3 (diff)
Compose stuff
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Diffstat (limited to 'source')
-rw-r--r--source/rofi.c4
-rw-r--r--source/view.c27
2 files changed, 30 insertions, 1 deletions
diff --git a/source/rofi.c b/source/rofi.c
index 18b9c76f..3842ee14 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -38,6 +38,7 @@
#include <xcb/xcb_aux.h>
#include <xcb/xkb.h>
#include <xkbcommon/xkbcommon.h>
+#include <xkbcommon/xkbcommon-compose.h>
#include <xkbcommon/xkbcommon-x11.h>
#include <X11/X.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.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 );
TICK_N ( "Setup mainloop" );
diff --git a/source/view.c b/source/view.c
index ffde0a32..13f5a6e9 100644
--- a/source/view.c
+++ b/source/view.c
@@ -1310,7 +1310,32 @@ static void rofi_view_mainloop_iter ( RofiViewState *state, xcb_generic_event_t
int len = 0;
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 ) {
// Handling of paste