Files

28 lines
990 B
C#
Raw Permalink Normal View History

Ready for Review - [Mouse Jump] - port upstream WinUI3 code to Mouse Jump (microsoft#48290) (#48393) <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Changes for #48290 to convert Mouse Jump to a WinUI app and remove all remaining dependencies on WinForms, based on work already done in the original "FancyMouse" project (https://github.com/mikeclayton/FancyMouse). ## Notes for reviewers * the new WinUI build of the app is output into the "/WinUI3Apps" subfolder * there's 2 new assemblies that need to be added to the installation as well - MouseJump.HotKeys.dll and MouseJump.Models.dll. I'm not sure how to add those to the installer for signing / shipping... --- ### Summary of changes * New thumbnail layout and rendering code * WinUI rewrite (winforms version still committed) * MouseJump.Kicker (dev launch tool) * CsWin32 for interop * New assemblies - code reorganised --- ### 1. New layout code Incorporates latest FancyMouse core layout and rendering logic into Mouse Jump: * includes **support** for multiple devices in layout algorithms * preview still only shows local machine though * prerequisite for long-term goal #34126 <img width="650" height="709" alt="image" src="https://github.com/user-attachments/assets/9d1d996d-ed05-4471-b8a5-bd93442f70dc" /> ### 2. WinUI rewrite Port latest stable FancyMouse WinUI implementation into Mouse Jump. Existing WinForms UI left in-situ side-by-side for now - easy to delete if not needed. ### 3. MouseJump.Kicker A small dev utility to start Mouse Jump without needing to build the runner project: <img width="283" height="274" alt="image" src="https://github.com/user-attachments/assets/c81bb3f5-5008-48ce-8bc0-eef18413dee6" /> ### 4. Cswin32 for interop All win32 interop is now accessed via CsWin32 bindings. The original win32 bindings were heavily influenced by CsWin32 generated code (e.g. ```BOOL```, ```HWND```, etc structs), so there's not actually much change other than deleting a lot of boilerplate code. ### 5. New assemblies Some code has been reorganised into new assemblies to make it easier to keep Mouse Jump in sync with upstream FancyMouse * MouseJump.HotKeys * MouseJump.Models <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [x] Closes #48290 - [x] **Communication:** I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected - [x] **Tests:** Added/updated and all pass - [x] **Localization:** All end user facing strings can be localized - all ui strings come from Resources.resw - [x] **Dev docs:** Added/updated - no changes required - [x] **New binaries:** Added on the required places - no changes required - [x] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [x] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [x] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [x] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [x] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx - no changes required <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed - **Workflow tests** - [x] Automated tests passing locally - [x] Minimal actions workflow (spelling check) passing for PR - [ ] Full actions workflow (msbuild) passing for PR - **UI tests** - [x] Happy path - [x] preview image appears when activated - [x] clicking the preview image moves the mouse cursor to the correct location - [x] right-click dismisses the preview image without moving the mouse - [x] pressing escape dismisses the preview image without moving the mouse - [x] left or right clicking another application / desktop dismisses the preview image without moving the mouse - [x] Works on multiple monitors with different dpi scaling settings (e.g. 100% vs 150%) * https://github.com/microsoft/PowerToys/pull/23566#issuecomment-1411869418 * https://github.com/microsoft/PowerToys/pull/23566#issuecomment-1412834413 - [x] Handling negative coordinates on non-primary monitors if higher or "lefter" than primary monitor * https://github.com/microsoft/PowerToys/pull/23566#issuecomment-1404931694 - [x] Mouse crosshair moves when Mouse Jump moves the cursor (mouse clicks *and* keyboard shortcuts) * #24523 * #24527 - [x] Activating when the preview window is already visible moves the form to the new mouse position - [x] Number and key shortcuts (1-9, Home / End, Left / Right Arrow) jump to the appropriate monitor - [x] Number-pad shortcuts (1-9 jump to the appropriate monitor - **Settings tests** - [x] Changing thumbnail size settings updates the size of the thumbnail - [x] Changing preview type between Compact, Bezelled and Custom shows the correct preview type - [x] Changing custom preview settings shows the correct settings - [ ] Launching with settings version 1.0 upgrades settings to version 1.1, with "Bezelled" as the default style and the "Custom" settings preconfigured to match "Bezelled" - **Lifecycle tests** - [x] Starting PowerToys Runner launches MouseJump exe when enabled, and not when disabled - [x] Enabling / disabling Mouse Jump in settings starts / stops MouseJump exe - [x] Exiting PowerToys Runner stops MouseJump exe - [x] Killing runner exe via Task Manager stops MouseJump exe - [x] Stopping Visual Studio local debug run stops MouseJump exe - note - runner needs to be in *non*-admin mode otherwise Visual Studio debugger disconnects at launch - [x] Hotkey and size settings are automatically reloaded when config file is modified from Settings UI - [ ] ~~Hotkey and size settings are automatically reloaded when config file is modified manually (e.g. in notepad) while runner and MouseJumpUI.exe are running~~ - **[Internal Test Suite](https://github.com/microsoft/PowerToys/blob/5bc7201ae2b75b53d3a4bc35119c867ecf71c5f6/doc/releases/tests-checklist-template.md#mouse-utils)** - [x] Enable Mouse Jump. Then: - [x] Press the activation shortcut and verify the screens preview appears. - [x] Change activation shortcut and verify that new shortcut triggers Mouse Jump. - [x] Click around the screen preview and ensure that mouse cursor jumped to clicked location. - [x] Reorder screens in Display settings and confirm that Mouse Jump reflects the change and still works correctly. - [x] Change scaling of screens and confirm that Mouse Jump still works correctly. - [ ] Unplug additional monitors and confirm that Mouse Jump still works correctly. - [x] Disable Mouse Jump and verify that the module is not activated when you press the activation shortcut. --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Boliang Zhang (from Dev Box) <bozhang@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: moooyo <42196638+moooyo@users.noreply.github.com> Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com> Copilot-Session: 8e04a72e-3b0f-4ac4-8156-d04ea9b8bb85
2026-08-07 06:34:15 +01:00
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
using static MouseJump.Kicker.NativeMethods.Core;
namespace MouseJump.Kicker.NativeMethods;
internal static partial class User32
{
/// <summary>
/// Retrieves the identifier of the thread that created the specified window and,
/// optionally, the identifier of the process that created the window.
/// </summary>
/// <returns>
/// The return value is the identifier of the thread that created the window.
/// </returns>
/// <remarks>
/// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowthreadprocessid
/// </remarks>
[LibraryImport(Libraries.User32, SetLastError = true)]
internal static partial uint GetWindowThreadProcessId(
HWND hWnd,
out uint lpdwProcessId);
}