===============================
diff -u -r gtk+-2.8.0/gdk/x11/gdkevents-x11.c gtk+-2.8.0.phone/gdk/x11/gdkevents-x11.c
--- gtk+-2.8.0/gdk/x11/gdkevents-x11.c	2005-08-01 12:01:24.000000000 -0400
+++ gtk+-2.8.0.phone/gdk/x11/gdkevents-x11.c	2005-10-12 13:30:51.000000000 -0400
@@ -2797,6 +2797,8 @@
   { "Gtk/MenuBarAccel", "gtk-menu-bar-accel" },
   { "Gtk/CursorThemeName", "gtk-cursor-theme-name" },
   { "Gtk/CursorThemeSize", "gtk-cursor-theme-size" },
+//yjyu modifies here
+  { "Gtk/PhoneKeypadMode", "gtk-phone-keypad-mode" },
   { "Xft/Antialias", "gtk-xft-antialias" },
   { "Xft/Hinting", "gtk-xft-hinting" },
   { "Xft/HintStyle", "gtk-xft-hintstyle" },

=======================
diff -u -r gtk+-2.8.0/gtk/gtkcombobox.c gtk+-2.8.0.phone/gtk/gtkcombobox.c
--- gtk+-2.8.0/gtk/gtkcombobox.c	2005-07-21 23:38:14.000000000 -0400
+++ gtk+-2.8.0.phone/gtk/gtkcombobox.c	2005-10-12 14:47:26.000000000 -0400
@@ -3483,6 +3483,7 @@
   gboolean found;
   GtkTreeIter iter;
   GtkTreeIter new_iter;
+  gboolean keypad;
 
   if (combo_box->priv->model == NULL)
     return FALSE;
@@ -3528,6 +3529,29 @@
     case GDK_KP_End:
       found = tree_last (combo_box, combo_box->priv->model, &new_iter, FALSE);
       break;
+	//yjyu modifies here
+    case GDK_Left:
+    case GDK_KP_Left:
+	g_object_get(gtk_settings_get_default(), "gtk-phone-keypad-mode", &keypad, NULL);
+	if (keypad)
+	{
+		if (gtk_widget_get_direction(GTK_WIDGET(combo_box)) == GTK_TEXT_DIR_RTL)
+       			gtk_widget_child_focus (gtk_widget_get_toplevel (combo_box), GTK_DIR_TAB_FORWARD);
+		else
+       			gtk_widget_child_focus (gtk_widget_get_toplevel (combo_box), GTK_DIR_TAB_BACKWARD);
+	}
+	break;
+    case GDK_Right:
+    case GDK_KP_Right:
+	g_object_get(gtk_settings_get_default(), "gtk-phone-keypad-mode", &keypad, NULL);
+	if (keypad)
+	{
+		if (gtk_widget_get_direction(GTK_WIDGET(combo_box)) == GTK_TEXT_DIR_RTL)
+       			gtk_widget_child_focus (gtk_widget_get_toplevel (combo_box), GTK_DIR_TAB_BACKWARD);
+		else
+       			gtk_widget_child_focus (gtk_widget_get_toplevel (combo_box), GTK_DIR_TAB_FORWARD);
+	}
+	break;
     default:
       return FALSE;
     }

==================================================
diff -u -r gtk+-2.8.0/gtk/gtkcontainer.c gtk+-2.8.0.phone/gtk/gtkcontainer.c
--- gtk+-2.8.0/gtk/gtkcontainer.c	2005-03-26 00:49:14.000000000 -0500
+++ gtk+-2.8.0.phone/gtk/gtkcontainer.c	2005-10-12 15:01:21.000000000 -0400
@@ -1564,7 +1564,7 @@
 
       if (container->has_focus_chain &&
 	  (direction == GTK_DIR_TAB_FORWARD ||
-	   direction == GTK_DIR_TAB_BACKWARD))
+	   direction == GTK_DIR_TAB_BACKWARD))   //yjyu, fixme, should i add GTK_DIR_LEFT/RIGHT here?
 	{
 	  sorted_children = g_list_copy (children);
 	  
@@ -1583,6 +1583,7 @@
   return return_val;
 }
 
+
 static gint
 tab_compare (gconstpointer a,
 	     gconstpointer b,
@@ -1984,18 +1985,40 @@
 			   GtkWidget        *old_focus)
 {
   children = g_list_copy (children);
+	gboolean keypad;
   
   switch (direction)
     {
+
     case GTK_DIR_TAB_FORWARD:
     case GTK_DIR_TAB_BACKWARD:
       return gtk_container_focus_sort_tab (container, children, direction, old_focus);
     case GTK_DIR_UP:
     case GTK_DIR_DOWN:
       return gtk_container_focus_sort_up_down (container, children, direction, old_focus);
+	//yjyu modifies here 
     case GTK_DIR_LEFT:
+	g_object_get(gtk_settings_get_default(), "gtk-phone-keypad-mode", &keypad, NULL);
+	if (keypad)
+	{
+		if (gtk_widget_get_direction(GTK_WIDGET (container)) == GTK_TEXT_DIR_RTL)
+      			return gtk_container_focus_sort_tab (container, children, GTK_DIR_TAB_FORWARD, old_focus);
+		else
+      			return gtk_container_focus_sort_tab (container, children, GTK_DIR_TAB_BACKWARD, old_focus);
+	}
+	else
+      		return gtk_container_focus_sort_left_right (container, children, direction, old_focus);
     case GTK_DIR_RIGHT:
-      return gtk_container_focus_sort_left_right (container, children, direction, old_focus);
+	g_object_get(gtk_settings_get_default(), "gtk-phone-keypad-mode", &keypad, NULL);
+	if (keypad)
+	{
+		if (gtk_widget_get_direction(GTK_WIDGET (container)) == GTK_TEXT_DIR_RTL)
+      			return gtk_container_focus_sort_tab (container, children, GTK_DIR_TAB_BACKWARD, old_focus);
+		else
+      			return gtk_container_focus_sort_tab (container, children, GTK_DIR_TAB_FORWARD, old_focus);
+	}
+	else
+      		return gtk_container_focus_sort_left_right (container, children, direction, old_focus);
     }
 
   g_assert_not_reached ();
===================================================
diff -u -r gtk+-2.8.0/gtk/gtkentry.c gtk+-2.8.0.phone/gtk/gtkentry.c
--- gtk+-2.8.0/gtk/gtkentry.c	2005-07-19 17:09:03.000000000 -0400
+++ gtk+-2.8.0.phone/gtk/gtkentry.c	2005-10-12 15:03:55.000000000 -0400
@@ -2384,13 +2384,17 @@
 		       gint            count,
 		       gboolean        extend_selection)
 {
+	gboolean keypad;
+	gint before;	
   gint new_pos = entry->current_pos;
 
   gtk_entry_reset_im_context (entry);
 
   if (entry->current_pos != entry->selection_bound && !extend_selection)
     {
       switch (step)
@@ -2433,8 +2437,23 @@
 	case GTK_MOVEMENT_LOGICAL_POSITIONS:
 	  new_pos = gtk_entry_move_logically (entry, new_pos, count);
 	  break;
-	case GTK_MOVEMENT_VISUAL_POSITIONS:
+	case GTK_MOVEMENT_VISUAL_POSITIONS:  //modified by yjyu
+		before = new_pos;
 	  new_pos = gtk_entry_move_visually (entry, new_pos, count);
+		g_object_get(gtk_settings_get_default(), "gtk-phone-keypad-mode", &keypad, NULL);
+		if (keypad){
+			if (before == new_pos)
+			{
+		 	//GtkDirectionType dir = (before == 0) ? GTK_DIR_LEFT : GTK_DIR_RIGHT;
+		 	GtkDirectionType dir = GTK_DIR_TAB_FORWARD;
+			if ((count < 0 && gtk_widget_get_direction(GTK_WIDGET(entry)) != GTK_TEXT_DIR_RTL) ||
+		   	(count > 0 && gtk_widget_get_direction(GTK_WIDGET(entry)) == GTK_TEXT_DIR_RTL))
+				dir = GTK_DIR_TAB_BACKWARD;
+
+      			gtk_widget_child_focus (gtk_widget_get_toplevel (entry), dir);
+			
+			}
+		}
 	  break;
 	case GTK_MOVEMENT_WORDS:
 	  while (count > 0)
=========================================
diff -u -r gtk+-2.8.0/gtk/gtksettings.c gtk+-2.8.0.phone/gtk/gtksettings.c
--- gtk+-2.8.0/gtk/gtksettings.c	2005-08-01 15:21:00.000000000 -0400
+++ gtk+-2.8.0.phone/gtk/gtksettings.c	2005-10-12 13:40:15.000000000 -0400
@@ -78,7 +78,9 @@
   PROP_CURSOR_THEME_NAME,
   PROP_CURSOR_THEME_SIZE,
 #endif
-  PROP_ALTERNATIVE_BUTTON_ORDER
+  PROP_ALTERNATIVE_BUTTON_ORDER,
+	//yjyu modifies here
+  PROP_PHONE_KEYPAD_MODE
 };
 
 
@@ -384,6 +386,14 @@
 								   GTK_PARAM_READWRITE),
                                              NULL);
   g_assert (result == PROP_ALTERNATIVE_BUTTON_ORDER);
+//yjyu modifies here
+  result = settings_install_property_parser(class, g_param_spec_boolean ("gtk-phone-keypad-mode",
+								  P_("Phone keypad mode"),
+								  P_("Whether the key device is phone keypad or normal keyboard"),
+								  FALSE,
+								  GTK_PARAM_READWRITE),
+								  NULL);
+  g_assert(result == PROP_PHONE_KEYPAD_MODE);
 }
 
 static void
@@ -572,6 +582,10 @@
       settings_update_cursor_theme (settings);
       break;
 #endif /* GDK_WINDOWING_X11 */
+//yjyu modifies here
+    case PROP_PHONE_KEYPAD_MODE:
+	g_printerr("Phone keypad mode changed=================\n");
+	break;
     }
 }
 
=============================================
diff -u -r gtk+-2.8.0/gtk/gtktextview.c gtk+-2.8.0.phone/gtk/gtktextview.c
--- gtk+-2.8.0/gtk/gtktextview.c	2005-07-11 15:46:43.000000000 -0400
+++ gtk+-2.8.0.phone/gtk/gtktextview.c	2005-10-12 14:53:47.000000000 -0400
@@ -84,7 +84,7 @@
  *
  */
 
-#if 0
+#if 1
 #define DEBUG_VALIDATION_AND_SCROLLING
 #endif
 
@@ -4638,11 +4638,14 @@
 {
   GtkTextIter insert;
   GtkTextIter newplace;
-
+  GtkTextIter before;
+  gboolean keypad;
+	
   gint cursor_x_pos = 0;
 
   if (!text_view->cursor_visible) 
     {
+	// cursor_visible: If the insertion cursor is shown.
       GtkScrollStep scroll_step;
 
       switch (step) 
@@ -4702,6 +4705,8 @@
   if (step == GTK_MOVEMENT_DISPLAY_LINES)
     gtk_text_view_get_virtual_cursor_pos (text_view, &cursor_x_pos, NULL);
 
+	//yjyu addes one line here
+	g_object_get(gtk_settings_get_default(), "gtk-phone-keypad-mode", &keypad, NULL);
   switch (step)
     {
     case GTK_MOVEMENT_LOGICAL_POSITIONS:
@@ -4709,8 +4714,22 @@
       break;
 
     case GTK_MOVEMENT_VISUAL_POSITIONS:
-      gtk_text_layout_move_iter_visually (text_view->layout,
+	// yjyu, Move the iterator (newplace) a given number (count) of characters visually, 
+	before = newplace;
+      gtk_text_layout_move_iter_visually (text_view->layout,   
                                           &newplace, count);
+	if (keypad)
+	{
+		if (gtk_text_iter_equal(&before,&newplace) )
+		{
+			GtkTextDirection dir = gtk_widget_get_direction(GTK_WIDGET(text_view));
+			if ((count > 0 && dir != GTK_TEXT_DIR_RTL) || 
+			(count < 0 && dir == GTK_TEXT_DIR_RTL))
+				gtk_text_view_move_focus (text_view,GTK_DIR_TAB_FORWARD);
+			else	
+				gtk_text_view_move_focus (text_view,GTK_DIR_TAB_BACKWARD);
+		}
+	}
       break;
 
     case GTK_MOVEMENT_WORDS:
@@ -4724,23 +4743,37 @@
       break;
 
     case GTK_MOVEMENT_DISPLAY_LINES:
+	DV(g_print (G_STRLOC": yjyu into GTK_MOVEMENT_DISPLAY_LINES+++++++++++++++++++++++=\n"));
       if (count < 0)
       {
         if (gtk_text_view_move_iter_by_lines (text_view, &newplace, count))
           gtk_text_layout_move_iter_to_x (text_view->layout, &newplace, cursor_x_pos);
         else
-          gtk_text_iter_set_line_offset (&newplace, 0);
+	{
+		//yjyu modifies here
+		if (keypad)
+		 	gtk_text_view_move_focus (text_view,GTK_DIR_UP);
+		else
+          		gtk_text_iter_set_line_offset (&newplace, 0);  
+	}
       }
       if (count > 0)
       {
         if (gtk_text_view_move_iter_by_lines (text_view, &newplace, count))
           gtk_text_layout_move_iter_to_x (text_view->layout, &newplace, cursor_x_pos);
         else
-          gtk_text_iter_forward_to_line_end (&newplace);
+	{
+		//yjyu modifies here
+		if (keypad)
+			gtk_text_view_move_focus (text_view,GTK_DIR_DOWN);
+		else
+         		gtk_text_iter_forward_to_line_end (&newplace); 
+	}
       }
       break;
 
     case GTK_MOVEMENT_DISPLAY_LINE_ENDS:
+	DV(g_print (G_STRLOC": into GTK_MOVEMENT_DISPLAY_LINES_ENDS+++++++++++++++++++++++=\n"));
       if (count > 1)
         gtk_text_view_move_iter_by_lines (text_view, &newplace, --count);
       else if (count < -1)
=============================== 
