After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 50626 - GtkIMContext needs a method for spot location hints
GtkIMContext needs a method for spot location hints
Status: VERIFIED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
1.3.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2001-02-06 22:08 UTC by Hidetoshi Tajima
Modified: 2011-02-04 16:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
add set_cursor_pos method and its implementation to XIM backend (7.42 KB, patch)
2001-03-12 23:14 UTC, Hidetoshi Tajima
none Details | Review
spot location hint for input method (1.46 KB, patch)
2001-08-02 01:49 UTC, Hidetoshi Tajima
none Details | Review

Description Hidetoshi Tajima 2001-02-06 22:08:15 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.
Comment 1 Owen Taylor 2001-03-08 06:27:57 UTC
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.
Comment 2 Hidetoshi Tajima 2001-03-08 21:12:40 UTC
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.
Comment 3 Hidetoshi Tajima 2001-03-09 00:37:27 UTC
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?
Comment 4 Hidetoshi Tajima 2001-03-12 23:14:30 UTC
Created attachment 398 [details] [review]
add set_cursor_pos method and its implementation to XIM backend
Comment 5 Owen Taylor 2001-03-26 19:38:13 UTC
Remaining item is to implement this for GtkTextView
Comment 6 Hidetoshi Tajima 2001-08-02 01:47:52 UTC
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.)



Comment 7 Hidetoshi Tajima 2001-08-02 01:49:50 UTC
Created attachment 833 [details] [review]
spot location hint for input method
Comment 8 Havoc Pennington 2001-10-23 17:26:35 UTC
Attempted fix in CVS, please test and let me know if it doesn't work. 
Comment 9 Hidetoshi Tajima 2001-10-30 03:13:41 UTC
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..
Comment 10 Havoc Pennington 2001-10-30 03:47:37 UTC
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.
Comment 11 Hidetoshi Tajima 2001-10-30 19:41:08 UTC
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.
Comment 12 Hidetoshi Tajima 2001-10-31 00:46:52 UTC
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.
Comment 13 Hidetoshi Tajima 2001-10-31 00:55:06 UTC
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);
Comment 14 Hidetoshi Tajima 2001-12-15 03:19:39 UTC
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?
Comment 15 Havoc Pennington 2002-02-22 16:48:56 UTC
I guess this bug is fixed?
Comment 16 Hidetoshi Tajima 2002-02-22 18:37:42 UTC
I'll verify the fix again on today's HEAD.
Comment 17 Hidetoshi Tajima 2002-02-25 22:28:11 UTC
I verified the fix on the latest(last Frday's) build.