def processGenericWinEvent(eventID, window, objectID, childID): """Converts the win event to an NVDA event, Checks to see if this NVDAObject equals the current focus. If all goes well, then the event is queued and we return True @param eventID: a win event ID (type) @type eventID: integer @param window: a win event's window handle @type window: integer @param objectID: a win event's object ID @type objectID: integer @param childID: a win event's child ID @type childID: integer @returns: True if the event was processed, False otherwise. @rtype: boolean """ # Notify appModuleHandler of this new window appModuleHandler.update(winUser.getWindowThreadProcessID(window)[0]) # Handle particular events for the special MSAA caret object just as if they were for the focus object focus = eventHandler.lastQueuedFocusObject if focus and objectID == winUser.OBJID_CARET and eventID in ( winUser.EVENT_OBJECT_LOCATIONCHANGE, winUser.EVENT_OBJECT_SHOW): NVDAEvent = ("caret", focus) else: NVDAEvent = winEventToNVDAEvent(eventID, window, objectID, childID) if not NVDAEvent: return False if NVDAEvent[0] == "nameChange" and objectID == winUser.OBJID_CURSOR: mouseHandler.updateMouseShape(NVDAEvent[1].name) return if NVDAEvent[1] == focus: NVDAEvent = (NVDAEvent[0], focus) eventHandler.queueEvent(*NVDAEvent) return True
def processGenericWinEvent(eventID,window,objectID,childID): """Converts the win event to an NVDA event, Checks to see if this NVDAObject equals the current focus. If all goes well, then the event is queued and we return True @param eventID: a win event ID (type) @type eventID: integer @param window: a win event's window handle @type window: integer @param objectID: a win event's object ID @type objectID: integer @param childID: a win event's child ID @type childID: integer @returns: True if the event was processed, False otherwise. @rtype: boolean """ #Notify appModuleHandler of this new window appModuleHandler.update(winUser.getWindowThreadProcessID(window)[0]) #Handle particular events for the special MSAA caret object just as if they were for the focus object focus=eventHandler.lastQueuedFocusObject if focus and objectID==winUser.OBJID_CARET and eventID in (winUser.EVENT_OBJECT_LOCATIONCHANGE,winUser.EVENT_OBJECT_SHOW): NVDAEvent=("caret",focus) else: NVDAEvent=winEventToNVDAEvent(eventID,window,objectID,childID) if not NVDAEvent: return False if NVDAEvent[0]=="nameChange" and objectID==winUser.OBJID_CURSOR: mouseHandler.updateMouseShape(NVDAEvent[1].name) return if NVDAEvent[1]==focus: NVDAEvent=(NVDAEvent[0],focus) eventHandler.queueEvent(*NVDAEvent) return True
def processFocusWinEvent(window, objectID, childID, force=False): """checks to see if the focus win event is not the same as the existing focus, then converts the win event to an NVDA event (instantiating an NVDA Object) then calls processFocusNVDAEvent. If all is ok it returns True. @type window: integer @param objectID: a win event's object ID @type objectID: integer @param childID: a win event's child ID @type childID: integer @param force: If True, the shouldAllowIAccessibleFocusEvent property of the object is ignored. @type force: boolean @returns: True if the focus is valid and was handled, False otherwise. @rtype: boolean """ windowClassName = winUser.getClassName(window) # Generally, we must ignore focus on child windows of SDM windows as we only want the SDM MSAA events. # However, we don't want to ignore focus if the child ID isn't 0, # as this is a child control and the SDM MSAA events don't handle child controls. if (childID == 0 and not windowClassName.startswith('bosa_sdm') and winUser.getClassName( winUser.getAncestor( window, winUser.GA_PARENT)).startswith('bosa_sdm')): return False # Notify appModuleHandler of this new foreground window appModuleHandler.update(winUser.getWindowThreadProcessID(window)[0]) # If Java access bridge is running, and this is a java window, then pass it to java and forget about it if (childID == 0 and objectID == winUser.OBJID_CLIENT and JABHandler.isRunning and JABHandler.isJavaWindow(window)): JABHandler.event_enterJavaWindow(window) return True # Convert the win event to an NVDA event NVDAEvent = winEventToNVDAEvent(winUser.EVENT_OBJECT_FOCUS, window, objectID, childID, useCache=False) if not NVDAEvent: return False eventName, obj = NVDAEvent if ((childID == 0 and obj.IAccessibleRole == oleacc.ROLE_SYSTEM_LIST) or (objectID == winUser.OBJID_CLIENT and "SysListView32" in obj.windowClassName)): # Some controls incorrectly fire focus on child ID 0, even when there is a child with focus. try: realChildID = obj.IAccessibleObject.accFocus except: # noqa: E722 Bare except realChildID = None if isinstance(realChildID, int) and realChildID > 0 and realChildID != childID: realObj = NVDAObjects.IAccessible.IAccessible( IAccessibleObject=obj.IAccessibleObject, IAccessibleChildID=realChildID, event_windowHandle=window, event_objectID=objectID, event_childID=realChildID) if realObj: obj = realObj return processFocusNVDAEvent(obj, force=force)
def processFocusWinEvent(window,objectID,childID,force=False): """checks to see if the focus win event is not the same as the existing focus, then converts the win event to an NVDA event (instanciating an NVDA Object) then calls processFocusNVDAEvent. If all is ok it returns True. @type window: integer @param objectID: a win event's object ID @type objectID: integer @param childID: a win event's child ID @type childID: integer @param force: If True, the shouldAllowIAccessibleFocusEvent property of the object is ignored. @type force: boolean @returns: True if the focus is valid and was handled, False otherwise. @rtype: boolean """ windowClassName=winUser.getClassName(window) # Generally, we must ignore focus on child windows of SDM windows as we only want the SDM MSAA events. # However, we don't want to ignore focus if the child ID isn't 0, # as this is a child control and the SDM MSAA events don't handle child controls. if childID==0 and not windowClassName.startswith('bosa_sdm') and winUser.getClassName(winUser.getAncestor(window,winUser.GA_PARENT)).startswith('bosa_sdm'): return False rootWindow=winUser.getAncestor(window,winUser.GA_ROOT) # If this window is not within the foreground window and this window or its root window is not a popup window, and this window's root window is not the highest in the z-order if not winUser.isDescendantWindow(winUser.getForegroundWindow(),window) and not (winUser.getWindowStyle(window) & winUser.WS_POPUP or winUser.getWindowStyle(rootWindow)&winUser.WS_POPUP) and winUser.getPreviousWindow(rootWindow)!=0: # This is a focus event from a background window, so ignore it. return False #Notify appModuleHandler of this new foreground window appModuleHandler.update(winUser.getWindowThreadProcessID(window)[0]) #If Java access bridge is running, and this is a java window, then pass it to java and forget about it if JABHandler.isRunning and JABHandler.isJavaWindow(window): JABHandler.event_enterJavaWindow(window) return True #Convert the win event to an NVDA event NVDAEvent=winEventToNVDAEvent(winUser.EVENT_OBJECT_FOCUS,window,objectID,childID,useCache=False) if not NVDAEvent: return False eventName,obj=NVDAEvent if (childID==0 and obj.IAccessibleRole==oleacc.ROLE_SYSTEM_LIST) or (objectID==winUser.OBJID_CLIENT and "SysListView32" in obj.windowClassName): # Some controls incorrectly fire focus on child ID 0, even when there is a child with focus. try: realChildID=obj.IAccessibleObject.accFocus except: realChildID=None if isinstance(realChildID,int) and realChildID>0 and realChildID!=childID: realObj=NVDAObjects.IAccessible.IAccessible(IAccessibleObject=obj.IAccessibleObject,IAccessibleChildID=realChildID,event_windowHandle=window,event_objectID=objectID,event_childID=realChildID) if realObj: obj=realObj return processFocusNVDAEvent(obj,force=force)
def processForegroundWinEvent(window, objectID, childID): """checks to see if the foreground win event is not the same as the existing focus or any of its parents, then converts the win event to an NVDA event (instantiating an NVDA Object) and then checks the NVDAObject against the existing focus object. If all is ok it queues the foreground event to NVDA and returns True. @param window: a win event's window handle @type window: integer @param objectID: a win event's object ID @type objectID: integer @param childID: a win event's child ID @type childID: integer @returns: True if the foreground was processed, False otherwise. @rtype: boolean """ # Ignore foreground events on windows that aren't the current foreground window if window != winUser.getForegroundWindow(): return False # If there is a pending gainFocus, it will handle the foreground object. oldFocus = eventHandler.lastQueuedFocusObject # If this foreground win event's window is an ancestor of the existing focus's window, then ignore it if (isinstance(oldFocus, NVDAObjects.window.Window) and winUser.isDescendantWindow(window, oldFocus.windowHandle)): return False # If the existing focus has the same win event params as these, then ignore this event if (isinstance(oldFocus, NVDAObjects.IAccessible.IAccessible) and window == oldFocus.event_windowHandle and objectID == oldFocus.event_objectID and childID == oldFocus.event_childID): return False # Notify appModuleHandler of this new foreground window appModuleHandler.update(winUser.getWindowThreadProcessID(window)[0]) # If Java access bridge is running, and this is a java window, then pass it to java and forget about it if JABHandler.isRunning and JABHandler.isJavaWindow(window): JABHandler.event_enterJavaWindow(window) return True # Convert the win event to an NVDA event NVDAEvent = winEventToNVDAEvent(winUser.EVENT_SYSTEM_FOREGROUND, window, objectID, childID, useCache=False) if not NVDAEvent: return False eventHandler.queueEvent(*NVDAEvent) return True
def processForegroundWinEvent(window,objectID,childID): """checks to see if the foreground win event is not the same as the existing focus or any of its parents, then converts the win event to an NVDA event (instanciating an NVDA Object) and then checks the NVDAObject against the existing focus object. If all is ok it queues the foreground event to NVDA and returns True. @param window: a win event's window handle @type window: integer @param objectID: a win event's object ID @type objectID: integer @param childID: a win event's child ID @type childID: integer @returns: True if the foreground was processed, False otherwise. @rtype: boolean """ #Ignore foreground events on windows that aren't the current foreground window if window!=winUser.getForegroundWindow(): return False # If there is a pending gainFocus, it will handle the foreground object. oldFocus=eventHandler.lastQueuedFocusObject #If this foreground win event's window is an ancestor of the existing focus's window, then ignore it if isinstance(oldFocus,NVDAObjects.window.Window) and winUser.isDescendantWindow(window,oldFocus.windowHandle): return False #If the existing focus has the same win event params as these, then ignore this event if isinstance(oldFocus,NVDAObjects.IAccessible.IAccessible) and window==oldFocus.event_windowHandle and objectID==oldFocus.event_objectID and childID==oldFocus.event_childID: return False #Notify appModuleHandler of this new foreground window appModuleHandler.update(winUser.getWindowThreadProcessID(window)[0]) #If Java access bridge is running, and this is a java window, then pass it to java and forget about it if JABHandler.isRunning and JABHandler.isJavaWindow(window): JABHandler.event_enterJavaWindow(window) return True #Convert the win event to an NVDA event NVDAEvent=winEventToNVDAEvent(winUser.EVENT_SYSTEM_FOREGROUND,window,objectID,childID,useCache=False) if not NVDAEvent: return False eventHandler.queueEvent(*NVDAEvent) return True