@@ -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 = None ):
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 :
@@ -89,10 +91,12 @@ def flushEvents(self):
8991 threadCounters = {}
9092 for k , v in sorted (g .items (), key = lambda item : item [1 ], reverse = True ):
9193 threadCount = threadCounters .get (k [- 1 ], 0 )
92- if threadCount > MAX_WINEVENTS_PER_THREAD :
94+ threadCounters [k [- 1 ]] = threadCount + 1
95+ eventsForObjectAlwaysAllowed = alwaysAllowedObjects and k [1 :- 1 ] in alwaysAllowedObjects
96+ if threadCount > MAX_WINEVENTS_PER_THREAD and not eventsForObjectAlwaysAllowed :
9397 continue
98+
9499 heapq .heappush (self ._eventHeap , (v ,) + k )
95- threadCounters [k [- 1 ]] = threadCount + 1
96100 f = self ._focusEventCache
97101 self ._focusEventCache = {}
98102 for k , v in sorted (f .items (), key = lambda item : item [1 ])[0 - self .maxFocusItems :]:
0 commit comments