GNOME Bugzilla – Bug 50626
GtkIMContext needs a method for spot location hints
Last modified: 2011-02-04 16:09:36 UTC
XIM base input methods want to get spot location hints to control the location of the status and lookup-choice windows so that they can be near the text insertion point. This is still desired even if GtkIIMContext API does not want to support over-the-spot input style.
A reminder here - the GTK+ team is trying hard for an API freeze by the end of this month (March), so if you want to make a proposal in this area, it needs to be made soon.
I'd propose to add a virtual function: void (*set_cursor_pos) (GtkIMContext *context, GdkRectangle *area); into GtkIMContext class. I prefer to use GdkRectangle to GdkPoint, for win-IME backend will need width/height of cursor to call NS_IMM_SETCANDIDATEWINDOW(). If this looks okay, I'll also propose source patch for gtk/ and GtkIMContextXIM backend in module/input.
I'm ready to attach a patch, but have tried "Create a new attachment" a number of times(at least 5 times) without a luck. Also, I'm asked for my account name and password almost every single time I try to save changes. Are they known problems?
Created attachment 398 [details] [review] add set_cursor_pos method and its implementation to XIM backend
Remaining item is to implement this for GtkTextView
I'm implemting this for GtkTextView. A current wokring patch will be sent after the comment. Line cursor position is updated when GtkTextView calls gtk_text_layout_draw(), so I call gtk_im_set_spot_location right after it to update input method spot location. (If possible, I'd like to use the same x & y cooridates which are given to gdk_draw_line in gtk_text_layout_draw, but it seems difficult to get them from GtkTextView.)
Created attachment 833 [details] [review] spot location hint for input method
Attempted fix in CVS, please test and let me know if it doesn't work.
I tested the current code, running testtext in ja locale. The im spot location is once set to (x, y) = (0, one_line_font_height) when the program started, but it isn't updated when text is inserted/deleted and input cursor location in text view window changes, so XIM's look up choice window does not display near the input cursor. When I click the window, the spot location is updated from gtk_text_view_mark_set_handler, so the lookup choice window location becomes nearer, but as I input more text, it becomes far again, until I click the text view window and moves the mark next time. We'd need to update im spot location when text buffer is updated and cursor location changes. Is there any function to be called? Reopen the bug..
Let's try also updating the location on the "changed" signal from the buffer, maybe. Can you tell me how to test this? I am not sure how to use the input methods.
Here are the steps I just try on a redhat 7.1 box. (assuming "ja" locale is installed..) 1. login GNOME in "ja" locale. 2. If kinput2 is not running yet, run "/usr/X11R6/bin/kinput2 -canna" manually. (I have to run this manually in my system.) 3. start testtext. 4. type Shift+space on the testtext window to toggle to Japanese input mode. 5. type "kou", and hit space-bar twice to let kinput2 bring up a Candidate Selection window. 6. The candidate selection window is expected to be displayed just below the cursor location, but not.
Do japanese input methods work for you? I attempted to update the spot location in three more places, which I think are called when text buffer is updated: gtk_text_view_preedit_changed_handler gtk_text_view_commit_handler gtk_text_view_delete_from_cursor It has made the behaviour better in my system. I'll attach the patch for sure.
Index: gtktextview.c =================================================================== RCS file: /cvs/gnome/gtk+/gtk/gtktextview.c,v retrieving revision 1.136 diff -u -r1.136 gtktextview.c --- gtktextview.c 2001/10/27 02:41:24 1.136 +++ gtktextview.c 2001/10/31 00:45:45 @@ -4174,6 +4174,7 @@ gboolean leave_one = FALSE; gtk_text_view_reset_im_context (text_view); + gtk_text_view_update_im_spot_location (text_view); if (type == GTK_DELETE_CHARS) { @@ -5290,6 +5291,7 @@ gtk_text_view_scroll_mark_onscreen (text_view, gtk_text_buffer_get_mark (get_buffer (text_view), "insert")); + gtk_text_view_update_im_spot_location (text_view); } static void @@ -5302,6 +5304,7 @@ gtk_im_context_get_preedit_string (context, &str, &attrs, &cursor_pos); gtk_text_layout_set_preedit_string (text_view->layout, str, attrs, cursor_pos); + gtk_text_view_update_im_spot_location (text_view); pango_attr_list_unref (attrs); g_free (str);
Spot location on testtext works well on the head. I wonder any change has been made for fixing this. Maybe set_window_height/width made on Dev 03?
I guess this bug is fixed?
I'll verify the fix again on today's HEAD.
I verified the fix on the latest(last Frday's) build.