[orca] Fix for the problem of Flat Review taking over NumPad functionality.



commit 55d91146ba50f788610ea274214fe81c68b166e9
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Sun Jan 1 20:26:07 2012 -0500

    Fix for the problem of Flat Review taking over NumPad functionality.
    
    Now Orca's flat review will only kick in when NumLock is not locked.
    And there was much rejoicing. Yay!
    
    Also got rid of some cruft/unused code whilst I was in there.

 src/orca/desktop_keyboardmap.py |   63 ------------------------
 src/orca/keybindings.py         |  103 ++-------------------------------------
 src/orca/script.py              |    4 --
 src/orca/settings.py            |    5 --
 4 files changed, 4 insertions(+), 171 deletions(-)
---
diff --git a/src/orca/desktop_keyboardmap.py b/src/orca/desktop_keyboardmap.py
index 6a6b188..5f765b6 100644
--- a/src/orca/desktop_keyboardmap.py
+++ b/src/orca/desktop_keyboardmap.py
@@ -79,27 +79,12 @@ keymap = (
     ("KP_Delete", defaultModifierMask, ORCA_SHIFT_MODIFIER_MASK,
     "findPreviousHandler"),
 
-    ("KP_7", defaultModifierMask, NO_MODIFIER_MASK,
-    "reviewPreviousLineHandler"),
-
     ("KP_Home", defaultModifierMask, NO_MODIFIER_MASK,
     "reviewPreviousLineHandler"),
 
-    ("KP_7", defaultModifierMask, ORCA_MODIFIER_MASK,
-    "reviewHomeHandler"),
-
     ("KP_Home", defaultModifierMask, ORCA_MODIFIER_MASK, 
     "reviewHomeHandler"),
 
-    ("KP_8", defaultModifierMask, NO_MODIFIER_MASK,
-    "reviewCurrentLineHandler", 1),
-
-    ("KP_8", defaultModifierMask, NO_MODIFIER_MASK,
-    "reviewSpellCurrentLineHandler", 2),
-
-    ("KP_8", defaultModifierMask, NO_MODIFIER_MASK,
-    "reviewPhoneticCurrentLineHandler", 3),
-
     ("KP_Up", defaultModifierMask, NO_MODIFIER_MASK,
     "reviewCurrentLineHandler", 1),
 
@@ -109,39 +94,18 @@ keymap = (
     ("KP_Up", defaultModifierMask, NO_MODIFIER_MASK,
     "reviewPhoneticCurrentLineHandler", 3),
 
-    ("KP_9", defaultModifierMask, NO_MODIFIER_MASK,
-    "reviewNextLineHandler"),
-
     ("KP_Page_Up", defaultModifierMask, NO_MODIFIER_MASK, 
     "reviewNextLineHandler"),
 
-    ("KP_9", defaultModifierMask, ORCA_MODIFIER_MASK,
-    "reviewEndHandler"),
-
     ("KP_Page_Up", defaultModifierMask, ORCA_MODIFIER_MASK,
     "reviewEndHandler"),
 
-    ("KP_4", defaultModifierMask, NO_MODIFIER_MASK,
-    "reviewPreviousItemHandler"),
-
     ("KP_Left", defaultModifierMask, NO_MODIFIER_MASK, 
     "reviewPreviousItemHandler"),
 
-    ("KP_4", defaultModifierMask, ORCA_MODIFIER_MASK,
-    "reviewAboveHandler"),
-
     ("KP_Left", defaultModifierMask, ORCA_MODIFIER_MASK,
     "reviewAboveHandler"),
 
-    ("KP_5", defaultModifierMask, NO_MODIFIER_MASK,
-    "reviewCurrentItemHandler", 1),
-
-    ("KP_5", defaultModifierMask, NO_MODIFIER_MASK,
-    "reviewSpellCurrentItemHandler", 2),
-
-    ("KP_5", defaultModifierMask, NO_MODIFIER_MASK,
-    "reviewPhoneticCurrentItemHandler", 3),
-
     ("KP_Begin", defaultModifierMask, NO_MODIFIER_MASK,
     "reviewCurrentItemHandler", 1),
 
@@ -151,45 +115,21 @@ keymap = (
     ("KP_Begin", defaultModifierMask, NO_MODIFIER_MASK,
     "reviewPhoneticCurrentItemHandler", 3),
 
-    ("KP_5", defaultModifierMask, ORCA_MODIFIER_MASK,
-    "reviewCurrentAccessibleHandler"),
-
     ("KP_Begin", defaultModifierMask, ORCA_MODIFIER_MASK,
     "reviewCurrentAccessibleHandler"),
 
-    ("KP_6", defaultModifierMask, NO_MODIFIER_MASK,
-    "reviewNextItemHandler"),
-
     ("KP_Right", defaultModifierMask, NO_MODIFIER_MASK,
     "reviewNextItemHandler"),
 
-    ("KP_6", defaultModifierMask, ORCA_MODIFIER_MASK,
-    "reviewBelowHandler"),
-
     ("KP_Right", defaultModifierMask, ORCA_MODIFIER_MASK,
     "reviewBelowHandler"),
 
-    ("KP_1", defaultModifierMask, NO_MODIFIER_MASK,
-    "reviewPreviousCharacterHandler"),
-
     ("KP_End", defaultModifierMask, NO_MODIFIER_MASK,
     "reviewPreviousCharacterHandler"),
 
-    ("KP_1", defaultModifierMask, ORCA_MODIFIER_MASK,
-    "reviewEndOfLineHandler"),
-
     ("KP_End", defaultModifierMask, ORCA_MODIFIER_MASK,
     "reviewEndOfLineHandler"),
 
-    ("KP_2", defaultModifierMask, NO_MODIFIER_MASK,
-    "reviewCurrentCharacterHandler", 1),
-
-    ("KP_2", defaultModifierMask, NO_MODIFIER_MASK,
-    "reviewSpellCurrentCharacterHandler", 2),
-
-    ("KP_2", defaultModifierMask, NO_MODIFIER_MASK,
-    "reviewUnicodeCurrentCharacterHandler", 3),
-
     ("KP_Down", defaultModifierMask, NO_MODIFIER_MASK,
     "reviewCurrentCharacterHandler", 1),
 
@@ -199,9 +139,6 @@ keymap = (
     ("KP_Down", defaultModifierMask, NO_MODIFIER_MASK,
     "reviewUnicodeCurrentCharacterHandler", 3),
 
-    ("KP_3", defaultModifierMask, NO_MODIFIER_MASK,
-    "reviewNextCharacterHandler"),
-
     ("KP_Page_Down", defaultModifierMask, NO_MODIFIER_MASK,
     "reviewNextCharacterHandler"),
 
diff --git a/src/orca/keybindings.py b/src/orca/keybindings.py
index b2bdb1d..652ea6c 100644
--- a/src/orca/keybindings.py
+++ b/src/orca/keybindings.py
@@ -32,58 +32,11 @@ import pyatspi
 import debug
 import settings
 
-from orca_i18n import _           # for gettext support
+from orca_i18n import _
 
 _keysymsCache = {}
 _keycodeCache = {}
 
-def getAllKeysyms(keysym):
-    """Given a keysym, find all other keysyms associated with the key
-    that is mapped to the given keysym.  This allows us, for example,
-    to determine that the key bound to KP_Insert is also bound to KP_0."""
-
-    if keysym not in _keysymsCache:
-        # The keysym itself is always part of the list.
-        #
-        _keysymsCache[keysym] = [keysym]
-
-        # Find the numerical value of the keysym
-        #
-        keyval = Gdk.keyval_from_name(keysym)
-
-        if keyval != 0:
-            # Find the keycodes for the keysym.  Since a keysym
-            # can be associated with more than one key, we'll shoot
-            # for the keysym that's in group 0, regardless of shift
-            # level (each entry is of the form [keycode, group,
-            # level]).
-            #
-            keymap = Gdk.Keymap.get_default()
-            success, entries = keymap.get_entries_for_keyval(keyval)
-
-            keycode = 0
-            if entries:
-                for entry in entries:
-                    if entry[1] == 0:  # group = 0
-                        keycode = entry[0]
-                        break
-
-            # Find the keysyms bound to the keycode.  These are what
-            # we are looking for.
-            #
-            if keycode != 0:
-                entries_for_keycode = keymap.get_entries_for_keycode(keycode)
-                success = entries_for_keycode[0]
-                entries = entries_for_keycode[1]
-
-                for entry in entries:
-                    keyval = entry[0]
-                    name = Gdk.keyval_name(keyval)
-                    if name and (name != keysym):
-                        _keysymsCache[keysym].append(name)
-
-    return _keysymsCache[keysym]
-
 def getKeycode(keysym):
     """Converts an XKeysym string (e.g., 'KP_Enter') to a keycode that
     should match the event.hw_code for key events.
@@ -407,6 +360,9 @@ class KeyBindings:
                 if keyBinding.keysymstring:
                     candidates.append(keyBinding)
 
+        if keyboardEvent.modifiers & (1 << pyatspi.MODIFIER_NUMLOCK):
+            return None
+
         # If we're still here, we don't have an exact match. Prefer
         # the one whose click count is closest to, but does not exceed,
         # the actual click count.
@@ -465,54 +421,3 @@ class KeyBindings:
                 debug.println(debug.LEVEL_WARNING, \
                   "WARNING: could not find %s handler to associate " \
                   "with keybinding." % handler)
-
-    def validate(self):
-        """Tries to find keybindings where the keysym is not set for the
-        keyboard layout or where multiple keybindings map to the same
-        physical key."""
-
-        errorString = ""
-
-        # Find keybindings where the keysym is not found in the
-        # system's keymap.
-        #
-        for keyBinding in self.keyBindings:
-            keysymstring = keyBinding.keysymstring
-            if keysymstring:
-                if not getKeycode(keysymstring):
-                    errorString += "No physical key defines %s\n" \
-                                   % keysymstring
-                    if keyBinding.handler:
-                        errorString += "needed for %s\n" \
-                                       % keyBinding.handler.description
-
-        # Now, find duplicate bindings that are unintended duplicates.
-        #
-        for i in range(0, len(self.keyBindings)):
-            iKeyBinding = self.keyBindings[i]
-            if not iKeyBinding.keycode:
-                iKeyBinding.keycode = getKeycode(iKeyBinding.keysymstring)
-            if iKeyBinding.keycode:
-                for j in range(i + 1, len(self.keyBindings)):
-                    jKeyBinding = self.keyBindings[j]
-                    if not jKeyBinding.keycode:
-                        jKeyBinding.keycode = \
-                            getKeycode(jKeyBinding.keysymstring)
-                    if (iKeyBinding.keycode == jKeyBinding.keycode) \
-                       and (iKeyBinding.click_count \
-                            == jKeyBinding.click_count) \
-                       and (iKeyBinding.handler != jKeyBinding.handler) \
-                       and ((iKeyBinding.modifiers
-                             & iKeyBinding.modifier_mask) \
-                            == (jKeyBinding.modifiers
-                                & jKeyBinding.modifier_mask)):
-                        errorString += "%s maps to the same key as %s\n" \
-                                       % (iKeyBinding.keysymstring,
-                                          jKeyBinding.keysymstring)
-                        if iKeyBinding.handler:
-                            errorString += "used by %s\n" \
-                                           % iKeyBinding.handler.description
-                        if jKeyBinding.handler:
-                            errorString += "used by %s\n" \
-                                           % jKeyBinding.handler.description
-        return errorString
diff --git a/src/orca/script.py b/src/orca/script.py
index f74c19b..79a15eb 100644
--- a/src/orca/script.py
+++ b/src/orca/script.py
@@ -96,10 +96,6 @@ class Script:
         self.pointOfReference = {}
         self.setupInputEventHandlers()
         self.keyBindings = self.getKeyBindings()
-        if settings.validateKeyBindings:
-            validation = self.keyBindings.validate()
-            if len(validation):
-                debug.println(debug.LEVEL_SEVERE, validation)
         self.brailleBindings = self.getBrailleBindings()
         self.app_pronunciation_dict = self.getPronunciations()
 
diff --git a/src/orca/settings.py b/src/orca/settings.py
index 91cea92..29e2092 100644
--- a/src/orca/settings.py
+++ b/src/orca/settings.py
@@ -197,11 +197,6 @@ DESKTOP_MODIFIER_KEYS = ["Insert", "KP_Insert"]
 LAPTOP_MODIFIER_KEYS  = ["Caps_Lock"]
 orcaModifierKeys      = DESKTOP_MODIFIER_KEYS
 
-# If True, some validation of the keybindings will be done to check for
-# missing keysyms and duplicate keys used for different operations.
-#
-validateKeyBindings = False
-
 # A new modifier to use (set by the press of any key in the
 # orcaModifierKeys list) to represent the Orca modifier.
 #



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]