Skip to content

Commit b7adbf0

Browse files
committed
typing: context: add to break screen
1 parent d375a4c commit b7adbf0

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

safeeyes/ui/break_screen.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import gi
2626
from safeeyes import utility
27+
from safeeyes.context import Context
2728
from safeeyes.model import Break, Config, TrayAction
2829
from safeeyes.translations import translate as _
2930
import Xlib
@@ -50,7 +51,7 @@ class BreakScreen:
5051
def __init__(
5152
self,
5253
application: Gtk.Application,
53-
context,
54+
context: Context,
5455
on_skipped: typing.Callable[[], None],
5556
on_postponed: typing.Callable[[], None],
5657
):
@@ -70,7 +71,7 @@ def __init__(
7071
self.show_skip_button = False
7172
self.show_postpone_button = False
7273

73-
if not self.context["is_wayland"]:
74+
if not self.context.is_wayland:
7475
self.x11_display = Display()
7576

7677
def initialize(self, config: Config) -> None:
@@ -80,7 +81,7 @@ def initialize(self, config: Config) -> None:
8081
self.keycode_shortcut_postpone = config.get("shortcut_postpone", 65)
8182
self.keycode_shortcut_skip = config.get("shortcut_skip", 9)
8283

83-
if self.context["is_wayland"] and (
84+
if self.context.is_wayland and (
8485
self.keycode_shortcut_postpone != 65 or self.keycode_shortcut_skip != 9
8586
):
8687
logging.warning(
@@ -138,7 +139,7 @@ def close(self) -> None:
138139
windows.
139140
"""
140141
logging.info("Close the break screen(s)")
141-
if not self.context["is_wayland"]:
142+
if not self.context.is_wayland:
142143
self.__release_keyboard_x11()
143144

144145
# Destroy other windows if exists
@@ -153,7 +154,7 @@ def __show_break_screen(
153154
) -> None:
154155
"""Show an empty break screen on all screens."""
155156
# Lock the keyboard
156-
if not self.context["is_wayland"]:
157+
if not self.context.is_wayland:
157158
utility.start_thread(self.__lock_keyboard_x11)
158159

159160
display = Gdk.Display.get_default()
@@ -188,7 +189,7 @@ def __show_break_screen(
188189
self.on_skip_clicked,
189190
)
190191

191-
if self.context["is_wayland"]:
192+
if self.context.is_wayland:
192193
# Note: in theory, this could also be used on X11
193194
# however, that already has its own implementation below
194195
controller = Gtk.EventControllerKey()
@@ -200,7 +201,7 @@ def __show_break_screen(
200201

201202
self.windows.append(window)
202203

203-
if self.context["desktop"] == "kde":
204+
if self.context.desktop == "kde":
204205
# Fix flickering screen in KDE by setting opacity to 1
205206
window.set_opacity(0.9)
206207

@@ -212,10 +213,10 @@ def __show_break_screen(
212213
# shortcut
213214
window.set_focus(None)
214215

215-
if not self.context["is_wayland"]:
216+
if not self.context.is_wayland:
216217
self.__window_set_keep_above_x11(window)
217218

218-
if self.context["is_wayland"]:
219+
if self.context.is_wayland:
219220
# this may or may not be granted by the window system
220221
surface = window.get_surface()
221222
if surface is not None:

0 commit comments

Comments
 (0)