From b44a235d9fca562522ea02832424c37bf30185e7 Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Tue, 18 Sep 2012 09:37:35 +0200 Subject: [PATCH] OSK support: canvas auto panning based on input focus Listen to the 'request-clear-area' and 'unset-clear-area' of the widget and adjust allocation accordingly. Signed-off-by: Carlos Garnacho Acked-by: Simon Schampijer --- src/sugar3/graphics/window.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/sugar3/graphics/window.py b/src/sugar3/graphics/window.py index 23a8d4fc..1d45210c 100644 --- a/src/sugar3/graphics/window.py +++ b/src/sugar3/graphics/window.py @@ -94,6 +94,14 @@ class Window(Gtk.Window): self.connect('realize', self.__window_realize_cb) self.connect('key-press-event', self.__key_press_cb) + # OSK support: canvas auto panning based on input focus + if GObject.signal_lookup('request-clear-area', Window) != 0 and \ + GObject.signal_lookup('unset-clear-area', Window) != 0: + self.connect('size-allocate', self.__size_allocate_cb) + self.connect('request-clear-area', self.__request_clear_area_cb) + self.connect('unset-clear-area', self.__unset_clear_area_cb) + self._clear_area_dy = 0 + self._toolbar_box = None self._alerts = [] self._canvas = None @@ -277,6 +285,19 @@ class Window(Gtk.Window): self._unfullscreen_button_timeout_id = None return False + def __request_clear_area_cb(self, activity, osk_rect, cursor_rect): + self._clear_area_dy = cursor_rect.y + cursor_rect.height - osk_rect.y + self.queue_resize() + + def __unset_clear_area_cb(self, activity, snap_back): + self._clear_area_dy = 0 + self.queue_resize() + + def __size_allocate_cb(self, widget, allocation): + self.set_allocation(allocation) + allocation.y -= self._clear_area_dy + self.__vbox.size_allocate(allocation) + def set_enable_fullscreen_mode(self, enable_fullscreen_mode): self._enable_fullscreen_mode = enable_fullscreen_mode