From f924868e0782633a0a4bc146ed394bf689b4e8f0 Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Fri, 11 May 2018 10:27:50 +1000 Subject: [PATCH 1/7] Report virtual desktop switches in Windows 10. The desktop is checked on focus changes, and also the desktop's own name changes in case the focus does not move (such as when on the task bar). --- source/NVDAObjects/IAccessible/__init__.py | 13 +++++++++++++ source/eventHandler.py | 17 +++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/source/NVDAObjects/IAccessible/__init__.py b/source/NVDAObjects/IAccessible/__init__.py index bed54661a28..d7db9bccc87 100644 --- a/source/NVDAObjects/IAccessible/__init__.py +++ b/source/NVDAObjects/IAccessible/__init__.py @@ -30,6 +30,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 @@ -1829,9 +1830,21 @@ 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). + Note that IAccessible is not usually used for the Desktop at all, except for Desktop name Changes. + """ + + 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/eventHandler.py b/source/eventHandler.py index af95d062704..c8e2d6097c8 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,20 @@ _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 + if winVersion.winVersion.major>=10: + 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 @@ -169,6 +185,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:]: From 0f692c4e6937ac9d7f11bc96a379fa68357741a2 Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Thu, 21 Feb 2019 16:41:45 +1000 Subject: [PATCH 2/7] eventHandler: desktop switches can only be reported on Windows 10 April 2019 and above. --- source/eventHandler.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/eventHandler.py b/source/eventHandler.py index 80439d41c8c..1cb4249fa71 100755 --- a/source/eventHandler.py +++ b/source/eventHandler.py @@ -34,7 +34,9 @@ def handlePossibleDesktopNameChange(): On Windows versions lower than Windows 10, this function does nothing. """ global _lastDesktopName - if winVersion.winVersion.major>=10: + # Desktop switch reporting can only be supported on Windows 10 April 2019 and above, + # As previous Windows builds could experience delays and incorrect desktop names. + if winVersion.winVersion.major>=(10,0,18334): import UIAHandler newName=UIAHandler.handler.rootElement.currentName if newName!=_lastDesktopName: From cc5000d9e36e1274e2ca6a39878ef36d261a8867 Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Thu, 21 Feb 2019 16:44:51 +1000 Subject: [PATCH 3/7] Update what's new. --- user_docs/en/changes.t2t | 1 + 1 file changed, 1 insertion(+) diff --git a/user_docs/en/changes.t2t b/user_docs/en/changes.t2t index a7c40721688..bdf10f54936 100644 --- a/user_docs/en/changes.t2t +++ b/user_docs/en/changes.t2t @@ -24,6 +24,7 @@ What's New in NVDA - Rubber band effect: NVDA sporadically undoes the last browse mode keystroke by jumping to the previous location. - Edit boxes steal system focus when arrowing down through them on some websites. - Browse mode keystrokes are slow to respond. +- The name of the current virtual desktop is now reported when switching virtual desktops on Windows 10 April 2019 and above. (#8259) == Changes == From 36e5eca3fe3626a5d400eba2b84776096d91be09 Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Thu, 21 Feb 2019 17:38:13 +1000 Subject: [PATCH 4/7] Fix winVersion check for virtual desktop switches. --- source/eventHandler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/eventHandler.py b/source/eventHandler.py index 1cb4249fa71..7651911ad39 100755 --- a/source/eventHandler.py +++ b/source/eventHandler.py @@ -36,7 +36,7 @@ def handlePossibleDesktopNameChange(): global _lastDesktopName # Desktop switch reporting can only be supported on Windows 10 April 2019 and above, # As previous Windows builds could experience delays and incorrect desktop names. - if winVersion.winVersion.major>=(10,0,18334): + if winVersion.winVersion>=(10,0,18334): import UIAHandler newName=UIAHandler.handler.rootElement.currentName if newName!=_lastDesktopName: From e0ce008108ef6921a9b6248d4b4a199b4b478b57 Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Fri, 22 Feb 2019 08:17:43 +1000 Subject: [PATCH 5/7] Desktop IAccessible NVDAObject: hardcode its role to window, and ensure that parent, next and previous are all None, so that it could be used for the root of the NVDAObject tree. Window NVDAObject: don't ban the desktop window class from using a higher API, which means it will no use IAccessible., and therefore on newer Windows 10 builds, the virtual desktop name will be reflected in the Desktop NVDAObject's name. --- source/NVDAObjects/IAccessible/__init__.py | 9 ++++++++- source/NVDAObjects/window/__init__.py | 3 --- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/source/NVDAObjects/IAccessible/__init__.py b/source/NVDAObjects/IAccessible/__init__.py index 693034f1c82..ff274cda880 100644 --- a/source/NVDAObjects/IAccessible/__init__.py +++ b/source/NVDAObjects/IAccessible/__init__.py @@ -1906,9 +1906,16 @@ def event_alert(self): class Desktop(IAccessible): """ An IAccessible overlay class for the Desktop (root of all windows on the system). - Note that IAccessible is not usually used for the Desktop at all, except for Desktop name Changes. """ + # 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. diff --git a/source/NVDAObjects/window/__init__.py b/source/NVDAObjects/window/__init__.py index 102dfee0b14..650ec9c0d7c 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 From c36aa6b217ecb7488f8ee871a3b065cb9d9d86f9 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Mon, 20 May 2019 23:22:43 -0700 Subject: [PATCH 6/7] Event handler: April 2019 -> May 2019 Update --- source/eventHandler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/eventHandler.py b/source/eventHandler.py index 7651911ad39..9f013ff7619 100755 --- a/source/eventHandler.py +++ b/source/eventHandler.py @@ -34,7 +34,7 @@ def handlePossibleDesktopNameChange(): On Windows versions lower than Windows 10, this function does nothing. """ global _lastDesktopName - # Desktop switch reporting can only be supported on Windows 10 April 2019 and above, + # 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 From 9a5f43861741db9ee3d59cda497651b46abc4b98 Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Wed, 22 May 2019 11:19:51 +1000 Subject: [PATCH 7/7] Update what's new. --- user_docs/en/changes.t2t | 1 + 1 file changed, 1 insertion(+) 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 ==