diff options
author | Sébastien Dailly <sebastien@dailly.me> | 2025-05-06 19:33:30 +0200 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2025-05-06 19:33:30 +0200 |
commit | 4bf1c1ffe795a1d28a543a20cc3771a30a090b89 (patch) | |
tree | 09e1bb81744be02fd3a8422f9002ec3139f54100 /win32.py | |
parent | 0d037fd1170ecc30cea677f563dfb50dff7360c6 (diff) |
Added a dedicated thread for handling events sent to the endpoint
Diffstat (limited to 'win32.py')
-rw-r--r-- | win32.py | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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()]
|