diff options
Diffstat (limited to 'src/caribou.py')
-rw-r--r-- | src/caribou.py | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/caribou.py b/src/caribou.py index 8d51c83..82bfaa6 100644 --- a/src/caribou.py +++ b/src/caribou.py @@ -41,18 +41,28 @@ class Test: def __set_text_location(self, acc): text = acc.queryText() [x, y, width, height] = text.getCharacterExtents(text.caretOffset, pyatspi.DESKTOP_COORDS) - cp.set_cursor_location(x, y + height) + cp.set_cursor_location(gtk.gdk.Rectangle(x, y, width, height)) + + component = acc.queryComponent() + entry_bb = component.getExtents(pyatspi.DESKTOP_COORDS) + cp.set_entry_location(entry_bb) cp.show_all() def __set_entry_location(self, acc): text = acc.queryText() - [x, y, width, height] = text.getCharacterExtents(text.caretOffset, pyatspi.DESKTOP_COORDS) - if x == 0 and y == 0 and width == 0 and height == 0: - component = acc.queryComponent() - bb = component.getExtents(pyatspi.DESKTOP_COORDS) - cp.set_cursor_location(bb.x, bb.y + bb.height) - else: - cp.set_cursor_location(x, y + height) + cursor_bb = gtk.gdk.Rectangle( + *text.getCharacterExtents(text.caretOffset, + pyatspi.DESKTOP_COORDS)) + + component = acc.queryComponent() + entry_bb = component.getExtents(pyatspi.DESKTOP_COORDS) + + if cursor_bb == gtk.gdk.Rectangle(0, 0, 0, 0): + cursor_bb = entry_bb + + cp.set_cursor_location(cursor_bb) + cp.set_entry_location(entry_bb) + cp.show_all() def on_state_changed_focused(self, event): @@ -165,7 +175,8 @@ if __name__ == "__main__": pyatspi.Registry.registerKeystrokeListener(test.on_key_down, mask = None, kind = (pyatspi.KEY_PRESSED_EVENT,)) # TODO: move text entry detection to its own file - cp = keyboard.CaribouWindow() + + cp = keyboard.CaribouWindowEntry() cp.hide_all() gtk.main() |