Repository: nvaccess/nvda

Issue:
Windows 11 22H2 (Moment 2): redesigned system tray overflow window cannot be interacted with using mouse and/or touch
Hi,

Follow-up to #14538 but won't show up for a while (Insider Preview feature at the moment):

### Background:
As part of Windows 11 22H2 Moment 2 (under testing), redesigned taskbar and system tray will be made available to users, more so if using tablets such as two-in-one devices. At least taskbar can be navigated using mouse and/or touch, but the redesigned system tray overflow window cannot (at the moment).

### Steps to reproduce:
Prerequisites: Windows 11 22H2 beta builds (one must be a Windows Insider to test this):

1. Install Windows 11 22H2 build 22623 or later (must be a Windows Insider subscribed to beta and/or dev channel).
2. Enable mouse tracking (NVDA+M) and follow mouse from review cursor settings panel.
3. Press Windows+B to move focus to system tray/show hidden icons button.
4. Press Space to activate it.
5. Use the mouse to navigate the overflow window.

### Actual behavior:
No announcement from NVDA regarding overflow buttons.

### Expected behavior:
NVDA announces overflow buttons when moving the mouse.

### NVDA logs, crash dumps and other attachments:

### System configuration
#### NVDA installed/portable/running from source:
Installed

#### NVDA version:
alpha-27514

#### Windows version:
Windows 11 22H2 beta (10.0.22623)

#### Name and version of other software in use when reproducing the issue:
None

#### Other information about your system:
This is an Insider Preview machine

### Other questions
#### Does the issue still occur after restarting your computer?
Yes

#### Have you tried any other versions of NVDA? If so, please report their behaviors.
Yes - reproducible in 2022.4

#### If NVDA add-ons are disabled, is your problem still occurring?
Yes

#### Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu?
N/A

### Solution:
Treat the top-level window of the redesigned system tray overflow window as good UIA window (window class name: TopLevelWindowForOverflowXamlIsland). Windows App Essentials add-on includes this solution.



Discussion:
Hi,

Two pull request options:

1. A combined pull request that also resolves #14538
2. A separate pull request just for resolving this issue once Moment 2 comes to release preview channel

The combined pull request can simplify the resulting changelog and get the Moment 2 change ready for 2023.1, while the separate pull request approach can anticipate possible late changes to redesigned system tray overflow menu by the time it comes to release preview. I'm leaning toward the former at the moment as the system tray redesign is here to stay unless Microsoft changes things in January and February.

Thanks.

Resolving patch:
diff --git a/source/appModules/explorer.py b/source/appModules/explorer.py
--- a/source/appModules/explorer.py
+++ b/source/appModules/explorer.py
@@ -1,6 +1,6 @@
 # -*- coding: UTF-8 -*-
 # A part of NonVisual Desktop Access (NVDA)
-# Copyright (C) 2006-2022 NV Access Limited, Joseph Lee, Łukasz Golonka, Julien Cochuyt
+# Copyright (C) 2006-2023 NV Access Limited, Joseph Lee, Łukasz Golonka, Julien Cochuyt
 # This file is covered by the GNU General Public License.
 # See the file COPYING for more details.
 
@@ -23,6 +23,7 @@
 from NVDAObjects.behaviors import ToolTip
 from NVDAObjects.window.edit import RichEdit50, EditTextInfo
 import config
+from winAPI.types import HWNDValT
 
 
 # Suppress incorrect Win 10 Task switching window focus
@@ -504,7 +505,7 @@ def event_gainFocus(self, obj, nextHandler):
 
 		nextHandler()
 
-	def isGoodUIAWindow(self, hwnd):
+	def isGoodUIAWindow(self, hwnd: HWNDValT) -> bool:
 		currentWinVer = winVersion.getWinVer()
 		# #9204: shell raises window open event for emoji panel in build 18305 and later.
 		if (
@@ -528,6 +529,7 @@ def isGoodUIAWindow(self, hwnd):
 				# Top-level window class names from Windows 11 shell features
 				"Shell_InputSwitchTopLevelWindow",  # Language switcher
 				"XamlExplorerHostIslandWindow",  # Task View and Snap Layouts
+				"TopLevelWindowForOverflowXamlIsland",  # #14539: redesigned systray overflow in 22H2
 			)
 			# #13717: on some systems, Windows 11 shell elements are reported as IAccessible,
 			# notably Start button, causing IAccessible handler to report attribute error when handling events.
diff --git a/source/appModules/openwith.py b/source/appModules/openwith.py
--- a/source/appModules/openwith.py
+++ b/source/appModules/openwith.py
@@ -1,5 +1,5 @@
 # A part of NonVisual Desktop Access (NVDA)
-# Copyright (C) 2011-2022 NV Access Limited, Joseph Lee
+# Copyright (C) 2011-2023 NV Access Limited, Joseph Lee
 # This file is covered by the GNU General Public License.
 # See the file COPYING for more details.
 
@@ -8,6 +8,7 @@
 from NVDAObjects.UIA import UIA
 from NVDAObjects.behaviors import Dialog
 import winUser
+from winAPI.types import HWNDValT
 
 #win8hack: the nondefault items in the list of applications are not labeled
 class NonDefaultAppTile(UIA):
@@ -40,9 +41,14 @@ def chooseNVDAObjectOverlayClasses(self, obj, clsList):
 			elif automationId == "ImmersiveOpenWithFlyout":
 				clsList.insert(0, ImmersiveOpenWithFlyout)
 
-	def isGoodUIAWindow(self, hwnd):
-		# #11335: Open With dialog isn't read in Windows 10 Version 2004 (May 2020 Update).
-		# Note that treating the below window as a UIA window will make NVDA no longer announce "pane".
-		if winUser.getClassName(hwnd) == "Shell_Flyout":
+	def isGoodUIAWindow(self, hwnd: HWNDValT) -> bool:
+		if winUser.getClassName(hwnd) in (
+			# #11335: Open With dialog isn't read in Windows 10 Version 2004 (May 2020 Update).
+			# Note that treating the below window as a UIA window will make NVDA no longer announce "pane".
+			"Shell_Flyout",
+			# #14538: Windows 11 Version 22H2 (2022 Update) comes with a modernized Open With dialog
+			# but prevents proper mouse and touch interaction.
+			"Open With",
+		):
 			return True
 		return False


Test patch: