[uim-commit] r851 - trunk/xim
ekato at freedesktop.org
ekato at freedesktop.org
Wed Jun 1 01:42:55 PDT 2005
Author: ekato
Date: 2005-06-01 01:42:52 -0700 (Wed, 01 Jun 2005)
New Revision: 851
Modified:
trunk/xim/canddisp.cpp
trunk/xim/canddisp.h
trunk/xim/helper.cpp
trunk/xim/helper.h
trunk/xim/main.cpp
trunk/xim/ximserver.cpp
trunk/xim/ximserver.h
Log:
* xim/helper.cpp (helper_disconnect_cb) : Make public function.
Close fd explicitly.
* xim/ximserver.cpp (InputContext::createUimContext) : Change
return type of the function and set mUc internally.
* xim/main.cpp (error_handler_setup) : New function divided from
pretrans_setup().
(pretrans_setup) : Move X error handler setting into
error_handler_setup().
(terminate_x_connection) : New function.
(reload_uim) : New function to re-initialize uim.
(main) : Handle SIGINT.
* xim/helper.h : Add prototype of helper_disconnect_cb().
(Canddisp::check_connection) : New function.
(Canddisp::activate) : Check connection after sending message.
(Canddisp::select) : Ditto.
(Canddisp::deactivate) : Ditto.
(Canddisp::show) : Ditto.
(Canddisp::hide) : Ditto.
(Canddisp::move) : Ditto.
(Canddisp::show_caret_state) : Ditto.
* xim/ximserver.h (class InputContext) : Change return type of
createUimContext and make it public.
(class XimServer) : Make ic_list public.
* xim/canddisp.h (class Canddisp) : Add new private member
check_connection().
(terminate_canddisp_connection) : New prototype.
Modified: trunk/xim/canddisp.cpp
===================================================================
--- trunk/xim/canddisp.cpp 2005-05-31 03:32:42 UTC (rev 850)
+++ trunk/xim/canddisp.cpp 2005-06-01 08:42:52 UTC (rev 851)
@@ -108,6 +108,7 @@
}
fprintf(candwin_w, "\n");
fflush(candwin_w);
+ check_connection();
}
void Canddisp::select(int index)
@@ -117,6 +118,7 @@
fprintf(candwin_w, "select\n");
fprintf(candwin_w, "%d\n\n", index);
fflush(candwin_w);
+ check_connection();
}
void Canddisp::deactivate()
@@ -125,6 +127,7 @@
return;
fprintf(candwin_w, "deactivate\n\n");
fflush(candwin_w);
+ check_connection();
}
void Canddisp::show()
@@ -133,6 +136,7 @@
return;
fprintf(candwin_w, "show\n\n");
fflush(candwin_w);
+ check_connection();
}
void Canddisp::hide()
@@ -141,6 +145,7 @@
return;
fprintf(candwin_w, "hide\n\n");
fflush(candwin_w);
+ check_connection();
}
void Canddisp::move(int x, int y)
@@ -152,6 +157,7 @@
fprintf(candwin_w, "%d\n", y);
fprintf(candwin_w, "\n");
fflush(candwin_w);
+ check_connection();
}
void Canddisp::show_caret_state(const char *str)
@@ -162,8 +168,19 @@
fprintf(candwin_w, "%s", str);
fprintf(candwin_w, "\n");
fflush(candwin_w);
+ check_connection();
}
+void Canddisp::check_connection()
+{
+ if (errno == EBADF || errno == EPIPE) {
+ disp = NULL;
+ int fd = fileno(candwin_r);
+ remove_current_fd_watch(fd);
+ delete this;
+ }
+}
+
static void candwin_read_cb(int fd, int ev)
{
char buf[1024];
@@ -214,3 +231,22 @@
}
return;
}
+
+void terminate_canddisp_connection()
+{
+ int fd_r, fd_w;
+
+ if (candwin_r) {
+ fd_r = fileno(candwin_r);
+ close(fd_r);
+ remove_current_fd_watch(fd_r);
+ }
+ if (candwin_w) {
+ fd_w = fileno(candwin_w);
+ close(fd_w);
+ }
+
+ disp = NULL;
+
+ return;
+}
Modified: trunk/xim/canddisp.h
===================================================================
--- trunk/xim/canddisp.h 2005-05-31 03:32:42 UTC (rev 850)
+++ trunk/xim/canddisp.h 2005-06-01 08:42:52 UTC (rev 851)
@@ -47,9 +47,12 @@
void hide();
void move(int x, int y);
void show_caret_state(const char *str);
+private:
+ void check_connection();
};
Canddisp *canddisp_singleton();
+void terminate_canddisp_connection();
#endif
/*
Modified: trunk/xim/helper.cpp
===================================================================
--- trunk/xim/helper.cpp 2005-05-31 03:32:42 UTC (rev 850)
+++ trunk/xim/helper.cpp 2005-06-01 08:42:52 UTC (rev 851)
@@ -237,10 +237,11 @@
}
}
-static void
+void
helper_disconnect_cb(void)
{
remove_current_fd_watch(lib_uim_fd);
+ close(lib_uim_fd);
lib_uim_fd = -1;
}
Modified: trunk/xim/helper.h
===================================================================
--- trunk/xim/helper.h 2005-05-31 03:32:42 UTC (rev 850)
+++ trunk/xim/helper.h 2005-06-01 08:42:52 UTC (rev 851)
@@ -35,6 +35,7 @@
#define _helper_h_included_
void check_helper_connection();
+void helper_disconnect_cb();
#endif
/*
Modified: trunk/xim/main.cpp
===================================================================
--- trunk/xim/main.cpp 2005-05-31 03:32:42 UTC (rev 850)
+++ trunk/xim/main.cpp 2005-06-01 08:42:52 UTC (rev 851)
@@ -327,11 +327,16 @@
check_pending_xevent();
}
+static void
+error_handler_setup()
+{
+ XSetErrorHandler(X_ErrorHandler);
+ XSetIOErrorHandler(X_IOErrorHandler);
+}
+
static int
pretrans_setup()
{
- XSetErrorHandler(X_ErrorHandler);
- XSetIOErrorHandler(X_IOErrorHandler);
int fd = XConnectionNumber(XimServer::gDpy);
add_fd_watch(fd, READ_OK, xEventRead);
@@ -481,6 +486,47 @@
host_byte_order = MSB_FIRST;
}
+static void
+terminate_x_connection()
+{
+ int fd = XConnectionNumber(XimServer::gDpy);
+
+ remove_current_fd_watch(fd);
+}
+
+static void
+reload_uim(int x)
+{
+ fprintf(stderr, "\nReloading uim...\n\n");
+
+ terminate_canddisp_connection();
+ helper_disconnect_cb();
+ terminate_x_connection();
+
+ std::map<Window, XimServer *>::iterator it;
+ std::list<InputContext *>::iterator it_c;
+
+ for (it = XimServer::gServerMap.begin(); it != XimServer::gServerMap.end(); it++) {
+ XimServer *xs = it->second;
+ for (it_c = xs->ic_list.begin(); it_c != xs->ic_list.end(); it_c++)
+ (*it_c)->clear();
+ }
+
+ uim_quit();
+ uim_info.clear();
+ get_uim_info();
+ print_uim_info();
+
+ for (it = XimServer::gServerMap.begin(); it != XimServer::gServerMap.end(); it++) {
+ XimServer *xs = it->second;
+ for (it_c = xs->ic_list.begin(); it_c != xs->ic_list.end(); it_c++) {
+ const char *engine = (*it_c)->get_engine_name();
+ (*it_c)->createUimContext(engine);
+ }
+ }
+ pretrans_setup();
+}
+
int
main(int argc, char **argv)
{
@@ -498,6 +544,7 @@
printf("Using full-synchronous XIM event flow\n");
signal(SIGPIPE, SIG_IGN);
+ signal(SIGINT, reload_uim);
check_helper_connection();
@@ -545,6 +592,7 @@
}
connection_setup();
+ error_handler_setup();
if (pretrans_setup() == -1)
return 0;
Modified: trunk/xim/ximserver.cpp
===================================================================
--- trunk/xim/ximserver.cpp 2005-05-31 03:32:42 UTC (rev 850)
+++ trunk/xim/ximserver.cpp 2005-06-01 08:42:52 UTC (rev 851)
@@ -290,7 +290,7 @@
mEngineName = NULL;
mLocaleName = NULL;
mFocusedContext = this;
- mUc = createUimContext(engine);
+ createUimContext(engine);
mCandwinActive = false;
mNumPage = 1;
mDisplayLimit = 0;
@@ -311,7 +311,7 @@
free(mLocaleName);
}
-uim_context
+void
InputContext::createUimContext(const char *engine)
{
char *locale;
@@ -354,12 +354,10 @@
setlocale(LC_CTYPE, locale);
- if (mLocaleName)
- free(mLocaleName);
+ free(mLocaleName);
mLocaleName = locale;
- if (mEngineName)
- free(mEngineName);
+ free(mEngineName);
mEngineName = strdup(real_im);
uim_context uc = uim_create_context((void *) this, "UTF-8",
@@ -383,7 +381,7 @@
if (mFocusedContext == this)
uim_prop_list_update(uc);
- return uc;
+ mUc = uc;
}
void
@@ -403,7 +401,7 @@
clear();
uim_release_context(mUc);
- mUc = createUimContext(engine); // mEngineName and locale will be set here.
+ createUimContext(engine); // mUc, mEngineName, and locale will be set here.
if (mConvdisp) {
mConvdisp->set_im_lang(get_im_lang_from_engine(mEngineName));
mConvdisp->set_locale_name(mLocaleName);
Modified: trunk/xim/ximserver.h
===================================================================
--- trunk/xim/ximserver.h 2005-05-31 03:32:42 UTC (rev 850)
+++ trunk/xim/ximserver.h 2005-06-01 08:42:52 UTC (rev 851)
@@ -168,6 +168,7 @@
const char *get_locale_name();
void changeContext(const char *engine);
void customContext(const char *custom, const char *val);
+ void createUimContext(const char *engine);
public:
static void commit_cb(void *, const char *);
static void clear_cb(void *);
@@ -189,7 +190,6 @@
Convdisp *mConvdisp;
uim_context mUc;
private:
- uim_context createUimContext(const char *engine);
static InputContext *mFocusedContext;
bool mCandwinActive;
int mDisplayLimit;
@@ -234,6 +234,7 @@
void set_im(const char *name);
void changeContext(const char *engine);
void customContext(const char *custom, const char *val);
+ std::list<InputContext *> ic_list;
public:
static XimServer *findServer(Window w);
static Display *gDpy;
@@ -243,7 +244,6 @@
Atom mServerAtom;
char *mIMName;
const char *mIMLang;
- std::list<InputContext *> ic_list;
bool mUsePreservedDefaultIM;
};
More information about the uim-commit
mailing list