DND plugin: prevent notifications in fullscreen (#255)

Check for fullscreen windows and cancel the break in the on_pre_break hook,
thus preventing the "Ready for a break" notification.
This commit is contained in:
Dmitriy Bogdanov 2018-05-15 14:47:25 +04:00 committed by Gobinath
parent 30bcafab4e
commit 195b08381a
1 changed files with 9 additions and 3 deletions

View File

@ -36,7 +36,7 @@ take_break_window_classes = []
unfullscreen_allowed = True unfullscreen_allowed = True
def is_active_window_skipped(): def is_active_window_skipped(pre_break):
""" """
Check for full-screen applications. Check for full-screen applications.
This method must be executed by the main thread. If not, it will cause to random failure. This method must be executed by the main thread. If not, it will cause to random failure.
@ -63,7 +63,7 @@ def is_active_window_skipped():
if process in skip_break_window_classes: if process in skip_break_window_classes:
return True return True
elif process in take_break_window_classes: elif process in take_break_window_classes:
if is_fullscreen and unfullscreen_allowed: if is_fullscreen and unfullscreen_allowed and not pre_break:
try: try:
active_window.unfullscreen() active_window.unfullscreen()
except BaseException: except BaseException:
@ -87,7 +87,13 @@ def init(ctx, safeeyes_config, plugin_config):
unfullscreen_allowed = plugin_config['unfullscreen'] unfullscreen_allowed = plugin_config['unfullscreen']
def on_pre_break(break_obj):
"""
"""
return is_active_window_skipped(True)
def on_start_break(break_obj): def on_start_break(break_obj):
""" """
""" """
return is_active_window_skipped() return is_active_window_skipped(False)