prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Windows 10 Calculator: results are not announced in compact overlay mode
  Hi,
  
  Follow-up to PR #9429 
  
  ### Steps to reproduce:
  In Windows 10 Calculator:
  
  1. Switch to standard calculator mode (Alt+number row 1).
  2. Press Alt+Up arrow to switch to always on top (compact overlay) mode.
  3. Perform some calculations.
  
  ### Actual behavior:
  Results are not announced.
  
  ### Expected behavior:
  Results are announced.
  
  ### System configuration
  #### NVDA installed/portable/running from source:
  Installed
  
  #### NVDA version:
  alpha-21429,874230a7
  
  #### Windows version:
  Windows 10 Version 20H2 (build 19042.662 beta)
  
  #### Name and version of other software in use when reproducing the issue:
  Calculator 10.2010.0.0
  
  #### Other information about your system:
  N/A
  
  ### 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.
  Same behavior in 2020.3.
  
  #### If addons are disabled, is your problem still occuring?
  Yes
  
  #### Did you try to run the COM registry fixing tool in NVDA menu / tools?
  Not applicable
  
  ### Additional context and solution
  Caused by a missing Automation Id that should be included in result announcement script (UIA Automation Id is different for always on top result element). The same PR for #11880 will be applicable to this issue as well.
  
  Thanks.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `source/appModules/calculator.py`
  Content:
  ```
  1 # A part of NonVisual Desktop Access (NVDA)
  2 # Copyright (C) 2020 NV Access Limited, Joseph Lee
  3 # This file is covered by the GNU General Public License.
  4 # See the file COPYING for more details.
  5 
  6 """App module for Windows 10 Calculator"""
  7 
  8 import appModuleHandler
  9 import api
  10 from NVDAObjects.UIA import UIA
  11 import queueHandler
  12 import ui
  13 import scriptHandler
  14 
  15 # #9428: do not announce current values until calculations are done in order to avoid repetitions.
  16 noCalculatorEntryAnnouncements = [
  17 	# Display field with Calculator set to full screen mode.
  18 	"CalculatorResults",
  19 	# In the middle of a calculation expression entry.
  20 	"CalculatorExpression",
  21 	# Results display with Calculator set to compact overlay i.e. always on top mode.
  22 	"CalculatorAlwaysOnTopResults",
  23 	# Calculator expressions with Calculator set to always on top mode.
  24 	"ExpressionContainer",
  25 	# Date range selector.
  26 	"ContentPresenter",
  27 	# Briefly shown when closing date calculation calendar.
  28 	"Light Dismiss",
  29 ]
  30 
  31 
  32 class AppModule(appModuleHandler.AppModule):
  33 
  34 	_shouldAnnounceResult = False
  35 	# Name change says the same thing multiple times for some items.
  36 	_resultsCache = ""
  37 
  38 	def event_nameChange(self, obj, nextHandler):
  39 		if not isinstance(obj, UIA):
  40 			return
  41 		# No, announce value changes immediately except for calculator results and expressions.
  42 		if (
  43 			obj.UIAAutomationId in noCalculatorEntryAnnouncements
  44 			or obj.UIAElement.cachedClassName == "LandmarkTarget"
  45 		):
  46 			self._shouldAnnounceResult = False
  47 		# For the rest:
  48 		elif (
  49 			obj.UIAAutomationId not in noCalculatorEntryAnnouncements
  50 			and obj.name != self._resultsCache
  51 		):
  52 			# For unit conversion, UIA notification event presents much better messages.
  53 			# For date calculation, live region change event is also fired for difference between dates.
  54 			if obj.UIAAutomationId not in ("Value1", "Value2", "DateDiffAllUnitsResultLabel"):
  55 				ui.message(obj.name)
  56 			self._resultsCache = obj.name
  57 		if not self._shouldAnnounceResult:
  58 			return
  59 		self._shouldAnnounceResult = False
  60 		nextHandler()
  61 
  62 	def event_UIA_notification(self, obj, nextHandler, activityId=None, **kwargs):
  63 		try:
  64 			shouldAnnounceNotification = (
  65 				obj.previous.UIAAutomationId in
  66 				("numberPad", "UnitConverterRootGrid")
  67 			)
  68 		except AttributeError:
  69 			resultElement = api.getForegroundObject().children[1].lastChild
  70 			# Redesigned in 2019 due to introduction of "always on top" i.e. compact overlay mode.
  71 			if resultElement.UIAElement.cachedClassName != "LandmarkTarget":
  72 				resultElement = resultElement.parent.children[1]
  73 			shouldAnnounceNotification = (
  74 				resultElement
  75 				and resultElement.firstChild
  76 				and resultElement.firstChild.UIAAutomationId not in noCalculatorEntryAnnouncements
  77 			)
  78 		# Display updated activity ID seen when entering calculations should be ignored
  79 		# as as it is redundant if speak typed characters is on.
  80 		if shouldAnnounceNotification or activityId != "DisplayUpdated":
  81 			nextHandler()
  82 
  83 	# A list of native commands to handle calculator result announcement.
  84 	_calculatorResultGestures = ("kb:enter", "kb:numpadEnter", "kb:escape")
  85 
  86 	@scriptHandler.script(gestures=_calculatorResultGestures)
  87 	def script_calculatorResult(self, gesture):
  88 		# To prevent double focus announcement, check where we are.
  89 		focus = api.getFocusObject()
  90 		gesture.send()
  91 		# In redstone, calculator result keeps firing name change,
  92 		# so tell it to do so if and only if enter has been pressed.
  93 		self._shouldAnnounceResult = True
  94 		# Hack: only announce display text when an actual calculator button (usually equals button) is pressed.
  95 		# In redstone, pressing enter does not move focus to equals button.
  96 		if isinstance(focus, UIA):
  97 			if focus.UIAAutomationId == "CalculatorResults":
  98 				queueHandler.queueFunction(queueHandler.eventQueue, focus.reportFocus)
  99 			else:
  100 				resultsScreen = api.getForegroundObject().children[1].lastChild
  101 				if isinstance(resultsScreen, UIA) and resultsScreen.UIAElement.cachedClassName == "LandmarkTarget":
  102 					# And no, do not allow focus to move.
  103 					queueHandler.queueFunction(queueHandler.eventQueue, resultsScreen.firstChild.reportFocus)
  104
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/source/appModules/calculator.py b/source/appModules/calculator.py
  --- a/source/appModules/calculator.py
  +++ b/source/appModules/calculator.py
  @@ -26,6 +26,10 @@
   	"ContentPresenter",
   	# Briefly shown when closing date calculation calendar.
   	"Light Dismiss",
  +	# Unit conversion/convert from.
  +	"Value1",
  +	# Unit conversion/converts into.
  +	"Value2",
   ]
   
   
  @@ -49,9 +53,10 @@
   			obj.UIAAutomationId not in noCalculatorEntryAnnouncements
   			and obj.name != self._resultsCache
   		):
  -			# For unit conversion, UIA notification event presents much better messages.
  +			# For unit conversion, both name change and notification events are fired,
  +			# although UIA notification event presents much better messages.
   			# For date calculation, live region change event is also fired for difference between dates.
  -			if obj.UIAAutomationId not in ("Value1", "Value2", "DateDiffAllUnitsResultLabel"):
  +			if obj.UIAAutomationId != "DateDiffAllUnitsResultLabel":
   				ui.message(obj.name)
   			self._resultsCache = obj.name
   		if not self._shouldAnnounceResult:
  @@ -94,7 +99,7 @@
   		# Hack: only announce display text when an actual calculator button (usually equals button) is pressed.
   		# In redstone, pressing enter does not move focus to equals button.
   		if isinstance(focus, UIA):
  -			if focus.UIAAutomationId == "CalculatorResults":
  +			if focus.UIAAutomationId in ("CalculatorResults", "CalculatorAlwaysOnTopResults"):
   				queueHandler.queueFunction(queueHandler.eventQueue, focus.reportFocus)
   			else:
   				resultsScreen = api.getForegroundObject().children[1].lastChild
  
verification_info: {"golden_diff": "diff --git a/source/appModules/calculator.py b/source/appModules/calculator.py\n--- a/source/appModules/calculator.py\n+++ b/source/appModules/calculator.py\n@@ -26,6 +26,10 @@\n \t\"ContentPresenter\",\n \t# Briefly shown when closing date calculation calendar.\n \t\"Light Dismiss\",\n+\t# Unit conversion/convert from.\n+\t\"Value1\",\n+\t# Unit conversion/converts into.\n+\t\"Value2\",\n ]\n \n \n@@ -49,9 +53,10 @@\n \t\t\tobj.UIAAutomationId not in noCalculatorEntryAnnouncements\n \t\t\tand obj.name != self._resultsCache\n \t\t):\n-\t\t\t# For unit conversion, UIA notification event presents much better messages.\n+\t\t\t# For unit conversion, both name change and notification events are fired,\n+\t\t\t# although UIA notification event presents much better messages.\n \t\t\t# For date calculation, live region change event is also fired for difference between dates.\n-\t\t\tif obj.UIAAutomationId not in (\"Value1\", \"Value2\", \"DateDiffAllUnitsResultLabel\"):\n+\t\t\tif obj.UIAAutomationId != \"DateDiffAllUnitsResultLabel\":\n \t\t\t\tui.message(obj.name)\n \t\t\tself._resultsCache = obj.name\n \t\tif not self._shouldAnnounceResult:\n@@ -94,7 +99,7 @@\n \t\t# Hack: only announce display text when an actual calculator button (usually equals button) is pressed.\n \t\t# In redstone, pressing enter does not move focus to equals button.\n \t\tif isinstance(focus, UIA):\n-\t\t\tif focus.UIAAutomationId == \"CalculatorResults\":\n+\t\t\tif focus.UIAAutomationId in (\"CalculatorResults\", \"CalculatorAlwaysOnTopResults\"):\n \t\t\t\tqueueHandler.queueFunction(queueHandler.eventQueue, focus.reportFocus)\n \t\t\telse:\n \t\t\t\tresultsScreen = api.getForegroundObject().children[1].lastChild\n", "issue": "Windows 10 Calculator: results are not announced in compact overlay mode\nHi,\r\n\r\nFollow-up to PR #9429 \r\n\r\n### Steps to reproduce:\r\nIn Windows 10 Calculator:\r\n\r\n1. Switch to standard calculator mode (Alt+number row 1).\r\n2. Press Alt+Up arrow to switch to always on top (compact overlay) mode.\r\n3. Perform some calculations.\r\n\r\n### Actual behavior:\r\nResults are not announced.\r\n\r\n### Expected behavior:\r\nResults are announced.\r\n\r\n### System configuration\r\n#### NVDA installed/portable/running from source:\r\nInstalled\r\n\r\n#### NVDA version:\r\nalpha-21429,874230a7\r\n\r\n#### Windows version:\r\nWindows 10 Version 20H2 (build 19042.662 beta)\r\n\r\n#### Name and version of other software in use when reproducing the issue:\r\nCalculator 10.2010.0.0\r\n\r\n#### Other information about your system:\r\nN/A\r\n\r\n### Other questions\r\n#### Does the issue still occur after restarting your computer?\r\nYes\r\n\r\n#### Have you tried any other versions of NVDA? If so, please report their behaviors.\r\nSame behavior in 2020.3.\r\n\r\n#### If addons are disabled, is your problem still occuring?\r\nYes\r\n\r\n#### Did you try to run the COM registry fixing tool in NVDA menu / tools?\r\nNot applicable\r\n\r\n### Additional context and solution\r\nCaused by a missing Automation Id that should be included in result announcement script (UIA Automation Id is different for always on top result element). The same PR for #11880 will be applicable to this issue as well.\r\n\r\nThanks.\n", "before_files": [{"content": "# A part of NonVisual Desktop Access (NVDA)\n# Copyright (C) 2020 NV Access Limited, Joseph Lee\n# This file is covered by the GNU General Public License.\n# See the file COPYING for more details.\n\n\"\"\"App module for Windows 10 Calculator\"\"\"\n\nimport appModuleHandler\nimport api\nfrom NVDAObjects.UIA import UIA\nimport queueHandler\nimport ui\nimport scriptHandler\n\n# #9428: do not announce current values until calculations are done in order to avoid repetitions.\nnoCalculatorEntryAnnouncements = [\n\t# Display field with Calculator set to full screen mode.\n\t\"CalculatorResults\",\n\t# In the middle of a calculation expression entry.\n\t\"CalculatorExpression\",\n\t# Results display with Calculator set to compact overlay i.e. always on top mode.\n\t\"CalculatorAlwaysOnTopResults\",\n\t# Calculator expressions with Calculator set to always on top mode.\n\t\"ExpressionContainer\",\n\t# Date range selector.\n\t\"ContentPresenter\",\n\t# Briefly shown when closing date calculation calendar.\n\t\"Light Dismiss\",\n]\n\n\nclass AppModule(appModuleHandler.AppModule):\n\n\t_shouldAnnounceResult = False\n\t# Name change says the same thing multiple times for some items.\n\t_resultsCache = \"\"\n\n\tdef event_nameChange(self, obj, nextHandler):\n\t\tif not isinstance(obj, UIA):\n\t\t\treturn\n\t\t# No, announce value changes immediately except for calculator results and expressions.\n\t\tif (\n\t\t\tobj.UIAAutomationId in noCalculatorEntryAnnouncements\n\t\t\tor obj.UIAElement.cachedClassName == \"LandmarkTarget\"\n\t\t):\n\t\t\tself._shouldAnnounceResult = False\n\t\t# For the rest:\n\t\telif (\n\t\t\tobj.UIAAutomationId not in noCalculatorEntryAnnouncements\n\t\t\tand obj.name != self._resultsCache\n\t\t):\n\t\t\t# For unit conversion, UIA notification event presents much better messages.\n\t\t\t# For date calculation, live region change event is also fired for difference between dates.\n\t\t\tif obj.UIAAutomationId not in (\"Value1\", \"Value2\", \"DateDiffAllUnitsResultLabel\"):\n\t\t\t\tui.message(obj.name)\n\t\t\tself._resultsCache = obj.name\n\t\tif not self._shouldAnnounceResult:\n\t\t\treturn\n\t\tself._shouldAnnounceResult = False\n\t\tnextHandler()\n\n\tdef event_UIA_notification(self, obj, nextHandler, activityId=None, **kwargs):\n\t\ttry:\n\t\t\tshouldAnnounceNotification = (\n\t\t\t\tobj.previous.UIAAutomationId in\n\t\t\t\t(\"numberPad\", \"UnitConverterRootGrid\")\n\t\t\t)\n\t\texcept AttributeError:\n\t\t\tresultElement = api.getForegroundObject().children[1].lastChild\n\t\t\t# Redesigned in 2019 due to introduction of \"always on top\" i.e. compact overlay mode.\n\t\t\tif resultElement.UIAElement.cachedClassName != \"LandmarkTarget\":\n\t\t\t\tresultElement = resultElement.parent.children[1]\n\t\t\tshouldAnnounceNotification = (\n\t\t\t\tresultElement\n\t\t\t\tand resultElement.firstChild\n\t\t\t\tand resultElement.firstChild.UIAAutomationId not in noCalculatorEntryAnnouncements\n\t\t\t)\n\t\t# Display updated activity ID seen when entering calculations should be ignored\n\t\t# as as it is redundant if speak typed characters is on.\n\t\tif shouldAnnounceNotification or activityId != \"DisplayUpdated\":\n\t\t\tnextHandler()\n\n\t# A list of native commands to handle calculator result announcement.\n\t_calculatorResultGestures = (\"kb:enter\", \"kb:numpadEnter\", \"kb:escape\")\n\n\t@scriptHandler.script(gestures=_calculatorResultGestures)\n\tdef script_calculatorResult(self, gesture):\n\t\t# To prevent double focus announcement, check where we are.\n\t\tfocus = api.getFocusObject()\n\t\tgesture.send()\n\t\t# In redstone, calculator result keeps firing name change,\n\t\t# so tell it to do so if and only if enter has been pressed.\n\t\tself._shouldAnnounceResult = True\n\t\t# Hack: only announce display text when an actual calculator button (usually equals button) is pressed.\n\t\t# In redstone, pressing enter does not move focus to equals button.\n\t\tif isinstance(focus, UIA):\n\t\t\tif focus.UIAAutomationId == \"CalculatorResults\":\n\t\t\t\tqueueHandler.queueFunction(queueHandler.eventQueue, focus.reportFocus)\n\t\t\telse:\n\t\t\t\tresultsScreen = api.getForegroundObject().children[1].lastChild\n\t\t\t\tif isinstance(resultsScreen, UIA) and resultsScreen.UIAElement.cachedClassName == \"LandmarkTarget\":\n\t\t\t\t\t# And no, do not allow focus to move.\n\t\t\t\t\tqueueHandler.queueFunction(queueHandler.eventQueue, resultsScreen.firstChild.reportFocus)\n", "path": "source/appModules/calculator.py"}], "after_files": [{"content": "# A part of NonVisual Desktop Access (NVDA)\n# Copyright (C) 2020 NV Access Limited, Joseph Lee\n# This file is covered by the GNU General Public License.\n# See the file COPYING for more details.\n\n\"\"\"App module for Windows 10 Calculator\"\"\"\n\nimport appModuleHandler\nimport api\nfrom NVDAObjects.UIA import UIA\nimport queueHandler\nimport ui\nimport scriptHandler\n\n# #9428: do not announce current values until calculations are done in order to avoid repetitions.\nnoCalculatorEntryAnnouncements = [\n\t# Display field with Calculator set to full screen mode.\n\t\"CalculatorResults\",\n\t# In the middle of a calculation expression entry.\n\t\"CalculatorExpression\",\n\t# Results display with Calculator set to compact overlay i.e. always on top mode.\n\t\"CalculatorAlwaysOnTopResults\",\n\t# Calculator expressions with Calculator set to always on top mode.\n\t\"ExpressionContainer\",\n\t# Date range selector.\n\t\"ContentPresenter\",\n\t# Briefly shown when closing date calculation calendar.\n\t\"Light Dismiss\",\n\t# Unit conversion/convert from.\n\t\"Value1\",\n\t# Unit conversion/converts into.\n\t\"Value2\",\n]\n\n\nclass AppModule(appModuleHandler.AppModule):\n\n\t_shouldAnnounceResult = False\n\t# Name change says the same thing multiple times for some items.\n\t_resultsCache = \"\"\n\n\tdef event_nameChange(self, obj, nextHandler):\n\t\tif not isinstance(obj, UIA):\n\t\t\treturn\n\t\t# No, announce value changes immediately except for calculator results and expressions.\n\t\tif (\n\t\t\tobj.UIAAutomationId in noCalculatorEntryAnnouncements\n\t\t\tor obj.UIAElement.cachedClassName == \"LandmarkTarget\"\n\t\t):\n\t\t\tself._shouldAnnounceResult = False\n\t\t# For the rest:\n\t\telif (\n\t\t\tobj.UIAAutomationId not in noCalculatorEntryAnnouncements\n\t\t\tand obj.name != self._resultsCache\n\t\t):\n\t\t\t# For unit conversion, both name change and notification events are fired,\n\t\t\t# although UIA notification event presents much better messages.\n\t\t\t# For date calculation, live region change event is also fired for difference between dates.\n\t\t\tif obj.UIAAutomationId != \"DateDiffAllUnitsResultLabel\":\n\t\t\t\tui.message(obj.name)\n\t\t\tself._resultsCache = obj.name\n\t\tif not self._shouldAnnounceResult:\n\t\t\treturn\n\t\tself._shouldAnnounceResult = False\n\t\tnextHandler()\n\n\tdef event_UIA_notification(self, obj, nextHandler, activityId=None, **kwargs):\n\t\ttry:\n\t\t\tshouldAnnounceNotification = (\n\t\t\t\tobj.previous.UIAAutomationId in\n\t\t\t\t(\"numberPad\", \"UnitConverterRootGrid\")\n\t\t\t)\n\t\texcept AttributeError:\n\t\t\tresultElement = api.getForegroundObject().children[1].lastChild\n\t\t\t# Redesigned in 2019 due to introduction of \"always on top\" i.e. compact overlay mode.\n\t\t\tif resultElement.UIAElement.cachedClassName != \"LandmarkTarget\":\n\t\t\t\tresultElement = resultElement.parent.children[1]\n\t\t\tshouldAnnounceNotification = (\n\t\t\t\tresultElement\n\t\t\t\tand resultElement.firstChild\n\t\t\t\tand resultElement.firstChild.UIAAutomationId not in noCalculatorEntryAnnouncements\n\t\t\t)\n\t\t# Display updated activity ID seen when entering calculations should be ignored\n\t\t# as as it is redundant if speak typed characters is on.\n\t\tif shouldAnnounceNotification or activityId != \"DisplayUpdated\":\n\t\t\tnextHandler()\n\n\t# A list of native commands to handle calculator result announcement.\n\t_calculatorResultGestures = (\"kb:enter\", \"kb:numpadEnter\", \"kb:escape\")\n\n\t@scriptHandler.script(gestures=_calculatorResultGestures)\n\tdef script_calculatorResult(self, gesture):\n\t\t# To prevent double focus announcement, check where we are.\n\t\tfocus = api.getFocusObject()\n\t\tgesture.send()\n\t\t# In redstone, calculator result keeps firing name change,\n\t\t# so tell it to do so if and only if enter has been pressed.\n\t\tself._shouldAnnounceResult = True\n\t\t# Hack: only announce display text when an actual calculator button (usually equals button) is pressed.\n\t\t# In redstone, pressing enter does not move focus to equals button.\n\t\tif isinstance(focus, UIA):\n\t\t\tif focus.UIAAutomationId in (\"CalculatorResults\", \"CalculatorAlwaysOnTopResults\"):\n\t\t\t\tqueueHandler.queueFunction(queueHandler.eventQueue, focus.reportFocus)\n\t\t\telse:\n\t\t\t\tresultsScreen = api.getForegroundObject().children[1].lastChild\n\t\t\t\tif isinstance(resultsScreen, UIA) and resultsScreen.UIAElement.cachedClassName == \"LandmarkTarget\":\n\t\t\t\t\t# And no, do not allow focus to move.\n\t\t\t\t\tqueueHandler.queueFunction(queueHandler.eventQueue, resultsScreen.firstChild.reportFocus)\n", "path": "source/appModules/calculator.py"}]}