[uim-commit] r744 - in trunk: doc gtk helper xim

ekato at freedesktop.org ekato at freedesktop.org
Thu Mar 3 07:46:27 PST 2005


Author: ekato
Date: 2005-03-03 07:46:24 -0800 (Thu, 03 Mar 2005)
New Revision: 744

Modified:
   trunk/doc/HELPER-CANDWIN
   trunk/gtk/caret-state-indicator.c
   trunk/gtk/gtk-im-uim.c
   trunk/helper/Makefile.am
   trunk/helper/helper-candwin-gtk.c
   trunk/xim/canddisp.cpp
   trunk/xim/canddisp.h
   trunk/xim/convdisp.cpp
   trunk/xim/locale.cpp
   trunk/xim/xim.h
   trunk/xim/ximic.cpp
   trunk/xim/ximserver.cpp
   trunk/xim/ximserver.h
Log:
* gtk/caret-state-indicator.c (caret_state_indicator_update) :
  Move check for "bridge-show-input-state?" into gtk-im-uim.c.
* gtk/gtk-im-uim.c (update_prop_label_cb) : Check
  "bridge-show-input-state?" here.

* helper/Makefile.am : Add gtk/caret-state-indicator.{c,h} as
  uim_candwin_gtk_SOURCES.
* helper/helper-candwin-gtk.c : Use caret-state-indicator.{c,h}
  for uim-xim.
(struct _UIMCandidateWindow) : Add caret_state_indicator pointer.
(candidate_window_init) : Initialize caret_state_indicator.
(candwin_move) : Set cursor location of caret_state_indicator.
(caret_state_show) : New function.  Show caret state indicator.
(str_parse) : Handle "show_caret_state" message.
* doc /HELPER-CANDWIN : Add new protocal "show_caret_state".
* xim/xim.h (class XimIC) : Add public member move_candwin.
* xim/ximic.cpp (XimIC::move_candwin) : New function.
(setFocus) : Move move_candwin() into InputContext::focusIn().
* xim/ximserver.cpp (InputContext::focusIn) : Move candwin here.
(InputContext::update_prop_label) : Check
  "bridge-show-input-state?".
* xim/convdisp.cpp (ConvdispOv::ConvdispOv) : Initialize
  revised_spot_y in the constructor.
(ConvdispOv::update_preedit) : Move check for preedit string into
  draw_preedit().
(ConvdispOv::draw_preedit) : Check preedit string here.  Fix
  comment.
(ConvdispOs::update_preedit) : Call move_candwin() at first.
* xim/canddisp.h (class canddisp) : Add public member
  show_caret_state().
* xim/canddisp.cpp (Canddisp::show_caret_state) : New function.
* xim/ximserver.h (class Locale) : Add virtual destructor.
* xim/locale.cpp : Fix compiler warning about destructor.


Modified: trunk/doc/HELPER-CANDWIN
===================================================================
--- trunk/doc/HELPER-CANDWIN	2005-03-03 07:26:04 UTC (rev 743)
+++ trunk/doc/HELPER-CANDWIN	2005-03-03 15:46:24 UTC (rev 744)
@@ -20,7 +20,8 @@
 	      move       |
 	      show       |
 	      hide       |
-	      deactivate) "\n" "\n"
+	      deactivate |
+	      show_caret_state) "\n" "\n"
   charset_specifier = "charset=" charset "\n"
   charset = "UTF-8" | "EUC-JP" | "GB18030" |
             <or any name that can be specified as iconv_open(3) argument>
@@ -68,6 +69,12 @@
 
     deactivate = "deactivate" "\n"
 
+  7. show_caret_state
+    Deactivating the candidate window
+
+    show_caret_state = "show_caret_state" "\n" caret_state
+    caret_state = "\n" str
+
 Sending Message format BNF
   session  = messages
   messages = messages message | message

Modified: trunk/gtk/caret-state-indicator.c
===================================================================
--- trunk/gtk/caret-state-indicator.c	2005-03-03 07:26:04 UTC (rev 743)
+++ trunk/gtk/caret-state-indicator.c	2005-03-03 15:46:24 UTC (rev 744)
@@ -36,7 +36,6 @@
 #include <uim/uim.h>
 #include "uim/config.h"
 #include "uim/uim-helper.h"
-#include "uim/uim-compat-scm.h"
 #include "uim/gettext.h"
 
 /*
@@ -68,13 +67,8 @@
   GtkWidget *label = g_object_get_data(G_OBJECT(window), "label");
   gint cursor_x = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(window), "cursor_x"));
   gint cursor_y = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(window), "cursor_y"));
-  uim_bool show_state = uim_scm_symbol_value_bool("bridge-show-input-state?");
   gchar **labels;
 
-  if(show_state == UIM_FALSE) {
-    return;
-  }
-
   labels = g_strsplit(str, "\t", 2);
   gtk_window_move(GTK_WINDOW(window), topwin_x + cursor_x, topwin_y + cursor_y + 3);
   gtk_label_set_text(GTK_LABEL(label), labels[0]);

Modified: trunk/gtk/gtk-im-uim.c
===================================================================
--- trunk/gtk/gtk-im-uim.c	2005-03-03 07:26:04 UTC (rev 743)
+++ trunk/gtk/gtk-im-uim.c	2005-03-03 15:46:24 UTC (rev 744)
@@ -51,6 +51,7 @@
 #include "uim/uim-im-switcher.h"
 #include "uim/config.h"
 #include "uim/gettext.h"
+#include "uim/uim-compat-scm.h"
 #include "uim-cand-win-gtk.h"
 #include "caret-state-indicator.h"
 
@@ -715,6 +716,7 @@
   IMUIMContext *uic = (IMUIMContext *)ptr;
   GString *tmp;
   gint x, y;
+  uim_bool show_state;
 
   if (uic != focused_context)
     return;
@@ -725,8 +727,11 @@
   uim_helper_send_message(im_uim_fd, tmp->str);
   g_string_free(tmp, TRUE);
 
-  gdk_window_get_origin(uic->win, &x, &y);
-  caret_state_indicator_update(uic->caret_state_indicator, x, y, str);
+  show_state = uim_scm_symbol_value_bool("bridge-show-input-state?");
+  if (show_state == UIM_TRUE) {
+    gdk_window_get_origin(uic->win, &x, &y);
+    caret_state_indicator_update(uic->caret_state_indicator, x, y, str);
+  }
 }
 
 static void

Modified: trunk/helper/Makefile.am
===================================================================
--- trunk/helper/Makefile.am	2005-03-03 07:26:04 UTC (rev 743)
+++ trunk/helper/Makefile.am	2005-03-03 15:46:24 UTC (rev 744)
@@ -47,7 +47,9 @@
 bin_PROGRAMS += uim-pref-gtk
 endif
 
-uim_candwin_gtk_SOURCES  = helper-candwin-gtk.c
+uim_candwin_gtk_SOURCES  = helper-candwin-gtk.c \
+			   ../gtk/caret-state-indicator.c \
+			   ../gtk/caret-state-indicator.h
 uim_candwin_gtk_LDADD    = @GTK2_LIBS@ $(top_builddir)/uim/libuim.la
 uim_candwin_gtk_CPPFLAGS = -I$(top_srcdir)
 uim_candwin_gtk_CFLAGS   = @GTK2_CFLAGS@  -Wall

Modified: trunk/helper/helper-candwin-gtk.c
===================================================================
--- trunk/helper/helper-candwin-gtk.c	2005-03-03 07:26:04 UTC (rev 743)
+++ trunk/helper/helper-candwin-gtk.c	2005-03-03 15:46:24 UTC (rev 744)
@@ -44,6 +44,8 @@
 #include <sys/types.h>
 #include <unistd.h>
 
+#include "../gtk/caret-state-indicator.h"
+
 #define UIM_TYPE_CANDIDATE_WINDOW	(candidate_window_get_type())
 #define UIM_CANDIDATE_WINDOW(obj)	(G_TYPE_CHECK_INSTANCE_CAST ((obj), candidate_window_get_type(), UIMCandidateWindow))
 #define UIM_IS_CANDIDATE_WINDOW(obj)	(G_TYPE_CHECK_INSTANCE_TYPE ((obj), UIM_TYPE_CANDIDATE_WINDOW))
@@ -72,6 +74,8 @@
   gint width;
   gint height;
 
+  GtkWidget *caret_state_indicator;
+
   gboolean is_active;
 };
 
@@ -365,6 +369,7 @@
   cwin->pos_x = 0;
   cwin->pos_y = 0;
   cwin->is_active = FALSE;
+  cwin->caret_state_indicator = caret_state_indicator_new();
 
   gtk_widget_show(cwin->scrolled_window);
   gtk_widget_show(cwin->view);
@@ -482,10 +487,17 @@
 static void
 candwin_move(char **str)
 {
+  GdkRectangle cursor_location;
+
   sscanf(str[1], "%d", &cwin->pos_x);
   sscanf(str[2], "%d", &cwin->pos_y);
 
+  cursor_location.x = 0;
+  cursor_location.y = 0;
+  cursor_location.height = 0;
+
   uim_cand_win_gtk_layout();
+  caret_state_indicator_set_cursor_location(cwin->caret_state_indicator, &cursor_location);
 }
 
 static void
@@ -502,6 +514,13 @@
   cwin->is_active = FALSE;
 }
 
+static void
+caret_state_show(gchar **str)
+{
+  caret_state_indicator_update(cwin->caret_state_indicator, cwin->pos_x, cwin->pos_y, str[1]);
+  gtk_widget_show(GTK_WIDGET(cwin->caret_state_indicator));
+}
+
 static void str_parse(gchar *str)
 {
   gchar **tmp;
@@ -523,6 +542,8 @@
       candwin_move(tmp);
     } else if (strcmp("deactivate", command) == 0) {
       candwin_deactivate();
+    } else if (strcmp("show_caret_state", command) == 0) {
+      caret_state_show(tmp);
     }
   }
   g_strfreev(tmp);

Modified: trunk/xim/canddisp.cpp
===================================================================
--- trunk/xim/canddisp.cpp	2005-03-03 07:26:04 UTC (rev 743)
+++ trunk/xim/canddisp.cpp	2005-03-03 15:46:24 UTC (rev 744)
@@ -154,6 +154,16 @@
     fflush(candwin_w);
 }
 
+void Canddisp::show_caret_state(const char *str)
+{
+    if (candwin_w == NULL)
+	return;
+    fprintf(candwin_w, "show_caret_state\n");
+    fprintf(candwin_w, "%s", str);
+    fprintf(candwin_w, "\n");
+    fflush(candwin_w);
+}
+
 static void candwin_read_cb(int fd, int ev)
 {
     char buf[1024];

Modified: trunk/xim/canddisp.h
===================================================================
--- trunk/xim/canddisp.h	2005-03-03 07:26:04 UTC (rev 743)
+++ trunk/xim/canddisp.h	2005-03-03 15:46:24 UTC (rev 744)
@@ -46,6 +46,7 @@
     void show();
     void hide();
     void move(int x, int y);
+    void show_caret_state(const char *str);
 };
 
 Canddisp *canddisp_singleton();

Modified: trunk/xim/convdisp.cpp
===================================================================
--- trunk/xim/convdisp.cpp	2005-03-03 07:26:04 UTC (rev 743)
+++ trunk/xim/convdisp.cpp	2005-03-03 15:46:24 UTC (rev 744)
@@ -685,6 +685,9 @@
     m_initial_lang = strdup(mIMLang);
     m_initial_fontset = NULL;
     m_lang_changed = false;
+#ifdef FLASHPLAYER_WORKAROUND
+    revised_spot_y = -1;
+#endif
 }
 
 ConvdispOv::~ConvdispOv()
@@ -717,14 +720,6 @@
 
 void ConvdispOv::update_preedit()
 {
-    if (!m_pe)
-	return;
-
-    if (!m_pe->get_char_count()) {
-	clear_preedit();
-	return;
-    }
-
     draw_preedit();
     move_candwin();
 }
@@ -842,7 +837,15 @@
 
 void ConvdispOv::draw_preedit()
 {
+    if (!m_pe)
+	return;
+
     m_ce_len = m_pe->get_char_count();
+    if (!m_ce_len) {
+	clear_preedit();
+	return;
+    }
+
     if (!check_win())
 	return;
 
@@ -903,7 +906,7 @@
 		    // preedit area goes beyond the top window's geometry
 		    if ((y - m_atr->area.y) < topattr.y) {
 			// Set preedit at upper side of the top
-			// window.  But it may doesn't work because it
+			// window.  But it may not work because it
 			// lacks height for window manager's title bar
 			// and some toolbars of browser...
 			m_ov_win->set_pos(m_atr->area.x, topattr.y - (y - m_atr->area.y));
@@ -1119,6 +1122,7 @@
 
 void ConvdispOs::update_preedit()
 {
+    move_candwin();
     if (!m_pe)
 	return;
 
@@ -1170,7 +1174,6 @@
       t->pushC32(style);
       mConn->push_packet(t);
       */
-    move_candwin();
 }
       
 void ConvdispOs::move_candwin()

Modified: trunk/xim/locale.cpp
===================================================================
--- trunk/xim/locale.cpp	2005-03-03 07:26:04 UTC (rev 743)
+++ trunk/xim/locale.cpp	2005-03-03 15:46:24 UTC (rev 744)
@@ -187,6 +187,10 @@
     return c;
 }
 
+Locale::~Locale()
+{
+}
+
 bool
 Locale::supportOverTheSpot()
 {
@@ -244,7 +248,8 @@
 
 class UTF8_Locale : public Locale {
 public:
-    UTF8_Locale::UTF8_Locale(const char *lang);
+    UTF8_Locale(const char *lang);
+    virtual ~UTF8_Locale();
     virtual char *uStringToCtext(uString *us, const char *encoding) {
 	char *str = ustring_to_utf8_str(us);
 	XTextProperty prop;
@@ -282,6 +287,11 @@
     mLocaleName = strdup(compose_localenames_from_im_lang(im_lang));
 }
 
+UTF8_Locale::~UTF8_Locale()
+{
+    free(mLocaleName);
+}
+
 static const char *
 get_valid_locales(const char *locales)
 {

Modified: trunk/xim/xim.h
===================================================================
--- trunk/xim/xim.h	2005-03-03 07:26:04 UTC (rev 743)
+++ trunk/xim/xim.h	2005-03-03 15:46:24 UTC (rev 744)
@@ -281,6 +281,7 @@
     void changeContext(const char *engine);
     const char *get_encoding();
     const char *get_lang_region();
+    void move_candwin();
 
 public:
     static XimIC *get_current_ic();

Modified: trunk/xim/ximic.cpp
===================================================================
--- trunk/xim/ximic.cpp	2005-03-03 07:26:04 UTC (rev 743)
+++ trunk/xim/ximic.cpp	2005-03-03 15:46:24 UTC (rev 744)
@@ -367,6 +367,12 @@
     return mIMid;
 }
 
+void XimIC::move_candwin()
+{
+    if (mConvdisp)
+	mConvdisp->move_candwin();
+}
+
 void XimIC::setFocus()
 {
     if (!mIsActive)
@@ -374,18 +380,21 @@
 
     current_ic = this;
     mIsActive = true;
+
+    bool is_candwin_active = m_kkContext->hasActiveCandwin();
+
+    if (mConvdisp && is_candwin_active == false) {
+	// unset_focus before move_candwin in m_kkContext->focusIn()
+	mConvdisp->unset_focus();
+    }
+
     m_kkContext->focusIn();
 
-    if (mConvdisp) {
+    if (mConvdisp && is_candwin_active == true) {
 	// Updating preedit here causes string mismatch if the context
 	// receives XIM_RESET_IC after XIM_SET_IC_FOCUS.  Should only
 	// update candidate window.
-	if (m_kkContext->hasActiveCandwin()) {
-	    mConvdisp->move_candwin();
-	    m_kkContext->candidate_update();
-	} else {
-	    mConvdisp->unset_focus();
-	}
+	m_kkContext->candidate_update();
     }
 }
 

Modified: trunk/xim/ximserver.cpp
===================================================================
--- trunk/xim/ximserver.cpp	2005-03-03 07:26:04 UTC (rev 743)
+++ trunk/xim/ximserver.cpp	2005-03-03 15:46:24 UTC (rev 744)
@@ -54,6 +54,7 @@
 #include "helper.h"
 
 #include "uim/uim-helper.h"
+#include "uim/uim-compat-scm.h"
 
 #ifndef __GNUC__
 # ifdef HAVE_ALLOCA_H
@@ -481,6 +482,7 @@
     check_helper_connection();
     uim_helper_client_focus_in(mUc);
     mFocusedContext = this;
+    mXic->move_candwin(); // move candwin before updating prop label
     uim_prop_list_update(mUc);	
     uim_prop_label_update(mUc);	
 }
@@ -790,12 +792,18 @@
 void InputContext::update_prop_label(const char *str)
 {
     char *buf;
+    uim_bool show_caret_state = uim_scm_symbol_value_bool("bridge-show-input-state?");
 
     asprintf(&buf, "prop_label_update\ncharset=UTF-8\n%s", str);
     if (!buf)
 	return;
     uim_helper_send_message(lib_uim_fd, buf);
     free(buf);
+    
+    if (show_caret_state == UIM_TRUE) {
+	Canddisp *disp = canddisp_singleton();
+	disp->show_caret_state(str);
+    }
 }
 
 const char *InputContext::get_engine_name()

Modified: trunk/xim/ximserver.h
===================================================================
--- trunk/xim/ximserver.h	2005-03-03 07:26:04 UTC (rev 743)
+++ trunk/xim/ximserver.h	2005-03-03 15:46:24 UTC (rev 744)
@@ -203,6 +203,7 @@
 
 class Locale {
 public:
+    virtual ~Locale();
     virtual char *uStringToCtext(uString *us, const char *encoding) = 0;
     virtual bool supportOverTheSpot();
     virtual void set_localename_from_im_lang(const char *im_lang) = 0;



More information about the Uim-commit mailing list