* doc/HELPER-PROTOCOL - Add im_switcher_start and im_switcher_quit to fix bug #2112. * helper/im-switcher-gtk.c - (parse_helper_str): Parse "im_switcher_{start,quit}". - (main): Check if another uim-im-switcher exists by trying to contact one. If one exists, this process exits. * qt4/switcher/qt4.cpp - (UimImSwitcher::UimImSwitcher): Check if another uim-im-switcher exists by trying to contact one. If one exists, this process exits. - (UimImSwitcher::slotStdinActivated): Parse "im_switcher_{start,quit}". --- doc/HELPER-PROTOCOL | 23 ++++++++++++++++++++++- helper/im-switcher-gtk.c | 7 +++++++ qt4/switcher/qt4.cpp | 7 +++++++ 3 files changed, 36 insertions(+), 1 deletions(-) diff --git a/doc/HELPER-PROTOCOL b/doc/HELPER-PROTOCOL index 2787ce6..1d6ee8f 100644 --- a/doc/HELPER-PROTOCOL +++ b/doc/HELPER-PROTOCOL @@ -91,7 +91,9 @@ protocol within uim. im_change_this_application_only | prop_update_custom | custom_reload_notify | - commit_string) "\n" + commit_string | + im_switcher_start | + im_switcher_quit) "\n" charset_specifier = "charset=" charset "\n" charset = "UTF-8" | "EUC-JP" | "GB18030" | @@ -324,6 +326,25 @@ protocol within uim. commit_string = "commit_string\n" charset_specifier str_to_commit "\n" str_to_commit = /^[^\n]+$/ + - im_switcher_start + + This message notifies that a new uim-im-switcher is started. + When an existing old uim-im-switcher receives im_switcher_start, + the existing uim-im-switcher must send im_switcher_quit + to quit newly started uim-im-switcher. + + See also im_switcher_quit. + + im_switcher_start = "im_switcher_start\n" + + - im_switcher_quit + + This message requests newly started uim-im-switcher to quit. + All uim-im-switcher must quit immediately after received this message. + + See also im_switcher_start. + + im_switcher_quit = "im_switcher_quit\n" Local Variables: mode: indented-text diff --git a/helper/im-switcher-gtk.c b/helper/im-switcher-gtk.c index af09ae2..56c170f 100644 --- a/helper/im-switcher-gtk.c +++ b/helper/im-switcher-gtk.c @@ -430,6 +430,10 @@ parse_helper_str(const char *sent_str) { if (g_str_has_prefix(sent_str, "im_list") == TRUE) { parse_helper_str_im_list(sent_str); + } else if (g_str_has_prefix(sent_str, "im_switcher_start") == TRUE) { + uim_helper_send_message(uim_fd, "im_switcher_quit\n"); + } else if (g_str_has_prefix(sent_str, "im_switcher_quit") == TRUE) { + gtk_main_quit(); } } @@ -556,6 +560,9 @@ main(int argc, char *argv[]) uim_fd = -1; check_helper_connection(); + /* To check if another uim-im-switcher exists */ + uim_helper_send_message( uim_fd, "im_switcher_start\n" ); + /* To load input method list */ uim_helper_send_message(uim_fd, "im_list_get\n"); diff --git a/qt4/switcher/qt4.cpp b/qt4/switcher/qt4.cpp index f29b42a..f5ac266 100644 --- a/qt4/switcher/qt4.cpp +++ b/qt4/switcher/qt4.cpp @@ -85,6 +85,9 @@ UimImSwitcher::UimImSwitcher( QWidget *parent ) uim_fd = -1; checkHelperConnection(); + /* to check if another uim-im-switcher exists */ + uim_helper_send_message( uim_fd, "im_switcher_start\n" ); + /* to load input method list */ uim_helper_send_message( uim_fd, "im_list_get\n" ); @@ -244,6 +247,10 @@ void UimImSwitcher::slotStdinActivated() reloadImList(); else if ( msg.startsWith( QLatin1String( "im_list" ) ) ) parseHelperStrImList( msg ); + else if ( msg.startsWith( QLatin1String( "im_switcher_start" ) ) ) + uim_helper_send_message( uim_fd, "im_switcher_quit\n" ); + else if ( msg.startsWith( QLatin1String( "im_switcher_quit" ) ) ) + QApplication::instance()->quit(); } } -- 1.6.4.2