Skip to content

Commit

Permalink
Remove dependency on X11 (slgobinath#672)
Browse files Browse the repository at this point in the history
* Remove dependency on X11 from break_screen
  • Loading branch information
m00nwtchr authored Dec 18, 2024
1 parent 9927bfe commit 2e63463
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions safeeyes/ui/break_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class BreakScreen:
def __init__(self, context, on_skipped, on_postponed, style_sheet_path):
self.context = context
self.count_labels = []
self.display = Display()
self.display = None
self.enable_postpone = False
self.enable_shortcut = False
self.is_pretified = False
Expand All @@ -56,6 +56,9 @@ def __init__(self, context, on_skipped, on_postponed, style_sheet_path):
self.strict_break = False
self.windows = []

if not self.context['is_wayland']:
self.display = Display()

# Initialize the theme
css_provider = Gtk.CssProvider()
css_provider.load_from_path(style_sheet_path)
Expand Down Expand Up @@ -131,7 +134,8 @@ def close(self):
Hide the break screen from active window and destroy all other windows
"""
logging.info("Close the break screen(s)")
self.__release_keyboard()
if not self.context['is_wayland']:
self.__release_keyboard()

# Destroy other windows if exists
GLib.idle_add(lambda: self.__destroy_all_screens())
Expand All @@ -149,7 +153,11 @@ def __show_break_screen(self, message, image_path, widget, tray_actions):
Show an empty break screen on all screens.
"""
# Lock the keyboard
utility.start_thread(self.__lock_keyboard)
if not self.context['is_wayland']:
utility.start_thread(self.__lock_keyboard)
else:
# TODO: Wayland keyboard locking
logging.warning("Keyboard locking not yet implemented for Wayland.")

display = Gdk.Display.get_default()
screen = display.get_default_screen()
Expand Down Expand Up @@ -243,7 +251,7 @@ def __update_count_down(self, count):

def __lock_keyboard(self):
"""
Lock the keyboard to prevent the user from using keyboard shortcuts
Lock the keyboard to prevent the user from using keyboard shortcuts (X11 only)
"""
logging.info("Lock the keyboard")
self.lock_keyboard = True
Expand Down

0 comments on commit 2e63463

Please sign in to comment.