Esempio n. 1
0
 def deregisterKeystrokeListener(self, client, key_set=[], mask=0, 
                                 kind=(constants.KEY_PRESSED_EVENT, 
                                       constants.KEY_RELEASED_EVENT)):
   '''
   Deregisters a listener for key stroke events.
   
   @param client: Callable to be invoked when the event occurs
   @type client: callable
   @param key_set: Set of hardware key codes to stop monitoring. Leave empty
     to indicate all keys.
   @type key_set: list of integer
   @param mask: When the mask is None, the codes in the key_set will be 
     monitored only when no modifier is held. When the mask is an 
     integer, keys in the key_set will be monitored only when the modifiers in
     the mask are held. When the mask is an iterable over more than one 
     integer, keys in the key_set will be monitored when any of the modifier
     combinations in the set are held.
   @type mask: integer, iterable, None
   @param kind: Kind of events to stop watching, KEY_PRESSED_EVENT or 
     KEY_RELEASED_EVENT.
   @type kind: list
   @raise KeyError: When the client isn't already registered for events
   '''
   # see if we already have an observer for this client
   ob = self.clients[client]
   if mask is None:
     # None means all modifier combinations
     mask = utils.allModifiers()
   # register for new keystrokes on the observer
   ob.unregister(self.dev, key_set, mask, kind)
Esempio n. 2
0
 def registerKeystrokeListener(self, client, key_set=[], mask=0, 
                               kind=(constants.KEY_PRESSED_EVENT, 
                                     constants.KEY_RELEASED_EVENT),
                               synchronous=True, preemptive=True, 
                               global_=False):
   '''
   Registers a listener for key stroke events.
   
   @param client: Callable to be invoked when the event occurs
   @type client: callable
   @param key_set: Set of hardware key codes to stop monitoring. Leave empty
     to indicate all keys.
   @type key_set: list of integer
   @param mask: When the mask is None, the codes in the key_set will be 
     monitored only when no modifier is held. When the mask is an 
     integer, keys in the key_set will be monitored only when the modifiers in
     the mask are held. When the mask is an iterable over more than one 
     integer, keys in the key_set will be monitored when any of the modifier
     combinations in the set are held.
   @type mask: integer, iterable, None
   @param kind: Kind of events to watch, KEY_PRESSED_EVENT or 
     KEY_RELEASED_EVENT.
   @type kind: list
   @param synchronous: Should the callback notification be synchronous, giving
     the client the chance to consume the event?
   @type synchronous: boolean
   @param preemptive: Should the callback be allowed to preempt / consume the
     event?
   @type preemptive: boolean
   @param global_: Should callback occur even if an application not supporting
     AT-SPI is in the foreground? (requires xevie)
   @type global_: boolean
   '''
   try:
     # see if we already have an observer for this client
     ob = self.clients[client]
   except KeyError:
     # create a new device observer for this client
     ob = _DeviceObserver(self, synchronous, preemptive, global_)
     # store the observer to client mapping, and the inverse
     self.clients[ob] = client
     self.clients[client] = ob
   if mask is None:
     # None means all modifier combinations
     mask = utils.allModifiers()
   # register for new keystrokes on the observer
   ob.register(self.dev, key_set, mask, kind)