[maemo-commits] [maemo-commits] r14157 - in projects/haf/trunk/hildon-input-method-framework: . src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Fri Sep 28 11:49:32 EEST 2007
Author: tjunnone
Date: 2007-09-28 11:49:30 +0300 (Fri, 28 Sep 2007)
New Revision: 14157

Modified:
   projects/haf/trunk/hildon-input-method-framework/ChangeLog
   projects/haf/trunk/hildon-input-method-framework/src/hildon-im-context.c
Log:
2007-09-28  Tomas Junnonen  <tomas.junnonen at nokia.com>

        * src/hildon-im-context.c: Applied patch by Mohammad Anwari:
         - Compare surroundings and relative cursor positions therein
           when checking if the cursor has moved. This fixes a context
           reset being issued whenever the text shifts as a result of
           formatting being applied, or the client widget allocation
           changing.
        Fixes NB#69229, NB#71149.


Modified: projects/haf/trunk/hildon-input-method-framework/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-input-method-framework/ChangeLog	2007-09-28 08:21:37 UTC (rev 14156)
+++ projects/haf/trunk/hildon-input-method-framework/ChangeLog	2007-09-28 08:49:30 UTC (rev 14157)
@@ -1,3 +1,13 @@
+2007-09-28  Tomas Junnonen  <tomas.junnonen at nokia.com>
+
+	* src/hildon-im-context.c: Applied patch by Mohammad Anwari:
+	 - Compare surroundings and relative cursor positions therein
+	   when checking if the cursor has moved. This fixes a context
+	   reset being issued whenever the text shifts as a result of
+	   formatting being applied, or the client widget allocation
+	   changing.
+	Fixes NB#69229, NB#71149.
+
 2007-09-21  Mohammad Anwari  <mohammad.anwari at nokia.com> 
 
 	* Version 1:1.99.21-1

Modified: projects/haf/trunk/hildon-input-method-framework/src/hildon-im-context.c
===================================================================
--- projects/haf/trunk/hildon-input-method-framework/src/hildon-im-context.c	2007-09-28 08:21:37 UTC (rev 14156)
+++ projects/haf/trunk/hildon-input-method-framework/src/hildon-im-context.c	2007-09-28 08:49:30 UTC (rev 14157)
@@ -115,6 +115,8 @@
   gint prev_cursor_y;
 
   gchar *surrounding;
+  guint  prev_surrounding_hash;
+  guint  prev_surrounding_cursor_pos;
 };
 
 /* Initialisation/finalisation functions */
@@ -1762,17 +1764,37 @@
     /* Our own change */
     hildon_im_context_check_sentence_start(imc);
     imc->last_internal_change = FALSE;
+    imc->prev_surrounding_hash = 0;
   }
   else
   {
+    gboolean need_free;
+    gchar *surrounding;
+    gint   cpos;
+    guint  hash = 0;
+
+    need_free = gtk_im_context_get_surrounding(context, &surrounding, &cpos); 
+    if (surrounding)
+      hash = g_str_hash(surrounding);
+
+    if (need_free)
+      g_free(surrounding);
+
     /* Now we wish to see if cursor has actually moved.
        If cursor x/y hasn't moved, we're in same position */
-    if (area->y != imc->prev_cursor_y || area->x != imc->prev_cursor_x)
+    if ((area->y != imc->prev_cursor_y || area->x != imc->prev_cursor_x) &&
+        (imc->prev_surrounding_cursor_pos != cpos ||
+         imc->prev_surrounding_hash != hash ||
+         imc->prev_surrounding_hash == 0)
+       )
     {
       /* Moved, clear IM. */
       hildon_im_context_check_sentence_start(imc);
       hildon_im_context_reset_real(context);
     }
+
+    imc->prev_surrounding_hash = hash;
+    imc->prev_surrounding_cursor_pos = cpos;
   }
 
   imc->prev_cursor_y = area->y;
@@ -1991,6 +2013,7 @@
   /* If last_internal_change is still TRUE, it means set_cursor_location()
      wasn't called yet. This happens at least with GtkEntry where it's called
      in idle handler. */
+  
   if (self->last_internal_change && self->changed_count > 1)
   {
     /* External change seen, clear IM in set_cursor_location() handler */


More information about the maemo-commits mailing list