[core/input] add default workspace wrap bindings (mouse wheel up/down)
This commit is contained in:
parent
d0bb0f9b7a
commit
ba24ba13db
4 changed files with 15 additions and 5 deletions
|
@ -83,6 +83,9 @@ def main():
|
|||
output = core.output.i3(theme, config)
|
||||
modules = []
|
||||
|
||||
core.input.register(None, core.input.WHEEL_UP, 'i3-msg workspace prev_on_output')
|
||||
core.input.register(None, core.input.WHEEL_DOWN, 'i3-msg workspace next_on_output')
|
||||
|
||||
input_thread = threading.Thread(target=handle_input, args=(output,))
|
||||
input_thread.daemon = True
|
||||
input_thread.start()
|
||||
|
|
|
@ -12,10 +12,14 @@ def clear():
|
|||
__callbacks.clear()
|
||||
|
||||
def trigger(event, *args, **kwargs):
|
||||
for callback in __callbacks.get(event, []):
|
||||
cb = __callbacks.get(event, [])
|
||||
if len(cb) == 0: return False
|
||||
|
||||
for callback in cb:
|
||||
if len(args) + len(kwargs) == 0:
|
||||
callback()
|
||||
else:
|
||||
callback(*args, **kwargs)
|
||||
return True
|
||||
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
|
|
@ -34,7 +34,7 @@ def __execute(cmd):
|
|||
logging.error('failed to invoke callback: {}'.format(e))
|
||||
|
||||
def register(obj, button=None, cmd=None):
|
||||
event_id = __event_id(obj.id, button)
|
||||
event_id = __event_id(obj.id if obj is not None else '', button)
|
||||
logging.debug('registering callback {}'.format(event_id))
|
||||
if callable(cmd):
|
||||
core.event.register(event_id, cmd)
|
||||
|
@ -43,8 +43,13 @@ def register(obj, button=None, cmd=None):
|
|||
|
||||
def trigger(event):
|
||||
if not 'button' in event: return
|
||||
|
||||
triggered = False
|
||||
for field in ['instance', 'name']:
|
||||
if not field in event: continue
|
||||
core.event.trigger(__event_id(event[field], event['button']), event)
|
||||
if core.event.trigger(__event_id(event[field], event['button']), event):
|
||||
triggered = True
|
||||
if not triggered:
|
||||
core.event.trigger(__event_id('', event['button']), event)
|
||||
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
## Backwards-compatibility
|
||||
- alignment parameter
|
||||
- default wheel handlers
|
||||
|
||||
## Improvements
|
||||
- API documentation
|
||||
|
@ -22,5 +21,4 @@
|
|||
- themes: use colors to improve theme readability
|
||||
- convert some stuff to simple attributes to reduce LOCs
|
||||
- theme.exclude (battery)
|
||||
- configuration files
|
||||
- use add_widget() instead of core.widget.Widget()
|
||||
|
|
Loading…
Reference in a new issue