Repository: nvaccess/nvda

Issue:
Windows 10 settings: NVDA does not provide easy access to the back button
In the Windows 10 settings app, win+i, The back button appears adjacent to the system menu and to the minimize, maximize, and close buttons. But, navigation to this button via the NVDA object navigation leads to a lot of confusion. there are multiple "Settings window" objects that appear in the object navigation. For example, two "Settings Window; settings" objects appear adjacent to each other and more. This behavior does not occur in Narrator. I've asked Microsoft to assign a keyboard command to Back and Home buttons. But, ideally, both home and back buttons should appear in the tab order. Let me know if you want a log.
STR:
1. Open the Settings app (windows+i).
2. Go to one of the settings such as "updates and security."
3. Use object nav to move up the hierarchy to the "settings window" level and move to the next and previous objects.

Test environment: Windows 10 Pro build 15048 
NVDA version next-13899,af44c1d4



Discussion:
I can confirm this. Narrator navigation is difficult to compare with NVDA
object navigation because Narrator's navigation is completely flat, which
is not always a good thing; e.g. where there are multiple large containers.
Regardless, these window objects don't really serve any useful purpose and
just confuse the user. The question is how to filter them out without
breaking cases where these might be useful.

@MichaelDCurran, aside from top level windows, do you think having windows
in simple review (even if they are labelled) is actually useful? I guess we
chose to do this for a reason, but I can't really remember why. It's also
worth noting that these windows are not considered to be "content elements"
by UIA (though they are unfortunately considered "control elements").
Should we be using the UIA content element check for presentationType? I'm
concerned this might filter out more than we want, but in the modern world,
it seems like less objects is a lesser evil than more.

Btw, you can go back with the keyboard quickly by pressing backspace.

Ah. I hadn’t realized the backspace command was working there. I should have tried and known. Thank you.


Resolving patch:
diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py
--- a/source/NVDAObjects/UIA/__init__.py
+++ b/source/NVDAObjects/UIA/__init__.py
@@ -871,6 +871,13 @@ def _get_states(self):
 					states.add(controlTypes.STATE_CHECKED)
 		return states
 
+	def _get_presentationType(self):
+		presentationType=super(UIA,self).presentationType
+		# UIA NVDAObjects can only be considered content if UI Automation considers them both a control and content.
+		if presentationType==self.presType_content and not (self.UIAElement.cachedIsContentElement and self.UIAElement.cachedIsControlElement):
+			presentationType=self.presType_layout
+		return presentationType 
+
 	def correctAPIForRelation(self, obj, relation=None):
 		if obj and self.windowHandle != obj.windowHandle and not obj.UIAElement.cachedNativeWindowHandle:
 			# The target element is not the root element for the window, so don't change API class; i.e. always use UIA.
diff --git a/source/_UIAHandler.py b/source/_UIAHandler.py
--- a/source/_UIAHandler.py
+++ b/source/_UIAHandler.py
@@ -181,7 +181,7 @@ def MTAThreadFunc(self):
 			import UIAHandler
 			self.ItemIndex_PropertyId=NVDAHelper.localLib.registerUIAProperty(byref(ItemIndex_Property_GUID),u"ItemIndex",1)
 			self.ItemCount_PropertyId=NVDAHelper.localLib.registerUIAProperty(byref(ItemCount_Property_GUID),u"ItemCount",1)
-			for propertyId in (UIA_FrameworkIdPropertyId,UIA_AutomationIdPropertyId,UIA_ClassNamePropertyId,UIA_ControlTypePropertyId,UIA_ProviderDescriptionPropertyId,UIA_ProcessIdPropertyId,UIA_IsTextPatternAvailablePropertyId):
+			for propertyId in (UIA_FrameworkIdPropertyId,UIA_AutomationIdPropertyId,UIA_ClassNamePropertyId,UIA_ControlTypePropertyId,UIA_ProviderDescriptionPropertyId,UIA_ProcessIdPropertyId,UIA_IsTextPatternAvailablePropertyId,UIA_IsContentElementPropertyId,UIA_IsControlElementPropertyId):
 				self.baseCacheRequest.addProperty(propertyId)
 			self.baseCacheRequest.addPattern(UIA_TextPatternId)
 			self.rootElement=self.clientObject.getRootElementBuildCache(self.baseCacheRequest)


Test patch: