diff --git a/CHANGELOG.md b/CHANGELOG.md index 40006957..abfeb359 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ This just tracks the most notable changes, if you want all the details checkout the commit history. Probably all versions contain changes regarding documentation, translation, fixes and other minor refactors ## Untagged +* allow showing/hiding cursor from the settings * some wpa-eap support, adds the security type selector and user field * extrude: wait for temp or open temp panel automatically close #1416 * extrude: show more filament sensors (up to 9) diff --git a/docs/Configuration.md b/docs/Configuration.md index acc80d28..a3a07a4d 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -24,9 +24,6 @@ The options listed here are not editable from within the user interface. # Time in seconds before the Job Status closes itself if an error is encountered # job_error_timeout: 0 -# Allows the cursor to be displayed on the screen -# show_cursor: False - # If multiple printers are defined, this can be set the name of the one to show at startup. # default_printer: MyPrinter diff --git a/ks_includes/KlippyGtk.py b/ks_includes/KlippyGtk.py index d5729ed5..1f064568 100644 --- a/ks_includes/KlippyGtk.py +++ b/ks_includes/KlippyGtk.py @@ -35,7 +35,6 @@ class KlippyGtk: def __init__(self, screen): self.screen = screen self.themedir = os.path.join(pathlib.Path(__file__).parent.resolve().parent, "styles", screen.theme, "images") - self.cursor = screen.show_cursor self.font_size_type = screen._config.get_main_config().get("font_size", "medium") self.width = screen.width self.height = screen.height @@ -250,12 +249,7 @@ class KlippyGtk: dialog.show_all() # Change cursor to blank - if self.cursor: - dialog.get_window().set_cursor( - Gdk.Cursor.new_for_display(Gdk.Display.get_default(), Gdk.CursorType.ARROW)) - else: - dialog.get_window().set_cursor( - Gdk.Cursor.new_for_display(Gdk.Display.get_default(), Gdk.CursorType.BLANK_CURSOR)) + self.set_cursor(show=self.screen.show_cursor, window=dialog.get_window()) self.screen.dialogs.append(dialog) logging.info(f"Showing dialog {dialog.get_title()} {dialog.get_size()}") @@ -274,3 +268,13 @@ class KlippyGtk: def ScrolledWindow(self, steppers=True, **kwargs): steppers = steppers and self.screen._config.get_main_config().getboolean("show_scroll_steppers", fallback=False) return CustomScrolledWindow(steppers, **kwargs) + + def set_cursor(self, show: bool, window: Gdk.Window): + if show: + window.set_cursor( + Gdk.Cursor.new_for_display(Gdk.Display.get_default(), Gdk.CursorType.ARROW)) + os.system("xsetroot -cursor_name arrow") + else: + window.set_cursor( + Gdk.Cursor.new_for_display(Gdk.Display.get_default(), Gdk.CursorType.BLANK_CURSOR)) + os.system("xsetroot -cursor ks_includes/emptyCursor.xbm ks_includes/emptyCursor.xbm") diff --git a/ks_includes/config.py b/ks_includes/config.py index 28b1efd0..ce497169 100644 --- a/ks_includes/config.py +++ b/ks_includes/config.py @@ -309,6 +309,9 @@ class KlipperScreenConfig: "value": "False", "callback": screen.reload_panels}}, {"auto_open_extrude": {"section": "main", "name": _("Auto-open Extrude On Pause"), "type": "binary", "value": "True", "callback": screen.reload_panels}}, + {"show_cursor": {"section": "main", "name": _("Show cursor"), "type": "binary", + "tooltip": _("For mouse control or to verify touchscreen accuracy"), + "value": "False", "callback": screen.update_cursor}}, # {"": {"section": "main", "name": _(""), "type": ""}} ] diff --git a/screen.py b/screen.py index 14a32e09..bb858999 100755 --- a/screen.py +++ b/screen.py @@ -146,6 +146,7 @@ class KlipperScreen(Gtk.Window): self.change_theme(self.theme) self.add(self.base_panel.main_grid) self.show_all() + self.update_cursor(self.show_cursor) min_ver = (3, 8) if sys.version_info < min_ver: self.show_error_modal( @@ -158,19 +159,15 @@ class KlipperScreen(Gtk.Window): if self._config.errors: self.show_error_modal("Invalid config file", self._config.get_errors()) return - if self.show_cursor: - self.get_window().set_cursor( - Gdk.Cursor.new_for_display(Gdk.Display.get_default(), Gdk.CursorType.ARROW)) - os.system("xsetroot -cursor_name arrow") - else: - self.get_window().set_cursor( - Gdk.Cursor.new_for_display(Gdk.Display.get_default(), Gdk.CursorType.BLANK_CURSOR)) - os.system("xsetroot -cursor ks_includes/emptyCursor.xbm ks_includes/emptyCursor.xbm") self.base_panel.activate() self.set_screenblanking_timeout(self._config.get_main_config().get('screen_blanking')) self.log_notification("KlipperScreen Started", 1) self.initial_connection() + def update_cursor(self, show: bool): + self.show_cursor = show + self.gtk.set_cursor(show, window=self.get_window()) + def state_execute(self, state, callback): self.close_screensaver() if 'printer_select' in self._cur_panels: @@ -633,6 +630,8 @@ class KlipperScreen(Gtk.Window): # Avoid leaving a cursor-handle close.grab_focus() + self.gtk.set_cursor(False, window=self.get_window()) + self.screensaver = box self.screensaver.show_all() self.power_devices(None, self._config.get_main_config().get("screen_off_devices", ""), on=False) @@ -652,6 +651,7 @@ class KlipperScreen(Gtk.Window): for dialog in self.dialogs: logging.info(f"Restoring Dialog {dialog}") dialog.show() + self.gtk.set_cursor(self.show_cursor, window=self.get_window()) self.show_all() self.power_devices(None, self._config.get_main_config().get("screen_on_devices", ""), on=True)