@skyrilhd I tried both versions above, it fixed the error when the device went to sleep for a short time. However, I think it takes time to monitor when the device sleeps for a longer period of time. Up to now, what you have done is amazing
Edit: Hey, I just noticed a new bug that after I try to take a screenshot a few times (I haven't figured out how to reproduce the error correctly, sometimes it happens but sometimes it doesn't), the touchpad can only move horizontally but not vertically. Besides, the screenshot key combination (Command Shift 3) no longer works but instead it returns me a character (F with Command Shift 3 and H with Command Shift 4). Another small issue is about the smoothness of the gestures, I found it still a bit choppy when using them.