From bd3cf9079196ab2e82d9b032d53c06d8d778fcf4 Mon Sep 17 00:00:00 2001 From: multiSnow Date: Tue, 6 Dec 2022 15:10:30 +0800 Subject: [PATCH] win32 compatibility --- README.rst | 3 ++- src/ssiv/constants.py | 2 +- src/ssiv/mainloop.py | 12 +++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 5ce974d..144091c 100644 --- a/README.rst +++ b/README.rst @@ -16,7 +16,8 @@ Optional: Supported platform: - linux - - (others need to test: such as win32, cygwin, darwin, bsd, ...) + - win32 + - (others need to test: such as cygwin, darwin, bsd, ...) Feature: - | configurable full keyboard control diff --git a/src/ssiv/constants.py b/src/ssiv/constants.py index e3dfbe8..5369d48 100644 --- a/src/ssiv/constants.py +++ b/src/ssiv/constants.py @@ -25,7 +25,7 @@ version_info=(0,0,0) required_pyver=(3,11,0) # TODO: test on different platform -supported_platform=('linux',) +supported_platform=('linux','win32') # for SDL 2.26.0 required_pysdl2ver=(0,9,15) diff --git a/src/ssiv/mainloop.py b/src/ssiv/mainloop.py index 5c82859..b21852d 100644 --- a/src/ssiv/mainloop.py +++ b/src/ssiv/mainloop.py @@ -15,7 +15,12 @@ from _thread import allocate_lock from functools import partial -from signal import SIG_IGN,SIGINT,SIGTERM,SIGUSR1,SIGUSR2,signal,strsignal +from signal import SIG_IGN,SIGINT,SIGTERM,signal,strsignal + +try: + from signal import SIG_IGN,SIGINT,SIGTERM,SIGUSR1,SIGUSR2,signal,strsignal +except ImportError: + SIGUSR1=SIGUSR2=None from .co import AttrDict from .config import * @@ -89,8 +94,9 @@ def mainloop(*,images=(),containers=()): handler=partial(signal_close,ui=ui) signal(SIGINT,handler) signal(SIGTERM,handler) - signal(SIGUSR1,handler) - signal(SIGUSR2,handler) + if SIGUSR1 is not None: + signal(SIGUSR1,handler) + signal(SIGUSR2,handler) if images: command_listed(images,ui)