Commit 6bbdea92 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

#80023, Yao Zhang, TOKUNAGA Hiroyuki

Thu Jun  5 16:12:54 2003  Owen Taylor  <otaylor@redhat.com>

        #80023, Yao Zhang, TOKUNAGA Hiroyuki

        * gtk/gtktextlayout.c (gtk_text_layout_get_cursor_locations):
        Account for the preedit cursor offset if the iter passed
        in is at the same place as the insertion cursor.

        * gtk/gtktextview.c (gtk_text_view_get_cursor_location):
        Encapsulate getting the insertion cursor location.

        * gtk/gtktextview.c (gtk_text_view_update_im_spot_location):
        Pass the real y/height to the IM context. Take
        text_view->x/yoffset into account.
parent 4d5b395f
Thu Jun 5 16:12:54 2003 Owen Taylor <otaylor@redhat.com>
#80023, Yao Zhang, TOKUNAGA Hiroyuki
* gtk/gtktextlayout.c (gtk_text_layout_get_cursor_locations):
Account for the preedit cursor offset if the iter passed
in is at the same place as the insertion cursor.
* gtk/gtktextview.c (gtk_text_view_get_cursor_location):
Encapsulate getting the insertion cursor location.
* gtk/gtktextview.c (gtk_text_view_update_im_spot_location):
Pass the real y/height to the IM context. Take
text_view->x/yoffset into account.
Thu Jun 5 16:52:54 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.[ch]: Never scroll on focus in
......
Thu Jun 5 16:12:54 2003 Owen Taylor <otaylor@redhat.com>
#80023, Yao Zhang, TOKUNAGA Hiroyuki
* gtk/gtktextlayout.c (gtk_text_layout_get_cursor_locations):
Account for the preedit cursor offset if the iter passed
in is at the same place as the insertion cursor.
* gtk/gtktextview.c (gtk_text_view_get_cursor_location):
Encapsulate getting the insertion cursor location.
* gtk/gtktextview.c (gtk_text_view_update_im_spot_location):
Pass the real y/height to the IM context. Take
text_view->x/yoffset into account.
Thu Jun 5 16:52:54 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.[ch]: Never scroll on focus in
......
Thu Jun 5 16:12:54 2003 Owen Taylor <otaylor@redhat.com>
#80023, Yao Zhang, TOKUNAGA Hiroyuki
* gtk/gtktextlayout.c (gtk_text_layout_get_cursor_locations):
Account for the preedit cursor offset if the iter passed
in is at the same place as the insertion cursor.
* gtk/gtktextview.c (gtk_text_view_get_cursor_location):
Encapsulate getting the insertion cursor location.
* gtk/gtktextview.c (gtk_text_view_update_im_spot_location):
Pass the real y/height to the IM context. Take
text_view->x/yoffset into account.
Thu Jun 5 16:52:54 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.[ch]: Never scroll on focus in
......
Thu Jun 5 16:12:54 2003 Owen Taylor <otaylor@redhat.com>
#80023, Yao Zhang, TOKUNAGA Hiroyuki
* gtk/gtktextlayout.c (gtk_text_layout_get_cursor_locations):
Account for the preedit cursor offset if the iter passed
in is at the same place as the insertion cursor.
* gtk/gtktextview.c (gtk_text_view_get_cursor_location):
Encapsulate getting the insertion cursor location.
* gtk/gtktextview.c (gtk_text_view_update_im_spot_location):
Pass the real y/height to the IM context. Take
text_view->x/yoffset into account.
Thu Jun 5 16:52:54 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.[ch]: Never scroll on focus in
......
Thu Jun 5 16:12:54 2003 Owen Taylor <otaylor@redhat.com>
#80023, Yao Zhang, TOKUNAGA Hiroyuki
* gtk/gtktextlayout.c (gtk_text_layout_get_cursor_locations):
Account for the preedit cursor offset if the iter passed
in is at the same place as the insertion cursor.
* gtk/gtktextview.c (gtk_text_view_get_cursor_location):
Encapsulate getting the insertion cursor location.
* gtk/gtktextview.c (gtk_text_view_update_im_spot_location):
Pass the real y/height to the IM context. Take
text_view->x/yoffset into account.
Thu Jun 5 16:52:54 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtktextview.[ch]: Never scroll on focus in
......
......@@ -2188,6 +2188,7 @@ gtk_text_layout_get_cursor_locations (GtkTextLayout *layout,
GtkTextLineDisplay *display;
gint line_top;
gint index;
GtkTextIter insert_iter;
PangoRectangle pango_strong_pos;
PangoRectangle pango_weak_pos;
......@@ -2202,6 +2203,13 @@ gtk_text_layout_get_cursor_locations (GtkTextLayout *layout,
line_top = _gtk_text_btree_find_line_top (_gtk_text_buffer_get_btree (layout->buffer),
line, layout);
gtk_text_buffer_get_iter_at_mark (layout->buffer, &insert_iter,
gtk_text_buffer_get_mark (layout->buffer,
"insert"));
if (gtk_text_iter_equal (iter, &insert_iter))
index += layout->preedit_cursor - layout->preedit_len;
pango_layout_get_cursor_pos (display->layout, index,
strong_pos ? &pango_strong_pos : NULL,
weak_pos ? &pango_weak_pos : NULL);
......
......@@ -301,6 +301,8 @@ static void gtk_text_view_mark_set_handler (GtkTextBuffer *buffer,
const GtkTextIter *location,
GtkTextMark *mark,
gpointer data);
static void gtk_text_view_get_cursor_location (GtkTextView *text_view,
GdkRectangle *pos);
static void gtk_text_view_get_virtual_cursor_pos (GtkTextView *text_view,
gint *x,
gint *y);
......@@ -1723,16 +1725,19 @@ static void
gtk_text_view_update_im_spot_location (GtkTextView *text_view)
{
GdkRectangle area;
gint cursor_x_pos, cursor_y_pos;
if (text_view->layout == NULL)
return;
gtk_text_view_get_virtual_cursor_pos (text_view, &cursor_x_pos, &cursor_y_pos);
gtk_text_view_get_cursor_location (text_view, &area);
area.x = cursor_x_pos;
area.y = cursor_y_pos;
area.width = area.height = 0;
area.x -= text_view->xoffset;
area.y -= text_view->yoffset;
/* Width returned by Pango indicates direction of cursor,
* by it's sign more than the size of cursor.
*/
area.width = 0;
gtk_im_context_set_cursor_location (text_view->im_context, &area);
}
......@@ -6352,27 +6357,35 @@ gtk_text_view_mark_set_handler (GtkTextBuffer *buffer,
}
static void
gtk_text_view_get_virtual_cursor_pos (GtkTextView *text_view,
gint *x,
gint *y)
gtk_text_view_get_cursor_location (GtkTextView *text_view,
GdkRectangle *pos)
{
GdkRectangle strong_pos;
GtkTextIter insert;
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &insert,
gtk_text_buffer_get_mark (get_buffer (text_view),
"insert"));
gtk_text_layout_get_cursor_locations (text_view->layout, &insert, pos, NULL);
}
static void
gtk_text_view_get_virtual_cursor_pos (GtkTextView *text_view,
gint *x,
gint *y)
{
GdkRectangle pos;
if ((x && text_view->virtual_cursor_x == -1) ||
(y && text_view->virtual_cursor_y == -1))
gtk_text_layout_get_cursor_locations (text_view->layout, &insert, &strong_pos, NULL);
gtk_text_view_get_cursor_location (text_view, &pos);
if (x)
{
if (text_view->virtual_cursor_x != -1)
*x = text_view->virtual_cursor_x;
else
*x = strong_pos.x;
*x = pos.x;
}
if (y)
......@@ -6380,7 +6393,7 @@ gtk_text_view_get_virtual_cursor_pos (GtkTextView *text_view,
if (text_view->virtual_cursor_x != -1)
*y = text_view->virtual_cursor_y;
else
*y = strong_pos.y + strong_pos.height / 2;
*y = pos.y + pos.height / 2;
}
}
......@@ -6389,18 +6402,13 @@ gtk_text_view_set_virtual_cursor_pos (GtkTextView *text_view,
gint x,
gint y)
{
GdkRectangle strong_pos;
GtkTextIter insert;
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &insert,
gtk_text_buffer_get_mark (get_buffer (text_view),
"insert"));
GdkRectangle pos;
if (x == -1 || y == -1)
gtk_text_layout_get_cursor_locations (text_view->layout, &insert, &strong_pos, NULL);
gtk_text_view_get_cursor_location (text_view, &pos);
text_view->virtual_cursor_x = (x == -1) ? strong_pos.x : x;
text_view->virtual_cursor_y = (y == -1) ? strong_pos.y + strong_pos.height / 2 : y;
text_view->virtual_cursor_x = (x == -1) ? pos.x : x;
text_view->virtual_cursor_y = (y == -1) ? pos.y + pos.height / 2 : y;
}
/* Quick hack of a popup menu
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment