Ticket #4021: 0001-Cursor-tracker-only-display-the-cursor-in-mouse-trac.2.patch

File 0001-Cursor-tracker-only-display-the-cursor-in-mouse-trac.2.patch, 4.1 KB (added by erikos, 12 years ago)

Patch for the shell to start tracking the input

  • bin/sugar-session

    From a7181848d4d67b2f860d892c32184e828f30383f Mon Sep 17 00:00:00 2001
    From: Simon Schampijer <simon@laptop.org>
    Date: Mon, 15 Oct 2012 12:40:46 +0200
    Subject: [PATCH shell] 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 <simon@laptop.org>
    ---
     bin/sugar-session                |  6 +++++
     src/jarabe/view/Makefile.am      |  1 +
     src/jarabe/view/cursortracker.py | 54 ++++++++++++++++++++++++++++++++++++++++
     3 files changed, 61 insertions(+)
     create mode 100644 src/jarabe/view/cursortracker.py
    
    diff --git a/bin/sugar-session b/bin/sugar-session
    index 7455f38..5cdc028 100755
    a b def setup_gesturehandler_cb(): 
    122122    from jarabe import frame
    123123    gesturehandler.setup(frame.get_view())
    124124
     125def setup_cursortracker_cb():
     126    logging.debug('STARTUP: setup_cursortracker_cb')
     127    from jarabe.view import cursortracker
     128    cursortracker.setup()
     129
    125130def setup_journal_cb():
    126131    logging.debug('STARTUP: setup_journal_cb')
    127132    from jarabe.journal import journalactivity
    def bootstrap(): 
    222227    GObject.idle_add(setup_frame_cb)
    223228    GObject.idle_add(setup_keyhandler_cb)
    224229    GObject.idle_add(setup_gesturehandler_cb)
     230    GObject.idle_add(setup_cursortracker_cb)
    225231    GObject.idle_add(setup_journal_cb)
    226232    GObject.idle_add(setup_notification_service_cb)
    227233    GObject.idle_add(setup_file_transfer_cb)
  • src/jarabe/view/Makefile.am

    diff --git a/src/jarabe/view/Makefile.am b/src/jarabe/view/Makefile.am
    index 1e8b0eb..8e060bd 100644
    a b sugar_PYTHON = \ 
    33        __init__.py                     \
    44        buddyicon.py                    \
    55        buddymenu.py                    \
     6        cursortracker.py                \
    67        customizebundle.py              \
    78        gesturehandler.py               \
    89        keyhandler.py                   \
  • new file src/jarabe/view/cursortracker.py

    diff --git a/src/jarabe/view/cursortracker.py b/src/jarabe/view/cursortracker.py
    new file mode 100644
    index 0000000..e14ca48
    - +  
     1# Copyright (C) 2012 One Laptop Per Child
     2#
     3# This program is free software; you can redistribute it and/or modify
     4# it under the terms of the GNU General Public License as published by
     5# the Free Software Foundation; either version 2 of the License, or
     6# (at your option) any later version.
     7#
     8# This program is distributed in the hope that it will be useful,
     9# but WITHOUT ANY WARRANTY; without even the implied warranty of
     10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11# GNU General Public License for more details.
     12#
     13# You should have received a copy of the GNU General Public License
     14# along with this program; if not, write to the Free Software
     15# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     16
     17import logging
     18
     19from gi.repository import Gdk
     20
     21from gi.repository import SugarExt
     22
     23_instance = None
     24
     25
     26def setup():
     27    '''Cursor tracker: only display the cursor in mouse/trackpad mode
     28
     29    We only display the cursor in mouse/trackpad mode, hence when
     30    a mouse motion is detected or a button press event. When a
     31    touch begin event is received the cursor will be hidden.
     32
     33    We only track the incoming events when a touchscreen device
     34    is available.
     35
     36    '''
     37    global _instance
     38
     39    if _instance:
     40        del _instance
     41
     42    display = Gdk.Display.get_default()
     43    device_manager = display.get_device_manager()
     44    devices = device_manager.list_devices(Gdk.DeviceType.SLAVE)
     45    for device in devices:
     46        if device.get_source() == Gdk.InputSource.TOUCHSCREEN:
     47            logging.debug('Cursor Tracker: found touchscreen, ' \
     48                              'will track input.')
     49            _instance = SugarExt.CursorTracker()
     50            break
     51
     52    if not _instance:
     53        logging.debug('Cursor Tracker: no touchscreen available, ' \
     54                          'will not track input.')