[uim-commit] r1358 - trunk/fep

yamamoto at freedesktop.org yamamoto at freedesktop.org
Mon Aug 29 08:20:11 PDT 2005


Author: yamamoto
Date: 2005-08-29 08:20:01 -0700 (Mon, 29 Aug 2005)
New Revision: 1358

Modified:
   trunk/fep/callbacks.c
   trunk/fep/callbacks.h
   trunk/fep/draw.c
   trunk/fep/draw.h
   trunk/fep/udsock.c
   trunk/fep/uim-fep.c
Log:
* fep/uim-fep.c (main_loop) :
  Revert the part of the changes of r1342 and r1343.
  Call update_backtick() every time user press keys.

* fep/callbacks.c
  (press_key) : Revert to r1341.
  (START_CALLBACKS) : Merge to start_callbacks.
  (activate_cb, select_cb, shift_page_cb, deactivate_cb, commit_cb,
    clear_cb, pushback_cb, mode_update_cb) : Replace START_CALLBACKS
      with start_callbacks

* fep/draw.c (draw, draw_statusline_*) : Call end_callbacks().

* fep/udsock.c (init_recvsocket) : chmod socket.


Modified: trunk/fep/callbacks.c
===================================================================
--- trunk/fep/callbacks.c	2005-08-29 14:01:45 UTC (rev 1357)
+++ trunk/fep/callbacks.c	2005-08-29 15:20:01 UTC (rev 1358)
@@ -154,9 +154,9 @@
   }
 }
 
-int *press_key(int key, int key_state)
+int press_key(int key, int key_state)
 {
-  static int raw_and_need_draw[2];
+  int raw;
 #if defined DEBUG && DEBUG > 2
   if (32 <= key && key <= 127) {
     debug2(("press key = %c key_state = %d\n", key, key_state));
@@ -164,22 +164,19 @@
     debug2(("press key = %d key_state = %d\n", key, key_state));
   }
 #endif
-  raw_and_need_draw[0] = uim_press_key(g_context, key, key_state);
+  raw = uim_press_key(g_context, key, key_state);
   uim_release_key(g_context, key, key_state);
-  raw_and_need_draw[1] = end_callbacks();
-  return raw_and_need_draw;
+  return raw;
 }
 
-#define START_CALLBACKS                        \
-do {                                           \
-  if (!s_start_callbacks) {                    \
-    s_start_callbacks = TRUE;                  \
-    start_callbacks();                         \
-  }                                            \
-} while (FALSE)
 
 void start_callbacks(void)
 {
+  if (s_start_callbacks) {
+    return;
+  }
+  s_start_callbacks = TRUE;
+
   debug2(("\n\nstart_callbacks()\n"));
   if (s_commit_str != NULL) {
     free(s_commit_str);
@@ -201,6 +198,9 @@
   s_mode = uim_get_current_mode(g_context);
 }
 
+/*
+ * ¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô¤¬¸Æ¤Ð¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢FALSE¤òÊÖ¤¹
+ */
 int end_callbacks(void)
 {
   debug2(("end_callbacks()\n\n"));
@@ -329,7 +329,7 @@
 static void activate_cb(void *ptr, int nr, int display_limit)
 {
   debug2(("activate_cb(nr = %d display_limit = %d)\n", nr, display_limit));
-  START_CALLBACKS;
+  start_callbacks();
   reset_candidate();
   s_candidate.nr = nr;
   s_candidate.limit = display_limit;
@@ -347,7 +347,7 @@
   debug2(("select_cb(index = %d)\n", index));
   return_if_fail(s_candidate.nr != UNDEFINED);
   return_if_fail(0 <= index && index < s_candidate.nr);
-  START_CALLBACKS;
+  start_callbacks();
   s_candidate.index = index;
   s_candidate.page = index2page(index);
 }
@@ -363,7 +363,7 @@
   int index;
   debug2(("shift_page_cb(direction = %d)\n", direction));
   return_if_fail(s_candidate.nr != UNDEFINED);
-  START_CALLBACKS;
+  start_callbacks();
   if (direction == 0) {
     direction = -1;
   }
@@ -382,7 +382,7 @@
 static void deactivate_cb(void *ptr)
 {
   debug2(("deactivate_cb()\n"));
-  START_CALLBACKS;
+  start_callbacks();
   reset_candidate();
 }
 
@@ -391,14 +391,14 @@
 {
   debug2(("commit_cb(commit_str = \"%s\")\n", commit_str));
   return_if_fail(commit_str != NULL);
-  START_CALLBACKS;
+  start_callbacks();
   s_commit_str = realloc(s_commit_str, strlen(s_commit_str) + strlen(commit_str) + 1);
   strcat(s_commit_str, commit_str);
 }
 
 static void clear_cb(void *ptr)
 {
-  START_CALLBACKS;
+  start_callbacks();
   if (s_preedit != NULL) {
     free_preedit(s_preedit);
   }
@@ -417,7 +417,7 @@
   static int cursor = FALSE;
   debug2(("pushback_cb(attr = %d str = \"%s\")\n", attr, str));
   return_if_fail(str && s_preedit != NULL);
-  START_CALLBACKS;
+  start_callbacks();
   width = strwidth(str);
   /* UPreeditAttr_Cursor¤Î¤È¤­¤Ë¶õʸ»úÎó¤È¤Ï¸Â¤é¤Ê¤¤ */
   if (attr & UPreeditAttr_Cursor) {
@@ -476,7 +476,7 @@
 static void mode_update_cb(void *ptr, int mode)
 {
   debug2(("mode_update_cb(mode = %d)\n", mode));
-  START_CALLBACKS;
+  start_callbacks();
   s_mode = mode;
 }
 

Modified: trunk/fep/callbacks.h
===================================================================
--- trunk/fep/callbacks.h	2005-08-29 14:01:45 UTC (rev 1357)
+++ trunk/fep/callbacks.h	2005-08-29 15:20:01 UTC (rev 1358)
@@ -51,7 +51,7 @@
 };
 
 void init_callbacks(void);
-int* press_key(int key, int key_state);
+int press_key(int key, int key_state);
 void start_callbacks(void);
 int end_callbacks(void);
 char *get_commit_str(void);

Modified: trunk/fep/draw.c
===================================================================
--- trunk/fep/draw.c	2005-08-29 14:01:45 UTC (rev 1357)
+++ trunk/fep/draw.c	2005-08-29 15:20:01 UTC (rev 1358)
@@ -95,7 +95,6 @@
 static int s_winch = FALSE;
 
 static void init_backtick(void);
-static void update_backtick(void);
 static void start_preedit(void);
 static void end_preedit(void);
 static void draw_statusline(int force, int restore, int visible, int draw_background);
@@ -137,7 +136,7 @@
   }
 }
 
-static void update_backtick(void)
+void update_backtick(void)
 {
   char sendbuf[CANDSIZE];
   if (s_candbuf[0] == '\0') {
@@ -161,6 +160,10 @@
 
   int i;
 
+  if (!end_callbacks()) {
+    return;
+  }
+
   /* üËö¥µ¥¤¥º¤¬Êѹ¹¤µ¤ì¤¿¤È¤­¤Ïs_head¤òÊѹ¹¤¹¤ë */
   if (s_winch && g_start_preedit) {
     if (g_opt.no_report_cursor) {
@@ -546,6 +549,12 @@
  */
 void draw_statusline_restore(void)
 {
+  if (!end_callbacks()) {
+    if (g_opt.status_type == BACKTICK) {
+      update_backtick();
+    }
+    return;
+  }
   draw_statusline(FALSE, TRUE, TRUE, FALSE);
 }
 
@@ -555,6 +564,7 @@
  */
 void draw_statusline_force_no_restore(void)
 {
+  end_callbacks();
   draw_statusline(TRUE, FALSE, FALSE, TRUE);
 }
 
@@ -564,6 +574,7 @@
  */
 void draw_statusline_force_restore(void)
 {
+  end_callbacks();
   draw_statusline(TRUE, TRUE, TRUE, TRUE);
 }
 

Modified: trunk/fep/draw.h
===================================================================
--- trunk/fep/draw.h	2005-08-29 14:01:45 UTC (rev 1357)
+++ trunk/fep/draw.h	2005-08-29 15:20:01 UTC (rev 1358)
@@ -45,6 +45,7 @@
 extern int g_commit;
 
 void init_draw(int master, const char *path_getmode);
+void update_backtick(void);
 void draw(void);
 void draw_statusline_restore(void);
 void draw_statusline_force_no_restore(void);

Modified: trunk/fep/udsock.c
===================================================================
--- trunk/fep/udsock.c	2005-08-29 14:01:45 UTC (rev 1357)
+++ trunk/fep/udsock.c	2005-08-29 15:20:01 UTC (rev 1358)
@@ -56,6 +56,9 @@
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
 
 #include "udsock.h"
 
@@ -117,6 +120,7 @@
     perror(sock_path);
     exit(1);
   }
+  chmod(sock_path, S_IRUSR|S_IWUSR);
 }
 
 void close_socket(void)

Modified: trunk/fep/uim-fep.c
===================================================================
--- trunk/fep/uim-fep.c	2005-08-29 14:01:45 UTC (rev 1357)
+++ trunk/fep/uim-fep.c	2005-08-29 15:20:01 UTC (rev 1358)
@@ -781,14 +781,10 @@
         buf[end + 1] = '\0';
         mode = atoi(&buf[start]);
         if (mode != uim_get_current_mode(g_context)) {
-          int need_draw;
           debug2(("mode change %d\n", mode));
           uim_set_mode(g_context, mode);
           /* callbacks_set_mode(uim_get_current_mode(g_context)); */
-          need_draw = end_callbacks();
-          if (need_draw) {
-            draw_statusline_restore();
-          }
+          draw_statusline_restore();
         }
       }
     }
@@ -862,11 +858,10 @@
           if (g_opt.print_key) {
             print_key(key, key_state);
           } else {
-            int *raw_and_need_draw = press_key(key, key_state);
-            int raw = raw_and_need_draw[0];
-            int need_draw = raw_and_need_draw[1];
-            if (need_draw) {
-              draw();
+            int raw = press_key(key, key_state);
+            draw();
+            if (g_opt.status_type == BACKTICK) {
+              update_backtick();
             }
             if (raw && !g_start_preedit) {
               if (key_state & UMod_Alt) {
@@ -915,12 +910,8 @@
     }
 
     if (g_helper_fd >= 0 && FD_ISSET(g_helper_fd, &fds)) {
-      int need_draw;
       helper_handler();
-      need_draw = end_callbacks();
-      if (need_draw) {
-        draw();
-      }
+      draw();
     }
   }
 }



More information about the uim-commit mailing list