diff options
author | Nohemi Fernandez <nf68@cornell.edu> | 2011-08-08 14:00:43 -0500 |
---|---|---|
committer | Eitan Isaacson <eitan@monotonous.org> | 2011-08-12 09:19:41 +0200 |
commit | e8ee7789378b430bcf59b233557a1a3ef314aa38 (patch) | |
tree | 8111e16484a6f2d5a8e1c8a5d961d0139440138d /modules | |
parent | c874366acbcbc6ec16f378c38794516ba441c589 (diff) | |
download | caribou-e8ee7789378b430bcf59b233557a1a3ef314aa38.tar.gz |
Implement set_cursor_location, off by a few pixels
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gtk3/caribou-gtk-module.vala | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/modules/gtk3/caribou-gtk-module.vala b/modules/gtk3/caribou-gtk-module.vala index f74404a..add5a79 100644 --- a/modules/gtk3/caribou-gtk-module.vala +++ b/modules/gtk3/caribou-gtk-module.vala @@ -13,6 +13,7 @@ namespace Caribou { private GLib.HashTable<Gtk.Window, bool> windows; private Keyboard keyboard; private Gdk.Display display; + private Atk.TextRectangle cursor_rect; public GtkModule () { windows = new GLib.HashTable<Gtk.Window, bool> (null, null); @@ -83,13 +84,24 @@ namespace Caribou { (widget is Gtk.TextView && ((Gtk.TextView) widget).get_editable ())) { Gdk.Window current_window = widget.get_window (); + Atk.Object object = widget.get_accessible (); int x = 0, y = 0, w = 0, h = 0; - if (current_window != null) - get_origin_geometry (current_window, out x, out y, out w, out h); + int caret_offset = 0; + + if (object is Atk.Text) { + caret_offset = ((Atk.Text) object).get_caret_offset (); + ((Atk.Text) object).get_range_extents (0, caret_offset, Atk.CoordType.SCREEN, cursor_rect); + + x = cursor_rect.x; y = cursor_rect.y; w = cursor_rect.width; h = cursor_rect.height; + } + else { + if (current_window != null) + get_origin_geometry (current_window, out x, out y, out w, out h); + } try { keyboard.show (timestamp); - keyboard.set_entry_location (x, y, w, h); + keyboard.set_cursor_location (x, y, w, h); } catch (IOError e) { stderr.printf ("%s\n", e.message); } |