Ticket #737: 0001-Remove-key-handlers-for-rotation-and-brightness-chan.patch

File 0001-Remove-key-handlers-for-rotation-and-brightness-chan.patch, 6.8 KB (added by tomeu, 15 years ago)
  • src/jarabe/model/screen.py

    From d1944e61be72d2231a4518a88ed2020be4a35a89 Mon Sep 17 00:00:00 2001
    From: Tomeu Vizoso <tomeu@sugarlabs.org>
    Date: Tue, 18 Aug 2009 11:05:31 +0200
    Subject: [PATCH] Remove key handlers for rotation and brightness change for the XO. #737
    
    olpc-kbdshim handles them directly.
    ---
     src/jarabe/model/screen.py    |   21 -----------
     src/jarabe/view/keyhandler.py |   76 -----------------------------------------
     2 files changed, 0 insertions(+), 97 deletions(-)
    
    diff --git a/src/jarabe/model/screen.py b/src/jarabe/model/screen.py
    index 87dc370..4403c1c 100644
    a b _HARDWARE_MANAGER_INTERFACE = 'org.freedesktop.ohm.Keystore' 
    2222_HARDWARE_MANAGER_SERVICE = 'org.freedesktop.ohm'
    2323_HARDWARE_MANAGER_OBJECT_PATH = '/org/freedesktop/ohm/Keystore'
    2424
    25 COLOR_MODE = 0
    26 B_AND_W_MODE = 1
    27 
    2825_ohm_service = None
    2926
    3027def _get_ohm():
    def set_dcon_freeze(frozen): 
    4441    except dbus.DBusException:
    4542        logging.error('Cannot unfreeze the DCON')
    4643
    47 def set_display_mode(mode):
    48     try:
    49         _get_ohm().SetKey("display.dcon_mode", mode)
    50     except dbus.DBusException:
    51         logging.error('Cannot change DCON mode')
    52 
    53 def set_display_brightness(level):
    54     try:
    55         _get_ohm().SetKey("backlight.hardware_brightness", level)
    56     except dbus.DBusException:
    57         logging.error('Cannot set display brightness')
    58 
    59 def get_display_brightness():
    60     try:
    61         return _get_ohm().GetKey("backlight.hardware_brightness")
    62     except dbus.DBusException:
    63         logging.error('Cannot get display brightness')
    64         return 0
  • src/jarabe/view/keyhandler.py

    diff --git a/src/jarabe/view/keyhandler.py b/src/jarabe/view/keyhandler.py
    index 5634ef4..0505c52 100644
    a b import gtk 
    2828
    2929from sugar._sugarext import KeyGrabber
    3030
    31 from jarabe.model import screen
    3231from jarabe.model import sound
    3332from jarabe.model import shell
    3433from jarabe.model import session
    from jarabe.model.shell import ShellModel 
    3736from jarabe import config
    3837from jarabe.journal import journalactivity
    3938
    40 _BRIGHTNESS_STEP = 2
    4139_VOLUME_STEP = sound.VOLUME_STEP
    42 _BRIGHTNESS_MAX = 15
    4340_VOLUME_MAX = 100
    4441_TABBING_MODIFIER = gtk.gdk.MOD1_MASK
    4542
    _actions_table = { 
    4845    'F2'                   : 'zoom_group',
    4946    'F3'                   : 'zoom_home',
    5047    'F4'                   : 'zoom_activity',
    51     'F9'                   : 'brightness_down',
    52     'F10'                  : 'brightness_up',
    53     '<alt>F9'              : 'brightness_min',
    54     '<alt>F10'             : 'brightness_max',
    5548    'XF86AudioMute'        : 'volume_mute',
    5649    'F11'                  : 'volume_down',
    5750    'XF86AudioLowerVolume' : 'volume_down',
    _actions_table = { 
    6053    '<alt>F11'             : 'volume_min',
    6154    '<alt>F12'             : 'volume_max',
    6255    '0x93'                 : 'frame',
    63     '0xEB'                 : 'rotate',
    6456    '<alt>Tab'             : 'next_window',
    6557    '<alt><shift>Tab'      : 'previous_window',
    6658    '<alt>Escape'          : 'close_window',
    _actions_table = { 
    7062    '<alt><shift>q'        : 'quit_emulator',
    7163    'XF86Search'           : 'open_search',
    7264    '<alt><shift>o'        : 'open_search',
    73     '<alt><shift>r'        : 'rotate',
    7465    '<alt><shift>s'        : 'say_text',
    7566}
    7667
    SPEECH_DBUS_INTERFACE = 'org.laptop.Speech' 
    8172class KeyHandler(object):
    8273    def __init__(self, frame):
    8374        self._frame = frame
    84         self._screen_rotation = 0
    8575        self._key_pressed = None
    8676        self._keycode_pressed = 0
    8777        self._keystate_pressed = 0
    class KeyHandler(object): 
    134124        sound.set_volume(volume)
    135125        sound.set_muted(volume == 0)
    136126
    137     def _change_brightness(self, step=None, value=None):
    138         if step is not None:
    139             level = screen.get_display_brightness() + step
    140         elif value is not None:
    141             level = value
    142 
    143         level = min(max(0, level), _BRIGHTNESS_MAX)
    144 
    145         screen.set_display_brightness(level)
    146         if level == 0:
    147             screen.set_display_mode(screen.B_AND_W_MODE)
    148         else:
    149             screen.set_display_mode(screen.COLOR_MODE)
    150 
    151127    def _get_speech_proxy(self):
    152128        if self._speech_proxy is None:
    153129            bus = dbus.SessionBus()
    class KeyHandler(object): 
    195171    def handle_zoom_activity(self, event_time):
    196172        shell.get_model().zoom_level = ShellModel.ZOOM_ACTIVITY
    197173
    198     def handle_brightness_max(self, event_time):
    199         self._change_brightness(value=_BRIGHTNESS_MAX)
    200 
    201     def handle_brightness_min(self, event_time):
    202         self._change_brightness(value=0)
    203 
    204174    def handle_volume_max(self, event_time):
    205175        self._change_volume(value=_VOLUME_MAX)
    206176
    207177    def handle_volume_min(self, event_time):
    208178        self._change_volume(value=0)
    209179
    210     def handle_brightness_up(self, event_time):
    211         self._change_brightness(step=_BRIGHTNESS_STEP)
    212 
    213     def handle_brightness_down(self, event_time):
    214         self._change_brightness(step=-_BRIGHTNESS_STEP)
    215 
    216180    def handle_volume_mute(self, event_time):
    217181        if sound.get_muted() is True:
    218182            sound.set_muted(False)
    class KeyHandler(object): 
    228192    def handle_frame(self, event_time):
    229193        self._frame.notify_key_press()
    230194
    231     def handle_rotate(self, event_time):
    232         """
    233         Handles rotation of the display (using xrandr) and of the d-pad.
    234 
    235         Notes: default mappings for keypad on MP
    236         KP_Up 80
    237         KP_Right 85
    238         KP_Down 88
    239         KP_Left 83
    240         """
    241 
    242         states = [ 'normal', 'left', 'inverted', 'right']
    243         keycodes = (80, 85, 88, 83, 80, 85, 88, 83)
    244         keysyms = ("KP_Up", "KP_Right", "KP_Down", "KP_Left")
    245 
    246         self._screen_rotation -= 1
    247         self._screen_rotation %= 4
    248 
    249         actual_keycodes = keycodes[self._screen_rotation:self._screen_rotation
    250                                    + 4]
    251         # code_pairs now contains a mapping of keycode -> keysym in the current
    252         # orientation
    253         code_pairs = zip(actual_keycodes, keysyms)
    254 
    255         # Using the mappings in code_pairs, we dynamically build up an xmodmap
    256         # command to rotate the dpad keys.
    257         argv = ['xmodmap']
    258         for arg in [('-e', 'keycode %i = %s' % p) for p in code_pairs]:
    259             argv.extend(arg)
    260 
    261         # If either the xmodmap or xrandr command fails, check_call will fail
    262         # with CalledProcessError, which we raise.
    263         try:
    264             subprocess.check_call(argv)
    265             subprocess.check_call(['xrandr', '-o',
    266                                    states[self._screen_rotation]])
    267         except OSError, e:
    268             if e.errno != errno.EINTR:
    269                 raise
    270 
    271195    def handle_quit_emulator(self, event_time):
    272196        session.get_session_manager().shutdown()
    273197