diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2fb25a4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+SOURCES/ibus-m17n-1.3.4.tar.gz
diff --git a/.ibus-m17n.metadata b/.ibus-m17n.metadata
new file mode 100644
index 0000000..9ae415f
--- /dev/null
+++ b/.ibus-m17n.metadata
@@ -0,0 +1 @@
+068de56caa87c002adeae0de9e908f47e3f9fde9 SOURCES/ibus-m17n-1.3.4.tar.gz
diff --git a/SOURCES/ibus-m17n-HEAD.patch b/SOURCES/ibus-m17n-HEAD.patch
new file mode 100644
index 0000000..cbfb685
--- /dev/null
+++ b/SOURCES/ibus-m17n-HEAD.patch
@@ -0,0 +1,1928 @@
+diff --git a/autogen.sh b/autogen.sh
+index 99be006..f8bf2b0 100755
+--- a/autogen.sh
++++ b/autogen.sh
+@@ -18,10 +18,10 @@ which gnome-autogen.sh || {
+ exit 1
+ }
+
+-export CFLAGS="-g -O0"
+-export CXXFLAGS="$CFLAGS"
++export CFLAGS=${CFLAGS-"-Wall"}
++export CXXFLAGS=${CXXFLAGS-"$CFLAGS"}
+
+ ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I m4"
+ REQUIRED_AUTOMAKE_VERSION=1.10
+
+-. gnome-autogen.sh
++. gnome-autogen.sh "$@"
+diff --git a/configure.ac b/configure.ac
+index 0548537..30d44ff 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -48,6 +48,7 @@ AM_PROG_CC_C_O
+ AC_PROG_CXX
+ AC_ISC_POSIX
+ AC_HEADER_STDC
++IT_PROG_INTLTOOL([0.35.0])
+ AM_PROG_LIBTOOL
+
+ # check ibus
+@@ -111,8 +112,6 @@ AC_CONFIG_FILES([ po/Makefile.in
+ Makefile
+ ibus-m17n.spec
+ src/Makefile
+-src/m17n.xml.in
+-src/default.xml.in
+ icons/Makefile
+ m4/Makefile
+ ])
+diff --git a/po/POTFILES.in b/po/POTFILES.in
+index a426e33..bb3bd6e 100644
+--- a/po/POTFILES.in
++++ b/po/POTFILES.in
+@@ -1,3 +1,5 @@
+ src/engine.c
+ src/m17nutil.c
+ src/main.c
++[type: gettext/glade]src/ibus-m17n-preferences.ui
++src/ibus-setup-m17n.desktop.in.in
+diff --git a/po/POTFILES.skip b/po/POTFILES.skip
+new file mode 100644
+index 0000000..3667f37
+--- /dev/null
++++ b/po/POTFILES.skip
+@@ -0,0 +1 @@
++src/ibus-setup-m17n.desktop.in
+diff --git a/src/Makefile.am b/src/Makefile.am
+index 39d6523..68ec953 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -19,15 +19,14 @@
+ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ AM_CFLAGS = \
+- @IBUS_CFLAGS@ \
+- @M17N_CFLAGS@ \
++ $(IBUS_CFLAGS) \
++ $(M17N_CFLAGS) \
+ -DPKGDATADIR=\"$(pkgdatadir)\" \
+ -DLIBEXECDIR=\"$(libexecdir)\" \
+- -DSETUPDIR=\"$(setupdir)\" \
+ $(NULL)
+ AM_LDADD = \
+- @IBUS_LIBS@ \
+- @M17N_LIBS@ \
++ $(IBUS_LIBS) \
++ $(M17N_LIBS) \
+ $(NULL)
+
+ check_PROGRAMS = \
+@@ -38,6 +37,7 @@ TESTS = \
+ $(check_PROGRAMS) \
+ $(NULL)
+
++TESTS_ENVIRONMENT = IBUS_M17N_PKGDATADIR=$(builddir)
+
+ test_m17n_SOURCES = \
+ test.c \
+@@ -46,10 +46,13 @@ test_m17n_CFLAGS = \
+ $(AM_CFLAGS) \
+ $(NULL)
+ test_m17n_LDADD = \
+- libm17ncommon.a \
++ libm17ncommon.la \
+ $(AM_LDADD) \
+ $(NULL)
+
++test: ibus-engine-m17n
++ $(builddir)/ibus-engine-m17n
++
+ libexec_PROGRAMS = ibus-engine-m17n
+
+ noinst_LTLIBRARIES = libm17ncommon.la
+@@ -67,8 +70,8 @@ ibus_engine_m17n_SOURCES = \
+ $(NULL)
+ ibus_engine_m17n_LDADD = \
+ libm17ncommon.la \
+- @IBUS_LIBS@ \
+- @M17N_LIBS@ \
++ $(IBUS_LIBS) \
++ $(M17N_LIBS) \
+ $(NULL)
+
+ if HAVE_GTK
+@@ -78,58 +81,61 @@ ibus_setup_m17n_SOURCES = \
+ setup.c \
+ $(NULL)
+ ibus_setup_m17n_CFLAGS = \
+- @GTK_CFLAGS@ \
++ $(GTK_CFLAGS) \
+ $(AM_CFLAGS) \
+ $(NULL)
+ ibus_setup_m17n_LDADD = \
+ libm17ncommon.la \
+- @IBUS_LIBS@ \
+- @M17N_LIBS@ \
+- @GTK_LIBS@ \
++ $(IBUS_LIBS) \
++ $(M17N_LIBS) \
++ $(GTK_LIBS) \
+ $(NULL)
++
++setupdir = $(pkgdatadir)/setup
+ dist_setup_DATA = \
+ ibus-m17n-preferences.ui \
+ $(NULL)
+ endif
+
+-setup_DATA = \
++pkgdata_DATA = \
+ default.xml \
+ $(NULL)
+-setupdir = $(pkgdatadir)/setup
+
+ component_DATA = \
+ m17n.xml \
+ $(NULL)
+-componentdir = @datadir@/ibus/component
++componentdir = $(datadir)/ibus/component
+
+ EXTRA_DIST = \
+- m17n.xml.in.in \
+- default.xml.in \
++ m17n.xml.in \
++ $(desktop_in_in_files) \
+ $(NULL)
+
+ DISTCLEANFILES = \
+ m17n.xml.in \
+- default.xml.in \
+ $(NULL)
+
+ CLEANFILES = \
+ m17n.xml \
+- default.xml \
++ $(desktop_DATA) \
++ $(desktop_in_files) \
+ $(NULL)
+
++edit = sed \
++ -e 's|@VERSION[@]|$(VERSION)|g' \
++ -e 's|@libexecdir[@]|$(libexecdir)|g' \
++ -e 's|@pkgdatadir[@]|$(pkgdatadir)|g'
++
+ m17n.xml: m17n.xml.in
+-default.xml: default.xml.in
+-
+-SUFFIXES = .xml.in .xml
+-.xml.in.xml:
+- $(AM_V_GEN) \
+- ( \
+- libexecdir=${libexecdir}; \
+- pkgdatadir=${pkgdatadir}; \
+- setupdir=${setupdir}; \
+- s=`cat $<`; \
+- eval "echo \"$${s}\""; \
+- ) > $@
++ $(AM_V_GEN) $(edit) $< > $@.tmp && mv $@.tmp $@
+
+-test: ibus-engine-m17n
+- $(builddir)/ibus-engine-m17n
++desktop_in_in_files = ibus-setup-m17n.desktop.in.in
++desktop_in_files = $(desktop_in_in_files:.in.in=.in)
++
++$(desktop_in_files): %.desktop.in: %.desktop.in.in Makefile
++ $(AM_V_GEN) $(edit) $< > $@.tmp && mv $@.tmp $@
++
++desktopdir=$(datadir)/applications
++desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
++
++@INTLTOOL_DESKTOP_RULE@
+diff --git a/src/default.xml b/src/default.xml
+new file mode 100644
+index 0000000..ffd733a
+--- /dev/null
++++ b/src/default.xml
+@@ -0,0 +1,434 @@
++
++
++
++
++
++ m17n:*
++ 0
++ FALSE
++
++
++
++
++
++ m17n:*:kbd
++ -1
++
++
++
++ m17n:zh:py
++ -1
++
++
++
++ m17n:ja:anthy
++ -1
++
++
++
++ m17n:ko:han2
++ -1
++
++
++
++ m17n:ko:romaja
++ -1
++
++
++
++ m17n:as:*
++ 1
++
++
++ m17n:bn:*
++ 1
++
++
++ m17n:gu:*
++ 1
++
++
++ m17n:hi:*
++ 1
++
++
++ m17n:kn:*
++ 1
++
++
++ m17n:ks:*
++ 1
++
++
++ m17n:mai:*
++ 1
++
++
++ m17n:ml:*
++ 1
++
++
++ m17n:mr:*
++ 1
++
++
++ m17n:ne:*
++ 1
++
++
++ m17n:or:*
++ 1
++
++
++ m17n:pa:*
++ 1
++
++
++ m17n:sa:*
++ 1
++
++
++ m17n:sd:*
++ 1
++
++
++ m17n:si:*
++ 1
++
++
++ m17n:ta:*
++ 1
++
++
++ m17n:te:*
++ 1
++
++
++
++ m17n:as:phonetic
++ 2
++
++
++ m17n:bn:inscript
++ 2
++
++
++ m17n:gu:inscript
++ 2
++
++
++ m17n:hi:inscript
++ 2
++
++
++ m17n:kn:kgp
++ 2
++
++
++ m17n:ks:kbd
++ 2
++
++
++ m17n:mai:inscript
++ 2
++
++
++ m17n:ml:inscript
++ 2
++
++
++ m17n:mr:inscript
++ 2
++
++
++ m17n:ne:rom
++ 2
++
++
++ m17n:or:inscript
++ 2
++
++
++ m17n:pa:inscript
++ 2
++
++
++ m17n:sa:harvard-kyoto
++ 2
++
++
++ m17n:sd:inscript
++ 2
++
++
++ m17n:si:wijesekera
++ 2
++
++
++ m17n:ta:tamil99
++ 2
++
++
++ m17n:te:inscript
++ 2
++
++
++
++ m17n:si:samanala
++ 0
++
++
++
++ m17n:zh:cangjie
++ TRUE
++
++
++ m17n:zh:py-b5
++ TRUE
++
++
++ m17n:zh:py-gb
++ TRUE
++
++
++ m17n:zh:py
++ TRUE
++
++
++ m17n:zh:quick
++ TRUE
++
++
++ m17n:zh:tonepy-b5
++ TRUE
++
++
++ m17n:zh:tonepy-gb
++ TRUE
++
++
++ m17n:zh:tonepy
++ TRUE
++
++
++ m17n:ja:anthy
++ TRUE
++
++
++
++ m17n:as:*
++ অ
++
++
++ m17n:bn:*
++ বা
++
++
++ m17n:gu:*
++ ગુ
++
++
++ m17n:hi:*
++ हिं
++
++
++ m17n:kn:*
++ ಕ
++
++
++ m17n:ks:*
++ क
++
++
++ m17n:mai:*
++ मै
++
++
++ m17n:ml:*
++ മ
++
++
++ m17n:mr:*
++ म
++
++
++ m17n:ne:*
++ ने
++
++
++ m17n:or:*
++ ଓ
++
++
++ m17n:pa:*
++ ਪੰ
++
++
++ m17n:sa:*
++ सं
++
++
++ m17n:sd:*
++ सिं
++
++
++ m17n:si:*
++ සි
++
++
++ m17n:ta:*
++ த
++
++
++ m17n:te:*
++ తె
++
++
++ m17n:*:kbd
++
++
++
++ m17n:*:pre
++
++
++
++ m17n:*:post
++
++
++
++ m17n:am:sera
++ አ
++
++
++ m17n:bo:*
++ ཀ
++
++
++ m17n:cr:*
++
++
++
++ m17n:dv:*
++
++
++
++ m17n:eo:*
++
++
++
++ m17n:fa:*
++ ف
++
++
++ m17n:fr:*
++
++
++
++ m17n:ii:*
++
++
++
++ m17n:iu:*
++
++
++
++ m17n:ja:anthy
++ あ
++
++
++ m17n:kk:*
++ قا
++
++
++ m17n:km:*
++ ក
++
++
++ m17n:lo:*
++ ກ
++
++
++ m17n:nsk:*
++
++
++
++ m17n:oj:*
++
++
++
++ m17n:ps:*
++
++
++
++ m17n:ru:*
++ Я
++
++
++ m17n:sv:*
++
++
++
++ m17n:syrc:*
++
++
++
++ m17n:tai:*
++ ꫞
++
++
++ m17n:th:*
++ ท
++
++
++ m17n:ur:*
++ خ
++
++
++ m17n:vi:han
++ 越
++
++
++ m17n:vi:nom*
++ 喃
++
++
++ m17n:vi:*
++ ắ
++
++
++ m17n:yi:*
++
++
++
++ m17n:zh:bopomofo
++ ㄅ
++
++
++ m17n:zh:cangjie
++ 倉
++
++
++ m17n:zh:pinyin
++ PY
++ hanyu pinyin (m17n)
++
++
++ m17n:zh:py*
++ 拼
++
++
++ m17n:zh:quick
++ 簡
++
++
++ m17n:zh:tonepy*
++ 调
++
++
+diff --git a/src/default.xml.in.in b/src/default.xml.in.in
+deleted file mode 100644
+index 9f5a01e..0000000
+--- a/src/default.xml.in.in
++++ /dev/null
+@@ -1,408 +0,0 @@
+-
+-
+-
+-
+-
+- m17n:*
+- 0
+- FALSE
+-
+-
+-
+-
+- m17n:as:*
+- 1
+-
+-
+- m17n:bn:*
+- 1
+-
+-
+- m17n:gu:*
+- 1
+-
+-
+- m17n:hi:*
+- 1
+-
+-
+- m17n:kn:*
+- 1
+-
+-
+- m17n:ks:*
+- 1
+-
+-
+- m17n:mai:*
+- 1
+-
+-
+- m17n:ml:*
+- 1
+-
+-
+- m17n:mr:*
+- 1
+-
+-
+- m17n:ne:*
+- 1
+-
+-
+- m17n:or:*
+- 1
+-
+-
+- m17n:pa:*
+- 1
+-
+-
+- m17n:sa:*
+- 1
+-
+-
+- m17n:sd:*
+- 1
+-
+-
+- m17n:si:*
+- 1
+-
+-
+- m17n:ta:*
+- 1
+-
+-
+- m17n:te:*
+- 1
+-
+-
+-
+- m17n:as:phonetic
+- 2
+-
+-
+- m17n:bn:inscript
+- 2
+-
+-
+- m17n:gu:inscript
+- 2
+-
+-
+- m17n:hi:inscript
+- 2
+-
+-
+- m17n:kn:kgp
+- 2
+-
+-
+- m17n:ks:kbd
+- 2
+-
+-
+- m17n:mai:inscript
+- 2
+-
+-
+- m17n:ml:inscript
+- 2
+-
+-
+- m17n:mr:inscript
+- 2
+-
+-
+- m17n:ne:rom
+- 2
+-
+-
+- m17n:or:inscript
+- 2
+-
+-
+- m17n:pa:inscript
+- 2
+-
+-
+- m17n:sa:harvard-kyoto
+- 2
+-
+-
+- m17n:sd:inscript
+- 2
+-
+-
+- m17n:si:wijesekera
+- 2
+-
+-
+- m17n:ta:tamil99
+- 2
+-
+-
+- m17n:te:inscript
+- 2
+-
+-
+-
+- m17n:si:samanala
+- 0
+-
+-
+-
+- m17n:zh:cangjie
+- TRUE
+-
+-
+- m17n:zh:py-b5
+- TRUE
+-
+-
+- m17n:zh:py-gb
+- TRUE
+-
+-
+- m17n:zh:py
+- TRUE
+-
+-
+- m17n:zh:quick
+- TRUE
+-
+-
+- m17n:zh:tonepy-b5
+- TRUE
+-
+-
+- m17n:zh:tonepy-gb
+- TRUE
+-
+-
+- m17n:zh:tonepy
+- TRUE
+-
+-
+- m17n:ja:anthy
+- TRUE
+-
+-
+-
+- m17n:as:*
+- অ
+-
+-
+- m17n:bn:*
+- বা
+-
+-
+- m17n:gu:*
+- ગુ
+-
+-
+- m17n:hi:*
+- हिं
+-
+-
+- m17n:kn:*
+- ಕ
+-
+-
+- m17n:ks:*
+- क
+-
+-
+- m17n:mai:*
+- मै
+-
+-
+- m17n:ml:*
+- മ
+-
+-
+- m17n:mr:*
+- म
+-
+-
+- m17n:ne:*
+- ने
+-
+-
+- m17n:or:*
+- ଓ
+-
+-
+- m17n:pa:*
+- ਪੰ
+-
+-
+- m17n:sa:*
+- सं
+-
+-
+- m17n:sd:*
+- सिं
+-
+-
+- m17n:si:*
+- සි
+-
+-
+- m17n:ta:*
+- த
+-
+-
+- m17n:te:*
+- తె
+-
+-
+- m17n:*:kbd
+-
+-
+-
+- m17n:*:pre
+-
+-
+-
+- m17n:*:post
+-
+-
+-
+- m17n:am:sera
+- አ
+-
+-
+- m17n:bo:*
+- ཀ
+-
+-
+- m17n:cr:*
+-
+-
+-
+- m17n:dv:*
+-
+-
+-
+- m17n:eo:*
+-
+-
+-
+- m17n:fa:*
+- ف
+-
+-
+- m17n:fr:*
+-
+-
+-
+- m17n:ii:*
+-
+-
+-
+- m17n:iu:*
+-
+-
+-
+- m17n:ja:anthy
+- あ
+-
+-
+- m17n:kk:*
+- قا
+-
+-
+- m17n:km:*
+- ក
+-
+-
+- m17n:lo:*
+- ກ
+-
+-
+- m17n:nsk:*
+-
+-
+-
+- m17n:oj:*
+-
+-
+-
+- m17n:ps:*
+-
+-
+-
+- m17n:ru:*
+- Я
+-
+-
+- m17n:sv:*
+-
+-
+-
+- m17n:syrc:*
+-
+-
+-
+- m17n:tai:*
+- ꫞
+-
+-
+- m17n:th:*
+- ท
+-
+-
+- m17n:ur:*
+- خ
+-
+-
+- m17n:vi:han
+- 越
+-
+-
+- m17n:vi:nom*
+- 喃
+-
+-
+- m17n:vi:*
+- Ắ
+-
+-
+- m17n:yi:*
+-
+-
+-
+- m17n:zh:bopomofo
+- ㄅ
+-
+-
+- m17n:zh:cangjie
+- 倉
+-
+-
+- m17n:zh:pinyin
+- PY
+- hanyu pinyin (m17n)
+-
+-
+- m17n:zh:py*
+- 拼
+-
+-
+- m17n:zh:quick
+- 簡
+-
+-
+- m17n:zh:tonepy*
+- 调
+-
+-
+diff --git a/src/engine.c b/src/engine.c
+index bd7ea0f..bcc1a71 100644
+--- a/src/engine.c
++++ b/src/engine.c
+@@ -23,6 +23,7 @@ struct _IBusM17NEngine {
+ IBusProperty *setup_prop;
+ #endif /* HAVE_SETUP */
+ IBusPropList *prop_list;
++ IBusKeymap *us_keymap;
+ };
+
+ struct _IBusM17NEngineClass {
+@@ -35,6 +36,7 @@ struct _IBusM17NEngineClass {
+ gint preedit_underline;
+ IBusPreeditFocusMode preedit_focus_mode;
+ gint lookup_table_orientation;
++ gboolean use_us_layout;
+
+ MInputMethod *im;
+ };
+@@ -64,14 +66,6 @@ static void ibus_m17n_engine_focus_out (IBusEngine *engine);
+ static void ibus_m17n_engine_reset (IBusEngine *engine);
+ static void ibus_m17n_engine_enable (IBusEngine *engine);
+ static void ibus_m17n_engine_disable (IBusEngine *engine);
+-static void ibus_engine_set_cursor_location (IBusEngine *engine,
+- gint x,
+- gint y,
+- gint w,
+- gint h);
+-static void ibus_m17n_engine_set_capabilities
+- (IBusEngine *engine,
+- guint caps);
+ static void ibus_m17n_engine_page_up (IBusEngine *engine);
+ static void ibus_m17n_engine_page_down (IBusEngine *engine);
+ static void ibus_m17n_engine_cursor_up (IBusEngine *engine);
+@@ -80,12 +74,6 @@ static void ibus_m17n_engine_property_activate
+ (IBusEngine *engine,
+ const gchar *prop_name,
+ guint prop_state);
+-static void ibus_m17n_engine_property_show
+- (IBusEngine *engine,
+- const gchar *prop_name);
+-static void ibus_m17n_engine_property_hide
+- (IBusEngine *engine,
+- const gchar *prop_name);
+
+ static void ibus_m17n_engine_commit_string
+ (IBusM17NEngine *m17n,
+@@ -263,6 +251,7 @@ ibus_m17n_engine_class_init (IBusM17NEngineClass *klass)
+ IBUS_ENGINE_PREEDIT_COMMIT :
+ IBUS_ENGINE_PREEDIT_CLEAR;
+ klass->lookup_table_orientation = IBUS_ORIENTATION_SYSTEM;
++ klass->use_us_layout = FALSE;
+
+ ibus_m17n_engine_config_free (engine_config);
+
+@@ -304,6 +293,14 @@ ibus_m17n_engine_class_init (IBusM17NEngineClass *klass)
+ klass->lookup_table_orientation = g_variant_get_int32 (value);
+ g_variant_unref (value);
+ }
++
++ value = g_variant_lookup_value (values,
++ "use_us_layout",
++ G_VARIANT_TYPE_BOOLEAN);
++ if (value != NULL) {
++ klass->use_us_layout = g_variant_get_boolean (value);
++ g_variant_unref (value);
++ }
+ g_variant_unref (values);
+ }
+
+@@ -340,6 +337,8 @@ ibus_m17n_config_value_changed (IBusConfig *config,
+ klass->preedit_underline = g_variant_get_int32 (value);
+ } else if (g_strcmp0 (name, "lookup_table_orientation") == 0) {
+ klass->lookup_table_orientation = g_variant_get_int32 (value);
++ } else if (g_strcmp0 (name, "use_us_layout") == 0) {
++ klass->use_us_layout = g_variant_get_boolean (value);
+ }
+ }
+ }
+@@ -384,6 +383,7 @@ ibus_m17n_engine_init (IBusM17NEngine *m17n)
+ m17n->table = ibus_lookup_table_new (9, 0, TRUE, TRUE);
+ g_object_ref_sink (m17n->table);
+ m17n->context = NULL;
++ m17n->us_keymap = ibus_keymap_get ("us");
+ }
+
+ static GObject*
+@@ -476,6 +476,11 @@ ibus_m17n_engine_destroy (IBusM17NEngine *m17n)
+ m17n->context = NULL;
+ }
+
++ if (m17n->us_keymap) {
++ g_object_unref (m17n->us_keymap);
++ m17n->us_keymap = NULL;
++ }
++
+ IBUS_OBJECT_CLASS (parent_class)->destroy ((IBusObject *)m17n);
+ }
+
+@@ -531,28 +536,25 @@ ibus_m17n_engine_commit_string (IBusM17NEngine *m17n,
+ Since IBus engines are supposed to be cross-platform, the code
+ should go into IBus core, instead of ibus-m17n. */
+ static MSymbol
+-ibus_m17n_key_event_to_symbol (guint keycode,
+- guint keyval,
+- guint modifiers)
++ibus_m17n_key_event_to_symbol (IBusM17NEngine *m17n,
++ guint keycode,
++ guint keyval,
++ guint modifiers)
+ {
+ GString *keysym;
+ MSymbol mkeysym = Mnil;
+ guint mask = 0;
+- IBusKeymap *keymap;
+
+ if (keyval >= IBUS_Shift_L && keyval <= IBUS_Hyper_R) {
+ return Mnil;
+ }
+
+- /* Here, keyval is already translated by IBUS_MOD5_MASK. Obtain
+- the untranslated keyval from the underlying keymap and
+- represent the translated keyval as the form "G-", which m17n-lib accepts. */
++ /* If keyval is already translated by IBUS_MOD5_MASK. Try to
++ obtain the untranslated keyval from the US keymap. */
+ if (modifiers & IBUS_MOD5_MASK) {
+- keymap = ibus_keymap_get ("us");
+- keyval = ibus_keymap_lookup_keysym (keymap, keycode,
++ keyval = ibus_keymap_lookup_keysym (m17n->us_keymap,
++ keycode,
+ modifiers & ~IBUS_MOD5_MASK);
+- g_object_unref (keymap);
+ }
+
+ keysym = g_string_new ("");
+@@ -656,15 +658,38 @@ ibus_m17n_engine_process_key_event (IBusEngine *engine,
+ guint modifiers)
+ {
+ IBusM17NEngine *m17n = (IBusM17NEngine *) engine;
++ IBusM17NEngineClass *klass =
++ (IBusM17NEngineClass *) G_OBJECT_GET_CLASS (m17n);
++ guint original_keyval = keyval;
+
+ if (modifiers & IBUS_RELEASE_MASK)
+ return FALSE;
+- MSymbol m17n_key = ibus_m17n_key_event_to_symbol (keycode, keyval, modifiers);
+
+- if (m17n_key == Mnil)
+- return FALSE;
++ if (klass->use_us_layout) {
++ keyval = ibus_keymap_lookup_keysym (m17n->us_keymap,
++ keycode,
++ modifiers);
++ }
+
+- return ibus_m17n_engine_process_key (m17n, m17n_key);
++ MSymbol m17n_key = ibus_m17n_key_event_to_symbol (m17n,
++ keycode,
++ keyval,
++ modifiers);
++ if (m17n_key != Mnil && ibus_m17n_engine_process_key (m17n, m17n_key)) {
++ return TRUE;
++ }
++
++ /* If keyval is translated in US layout, send the new keyval and
++ notify that the event is handled. */
++ if (keyval != original_keyval && 0x20 <= keyval && keyval < 0x7F) {
++ gchar buf[2];
++ buf[0] = keyval;
++ buf[1] = '\0';
++ ibus_m17n_engine_commit_string (m17n, buf);
++ return TRUE;
++ }
++
++ return FALSE;
+ }
+
+ static void
+@@ -704,8 +729,6 @@ ibus_m17n_engine_reset (IBusEngine *engine)
+ static void
+ ibus_m17n_engine_enable (IBusEngine *engine)
+ {
+- IBusM17NEngine *m17n = (IBusM17NEngine *) engine;
+-
+ parent_class->enable (engine);
+
+ /* Issue a dummy ibus_engine_get_surrounding_text() call to tell
+@@ -716,8 +739,6 @@ ibus_m17n_engine_enable (IBusEngine *engine)
+ static void
+ ibus_m17n_engine_disable (IBusEngine *engine)
+ {
+- IBusM17NEngine *m17n = (IBusM17NEngine *) engine;
+-
+ ibus_m17n_engine_focus_out (engine);
+ parent_class->disable (engine);
+ }
+@@ -951,7 +972,9 @@ ibus_m17n_engine_callback (MInputContext *context,
+ &anchor_pos);
+ nchars = ibus_text_get_length (text);
+ nbytes = g_utf8_offset_to_pointer (text->text, nchars) - text->text;
+- mt = mconv_decode_buffer (Mcoding_utf_8, text->text, nbytes);
++ mt = mconv_decode_buffer (Mcoding_utf_8,
++ (const unsigned char *) text->text,
++ nbytes);
+ g_object_unref (text);
+
+ len = (long) mplist_value (m17n->context->plist);
+diff --git a/src/ibus-m17n-preferences.ui b/src/ibus-m17n-preferences.ui
+index a46ab49..e85fb15 100644
+--- a/src/ibus-m17n-preferences.ui
++++ b/src/ibus-m17n-preferences.ui
+@@ -1,8 +1,8 @@
+-
++
+
+
+
+-