Skip to content

Commit 90d327b

Browse files
Merge dc89550 into 9a4074b
2 parents 9a4074b + dc89550 commit 90d327b

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

source/IAccessibleHandler/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@
126126

127127
from .orderedWinEventLimiter import MENU_EVENTIDS
128128

129-
MAX_WINEVENTS = 500
130-
131129
# Special Mozilla gecko MSAA constant additions
132130
NAVRELATION_LABEL_FOR = 0x1002
133131
NAVRELATION_LABELLED_BY = 0x1003
@@ -857,9 +855,14 @@ def pumpAll(): # noqa: C901
857855
fakeFocusEvent = None
858856
focus = eventHandler.lastQueuedFocusObject
859857

858+
alwaysAllowedObjects = []
859+
# winEvents for the currently focused object are special,
860+
# and should be never filtered out.
861+
if isinstance(focus, NVDAObjects.IAccessible.IAccessible) and focus.event_objectID is not None:
862+
alwaysAllowedObjects.append((focus.event_windowHandle, focus.event_objectID, focus.event_childID))
863+
860864
# Receive all the winEvents from the limiter for this cycle
861-
winEvents = winEventLimiter.flushEvents()
862-
winEvents = winEvents[0 - MAX_WINEVENTS:]
865+
winEvents = winEventLimiter.flushEvents(alwaysAllowedObjects)
863866

864867
for winEvent in winEvents:
865868
isEventOnCaret = winEvent[2] == winUser.OBJID_CARET

source/IAccessibleHandler/orderedWinEventLimiter.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)