prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Windows Store apps: use app title as product name instead of wwahost
  **Reported by nvdakor on 2014-07-07 13:10**
  Hi,
  Currently, when invoking appModule.productName for a Windows Store app, NVDA says "Windows operating system". Although this is fine for built-in apps such as Bing Weather and Windows Store, this may confuse users and developers when they are testing accessibility of Store apps (both existing ones and apps to be created in the future). As a way of providing actual product name for debugging purposes and for people to tell us which app they are having issues with, I propose using app title for productName.
  Before:
  1. Go to Windows Store app such as Weather.
  2. Once the app opens, press NVDA+F1 to show developer info. Look under appModule.productName.
  After:
  1. Open any Windows Store app.
  2. Press NVDA+F1 to open developer info. appModule.productName tells you the title of the app.
  Implementation:
  1. In appModules.wwahost.py, override _get_productName to return the title (api.getForegroundObject().name).
  2. wwahost.AppModule.productName will contain the actual title of the app.
  Thanks.
  
  **Blocked by #4569**
  
  Load specific app modules for apps hosted by wwahost.exe
  **Reported by jteh on 2014-10-23 07:35**
  wwahost.exe hosts many Windows Store apps (though it seems some do have their own executables). To allow for application specific customisation, we should identify the specific application in the app module name.
  
  I think we can use GetApplicationUserModelId (in kernel32) for this purpose. This includes a "!" character, so we'll need to check whether Python will cope with this and replace if not.
  **Blocked by #4360**
  **Blocking #4259**
  
  
  </issue>
  <code>
  [start of source/appModules/wwahost.py]
  1 #A part of NonVisual Desktop Access (NVDA)
  2 #This file is covered by the GNU General Public License.
  3 #See the file COPYING for more details.
  4 #Copyright (C) 2012 NV Access Limited
  5 
  6 from comtypes import COMError
  7 import IAccessibleHandler
  8 from NVDAObjects.IAccessible.MSHTML import Body
  9 import appModuleHandler
  10 import controlTypes
  11 import winUser
  12 
  13 class AppModule(appModuleHandler.AppModule):
  14 
  15 	def event_NVDAObject_init(self,obj):
  16 		#The root document of HTML Metro Apps must be treeted as an application. 
  17 		if isinstance(obj,Body) and obj.windowClassName=="Internet Explorer_Server":
  18 			try:
  19 				paccParent=obj.IAccessibleObject.accParent.accParent
  20 				identity=IAccessibleHandler.getIAccIdentity(paccParent,0)
  21 			except (COMError,AttributeError):
  22 				identity=None
  23 			if identity:
  24 				windowHandle=identity.get('windowHandle')
  25 				if windowHandle and winUser.getClassName(windowHandle)=="Web Platform Embedding":
  26 					obj.role=controlTypes.ROLE_APPLICATION
  27
  [end of source/appModules/wwahost.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/source/appModules/wwahost.py b/source/appModules/wwahost.py
  --- a/source/appModules/wwahost.py
  +++ b/source/appModules/wwahost.py
  @@ -1,26 +1,40 @@
  -#A part of NonVisual Desktop Access (NVDA)
  -#This file is covered by the GNU General Public License.
  -#See the file COPYING for more details.
  -#Copyright (C) 2012 NV Access Limited
  +# A part of NonVisual Desktop Access (NVDA)
  +# This file is covered by the GNU General Public License.
  +# See the file COPYING for more details.
  +# Copyright (C) 2012-2020 NV Access Limited, Joseph Lee
   
  -from comtypes import COMError
  -import IAccessibleHandler
  -from NVDAObjects.IAccessible.MSHTML import Body
  +"""App module host for Windows 8.x and 10 apps hosted by wwahost.exe.
  +In Windows 8, apps written in Javascript are executed inside WWAHost, including some WinRT apps.
  +In Windows 10, progressive web apps (PWA) and friends are hosted inside this process.
  +App modules wishing to support apps hosted inside this process must subclass the AppModule class.
  +"""
  +
  +import ctypes
   import appModuleHandler
  -import controlTypes
  -import winUser
  +import winKernel
  +
  +
  +def getAppNameFromHost(processId):
  +	# Some apps that come with Windows 8 and 8.1 are hosted by wwahost.exe.
  +	# App modules for these are named after the hosted app name.
  +	processHandle = winKernel.openProcess(
  +		winKernel.SYNCHRONIZE | winKernel.PROCESS_QUERY_INFORMATION, False, processId
  +	)
  +	length = ctypes.c_uint()
  +	winKernel.kernel32.GetApplicationUserModelId(processHandle, ctypes.byref(length), None)
  +	appModel = ctypes.create_unicode_buffer(length.value)
  +	winKernel.kernel32.GetApplicationUserModelId(processHandle, ctypes.byref(length), appModel)
  +	winKernel.closeHandle(processHandle)
  +	# Sometimes app model might be empty, so raise errors and fall back to wwahost.
  +	if not appModel.value:
  +		raise LookupError
  +	# App model is shown as familyName!appName,
  +	# and importing files with the exclamation point in the middle of the name isn't supported.
  +	# Therefore return only the app name portion.
  +	# Convert this into lowercase to make the file name consistent with other NVDA app modules.
  +	return appModel.value.split("!")[-1].lower()
   
   class AppModule(appModuleHandler.AppModule):
   
  -	def event_NVDAObject_init(self,obj):
  -		#The root document of HTML Metro Apps must be treeted as an application. 
  -		if isinstance(obj,Body) and obj.windowClassName=="Internet Explorer_Server":
  -			try:
  -				paccParent=obj.IAccessibleObject.accParent.accParent
  -				identity=IAccessibleHandler.getIAccIdentity(paccParent,0)
  -			except (COMError,AttributeError):
  -				identity=None
  -			if identity:
  -				windowHandle=identity.get('windowHandle')
  -				if windowHandle and winUser.getClassName(windowHandle)=="Web Platform Embedding":
  -					obj.role=controlTypes.ROLE_APPLICATION
  +	# WWAHost app content is treated as part of an app, not a browse mode document.
  +	disableBrowseModeByDefault = True
  
verification_info: {"golden_diff": "diff --git a/source/appModules/wwahost.py b/source/appModules/wwahost.py\n--- a/source/appModules/wwahost.py\n+++ b/source/appModules/wwahost.py\n@@ -1,26 +1,40 @@\n-#A part of NonVisual Desktop Access (NVDA)\r\n-#This file is covered by the GNU General Public License.\r\n-#See the file COPYING for more details.\r\n-#Copyright (C) 2012 NV Access Limited\r\n+# A part of NonVisual Desktop Access (NVDA)\r\n+# This file is covered by the GNU General Public License.\r\n+# See the file COPYING for more details.\r\n+# Copyright (C) 2012-2020 NV Access Limited, Joseph Lee\r\n \r\n-from comtypes import COMError\r\n-import IAccessibleHandler\r\n-from NVDAObjects.IAccessible.MSHTML import Body\r\n+\"\"\"App module host for Windows 8.x and 10 apps hosted by wwahost.exe.\r\n+In Windows 8, apps written in Javascript are executed inside WWAHost, including some WinRT apps.\r\n+In Windows 10, progressive web apps (PWA) and friends are hosted inside this process.\r\n+App modules wishing to support apps hosted inside this process must subclass the AppModule class.\r\n+\"\"\"\r\n+\r\n+import ctypes\r\n import appModuleHandler\r\n-import controlTypes\r\n-import winUser\r\n+import winKernel\r\n+\r\n+\r\n+def getAppNameFromHost(processId):\r\n+\t# Some apps that come with Windows 8 and 8.1 are hosted by wwahost.exe.\r\n+\t# App modules for these are named after the hosted app name.\r\n+\tprocessHandle = winKernel.openProcess(\r\n+\t\twinKernel.SYNCHRONIZE | winKernel.PROCESS_QUERY_INFORMATION, False, processId\r\n+\t)\r\n+\tlength = ctypes.c_uint()\r\n+\twinKernel.kernel32.GetApplicationUserModelId(processHandle, ctypes.byref(length), None)\r\n+\tappModel = ctypes.create_unicode_buffer(length.value)\r\n+\twinKernel.kernel32.GetApplicationUserModelId(processHandle, ctypes.byref(length), appModel)\r\n+\twinKernel.closeHandle(processHandle)\r\n+\t# Sometimes app model might be empty, so raise errors and fall back to wwahost.\r\n+\tif not appModel.value:\r\n+\t\traise LookupError\r\n+\t# App model is shown as familyName!appName,\r\n+\t# and importing files with the exclamation point in the middle of the name isn't supported.\r\n+\t# Therefore return only the app name portion.\r\n+\t# Convert this into lowercase to make the file name consistent with other NVDA app modules.\r\n+\treturn appModel.value.split(\"!\")[-1].lower()\r\n \r\n class AppModule(appModuleHandler.AppModule):\r\n \r\n-\tdef event_NVDAObject_init(self,obj):\r\n-\t\t#The root document of HTML Metro Apps must be treeted as an application. \r\n-\t\tif isinstance(obj,Body) and obj.windowClassName==\"Internet Explorer_Server\":\r\n-\t\t\ttry:\r\n-\t\t\t\tpaccParent=obj.IAccessibleObject.accParent.accParent\r\n-\t\t\t\tidentity=IAccessibleHandler.getIAccIdentity(paccParent,0)\r\n-\t\t\texcept (COMError,AttributeError):\r\n-\t\t\t\tidentity=None\r\n-\t\t\tif identity:\r\n-\t\t\t\twindowHandle=identity.get('windowHandle')\r\n-\t\t\t\tif windowHandle and winUser.getClassName(windowHandle)==\"Web Platform Embedding\":\r\n-\t\t\t\t\tobj.role=controlTypes.ROLE_APPLICATION\r\n+\t# WWAHost app content is treated as part of an app, not a browse mode document.\r\n+\tdisableBrowseModeByDefault = True\n", "issue": "Windows Store apps: use app title as product name instead of wwahost\n**Reported by nvdakor on 2014-07-07 13:10**\nHi,\nCurrently, when invoking appModule.productName for a Windows Store app, NVDA says \"Windows operating system\". Although this is fine for built-in apps such as Bing Weather and Windows Store, this may confuse users and developers when they are testing accessibility of Store apps (both existing ones and apps to be created in the future). As a way of providing actual product name for debugging purposes and for people to tell us which app they are having issues with, I propose using app title for productName.\nBefore:\n1. Go to Windows Store app such as Weather.\n2. Once the app opens, press NVDA+F1 to show developer info. Look under appModule.productName.\nAfter:\n1. Open any Windows Store app.\n2. Press NVDA+F1 to open developer info. appModule.productName tells you the title of the app.\nImplementation:\n1. In appModules.wwahost.py, override _get_productName to return the title (api.getForegroundObject().name).\n2. wwahost.AppModule.productName will contain the actual title of the app.\nThanks.\n\n**Blocked by #4569**\n\nLoad specific app modules for apps hosted by wwahost.exe\n**Reported by jteh on 2014-10-23 07:35**\nwwahost.exe hosts many Windows Store apps (though it seems some do have their own executables). To allow for application specific customisation, we should identify the specific application in the app module name.\n\nI think we can use GetApplicationUserModelId (in kernel32) for this purpose. This includes a \"!\" character, so we'll need to check whether Python will cope with this and replace if not.\n**Blocked by #4360**\n**Blocking #4259**\n\n", "before_files": [{"content": "#A part of NonVisual Desktop Access (NVDA)\r\n#This file is covered by the GNU General Public License.\r\n#See the file COPYING for more details.\r\n#Copyright (C) 2012 NV Access Limited\r\n\r\nfrom comtypes import COMError\r\nimport IAccessibleHandler\r\nfrom NVDAObjects.IAccessible.MSHTML import Body\r\nimport appModuleHandler\r\nimport controlTypes\r\nimport winUser\r\n\r\nclass AppModule(appModuleHandler.AppModule):\r\n\r\n\tdef event_NVDAObject_init(self,obj):\r\n\t\t#The root document of HTML Metro Apps must be treeted as an application. \r\n\t\tif isinstance(obj,Body) and obj.windowClassName==\"Internet Explorer_Server\":\r\n\t\t\ttry:\r\n\t\t\t\tpaccParent=obj.IAccessibleObject.accParent.accParent\r\n\t\t\t\tidentity=IAccessibleHandler.getIAccIdentity(paccParent,0)\r\n\t\t\texcept (COMError,AttributeError):\r\n\t\t\t\tidentity=None\r\n\t\t\tif identity:\r\n\t\t\t\twindowHandle=identity.get('windowHandle')\r\n\t\t\t\tif windowHandle and winUser.getClassName(windowHandle)==\"Web Platform Embedding\":\r\n\t\t\t\t\tobj.role=controlTypes.ROLE_APPLICATION\r\n", "path": "source/appModules/wwahost.py"}]}