From 9692027facae07a93dd529eb9c1f9b16a5a90b46 Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Mon, 15 Oct 2012 10:40:46 +0000 Subject: Cursor tracker: only display the cursor in mouse/trackpad mode, SL #4021 We only display the cursor in mouse/trackpad mode, hence when a mouse motion is detected or a button press event. When a touch begin event is received the cursor will be hidden. We only track the incoming events when a touchscreen device is available. Signed-off-by: Simon Schampijer Acked-by: Manuel QuiƱones --- diff --git a/bin/sugar-session b/bin/sugar-session index 7455f38..5cdc028 100755 --- a/bin/sugar-session +++ b/bin/sugar-session @@ -122,6 +122,11 @@ def setup_gesturehandler_cb(): from jarabe import frame gesturehandler.setup(frame.get_view()) +def setup_cursortracker_cb(): + logging.debug('STARTUP: setup_cursortracker_cb') + from jarabe.view import cursortracker + cursortracker.setup() + def setup_journal_cb(): logging.debug('STARTUP: setup_journal_cb') from jarabe.journal import journalactivity @@ -222,6 +227,7 @@ def bootstrap(): GObject.idle_add(setup_frame_cb) GObject.idle_add(setup_keyhandler_cb) GObject.idle_add(setup_gesturehandler_cb) + GObject.idle_add(setup_cursortracker_cb) GObject.idle_add(setup_journal_cb) GObject.idle_add(setup_notification_service_cb) GObject.idle_add(setup_file_transfer_cb) diff --git a/src/jarabe/view/Makefile.am b/src/jarabe/view/Makefile.am index 1e8b0eb..8e060bd 100644 --- a/src/jarabe/view/Makefile.am +++ b/src/jarabe/view/Makefile.am @@ -3,6 +3,7 @@ sugar_PYTHON = \ __init__.py \ buddyicon.py \ buddymenu.py \ + cursortracker.py \ customizebundle.py \ gesturehandler.py \ keyhandler.py \ diff --git a/src/jarabe/view/cursortracker.py b/src/jarabe/view/cursortracker.py new file mode 100644 index 0000000..e14ca48 --- /dev/null +++ b/src/jarabe/view/cursortracker.py @@ -0,0 +1,54 @@ +# Copyright (C) 2012 One Laptop Per Child +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import logging + +from gi.repository import Gdk + +from gi.repository import SugarExt + +_instance = None + + +def setup(): + '''Cursor tracker: only display the cursor in mouse/trackpad mode + + We only display the cursor in mouse/trackpad mode, hence when + a mouse motion is detected or a button press event. When a + touch begin event is received the cursor will be hidden. + + We only track the incoming events when a touchscreen device + is available. + + ''' + global _instance + + if _instance: + del _instance + + display = Gdk.Display.get_default() + device_manager = display.get_device_manager() + devices = device_manager.list_devices(Gdk.DeviceType.SLAVE) + for device in devices: + if device.get_source() == Gdk.InputSource.TOUCHSCREEN: + logging.debug('Cursor Tracker: found touchscreen, ' \ + 'will track input.') + _instance = SugarExt.CursorTracker() + break + + if not _instance: + logging.debug('Cursor Tracker: no touchscreen available, ' \ + 'will not track input.') -- cgit v0.9.1