diff --git a/engine/main.vala b/engine/main.vala index e1fd1294..acfa7371 100644 --- a/engine/main.vala +++ b/engine/main.vala @@ -34,16 +34,6 @@ public int main(string[] args) { return 1; } - uint flags = - IBus.BusNameFlag.REPLACE_EXISTING | - IBus.BusNameFlag.ALLOW_REPLACEMENT; - uint retval = bus.request_name("org.freedesktop.IBus.Simple", flags); - - if (retval == 0) { - warning("Registry bus name org.freedesktop.IBus.Simple failed!"); - return 1; - } - bus.disconnected.connect((bus) => { debug("bus disconnected"); IBus.quit(); @@ -61,6 +51,16 @@ public int main(string[] args) { return engine; }); + uint flags = + IBus.BusNameFlag.REPLACE_EXISTING | + IBus.BusNameFlag.ALLOW_REPLACEMENT; + uint retval = bus.request_name("org.freedesktop.IBus.Simple", flags); + + if (retval == 0) { + warning("Registry bus name org.freedesktop.IBus.Simple failed!"); + return 1; + } + IBus.main(); return 0; diff --git a/src/tests/ibus-bus.c b/src/tests/ibus-bus.c index da125343..4ec40cd5 100644 --- a/src/tests/ibus-bus.c +++ b/src/tests/ibus-bus.c @@ -621,6 +621,26 @@ test_bus_new_async (void) ibus_main (); } +static void +test_global_engine (void) +{ + IBusEngineDesc *engine_desc; + const gchar *engine_name; + + if (!ibus_bus_get_use_global_engine (bus)) + return; + + engine_name = "xkb:us::eng"; + ibus_bus_set_global_engine (bus, engine_name); + engine_desc = ibus_bus_get_global_engine (bus); + g_assert_cmpstr (ibus_engine_desc_get_name (engine_desc), ==, engine_name); + + engine_name = "xkb:jp::jpn"; + ibus_bus_set_global_engine (bus, engine_name); + engine_desc = ibus_bus_get_global_engine (bus); + g_assert_cmpstr (ibus_engine_desc_get_name (engine_desc), ==, engine_name); +} + gint main (gint argc, gchar **argv) @@ -646,6 +666,7 @@ main (gint argc, test_create_input_context_async); g_test_add_func ("/ibus/bus-new-async/get-engines-by-names", test_get_engines_by_names); g_test_add_func ("/ibus/bus-new-async/async-apis", test_async_apis); + g_test_add_func ("/ibus/global-engine", test_global_engine); result = g_test_run (); g_object_unref (bus);