@@ -75,10 +75,12 @@ def addEvent(
7575 self ._genericEventCache [(eventID , window , objectID , childID , threadID )] = next (self ._eventCounter )
7676 return True
7777
78- def flushEvents (self ):
78+ def flushEvents (self , alwaysAllowedObjects ):
7979 """Returns a list of winEvents that have been added.
8080 Due to limiting, it will not necessarily be all the winEvents that were originally added.
8181 They are definitely guaranteed to be in the correct order though.
82+ winEvents for objects listed in alwaysAllowedObjects will always be emitted,
83+ Even if the winEvent limit for that thread has been exceeded.
8284 @return Tuple[eventID,window,objectID,childID]
8385 """
8486 if self ._lastMenuEvent is not None :
@@ -88,11 +90,12 @@ def flushEvents(self):
8890 self ._genericEventCache = {}
8991 threadCounters = {}
9092 for k , v in sorted (g .items (), key = lambda item : item [1 ], reverse = True ):
91- threadCount = threadCounters .get (k [- 1 ], 0 )
92- if threadCount > MAX_WINEVENTS_PER_THREAD :
93- continue
93+ if k [1 :- 1 ] not in alwaysAllowedObjects :
94+ threadCount = threadCounters .get (k [- 1 ], 0 )
95+ threadCounters [k [- 1 ]] = threadCount + 1
96+ if threadCount > MAX_WINEVENTS_PER_THREAD :
97+ continue
9498 heapq .heappush (self ._eventHeap , (v ,) + k )
95- threadCounters [k [- 1 ]] = threadCount + 1
9699 f = self ._focusEventCache
97100 self ._focusEventCache = {}
98101 for k , v in sorted (f .items (), key = lambda item : item [1 ])[0 - self .maxFocusItems :]:
0 commit comments