1
0
Fork 0

Add ability to hide the mouse cursor

This commit is contained in:
Michał Rudowicz 2024-09-11 22:05:26 +02:00
parent 1dd3e4b22d
commit b8b2cb61f4
1 changed files with 6 additions and 2 deletions

View File

@ -186,7 +186,8 @@ class App:
SHOW_REQUEST_MESSAGE_FOR_AT_LEAST_S = 5 SHOW_REQUEST_MESSAGE_FOR_AT_LEAST_S = 5
IGNORE_EVENTS_FOR_TICKS_AFTER_SCREENSAVER = 5 IGNORE_EVENTS_FOR_TICKS_AFTER_SCREENSAVER = 5
def __init__(self, actions: List[Action], theme: Dict, fullscreen: bool, screensaver_delay: int): def __init__(self, actions: List[Action], theme: Dict, fullscreen: bool, screensaver_delay: int,
hide_cursor: bool):
pygame.init() pygame.init()
info = pygame.display.Info() info = pygame.display.Info()
flags = 0 flags = 0
@ -201,6 +202,8 @@ class App:
self.task_q = Queue() self.task_q = Queue()
self.screensaver = ClockScreensaver() self.screensaver = ClockScreensaver()
self.TICKS_UNTIL_SCREENSAVER = screensaver_delay * self.FPS self.TICKS_UNTIL_SCREENSAVER = screensaver_delay * self.FPS
if hide_cursor:
pygame.mouse.set_visible(False)
def get_screen_rect(self) -> pygame.Rect: def get_screen_rect(self) -> pygame.Rect:
return pygame.Rect(0, 0, self.screen.get_width(), self.screen.get_height()) return pygame.Rect(0, 0, self.screen.get_width(), self.screen.get_height())
@ -317,6 +320,7 @@ if __name__ == '__main__':
parser.add_argument("--no-fullscreen", help="Fullscreen", action='store_true') parser.add_argument("--no-fullscreen", help="Fullscreen", action='store_true')
parser.add_argument("--screensaver-delay", help="Screensaver delay, in seconds. Default=30", parser.add_argument("--screensaver-delay", help="Screensaver delay, in seconds. Default=30",
type=int, default=30) type=int, default=30)
parser.add_argument("--no-cursor", help="Hide the mouse cursor", action='store_true')
args = parser.parse_args() args = parser.parse_args()
url_defs: List[Action] = [] url_defs: List[Action] = []
@ -325,5 +329,5 @@ if __name__ == '__main__':
url_defs = get_url_defs(data) url_defs = get_url_defs(data)
app = App(url_defs, theme=data["theme"], fullscreen=not args.no_fullscreen, app = App(url_defs, theme=data["theme"], fullscreen=not args.no_fullscreen,
screensaver_delay=args.screensaver_delay) screensaver_delay=args.screensaver_delay, hide_cursor=args.no_cursor)
app.loop() app.loop()