1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- try:
- import Xlib.protocol.event
- except ImportError:
- pass
- class RewriteKeyEventAction:
- def __init__(self, keysym=None):
- self._keysym = keysym
- def execute(self, extended_controls, xkeyevent):
- attr = dict(
- window=extended_controls.engine_window,
- detail=xkeyevent.detail,
- state=xkeyevent.state,
- root_x=xkeyevent.root_x,
- root_y=xkeyevent.root_y,
- event_x=xkeyevent.event_x,
- event_y=xkeyevent.event_y,
- child=xkeyevent.child,
- root=xkeyevent.root,
- time=xkeyevent.time, # X.CurrentTime
- same_screen=xkeyevent.same_screen,
- )
- if self._keysym:
- attr['detail'] = extended_controls.xdisplay.keysym_to_keycode(
- self._keysym)
- extended_controls.engine_window.send_event(
- type(xkeyevent)(**attr),
- )
- class ForwardKeyEventAction(RewriteKeyEventAction):
- def __init__(self):
- super().__init__(keysym=None)
- class ToggleExtendedControlsAction:
- def execute(self, extended_controls, xkeyevent):
- if isinstance(xkeyevent, Xlib.protocol.event.KeyPress):
- extended_controls.toggle()
|