diff --git a/_template_addon_release.json b/_template_addon_release.json deleted file mode 100644 index c6d3a5f..0000000 --- a/_template_addon_release.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "addonId": "easyAddonTech.XYZ", - "addonVersionNumber": { - "major": 21, - "minor": 6, - "patch": 0 - }, - "addonVersionName": "21.06", - "displayName": "My addon", - "publisher": "easyAddonTech", - "description": "Makes doing XYZ easier", - "homepage": "https://github.com/nvaccess/addon-datastore", - "minNVDAVersion": { - "major": 2019, - "minor": 3, - "patch": 0 - }, - "lastTestedVersion": { - "major": 2020, - "minor": 4, - "patch": 0 - }, - "channel": "beta", - "URL": "https://github.com/nvaccess/addon-datastore/releases/download/v0.1.0/myAddon.nvda-addon", - "sha256": "69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8C82", - "sourceURL": "https://github.com/nvaccess/addon-datastore/", - "license": "GPL v2", - "licenseURL": "https://github.com/nvaccess/addon-datastore/license.MD" -} diff --git a/addon/appModules/windowsterminal.py b/addon/appModules/windowsterminal.py new file mode 100644 index 0000000..c1e50b8 --- /dev/null +++ b/addon/appModules/windowsterminal.py @@ -0,0 +1,32 @@ +from contextlib import contextmanager +from typing import Callable + +import appModuleHandler +import controlTypes +from NVDAObjects import UIA +from textInfos import UNIT_LINE, UNIT_PARAGRAPH + + +@contextmanager +def restrictParagraphToLine(): + import config + + try: + curTextUnit = config.conf["mouse"]["mouseTextUnit"] + if curTextUnit == UNIT_PARAGRAPH: + config.conf["mouse"]["mouseTextUnit"] = UNIT_LINE + yield + finally: + config.conf["mouse"]["mouseTextUnit"] = ( + curTextUnit or config.conf.getConfigValidation(("mouse", "mouseTextUnit")).default + ) + + +class AppModule(appModuleHandler.AppModule): + + def event_mouseMove(self, obj: UIA.UIA, nextHandler: Callable[[], None], x: int, y: int) -> None: + if obj.role == controlTypes.Role.TERMINAL: + with restrictParagraphToLine(): + nextHandler() + return + nextHandler() diff --git a/addon/globalPlugins/winUI.py b/addon/globalPlugins/winUI.py new file mode 100644 index 0000000..7064269 --- /dev/null +++ b/addon/globalPlugins/winUI.py @@ -0,0 +1,24 @@ +# mouseEnhancement add-on for NVDA +# This file is covered by the GNU General Public License. +# See the file COPYING.txt for more details. +# Copyright (C) 2025 hwf1324 <1398969445@qq.com> + +import controlTypes +import globalPluginHandler + + +class GlobalPlugin(globalPluginHandler.GlobalPlugin): + + def chooseNVDAObjectOverlayClasses(self, obj, clsList): + try: + if ( + ( + obj.windowClassName == "Microsoft.UI.Content.DesktopChildSiteBridge" + or obj.windowClassName == "Windows.UI.Composition.DesktopWindowContentBridge" + ) + and obj.role == controlTypes.Role.PANE + and not obj.appModule.isGoodUIAWindow(obj.windowHandle) + ): + obj.appModule.isGoodUIAWindow = lambda hwnd: True + except AttributeError: + pass diff --git a/buildVars.py b/buildVars.py index 881da82..f452c78 100644 --- a/buildVars.py +++ b/buildVars.py @@ -25,10 +25,13 @@ def _(arg): # Translators: Long description to be shown for this add-on on add-on information from add-ons manager "addon_description": _("""This add-on provides enhancement to mouse functionality in NVDA. -For example, fixed mouse tracking in Electron app (2024.4 only). -Electron apps, such as VS Code."""), +For example: +Fixed mouse tracking in Electron app (2024.4 only). +Electron apps, such as VS Code. +Experimental fix for mouse tracking in WinUI apps. +WinUI applications: e.g. Windows Terminal, PowerToys v0.86.0 and higher, some applications that come with Windows, etc."""), # version - "addon_version": "0.3.0", + "addon_version": "0.4.0", # Author(s) "addon_author": "hwf1324 <1398969445@qq.com>", # URL for the add-on documentation support diff --git a/changelog.md b/changelog.md index e78cba6..9aa1c63 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,4 @@ -* Change the add-on name to: Mouse Enhancement. (Doesn't take into account add-on upgrades.) -* Ignore the error when entering the security screen because the object does not have the windowClassName attribute. -* Mouse tracking can report the description of the option in the Git for Windows installer. (Individual options cannot be viewed individually.) +* Experimental: Fix mouse tracking in WinUI apps by making `obj.appModule.isGoodUIAWindow` always return `True` when an object with a specific `windowClassName` property is encountered. + * Windows Terminal: If the text unit is a paragraph, moving the mouse in the Terminal control restricts the text unit to lines. +* Electron: cleaned up some unnecessary judgment logic. * Update add-on template. diff --git a/readme.md b/readme.md index 26e14ef..8cafc2c 100644 --- a/readme.md +++ b/readme.md @@ -10,12 +10,21 @@ Some features may be moved out as standalone features in the future. * Fix mouse tracking in [Electron](https://www.electronjs.org/) apps (2024.4 only). * Electron apps, such as [VS Code](https://code.visualstudio.com/). +* Experimental fix mouse tracking in [WinUI](https://github.com/microsoft/microsoft-ui-xaml) apps. + * [Windows Terminal](https://github.com/microsoft/terminal): If the text unit is a paragraph, moving the mouse in the Terminal control restricts the text unit to lines. * Fix a part of the NVIDIA Control Panel where the content of the static text description control is incorrect. * Fixed the problem that some buttons in [PDFgear](https://www.pdfgear.com/) could not get the description text. * Mouse tracking can report the description of the option in the [Git for Windows](https://git-scm.com/downloads/win) installer. (Individual options cannot be viewed individually.) ## Changelog +### 0.4.0 + +* Experimental: Fix mouse tracking in WinUI apps by making `obj.appModule.isGoodUIAWindow` always return `True` when an object with a specific `windowClassName` property is encountered. + * Windows Terminal: If the text unit is a paragraph, moving the mouse in the Terminal control restricts the text unit to lines. +* Electron: cleaned up some unnecessary judgment logic. +* Update add-on template. + ### 0.3.0 * Change the add-on name to: Mouse Enhancement. (Doesn't take into account add-on upgrades.) @@ -34,4 +43,5 @@ Some features may be moved out as standalone features in the future. ## Acknowledgements -Thanks to @jcsteh for his guidance in fixing mouse tracking in the Electron app. +Thanks to @jcsteh in https://github.com/nvaccess/nvda/issues/17108 for his guidance in fixing mouse tracking in the Electron app. +Thanks to @codeofdusk in https://github.com/nvaccess/nvda/issues/17407#issuecomment-2544712156 for the way to experimentally fix mouse tracking in WinUI apps. diff --git a/sconstruct b/sconstruct index bb099bd..369b1f7 100644 --- a/sconstruct +++ b/sconstruct @@ -1,5 +1,5 @@ # NVDA add-on template SCONSTRUCT file -# Copyright (C) 2012-2024 Rui Batista, Noelia Martinez, Joseph Lee +# Copyright (C) 2012-2025 Rui Batista, Noelia Martinez, Joseph Lee # This file is covered by the GNU General Public License. # See the file COPYING.txt for more details. @@ -100,6 +100,7 @@ env.Append(**buildVars.addon_info) if env["dev"]: import datetime + buildDate = datetime.datetime.now() year, month, day = str(buildDate.year), str(buildDate.month), str(buildDate.day) versionTimestamp = "".join([year, month.zfill(2), day.zfill(2)]) @@ -247,6 +248,7 @@ addon = env.NVDAAddon(addonFile, env.Dir("addon")) langDirs = [f for f in env.Glob(os.path.join("addon", "locale", "*"))] # Allow all NVDA's gettext po files to be compiled in source/locale, and manifest files to be generated +moByLang = {} for dir in langDirs: poFile = dir.File(os.path.join("LC_MESSAGES", "nvda.po")) moFile = env.gettextMoFile(poFile)