diff --git a/source/NVDAObjects/IAccessible/__init__.py b/source/NVDAObjects/IAccessible/__init__.py index 1242e1f9b17..9a72d16f5b8 100644 --- a/source/NVDAObjects/IAccessible/__init__.py +++ b/source/NVDAObjects/IAccessible/__init__.py @@ -33,6 +33,7 @@ from NVDAObjects import NVDAObject, NVDAObjectTextInfo, InvalidNVDAObject import NVDAObjects.JAB import eventHandler +import core from NVDAObjects.behaviors import ProgressBar, Dialog, EditableTextWithAutoSelectDetection, FocusableUnfocusableContainer, ToolTip, Notification from locationHelper import RectLTWH @@ -1934,9 +1935,28 @@ def event_alert(self): speech.speakObject(child,reason=controlTypes.REASON_FOCUS) child=child.simpleNext +class Desktop(IAccessible): + """ + An IAccessible overlay class for the Desktop (root of all windows on the system). + """ + + # In the past, The Desktop NVDAObject was just a Window, not IAccessible. + # But now with the introduction of Virtual Desktops in Windows 10, Desktops can have names, thus why IAccessible is used. + # But, we still want to maintain compatibility with the existing tree structure, thus its role is still Window, and it has no parent, next or previous objects. + role=controlTypes.ROLE_WINDOW + parent=None + next=None + previous=None + + def event_nameChange(self): + # Instruct eventHandler to detect and handle a possible desktop name change, if it has not already. + # It is slightly delayed just in case a focus event is already going to occur, which will handle the name change itself. + core.callLater(250,eventHandler.handlePossibleDesktopNameChange) + ###class mappings _staticMap={ + ("#32769",oleacc.ROLE_SYSTEM_CLIENT):"Desktop", ("ReBarWindow32",oleacc.ROLE_SYSTEM_CLIENT):"ReBarWindow32Client", ("Static",oleacc.ROLE_SYSTEM_STATICTEXT):"StaticText", ("msctls_statusbar32",oleacc.ROLE_SYSTEM_STATICTEXT):"StaticText", diff --git a/source/NVDAObjects/window/__init__.py b/source/NVDAObjects/window/__init__.py index 93b644863cd..db715b2a3b6 100644 --- a/source/NVDAObjects/window/__init__.py +++ b/source/NVDAObjects/window/__init__.py @@ -83,9 +83,6 @@ class Window(NVDAObject): def getPossibleAPIClasses(cls,kwargs,relation=None): windowHandle=kwargs['windowHandle'] windowClassName=winUser.getClassName(windowHandle) - #The desktop window should stay as a window - if windowClassName=="#32769": - return #If this window has a ghost window its too dangerous to try any higher APIs if GhostWindowFromHungWindow and GhostWindowFromHungWindow(windowHandle): return diff --git a/source/eventHandler.py b/source/eventHandler.py index 6f724c293ef..9f013ff7619 100755 --- a/source/eventHandler.py +++ b/source/eventHandler.py @@ -5,6 +5,8 @@ #Copyright (C) 2007-2017 NV Access Limited, Babbage B.V. import threading +import winVersion +import ui import queueHandler import api import speech @@ -24,6 +26,22 @@ _pendingEventCountsByNameAndObj={} # Needed to ensure updates are atomic, as these might be updated from multiple threads simultaneously. _pendingEventCountsLock=threading.RLock() +_lastDesktopName=None + +def handlePossibleDesktopNameChange(): + """ + Reports the new virtual desktop name if changed. + On Windows versions lower than Windows 10, this function does nothing. + """ + global _lastDesktopName + # Desktop switch reporting can only be supported on Windows 10 May 2019 Update and above, + # As previous Windows builds could experience delays and incorrect desktop names. + if winVersion.winVersion>=(10,0,18334): + import UIAHandler + newName=UIAHandler.handler.rootElement.currentName + if newName!=_lastDesktopName: + ui.message(newName) + _lastDesktopName=newName #: the last object queued for a gainFocus event. Useful for code running outside NVDA's core queue lastQueuedFocusObject=None @@ -172,6 +190,7 @@ def doPreGainFocus(obj,sleepMode=False): newForeground=obj api.setForegroundObject(newForeground) executeEvent('foreground',newForeground) + handlePossibleDesktopNameChange() if sleepMode: return True #Fire focus entered events for all new ancestors of the focus if this is a gainFocus event for parent in globalVars.focusAncestors[globalVars.focusDifferenceLevel:]: diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index eb10eb50dec..81a8d5688a0 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -24,6 +24,7 @@ What's New in NVDA - Browse mode keystrokes are slow to respond. - For braille display drivers that support it, driver settings can now be changed from the braille settings category in NVDA's settings dialog. (#7452) - Freedom Scientific braille displays are now supported by braille display auto detection. (#7727) +- The name of the current virtual desktop on windows 10 May 2019update is now reported when switching virtual desktops. (#5641) == Changes ==