From 4bf1c1ffe795a1d28a543a20cc3771a30a090b89 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Tue, 6 May 2025 19:33:30 +0200 Subject: Added a dedicated thread for handling events sent to the endpoint --- win32.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'win32.py') diff --git a/win32.py b/win32.py index 5220cde..1b45a95 100644 --- a/win32.py +++ b/win32.py @@ -9,6 +9,7 @@ import win32gui import win32con from zope import component from interfaces.message import IMessage, Debug +from consumer import Mapping # This code tries to hook the Focus changes events with the callback method. @@ -54,10 +55,9 @@ def setHook(WinEventProc, eventType): @interface.implementer(desktopEvent.IDesktop) class Listener(object): - def __init__(self, mapping: Dict[str, str], queue): + def __init__(self, mapping: Dict[str, str]): self.WinEventProc = WinEventProcType(self.callback) self.mapping = mapping - self.queue = queue def getForegroundWindowTitle(self) -> Optional[str]: """ Get the window title name. @@ -100,7 +100,7 @@ class Listener(object): if pattern == "default": continue if pattern in title: - self.queue.put ( (code, None) ) + component.handle(Mapping((code, None))) return # Get the default mapping to apply if there is any defined # This only applies when the window raising the event is the main @@ -114,7 +114,7 @@ class Listener(object): # called with the GIL held, but the GIL is released (the current # Python thread state is NULL) print("Mapping '%s' to default" % title) - self.queue.put ( ("default", None) ) + component.handle(Mapping((default, None))) def start(self) -> None: self.hookIDs = [setHook(self.WinEventProc, et) for et in eventTypes.keys()] -- cgit v1.2.3