[uim-commit] r796 - trunk/xim

ekato at freedesktop.org ekato at freedesktop.org
Sat Mar 19 00:21:56 PST 2005


Author: ekato
Date: 2005-03-19 00:21:53 -0800 (Sat, 19 Mar 2005)
New Revision: 796

Modified:
   trunk/xim/main.cpp
Log:
* xim/main.cpp (check_pending_xevent) : New function derived from
  xEventRead().
(main_loop) : Use longer timeout value.  Call
  check_pending_xevent() if select(2) timeout to prevent hang with
  uim_custom.
(xEventRead) : Use check_pending_xevent();
(main) : Ditto.


Modified: trunk/xim/main.cpp
===================================================================
--- trunk/xim/main.cpp	2005-03-19 06:36:00 UTC (rev 795)
+++ trunk/xim/main.cpp	2005-03-19 08:21:53 UTC (rev 796)
@@ -92,6 +92,7 @@
 
 static char *supported_locales;
 std::list<UIMInfo> uim_info;
+static void check_pending_xevent(void);
 
 bool
 pretrans_register()
@@ -144,8 +145,8 @@
     while (1) {
 	FD_ZERO(&rfds);
 	FD_ZERO(&wfds);
-	tv.tv_sec = 0;
-	tv.tv_usec = 100000;
+	tv.tv_sec = 2;
+	tv.tv_usec = 0;
 
 	std::map<int, fd_watch_struct>::iterator it;
 	int  fd_max = 0;
@@ -158,8 +159,10 @@
 	    if (fd_max < fd)
 		fd_max = fd;
 	}
-	if ((select(fd_max + 1, &rfds, &wfds, NULL, &tv)) == 0)
+	if ((select(fd_max + 1, &rfds, &wfds, NULL, &tv)) == 0) {
+	    check_pending_xevent();
 	    continue;
+	}
 
 	for (it = fd_watch_stat.begin(); it != fd_watch_stat.end(); it++) {
 	    int fd = it->first;
@@ -302,10 +305,8 @@
 }
 
 static void
-xEventRead(int fd, int ev)
+check_pending_xevent(void)
 {
-    XFlush(XimServer::gDpy);
-
     XEvent e;
     while (XPending(XimServer::gDpy)) {
 	XNextEvent(XimServer::gDpy, &e);
@@ -313,6 +314,13 @@
     }
 }
 
+static void
+xEventRead(int fd, int ev)
+{
+    XFlush(XimServer::gDpy);
+    check_pending_xevent();
+}
+
 static int
 pretrans_setup()
 {
@@ -538,11 +546,7 @@
 	return 0;
 
     // Handle pending events to prevent hang just after startup
-    XEvent e;
-    while (XPending(XimServer::gDpy)) {
-	XNextEvent(XimServer::gDpy, &e);
-	ProcXEvent(&e);
-    }
+    check_pending_xevent();
 
     main_loop();
     return 0;



More information about the Uim-commit mailing list