[core] input: add logging for input events

to debug input event issues (which seem to become more frequent), add
some input event logging.

see #336
This commit is contained in:
Tobias Witek 2018-12-03 20:17:18 +01:00
parent 37faef033e
commit 1850ceefdc

View file

@ -5,9 +5,12 @@ import json
import uuid
import time
import select
import logging
import threading
import bumblebee.util
log = logging.getLogger(__name__)
LEFT_MOUSE = 1
MIDDLE_MOUSE = 2
RIGHT_MOUSE = 3
@ -24,6 +27,7 @@ def read_input(inp):
"""Read i3bar input and execute callbacks"""
epoll = select.epoll()
epoll.register(sys.stdin.fileno(), select.EPOLLIN)
log.debug("starting click event processing")
while inp.running:
if is_terminated():
return
@ -36,14 +40,18 @@ def read_input(inp):
line = "["
while line.startswith("["):
line = sys.stdin.readline().strip(",").strip()
log.debug("new event: {}".format(line))
inp.has_event = True
try:
event = json.loads(line)
if "instance" in event:
inp.callback(event)
inp.redraw()
except ValueError:
pass
else:
log.debug("field 'instance' missing in input, not processing the event")
except ValueError as e:
log.debug("failed to parse event: {}".format(e))
log.debug("exiting click event processing")
epoll.unregister(sys.stdin.fileno())
epoll.close()
inp.has_event = True