Skip to content
20 changes: 20 additions & 0 deletions source/NVDAObjects/IAccessible/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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",
Expand Down
3 changes: 0 additions & 3 deletions source/NVDAObjects/window/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions source/eventHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:]:
Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -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 ==
Expand Down