[core] guard against concurrent updates
when a "regular" update (once per interval) and a input-triggered update (e.g. mouse click on a widget) collide, this can cause the theme colors to be interleaved wrongly. fixes #661
This commit is contained in:
parent
441e7d5041
commit
582c828deb
1 changed files with 9 additions and 4 deletions
|
@ -39,7 +39,7 @@ class CommandSocket(object):
|
||||||
os.unlink(self.__name)
|
os.unlink(self.__name)
|
||||||
|
|
||||||
|
|
||||||
def handle_input(output):
|
def handle_input(output, update_lock):
|
||||||
with CommandSocket() as cmdsocket:
|
with CommandSocket() as cmdsocket:
|
||||||
poll = select.poll()
|
poll = select.poll()
|
||||||
poll.register(sys.stdin.fileno(), select.POLLIN)
|
poll.register(sys.stdin.fileno(), select.POLLIN)
|
||||||
|
@ -67,8 +67,10 @@ def handle_input(output):
|
||||||
modules[event["name"]] = True
|
modules[event["name"]] = True
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
update_lock.acquire()
|
||||||
core.event.trigger("update", modules.keys())
|
core.event.trigger("update", modules.keys())
|
||||||
core.event.trigger("draw")
|
core.event.trigger("draw")
|
||||||
|
update_lock.release()
|
||||||
|
|
||||||
poll.unregister(sys.stdin.fileno())
|
poll.unregister(sys.stdin.fileno())
|
||||||
|
|
||||||
|
@ -96,7 +98,8 @@ def main():
|
||||||
core.input.register(None, core.input.WHEEL_UP, "i3-msg workspace prev_on_output")
|
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")
|
core.input.register(None, core.input.WHEEL_DOWN, "i3-msg workspace next_on_output")
|
||||||
|
|
||||||
input_thread = threading.Thread(target=handle_input, args=(output,))
|
update_lock = threading.Lock()
|
||||||
|
input_thread = threading.Thread(target=handle_input, args=(output, update_lock, ))
|
||||||
input_thread.daemon = True
|
input_thread.daemon = True
|
||||||
input_thread.start()
|
input_thread.start()
|
||||||
|
|
||||||
|
@ -118,8 +121,10 @@ def main():
|
||||||
core.event.trigger("start")
|
core.event.trigger("start")
|
||||||
started = True
|
started = True
|
||||||
while True:
|
while True:
|
||||||
|
if update_lock.acquire(blocking=False) == True:
|
||||||
core.event.trigger("update")
|
core.event.trigger("update")
|
||||||
core.event.trigger("draw")
|
core.event.trigger("draw")
|
||||||
|
update_lock.release()
|
||||||
output.wait(config.interval())
|
output.wait(config.interval())
|
||||||
core.event.trigger("stop")
|
core.event.trigger("stop")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue