diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index e8af95b8ed..69f51bbaf8 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -112,7 +112,7 @@ AUTHN AUTHZ AUTOHIDE AUTOMATIONPROPERTIES -Autorun +autorun AUTOUPDATE AValid awakeness @@ -144,7 +144,7 @@ Blockquotes blogs Blt BLUEGRAY -Bluetooth +bluetooth BLURBEHIND BLURREGION bmi @@ -564,7 +564,6 @@ FARPROC fdw feimage fff -fileapi FILEEXPLORER FILEFLAGS FILEFLAGSMASK @@ -606,9 +605,9 @@ FZE gabime GAC gacutil -Galaxi Gaeilge Gaidhlig +Galaxi GBarm Gbits Gbps @@ -620,6 +619,7 @@ gdi gdiplus GDISCALED GEmoji +GETCLIENTAREAANIMATION GETDESKWALLPAPER GETDLGCODE GETDPISCALEDSIZE @@ -1569,7 +1569,6 @@ renamable RENAMEONCOLLISION Renamer reparent -reparented reparenting reparse reportbug @@ -1882,7 +1881,6 @@ talynone TApp TApplication TApplied -Taras targ TARGETAPPHEADER TARGETDIR diff --git a/.github/policies/resourceManagement.yml b/.github/policies/resourceManagement.yml index ae72e1266f..0a9e925b94 100644 --- a/.github/policies/resourceManagement.yml +++ b/.github/policies/resourceManagement.yml @@ -212,7 +212,7 @@ configuration: - addLabel: label: Resolution-Helped User - addReply: - reply: This issue is now marked as resolved. If you have any follow-up questions, please don't hesitate to ask. You can find out more about PowerToys functionalities in our [end-user documentation](https://aka.ms/powertoy-docs]. + reply: This issue is now marked as resolved. If you have any follow-up questions, please don't hesitate to ask. You can find out more about PowerToys functionalities in our [end-user documentation](https://aka.ms/powertoy-docs). - closeIssue description: - if: diff --git a/PowerToys.sln b/PowerToys.sln index 01508db104..f0d4f78656 100644 --- a/PowerToys.sln +++ b/PowerToys.sln @@ -281,6 +281,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "utils", "utils", "{B39DC643 src\common\utils\logger_helper.h = src\common\utils\logger_helper.h src\common\utils\modulesRegistry.h = src\common\utils\modulesRegistry.h src\common\utils\MsiUtils.h = src\common\utils\MsiUtils.h + src\common\utils\MsWindowsSettings.h = src\common\utils\MsWindowsSettings.h src\common\utils\os-detect.h = src\common\utils\os-detect.h src\common\utils\package.h = src\common\utils\package.h src\common\utils\ProcessWaiter.h = src\common\utils\ProcessWaiter.h diff --git a/README.md b/README.md index ce589d18d7..3923a7c827 100644 --- a/README.md +++ b/README.md @@ -39,19 +39,19 @@ Microsoft PowerToys is a set of utilities for power users to tune and streamline Go to [Microsoft PowerToys GitHub releases page][github-release-link], click on `Assets` at the bottom to show the files available in the release. Please use the appropriate PowerToys installer that matches your machine's architecture and install scope. For most, it is `x64` and per-user. -[github-next-release-work]: https://github.com/microsoft/PowerToys/issues?q=project%3Amicrosoft%2FPowerToys%2F46 -[github-current-release-work]: https://github.com/microsoft/PowerToys/issues?q=project%3Amicrosoft%2FPowerToys%2F45 -[ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.72.0/PowerToysUserSetup-0.72.0-x64.exe -[ptUserArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.72.0/PowerToysUserSetup-0.72.0-arm64.exe -[ptMachineX64]: https://github.com/microsoft/PowerToys/releases/download/v0.72.0/PowerToysSetup-0.72.0-x64.exe -[ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.72.0/PowerToysSetup-0.72.0-arm64.exe +[github-next-release-work]: https://github.com/microsoft/PowerToys/issues?q=project%3Amicrosoft%2FPowerToys%2F47 +[github-current-release-work]: https://github.com/microsoft/PowerToys/issues?q=project%3Amicrosoft%2FPowerToys%2F46 +[ptUserX64]: https://github.com/microsoft/PowerToys/releases/download/v0.73.0/PowerToysUserSetup-0.73.0-x64.exe +[ptUserArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.73.0/PowerToysUserSetup-0.73.0-arm64.exe +[ptMachineX64]: https://github.com/microsoft/PowerToys/releases/download/v0.73.0/PowerToysSetup-0.73.0-x64.exe +[ptMachineArm64]: https://github.com/microsoft/PowerToys/releases/download/v0.73.0/PowerToysSetup-0.73.0-arm64.exe | Description | Filename | sha256 hash | |----------------|----------|-------------| -| Per user - x64 | [PowerToysUserSetup-0.72.0-x64.exe][ptUserX64] | 9925894D797458C78A8C3DF6FE4BD748580638B01BB43680477763662915109A | -| Per user - ARM64 | [PowerToysUserSetup-0.72.0-arm64.exe][ptUserArm64] | 2E68139C22C56648E64514E4E8E0A0D12882F6CF30B48EB20ECC66B4CCDD5909 | -| Machine wide - x64 | [PowerToysSetup-0.72.0-x64.exe][ptMachineX64] | 788EE4D828169F092737A739030B218CEFEC79583E42858BB8F9F036B701BE6F | -| Machine wide - ARM64 | [PowerToysSetup-0.72.0-arm64.exe][ptMachineArm64] | 39C1D430A538B0F3D7869D39DF7F636A64AAFAD8DFB3C82059A97F4EBD3369C4 | +| Per user - x64 | [PowerToysUserSetup-0.73.0-x64.exe][ptUserX64] | BA55D245BDD734FD6F19803DD706A3AB8E0ABC491591195534997CF2122D3B7E | +| Per user - ARM64 | [PowerToysUserSetup-0.73.0-arm64.exe][ptUserArm64] | FBFA40EA5FFA05236A7CCDD05E5142EE0C93D7485B965784196ED9B086BFEBF4 | +| Machine wide - x64 | [PowerToysSetup-0.73.0-x64.exe][ptMachineX64] | 7FDA06292C7C2E6DA5AEF88D8E9D3DE89D331E9E356A232289F9B37CE4503894 | +| Machine wide - ARM64 | [PowerToysSetup-0.73.0-arm64.exe][ptMachineArm64] | 4260AA30A1F52F194EE07E9E7ECD9E9F4CF35289267F213BC933F7A5191AC17C | This is our preferred method. @@ -97,130 +97,138 @@ For guidance on developing for PowerToys, please read the [developer docs](/doc/ Our [prioritized roadmap][roadmap] of features and utilities that the core team is focusing on. -### 0.72 - July 2023 Update +### 0.73 - August 2023 Update -In this release, we focused on stability and improvements. +In this release, we focused on releasing new features, stability and improvements. **Highlights** - - Greatly reduced the PowerToys installed space by having utilities share the same installed path. When compared to 0.71, the 0.72 x64 machine installed version of PowerToys reduces the size reported in the Installed Apps screen from 1.15GB to 785 MB and the size in File Explorer properties for the installation folder from 3.10GB to 554 MB. - - Value Generator - A new PowerToys Run plugin that generates hashes and GUID values. Thanks [@IHorvalds](https://github.com/IHorvalds)! - - Mouse Highlighter has a new feature to have a highlight always follow the mouse pointer. Thanks [@hayatogh](https://github.com/hayatogh)! - - PowerRename was reworked to support a bigger number of files without crashing. - -### Known issues - - - Due to changing paths in the installation folder, the Mouse Without Borders service might be pointing to the wrong place. Users not running as admin will have to enable service mode again after install. A toast notification will appear if Mouse Without Borders is unable to start the service correctly. - - File Explorer extensions changed paths might not be loaded correctly until File Explorer and Preview Host processes are restarted, so we advise restarting the computer when possible after updating PowerToys. + - Keyboard manager now supports Numpad. Note, with previously bound hotkeys stored in settings.json would only react to non-Numpad keys now. If a user wishes to restore the previous behavior, it could be done by manually adding another binding for the Numpad variant. + - New utility: Crop And Lock allows you to crop a current application into a smaller window or just create a thumbnail. Focus the target window and press the shortcut to start cropping. + - FancyZones code improvements and refactor. + - Modernized ImageResizer UX. + - PowerRename advanced counter functionality. ### General - - Shared dependencies between applications in order to greatly reduce the installed size. - - Added missing icons and icon sizes. Thanks [@niels9001](https://github.com/niels9001)! + - Added missing CoUninitialize call in elevation logic. Thanks [@sredna](https://github.com/sredna)! + - New utility: Crop And Lock. Thanks [@robmikh](https://github.com/robmikh)! and [@kevinguo305](https://github.com/kevinguo305)! + - Added new /helped fabric bot command to GitHub repo. Thanks [@Aaron-Junker](https://github.com/Aaron-Junker)! + - Fixed crashes caused by invalid settings. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! + +### Always On Top + + - Added border transparency. ### FancyZones - - Fixed an issue where FancyZones wouldn't register a change to the "Switch between windows in the current zone" setting. - - Added a Setting to enable the behavior of clicking the middle mouse button to toggle multiple zone spanning. + - Fixed issue causing canvas zones being drawn only when dragging in zone area. + - Fixed user-defined default layout highlighting issue. + - Refactored and improved code quality. + - Fixed issue causing wrong layout to be applied when duplicating non-selected layout. ### File Locksmith - - Fixed a File Explorer crash when deleting a file, updating PowerToys and then trying to right-click the background of a folder in File Explorer. - - UI tweaks. Thanks [@Jay-o-Way](https://github.com/Jay-o-Way)! - + - Icon update. Thanks [@jmaraujouy](https://github.com/jmaraujouy)! + ### File Explorer add-ons - - Updated the Monaco dependency for Developer Files Preview, supporting new file extensions and fixing issues. Thanks [@Aaron-Junker](https://github.com/Aaron-Junker)! - -### Hosts File Editor - - - Consolidated the way the Hosts application is launched. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! - - UI tweaks. Thanks [@Jay-o-Way](https://github.com/Jay-o-Way)! + - Fixed issue causing thumbnail previewers to lock files. + - Open URIs from developer files in default browser. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! ### Installer - - Refactored the Monaco dependency inclusion. What to install is now being generated automatically. - - Removed hardlinks and simplified the installer files, now that many utilities use the same paths. + - Fixed PowerToys autorun after installing as SYSTEM user. + - Removed CreateScheduledTask custom action to handle task creation only from runner code. + +### Image Resizer + + - Moved from ModernWPF to WpfUI to refresh and modernize UI/UX. Thanks [@niels9001](https://github.com/niels9001)! + +### Keyboard Manager + + - Rephrased labels to enhance clarity. Thanks [@Jay-o-Way](https://github.com/Jay-o-Way)! + - Keyboard manager now supports Numpad. Note, with previously bound hotkeys stored in settings.json would only react to non-Numpad keys now. If a user wishes to restore the previous behavior, it could be done by manually adding another binding for the Numpad variant. ### Mouse Highlighter - - Added a feature so that a highlight follows the mouse even if no mouse button is being pressed. Thanks [@hayatogh](https://github.com/hayatogh)! + - Fixed highlighter being invisible issue for Always on Top windows. + - Added settings for automatic activation on startup. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! ### Mouse Pointer Crosshairs - - Added a setting to hide the crosshairs when the mouse pointer is also hidden. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! - - Added a setting to select a fixed length for the crosshairs, which also spans across screens. Thanks [@Epp-code](https://github.com/Epp-code)! - -### Mouse Without Borders - - - Switched to a UWP mouse input API to fix mouse pointer lag issues that were reported. - - A toast notification will appear when the service can't be started and Mouse Without Borders will try to start in non-service mode instead. - - Fixed a bug where the service path wouldn't update to the new binary path when trying to re-enable service mode. - - Fixed some grammar errors in the Mouse Without Borders user facing strings. Thanks [@KhurramJalil](https://github.com/KhurramJalil)! - - Allow changing the shortcuts in the same way as other utilities and changed them to better defaults to avoid conflicting with Alt Gr+letter combos on international layouts. + - Added settings for automatic activation on startup. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! ### Peek - - Also benefits from the Monaco dependency update when peeking into files supported by the Developer Files Preview. Thanks [@Aaron-Junker](https://github.com/Aaron-Junker)! - - Fixed a flash on PowerToys starting due to the Peek window activating and hiding right away. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! - - Updated icon design. Thanks [@niels9001](https://github.com/niels9001)! - - Fixed flipped content issues on systems with RTL languages. + - Show correct file type for shortcuts. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! + - Fixed issue causing wrong file size to be displayed. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! + - Show 1 byte instead of 1 bytes file size. Thanks [@Deepak-Sangle](https://github.com/Deepak-Sangle)! + - Open URIs from developer files in default browser. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! + - Show thumbnail and fallback to icon for unsupported files. Thanks [@pedrolamas](https://github.com/pedrolamas)! ### PowerRename - - Reworked the UI and resource consumption to fix crashes and hangs when trying to rename a huge number of files. - - Added the Mica background material and some UI tweaks. Thanks [@niels9001](https://github.com/niels9001)! + - Updated OOBE gif. Thanks [@ChaseKnowlden](https://github.com/ChaseKnowlden)! + - Localized renamed parts combo box. + - Introduced advanced counter functionality. + - Added remember last window size logic and optimized items sorting. + - Enable "Enumerate items" option by default. ### PowerToys Run - - New plugin: Value Generator - generates values like hashes and GUIDs. Thanks [@IHorvalds](https://github.com/IHorvalds)! - - The default input smoothing values were changed to the recommended values. Thanks [@SamMercer172](https://github.com/SamMercer172)! - - Fixed tab navigation issues when using Shift+Tab to go backwards. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! - - Fixed a crash caused by images not being found in the image cache due to racing conditions. - - Fixed synchronization issues in the WindowWalker plugin. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! - - Fixed a synchronization crash when getting localized system paths. - - The PowerToys plugin is now activated by default. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! - -### Quick Accent - - Added the ("ḍ", U+1E0D) unicode character. Thanks [@SamMercer172](https://github.com/SamMercer172)! - - Fixed an issue causing the left and right keys being discarded even when Quick Accent didn't activate. + - Fixed issue causing original search to be abandoned when cycling through results. + - Updated device and bluetooth results for Settings plugin. Thanks [@htcfreek](https://github.com/htcfreek)! + - Fixed InvalidOperationException exception thrown. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! + - Add Base64 Decoding function to the Value Generator plugin. Thanks [@LeagueOfPoro](https://github.com/LeagueOfPoro)! + - Added Keep shell open option for Shell plugin. + - Added Crop And Lock to PowerToys plugin. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! ### Registry Preview - - Fixed a bug causing DWORD values to not be shown correctly. Thanks [@randyrants](https://github.com/randyrants)! - - UI tweaks. Thanks [@Jay-o-Way](https://github.com/Jay-o-Way)! + - Updated AppBarButtons to use an explicit AppBarButton.Icon. Thanks [@randyrants](https://github.com/randyrants)! + - Fixed crash on clicking Save As button. ### Runner - - Show a warning asking the user to restart the computer after updating the PowerToys version. + - Removed unneeded RegisterWindowMessage from tray icon logic. Thanks [@sredna](https://github.com/sredna)! + - Fixed startup looping issue. + - Improved old logs and installers cleanup logic. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! ### Screen Ruler - - UI tweaks. Thanks [@Jay-o-Way](https://github.com/Jay-o-Way)! + - Use proper resources file. ### Settings - - Fix an unused Expander in the File Locksmith settings page. - - Added an info box to better explain what the extended context menu is. + - Fixed issue causing problems with modifier keys and ShortcutControl. Thanks [@sh0ckj0ckey](https://github.com/sh0ckj0ckey)! + - Fixed crash when clicking "Windows color settings" link. + - Added support for launching Settings app directly. + - Fixed issue causing DisplayDescription not showing for PowerToys Run PluginAdditionalOption. + - Fixed issue causing FileLocksmith 'Show File Locksmith in' setting not showing correct value. + - Fixed issue causing Awake on/off toggle in Settings flyout not to work when Settings Awake page is opened. + +### Documentation + + - Added documentation for PowerToys Run third-party plugins. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! + - Fixed broken links in keyboardmanagerui.md. Thanks [@shubhsardana29](https://github.com/shubhsardana29)! + - Updated core team in COMMUNITY.md. + - Fixed broken links in ui-architecture.md. Thanks [@SamB](https://github.com/SamB)! + - Updated community.valuegenerator.md with Base64DecodeRequest description. ### Development - - Projects were restructured to allow sharing the same folder and dependencies and to avoid resource name conflicts. - - Added scripts to CI to guard against applications having conflicting resources. - - Added scripts to CI to guard against depending on different versions of the same dependency. - - Test projects now build to a separate path. - - Dependencies updated across the solution to ensure every project is using the same dependencies. + - Updated test packages and StyleCop. Thanks [@davidegiacometti](https://github.com/davidegiacometti)! + - Condense NuGet Restore into MSBuild Tasks. Thanks [@snickler](https://github.com/snickler)! -#### What is being planned for version 0.73 +#### What is being planned for version 0.74 -For [v0.73][github-next-release-work], we'll work on below: +For [v0.74][github-next-release-work], we'll work on below: - - New utility: Crop and Lock - Language selection - - PowerRename enumeration keywords - Modernize and refresh UX of PowerToys based on WPF - Stability / bug fixes -- Peek: UI improvements + - Peek: UI improvements ## PowerToys Community diff --git a/src/common/interop/keyboard_layout.cpp b/src/common/interop/keyboard_layout.cpp index 6b40b66024..afac8fe141 100644 --- a/src/common/interop/keyboard_layout.cpp +++ b/src/common/interop/keyboard_layout.cpp @@ -145,6 +145,7 @@ void LayoutMap::LayoutMapImpl::UpdateLayout() keyboardLayoutMap[VK_RETURN | numpadOriginBit] = L"Enter (Numpad)"; keyboardLayoutMap[VK_DIVIDE | numpadOriginBit] = L"/ (Numpad)"; + keyboardLayoutMap[VK_SUBTRACT] = L"- (Substract)"; keyboardLayoutMap[VK_SELECT] = L"Select"; keyboardLayoutMap[VK_PRINT] = L"Print"; keyboardLayoutMap[VK_EXECUTE] = L"Execute"; diff --git a/src/common/utils/MsWindowsSettings.h b/src/common/utils/MsWindowsSettings.h new file mode 100644 index 0000000000..ceb54e41c2 --- /dev/null +++ b/src/common/utils/MsWindowsSettings.h @@ -0,0 +1,13 @@ +#pragma once + +inline bool GetAnimationsEnabled() +{ + BOOL enabled = 0; + BOOL fResult; + fResult = SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0, &enabled, 0); + if (!fResult) + { + Logger::error("SystemParametersInfo SPI_GETCLIENTAREAANIMATION failed."); + } + return enabled; +} \ No newline at end of file diff --git a/src/modules/Hosts/Hosts.Tests/EntryTest.cs b/src/modules/Hosts/Hosts.Tests/EntryTest.cs index 505f4d8474..04b02b4879 100644 --- a/src/modules/Hosts/Hosts.Tests/EntryTest.cs +++ b/src/modules/Hosts/Hosts.Tests/EntryTest.cs @@ -76,6 +76,8 @@ namespace Hosts.Tests [DataRow("host 10.1.1.1")] [DataRow("# comment 10.1.1.1 host # comment")] [DataRow("10.1.1.1 host01 host02 host03 host04 host05 host06 host07 host08 host09 host10")] + [DataRow("102.54.94.97 rhino.acme.com # source server")] + [DataRow("38.25.63.10 x.acme.com # x client host")] public void Not_Valid_Entry(string line) { var entry = new Entry(0, line); diff --git a/src/modules/Hosts/Hosts/HostsXAML/Views/MainPage.xaml b/src/modules/Hosts/Hosts/HostsXAML/Views/MainPage.xaml index d70e732665..28f4e836bf 100644 --- a/src/modules/Hosts/Hosts/HostsXAML/Views/MainPage.xaml +++ b/src/modules/Hosts/Hosts/HostsXAML/Views/MainPage.xaml @@ -448,7 +448,7 @@ ScrollViewer.IsVerticalRailEnabled="True" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollMode="Enabled" - Text="{Binding Comment, Mode=TwoWay}" /> + Text="{Binding Comment, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> #ifdef COMPOSITION @@ -246,6 +248,18 @@ LRESULT SuperSonar::BaseWndProc(UINT message, WPARAM wParam, LPARAM lParam) n return HTTRANSPARENT; } + if (message == WM_PRIV_SHORTCUT) + { + if (m_sonarStart == NoSonar) + { + StartSonar(); + } + else + { + StopSonar(); + } + } + return DefWindowProc(m_hwnd, message, wParam, lParam); } @@ -291,26 +305,27 @@ void SuperSonar::OnSonarInput(WPARAM flags, HRAWINPUT hInput) template void SuperSonar::OnSonarKeyboardInput(RAWINPUT const& input) { - if ( m_activationMethod != FindMyMouseActivationMethod::DoubleControlKey || input.data.keyboard.VKey != VK_CONTROL) + // Don't stop the sonar when the shortcut is released + if (m_activationMethod == FindMyMouseActivationMethod::Shortcut && (input.data.keyboard.Flags & RI_KEY_BREAK) != 0) + { + return; + } + + if ((m_activationMethod != FindMyMouseActivationMethod::DoubleRightControlKey && m_activationMethod != FindMyMouseActivationMethod::DoubleLeftControlKey) + || input.data.keyboard.VKey != VK_CONTROL) { StopSonar(); return; } bool pressed = (input.data.keyboard.Flags & RI_KEY_BREAK) == 0; - bool rightCtrl = (input.data.keyboard.Flags & RI_KEY_E0) != 0; - // Deal with rightCtrl first. - if (rightCtrl) + bool leftCtrlPressed = (input.data.keyboard.Flags & RI_KEY_E0) == 0; + bool rightCtrlPressed = (input.data.keyboard.Flags & RI_KEY_E0) != 0; + + if ((m_activationMethod == FindMyMouseActivationMethod::DoubleRightControlKey && !rightCtrlPressed) + || (m_activationMethod == FindMyMouseActivationMethod::DoubleLeftControlKey && !leftCtrlPressed)) { - /* - * SuperSonar originally exited when pressing right control after pressing left control twice. - * We take care of exiting FindMyMouse through module disabling in PowerToys settings instead. - if (m_sonarState == SonarState::ControlUp2) - { - Terminate(); - } - */ StopSonar(); return; } @@ -634,6 +649,8 @@ struct CompositionSpotlight : SuperSonar void SetSonarVisibility(bool visible) { m_batch = m_compositor.GetCommitBatch(winrt::CompositionBatchTypes::Animation); + BOOL isEnabledAnimations = GetAnimationsEnabled(); + m_animation.Duration(std::chrono::milliseconds{ isEnabledAnimations ? m_fadeDuration : 1 }); m_batch.Completed([hwnd = m_hwnd](auto&&, auto&&) { PostMessage(hwnd, WM_OPACITY_ANIMATION_COMPLETED, 0, 0); }); @@ -644,6 +661,11 @@ struct CompositionSpotlight : SuperSonar } } + HWND GetHwnd() noexcept + { + return m_hwnd; + } + private: bool OnCompositionCreate() try @@ -1057,6 +1079,8 @@ int FindMyMouseMain(HINSTANCE hinst, const FindMyMouseSettings& settings) m_sonar = &sonar; Logger::info("Initialized the sonar instance."); + InitializeWinhookEventIds(); + MSG msg; // Main message loop: @@ -1072,4 +1096,14 @@ int FindMyMouseMain(HINSTANCE hinst, const FindMyMouseSettings& settings) return (int)msg.wParam; } +HWND GetSonarHwnd() noexcept +{ + if (m_sonar != nullptr) + { + return m_sonar->GetHwnd(); + } + + return nullptr; +} + #pragma endregion Super_Sonar_API diff --git a/src/modules/MouseUtils/FindMyMouse/FindMyMouse.h b/src/modules/MouseUtils/FindMyMouse/FindMyMouse.h index bf70ee3279..149e52842b 100644 --- a/src/modules/MouseUtils/FindMyMouse/FindMyMouse.h +++ b/src/modules/MouseUtils/FindMyMouse/FindMyMouse.h @@ -3,9 +3,11 @@ enum struct FindMyMouseActivationMethod : int { - DoubleControlKey = 0, - ShakeMouse = 1, - EnumElements = 2, // number of elements in the enum, not counting this + DoubleLeftControlKey = 0, + DoubleRightControlKey = 1, + ShakeMouse = 2, + Shortcut = 3, + EnumElements = 4, // number of elements in the enum, not counting this }; constexpr bool FIND_MY_MOUSE_DEFAULT_DO_NOT_ACTIVATE_ON_GAME_MODE = true; @@ -15,7 +17,7 @@ constexpr int FIND_MY_MOUSE_DEFAULT_OVERLAY_OPACITY = 50; constexpr int FIND_MY_MOUSE_DEFAULT_SPOTLIGHT_RADIUS = 100; constexpr int FIND_MY_MOUSE_DEFAULT_ANIMATION_DURATION_MS = 500; constexpr int FIND_MY_MOUSE_DEFAULT_SPOTLIGHT_INITIAL_ZOOM = 9; -constexpr FindMyMouseActivationMethod FIND_MY_MOUSE_DEFAULT_ACTIVATION_METHOD = FindMyMouseActivationMethod::DoubleControlKey; +constexpr FindMyMouseActivationMethod FIND_MY_MOUSE_DEFAULT_ACTIVATION_METHOD = FindMyMouseActivationMethod::DoubleLeftControlKey; constexpr int FIND_MY_MOUSE_DEFAULT_SHAKE_MINIMUM_DISTANCE = 1000; struct FindMyMouseSettings @@ -36,3 +38,4 @@ int FindMyMouseMain(HINSTANCE hinst, const FindMyMouseSettings& settings); void FindMyMouseDisable(); bool FindMyMouseIsEnabled(); void FindMyMouseApplySettings(const FindMyMouseSettings& settings); +HWND GetSonarHwnd() noexcept; \ No newline at end of file diff --git a/src/modules/MouseUtils/FindMyMouse/FindMyMouse.vcxproj b/src/modules/MouseUtils/FindMyMouse/FindMyMouse.vcxproj index 28ff78ab9a..8c60095541 100644 --- a/src/modules/MouseUtils/FindMyMouse/FindMyMouse.vcxproj +++ b/src/modules/MouseUtils/FindMyMouse/FindMyMouse.vcxproj @@ -93,6 +93,7 @@ + @@ -101,6 +102,7 @@ Create + diff --git a/src/modules/MouseUtils/FindMyMouse/FindMyMouse.vcxproj.filters b/src/modules/MouseUtils/FindMyMouse/FindMyMouse.vcxproj.filters index 5bd41642ef..4a2f070986 100644 --- a/src/modules/MouseUtils/FindMyMouse/FindMyMouse.vcxproj.filters +++ b/src/modules/MouseUtils/FindMyMouse/FindMyMouse.vcxproj.filters @@ -30,6 +30,9 @@ Source Files + + Source Files + @@ -44,6 +47,9 @@ Resource Files + + Header Files + diff --git a/src/modules/MouseUtils/FindMyMouse/WinHookEventIDs.cpp b/src/modules/MouseUtils/FindMyMouse/WinHookEventIDs.cpp new file mode 100644 index 0000000000..76bfbdc861 --- /dev/null +++ b/src/modules/MouseUtils/FindMyMouse/WinHookEventIDs.cpp @@ -0,0 +1,14 @@ +#include "pch.h" + +#include "WinHookEventIDs.h" + +UINT WM_PRIV_SHORTCUT; + +std::once_flag init_flag; + +void InitializeWinhookEventIds() +{ + std::call_once(init_flag, [&] { + WM_PRIV_SHORTCUT = RegisterWindowMessage(L"{1365FFC7-A44E-4171-9692-A3EEF378AE60}"); + }); +} diff --git a/src/modules/MouseUtils/FindMyMouse/WinHookEventIDs.h b/src/modules/MouseUtils/FindMyMouse/WinHookEventIDs.h new file mode 100644 index 0000000000..47596969fe --- /dev/null +++ b/src/modules/MouseUtils/FindMyMouse/WinHookEventIDs.h @@ -0,0 +1,5 @@ +#pragma once + +extern UINT WM_PRIV_SHORTCUT; // Shortcut is pressed + +void InitializeWinhookEventIds(); \ No newline at end of file diff --git a/src/modules/MouseUtils/FindMyMouse/dllmain.cpp b/src/modules/MouseUtils/FindMyMouse/dllmain.cpp index f29526b335..2d1aa55acc 100644 --- a/src/modules/MouseUtils/FindMyMouse/dllmain.cpp +++ b/src/modules/MouseUtils/FindMyMouse/dllmain.cpp @@ -3,6 +3,7 @@ #include #include "trace.h" #include "FindMyMouse.h" +#include "WinHookEventIDs.h" #include #include #include @@ -22,6 +23,7 @@ namespace const wchar_t JSON_KEY_SPOTLIGHT_INITIAL_ZOOM[] = L"spotlight_initial_zoom"; const wchar_t JSON_KEY_EXCLUDED_APPS[] = L"excluded_apps"; const wchar_t JSON_KEY_SHAKING_MINIMUM_DISTANCE[] = L"shaking_minimum_distance"; + const wchar_t JSON_KEY_ACTIVATION_SHORTCUT[] = L"activation_shortcut"; } extern "C" IMAGE_DOS_HEADER __ImageBase; @@ -58,6 +60,9 @@ private: // The PowerToy state. bool m_enabled = false; + // Hotkey to invoke the module + HotkeyEx m_hotkey; + // Find My Mouse specific settings FindMyMouseSettings m_findMyMouseSettings; @@ -157,6 +162,27 @@ public: { return m_enabled; } + + virtual std::optional GetHotkeyEx() override + { + Logger::trace("GetHotkeyEx()"); + if (m_findMyMouseSettings.activationMethod == FindMyMouseActivationMethod::Shortcut) + { + return m_hotkey; + } + + return std::nullopt; + } + + virtual void OnHotkeyEx() override + { + Logger::trace("OnHotkeyEx()"); + HWND hwnd = GetSonarHwnd(); + if (hwnd != nullptr) + { + PostMessageW(hwnd, WM_PRIV_SHORTCUT, NULL, NULL); + } + } }; // Load the settings file. @@ -188,7 +214,15 @@ void FindMyMouse::parse_settings(PowerToysSettings::PowerToyValues& settings) int value = static_cast(jsonPropertiesObject.GetNamedNumber(JSON_KEY_VALUE)); if (value < static_cast(FindMyMouseActivationMethod::EnumElements) && value >= 0) { - findMyMouseSettings.activationMethod = static_cast(value); + std::wstring version = (std::wstring)settingsObject.GetNamedString(L"version"); + if (version == L"1.0" && value == 1) + { + findMyMouseSettings.activationMethod = FindMyMouseActivationMethod::ShakeMouse; + } + else + { + findMyMouseSettings.activationMethod = static_cast(value); + } } else { @@ -362,6 +396,46 @@ void FindMyMouse::parse_settings(PowerToysSettings::PowerToyValues& settings) { Logger::warn("Failed to initialize Shaking Minimum Distance from settings. Will use default value"); } + + try + { + // Parse HotKey + auto jsonPropertiesObject = settingsObject.GetNamedObject(JSON_KEY_PROPERTIES).GetNamedObject(JSON_KEY_ACTIVATION_SHORTCUT); + auto hotkey = PowerToysSettings::HotkeyObject::from_json(jsonPropertiesObject); + m_hotkey = HotkeyEx(); + if (hotkey.win_pressed()) + { + m_hotkey.modifiersMask |= MOD_WIN; + } + + if (hotkey.ctrl_pressed()) + { + m_hotkey.modifiersMask |= MOD_CONTROL; + } + + if (hotkey.shift_pressed()) + { + m_hotkey.modifiersMask |= MOD_SHIFT; + } + + if (hotkey.alt_pressed()) + { + m_hotkey.modifiersMask |= MOD_ALT; + } + + m_hotkey.vkCode = static_cast(hotkey.get_code()); + } + catch (...) + { + Logger::warn("Failed to initialize Activation Shortcut from settings. Will use default value"); + } + + if (!m_hotkey.modifiersMask) + { + Logger::info("Using default Activation Shortcut"); + m_hotkey.modifiersMask = MOD_SHIFT | MOD_WIN; + m_hotkey.vkCode = 0x46; // F key + } } else { diff --git a/src/modules/ShortcutGuide/ShortcutGuide/overlay_window.cpp b/src/modules/ShortcutGuide/ShortcutGuide/overlay_window.cpp index 0a2c899e7d..a589da85e4 100644 --- a/src/modules/ShortcutGuide/ShortcutGuide/overlay_window.cpp +++ b/src/modules/ShortcutGuide/ShortcutGuide/overlay_window.cpp @@ -5,6 +5,7 @@ #include "start_visible.h" #include #include +#include #include "shortcut_guide.h" #include "trace.h" @@ -269,11 +270,12 @@ D2D1_RECT_F D2DOverlaySVG::get_snap_right() const D2DOverlayWindow::D2DOverlayWindow() : total_screen({}), - background_animation(0.3), - global_windows_shortcuts_animation(0.3), - taskbar_icon_shortcuts_animation(0.3), D2DWindow() { + BOOL isEnabledAnimations = GetAnimationsEnabled(); + background_animation = isEnabledAnimations? 0.3f : 0.f; + global_windows_shortcuts_animation = isEnabledAnimations ? 0.3f : 0.f; + taskbar_icon_shortcuts_animation = isEnabledAnimations ? 0.3f : 0.f; tasklist_thread = std::thread([&] { while (running) { diff --git a/src/modules/awake/Awake/Assets/Awake/Awake.ico b/src/modules/awake/Awake/Assets/Awake/Awake.ico index 875ec0a63b..b093891ef9 100644 Binary files a/src/modules/awake/Awake/Assets/Awake/Awake.ico and b/src/modules/awake/Awake/Assets/Awake/Awake.ico differ diff --git a/src/modules/fancyzones/FancyZonesLib/WorkArea.cpp b/src/modules/fancyzones/FancyZonesLib/WorkArea.cpp index 002bcdc63b..2d4b6adf90 100644 --- a/src/modules/fancyzones/FancyZonesLib/WorkArea.cpp +++ b/src/modules/fancyzones/FancyZonesLib/WorkArea.cpp @@ -124,6 +124,14 @@ bool WorkArea::Snap(HWND window, const ZoneIndexSet& zones, bool updatePosition) return false; } + for (ZoneIndex zone : zones) + { + if (static_cast(zone) >= m_layout->Zones().size()) + { + return false; + } + } + m_layoutWindows.Assign(window, zones); AppZoneHistory::instance().SetAppLastZones(window, m_uniqueId, m_layout->Id(), zones); diff --git a/src/modules/fancyzones/FancyZonesLib/ZonesOverlay.cpp b/src/modules/fancyzones/FancyZonesLib/ZonesOverlay.cpp index ada45b5d5c..d7c9b537fd 100644 --- a/src/modules/fancyzones/FancyZonesLib/ZonesOverlay.cpp +++ b/src/modules/fancyzones/FancyZonesLib/ZonesOverlay.cpp @@ -7,6 +7,7 @@ #include #include +#include namespace { @@ -125,6 +126,12 @@ ZonesOverlay::RenderResult ZonesOverlay::Render() return RenderResult::AnimationEnded; } + BOOL isEnabledAnimations = GetAnimationsEnabled(); + if (!isEnabledAnimations) + { + animationAlpha = 1.f; + } + m_renderTarget->BeginDraw(); // Draw backdrop diff --git a/src/modules/fancyzones/FancyZonesTests/UnitTests/WorkArea.Spec.cpp b/src/modules/fancyzones/FancyZonesTests/UnitTests/WorkArea.Spec.cpp index c365a06c03..0506e0c6d4 100644 --- a/src/modules/fancyzones/FancyZonesTests/UnitTests/WorkArea.Spec.cpp +++ b/src/modules/fancyzones/FancyZonesTests/UnitTests/WorkArea.Spec.cpp @@ -316,6 +316,28 @@ namespace FancyZonesUnitTests Assert::IsTrue(expected == layoutWindows.GetZoneIndexSetFromWindow(window)); } + TEST_METHOD(SnapEmptyZones) + { + const auto workArea = WorkArea::Create(m_hInst, m_workAreaId, m_parentUniqueId, m_workAreaRect); + const auto window = Mocks::WindowCreate(m_hInst); + + Assert::IsFalse(workArea->Snap(window, {})); + } + + TEST_METHOD(SnapToIncorrectZone) + { + const auto workArea = WorkArea::Create(m_hInst, m_workAreaId, m_parentUniqueId, m_workAreaRect); + const auto window = Mocks::WindowCreate(m_hInst); + + const ZoneIndexSet zones = { 10 }; + Assert::IsFalse(workArea->Snap(window, zones)); + + const auto processPath = get_process_path(window); + const auto history = AppZoneHistory::instance().GetZoneHistory(processPath, m_workAreaId); + + Assert::IsFalse(history.has_value()); + } + TEST_METHOD (UnsnapPropertyTest) { const auto workArea = WorkArea::Create(m_hInst, m_workAreaId, m_parentUniqueId, m_workAreaRect); diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/CanvasEditor.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/CanvasEditor.xaml.cs index 6dc0f7e0ac..c97d4d1173 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/CanvasEditor.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/CanvasEditor.xaml.cs @@ -19,12 +19,13 @@ namespace FancyZonesEditor private CanvasLayoutModel _model; - public CanvasEditor() + public CanvasEditor(CanvasLayoutModel layout) { InitializeComponent(); Loaded += OnLoaded; Unloaded += OnUnloaded; KeyDown += CanvasEditor_KeyDown; + _model = layout; } private void CanvasEditor_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) @@ -47,17 +48,8 @@ namespace FancyZonesEditor private void OnLoaded(object sender, RoutedEventArgs e) { - CanvasLayoutModel model = (CanvasLayoutModel)DataContext; - if (model != null) - { - _model = model; - - var workArea = App.Overlay.WorkArea; - - UpdateZoneRects(); - - _model.PropertyChanged += OnModelChanged; - } + UpdateZoneRects(); + _model.PropertyChanged += OnModelChanged; } private void OnUnloaded(object sender, RoutedEventArgs e) diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/CanvasEditorWindow.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/CanvasEditorWindow.xaml.cs index 2bbaa067fe..029c413a6d 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/CanvasEditorWindow.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/CanvasEditorWindow.xaml.cs @@ -11,39 +11,28 @@ namespace FancyZonesEditor { public partial class CanvasEditorWindow : EditorWindow { - private CanvasLayoutModel _model; - private CanvasLayoutModel _stashedModel; - - public CanvasEditorWindow() + public CanvasEditorWindow(CanvasLayoutModel layout) + : base(layout) { InitializeComponent(); KeyUp += CanvasEditorWindow_KeyUp; KeyDown += CanvasEditorWindow_KeyDown; - - _model = App.Overlay.CurrentDataContext as CanvasLayoutModel; - _stashedModel = (CanvasLayoutModel)_model.Clone(); - } - - public LayoutModel Model - { - get - { - return _model; - } } private void OnAddZone(object sender, RoutedEventArgs e) { Logger.LogInfo("Add zone"); - _model.AddZone(); + if (EditingLayout is CanvasLayoutModel canvas) + { + canvas.AddZone(); + } } protected new void OnCancel(object sender, RoutedEventArgs e) { Logger.LogInfo("Cancel changes"); base.OnCancel(sender, e); - _stashedModel.RestoreTo(_model); } private void CanvasEditorWindow_KeyUp(object sender, KeyEventArgs e) diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/EditorWindow.cs b/src/modules/fancyzones/editor/FancyZonesEditor/EditorWindow.cs index 2f9cd05372..b79e66c07f 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/EditorWindow.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/EditorWindow.cs @@ -11,29 +11,35 @@ namespace FancyZonesEditor { public class EditorWindow : Window { + public LayoutModel EditingLayout { get; set; } + + public EditorWindow(LayoutModel editingLayout) + { + EditingLayout = editingLayout; + } + protected void OnSaveApplyTemplate(object sender, RoutedEventArgs e) { Logger.LogTrace(); - var mainEditor = App.Overlay; - if (mainEditor.CurrentDataContext is LayoutModel model) + + // If new custom Canvas layout is created (i.e. edited Blank layout), + // it's type needs to be updated + if (EditingLayout.Type == LayoutType.Blank) { - // If new custom Canvas layout is created (i.e. edited Blank layout), - // it's type needs to be updated - if (model.Type == LayoutType.Blank) - { - model.Type = LayoutType.Custom; - } - - model.Persist(); - - MainWindowSettingsModel settings = ((App)Application.Current).MainWindowSettings; - settings.SetAppliedModel(model); - App.Overlay.Monitors[App.Overlay.CurrentDesktop].SetLayoutSettings(model); + EditingLayout.Type = LayoutType.Custom; } + EditingLayout.Persist(); + + MainWindowSettingsModel settings = ((App)Application.Current).MainWindowSettings; + settings.SetAppliedModel(EditingLayout); + App.Overlay.Monitors[App.Overlay.CurrentDesktop].SetLayoutSettings(EditingLayout); + App.FancyZonesEditorIO.SerializeLayoutTemplates(); App.FancyZonesEditorIO.SerializeCustomLayouts(); App.FancyZonesEditorIO.SerializeAppliedLayouts(); + App.FancyZonesEditorIO.SerializeDefaultLayouts(); + App.FancyZonesEditorIO.SerializeLayoutHotkeys(); Close(); } @@ -46,7 +52,7 @@ namespace FancyZonesEditor protected void OnCancel(object sender, RoutedEventArgs e) { // restore backup, clean up - App.Overlay.EndEditing(true); + App.Overlay.EndEditing(EditingLayout); // select and draw applied layout var settings = ((App)Application.Current).MainWindowSettings; diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/GridEditor.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/GridEditor.xaml.cs index d49ad9232e..8af4114eec 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/GridEditor.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/GridEditor.xaml.cs @@ -36,7 +36,7 @@ namespace FancyZonesEditor private GridData _data; - public GridEditor() + public GridEditor(GridLayoutModel layoutModel) { InitializeComponent(); Loaded += GridEditor_Loaded; @@ -44,6 +44,9 @@ namespace FancyZonesEditor KeyDown += GridEditor_KeyDown; KeyUp += GridEditor_KeyUp; gridEditorUniqueId = ++gridEditorUniqueIdCounter; + + _data = new GridData(layoutModel); + Model = layoutModel; } public void FocusZone() @@ -58,16 +61,6 @@ namespace FancyZonesEditor private void GridEditor_Loaded(object sender, RoutedEventArgs e) { ((App)Application.Current).MainWindowSettings.PropertyChanged += ZoneSettings_PropertyChanged; - - GridLayoutModel model = (GridLayoutModel)DataContext; - if (model == null) - { - return; - } - - _data = new GridData(model); - - Model = model; Model.PropertyChanged += OnGridDimensionsChanged; SetupUI(); } diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/GridEditorWindow.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/GridEditorWindow.xaml.cs index 1aea412c66..eb0e03d5ac 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/GridEditorWindow.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/GridEditorWindow.xaml.cs @@ -10,7 +10,8 @@ namespace FancyZonesEditor { public partial class GridEditorWindow : EditorWindow { - public GridEditorWindow() + public GridEditorWindow(GridLayoutModel model) + : base(model) { InitializeComponent(); diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/LayoutBackup.cs b/src/modules/fancyzones/editor/FancyZonesEditor/LayoutBackup.cs index 36dd671107..feeb49724d 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/LayoutBackup.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/LayoutBackup.cs @@ -3,14 +3,15 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using System.Windows; using FancyZonesEditor.Models; +using FancyZonesEditor.Utils; namespace FancyZonesEditor { public class LayoutBackup { private LayoutModel _backup; + private string _hotkeyBackup; private List _defaultLayoutsBackup; public LayoutBackup() @@ -28,32 +29,31 @@ namespace FancyZonesEditor _backup = new CanvasLayoutModel(canvas); } + _hotkeyBackup = MainWindowSettingsModel.LayoutHotkeys.Key(model.Uuid); _defaultLayoutsBackup = new List(MainWindowSettingsModel.DefaultLayouts.Layouts); } - public void Restore() + public void Restore(LayoutModel layoutToRestore) { - if (_backup != null) + if (_backup != null && layoutToRestore != null) { - var settings = ((App)Application.Current).MainWindowSettings; - var selectedModel = settings.SelectedModel; - - if (selectedModel == null) - { - return; - } - if (_backup is GridLayoutModel grid) { - grid.RestoreTo((GridLayoutModel)selectedModel); + grid.RestoreTo((GridLayoutModel)layoutToRestore); grid.InitTemplateZones(); } else if (_backup is CanvasLayoutModel canvas) { - canvas.RestoreTo((CanvasLayoutModel)selectedModel); + canvas.RestoreTo((CanvasLayoutModel)layoutToRestore); + canvas.InitTemplateZones(); } } + if (_hotkeyBackup != null) + { + MainWindowSettingsModel.LayoutHotkeys.SelectKey(_hotkeyBackup, layoutToRestore.Uuid); + } + if (_defaultLayoutsBackup != null) { MainWindowSettingsModel.DefaultLayouts.Restore(_defaultLayoutsBackup); @@ -63,6 +63,7 @@ namespace FancyZonesEditor public void Clear() { _backup = null; + _hotkeyBackup = null; _defaultLayoutsBackup = null; } } diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml.cs index b5dd83edb6..944222b73d 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml.cs @@ -146,29 +146,17 @@ namespace FancyZonesEditor private void DecrementZones_Click(object sender, RoutedEventArgs e) { - var mainEditor = App.Overlay; - if (mainEditor.CurrentDataContext is not LayoutModel model) + if (_settings.SelectedModel.TemplateZoneCount > 1) { - return; - } - - if (model.TemplateZoneCount > 1) - { - model.TemplateZoneCount--; + _settings.SelectedModel.TemplateZoneCount--; } } private void IncrementZones_Click(object sender, RoutedEventArgs e) { - var mainEditor = App.Overlay; - if (mainEditor.CurrentDataContext is not LayoutModel model) + if (_settings.SelectedModel.IsZoneAddingAllowed) { - return; - } - - if (model.IsZoneAddingAllowed) - { - model.TemplateZoneCount++; + _settings.SelectedModel.TemplateZoneCount++; } } @@ -303,25 +291,23 @@ namespace FancyZonesEditor private void Apply() { Logger.LogTrace(); - var mainEditor = App.Overlay; - if (mainEditor.CurrentDataContext is LayoutModel model) - { - _settings.SetAppliedModel(model); - App.Overlay.Monitors[App.Overlay.CurrentDesktop].SetLayoutSettings(model); - App.FancyZonesEditorIO.SerializeAppliedLayouts(); - App.FancyZonesEditorIO.SerializeCustomLayouts(); - } + + LayoutModel model = _settings.SelectedModel; + _settings.SetAppliedModel(model); + App.Overlay.Monitors[App.Overlay.CurrentDesktop].SetLayoutSettings(model); + App.FancyZonesEditorIO.SerializeAppliedLayouts(); + App.FancyZonesEditorIO.SerializeCustomLayouts(); } private void OnClosing(object sender, EventArgs e) { Logger.LogTrace(); - App.Overlay.EndEditing(true); App.FancyZonesEditorIO.SerializeAppliedLayouts(); App.FancyZonesEditorIO.SerializeCustomLayouts(); App.FancyZonesEditorIO.SerializeLayoutHotkeys(); App.FancyZonesEditorIO.SerializeLayoutTemplates(); + App.FancyZonesEditorIO.SerializeDefaultLayouts(); App.Overlay.CloseLayoutWindow(); App.Current.Shutdown(); } @@ -345,7 +331,8 @@ namespace FancyZonesEditor var dataContext = ((FrameworkElement)sender).DataContext; Select((LayoutModel)dataContext); - App.Overlay.StartEditing((LayoutModel)dataContext); + + App.Overlay.StartEditing(_settings.SelectedModel); Keyboard.ClearFocus(); EditLayoutDialogTitle.Text = string.Format(CultureInfo.CurrentCulture, Properties.Resources.Edit_Template, ((LayoutModel)dataContext).Name); @@ -358,16 +345,8 @@ namespace FancyZonesEditor var dataContext = ((FrameworkElement)sender).DataContext; Select((LayoutModel)dataContext); EditLayoutDialog.Hide(); - var mainEditor = App.Overlay; - if (mainEditor.CurrentDataContext is not LayoutModel model) - { - return; - } - - _settings.SetSelectedModel(model); - Hide(); - mainEditor.OpenEditor(model); + App.Overlay.OpenEditor(_settings.SelectedModel); } private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e) @@ -438,7 +417,7 @@ namespace FancyZonesEditor // EditLayout: Cancel changes private void EditLayoutDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { - App.Overlay.EndEditing(false); + App.Overlay.EndEditing(_settings.SelectedModel); Select(_settings.AppliedModel); } @@ -447,13 +426,8 @@ namespace FancyZonesEditor { Logger.LogTrace(); - var mainEditor = App.Overlay; - if (mainEditor.CurrentDataContext is not LayoutModel model) - { - return; - } - - mainEditor.EndEditing(false); + App.Overlay.EndEditing(null); + LayoutModel model = _settings.SelectedModel; // update current settings if (model == _settings.AppliedModel) @@ -465,6 +439,7 @@ namespace FancyZonesEditor App.FancyZonesEditorIO.SerializeCustomLayouts(); App.FancyZonesEditorIO.SerializeLayoutTemplates(); App.FancyZonesEditorIO.SerializeLayoutHotkeys(); + App.FancyZonesEditorIO.SerializeDefaultLayouts(); // reset selected model Select(_settings.AppliedModel); @@ -653,7 +628,6 @@ namespace FancyZonesEditor if (dataContext is LayoutModel model) { MainWindowSettingsModel.DefaultLayouts.Set(model, MonitorConfigurationType.Vertical); - App.FancyZonesEditorIO.SerializeDefaultLayouts(); } } @@ -663,7 +637,6 @@ namespace FancyZonesEditor if (dataContext is LayoutModel model) { MainWindowSettingsModel.DefaultLayouts.Set(model, MonitorConfigurationType.Horizontal); - App.FancyZonesEditorIO.SerializeDefaultLayouts(); } } @@ -673,7 +646,6 @@ namespace FancyZonesEditor if (dataContext is LayoutModel model) { MainWindowSettingsModel.DefaultLayouts.Reset(MonitorConfigurationType.Horizontal); - App.FancyZonesEditorIO.SerializeDefaultLayouts(); } } @@ -683,7 +655,6 @@ namespace FancyZonesEditor if (dataContext is LayoutModel model) { MainWindowSettingsModel.DefaultLayouts.Reset(MonitorConfigurationType.Vertical); - App.FancyZonesEditorIO.SerializeDefaultLayouts(); } } } diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Models/CanvasLayoutModel.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Models/CanvasLayoutModel.cs index bad7a06aef..7eaa5f52e8 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/Models/CanvasLayoutModel.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Models/CanvasLayoutModel.cs @@ -184,6 +184,8 @@ namespace FancyZonesEditor.Models public void RestoreTo(CanvasLayoutModel other) { + base.RestoreTo(other); + other.Zones.Clear(); foreach (Int32Rect zone in Zones) { @@ -191,7 +193,6 @@ namespace FancyZonesEditor.Models } other._topLeft = _topLeft; - other.SensitivityRadius = SensitivityRadius; other.CanvasRect = CanvasRect; other.UpdateLayout(); } diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Models/GridLayoutModel.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Models/GridLayoutModel.cs index 9010b2e9e6..537dd741d1 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/Models/GridLayoutModel.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Models/GridLayoutModel.cs @@ -280,6 +280,8 @@ namespace FancyZonesEditor.Models public void RestoreTo(GridLayoutModel layout) { + base.RestoreTo(layout); + int rows = Rows; int cols = Columns; @@ -315,7 +317,6 @@ namespace FancyZonesEditor.Models layout.ShowSpacing = ShowSpacing; layout.Spacing = Spacing; - layout.SensitivityRadius = SensitivityRadius; layout.FirePropertyChanged(); } diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Models/LayoutHotkeysModel.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Models/LayoutHotkeysModel.cs index f48a25b552..54311b4b03 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/Models/LayoutHotkeysModel.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Models/LayoutHotkeysModel.cs @@ -68,6 +68,19 @@ namespace FancyZonesEditor.Models return true; } + public string Key(string uuid) + { + foreach (var pair in SelectedKeys) + { + if (pair.Value == uuid) + { + return pair.Key; + } + } + + return Properties.Resources.Quick_Key_None; + } + public void CleanUp() { var keys = SelectedKeys.Keys.ToList(); diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Models/LayoutModel.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Models/LayoutModel.cs index b7b244cdf2..8968ef6e21 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/Models/LayoutModel.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Models/LayoutModel.cs @@ -339,6 +339,12 @@ namespace FancyZonesEditor.Models } } + public void RestoreTo(LayoutModel layout) + { + layout.SensitivityRadius = SensitivityRadius; + layout.TemplateZoneCount = TemplateZoneCount; + } + // Adds new custom Layout public void AddCustomLayout(LayoutModel model) { diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Overlay.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Overlay.cs index a1cbaeb77b..1708ae6eef 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/Overlay.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Overlay.cs @@ -186,26 +186,19 @@ namespace FancyZonesEditor Logger.LogTrace(); _layoutPreview = null; - if (CurrentDataContext is GridLayoutModel) + if (model is GridLayoutModel grid) { - _editorLayout = new GridEditor(); + _editorLayout = new GridEditor(grid); + _editorWindow = new GridEditorWindow(grid); } - else if (CurrentDataContext is CanvasLayoutModel) + else if (model is CanvasLayoutModel canvas) { - _editorLayout = new CanvasEditor(); + _editorLayout = new CanvasEditor(canvas); + _editorWindow = new CanvasEditorWindow(canvas); } CurrentLayoutWindow.Content = _editorLayout; - if (model is GridLayoutModel) - { - _editorWindow = new GridEditorWindow(); - } - else - { - _editorWindow = new CanvasEditorWindow(); - } - _editorWindow.Owner = Monitors[App.Overlay.CurrentDesktop].Window; _editorWindow.DataContext = model; _editorWindow.Show(); @@ -267,11 +260,11 @@ namespace FancyZonesEditor _layoutBackup.Backup(model); } - public void EndEditing(bool restoreBackup) + public void EndEditing(LayoutModel modelToRestore) { - if (restoreBackup) + if (modelToRestore != null) { - _layoutBackup.Restore(); + _layoutBackup.Restore(modelToRestore); } _layoutBackup.Clear(); diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Utils/FancyZonesEditorIO.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Utils/FancyZonesEditorIO.cs index 604c8bf33e..e5ecc31a5c 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/Utils/FancyZonesEditorIO.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Utils/FancyZonesEditorIO.cs @@ -1019,6 +1019,45 @@ namespace FancyZonesEditor.Utils continue; } + LayoutType layoutType = JsonTagToLayoutType(layout.AppliedLayout.Type); + LayoutSettings settings = new LayoutSettings + { + ZonesetUuid = layout.AppliedLayout.Uuid, + ShowSpacing = layout.AppliedLayout.ShowSpacing, + Spacing = layout.AppliedLayout.Spacing, + Type = layoutType, + ZoneCount = layout.AppliedLayout.ZoneCount, + SensitivityRadius = layout.AppliedLayout.SensitivityRadius, + }; + + // check if the custom layout exists + bool existingLayout = layoutType != LayoutType.Custom; + if (layoutType == LayoutType.Custom) + { + foreach (LayoutModel custom in MainWindowSettingsModel.CustomModels) + { + if (custom.Uuid == layout.AppliedLayout.Uuid) + { + existingLayout = true; + break; + } + } + } + + // replace deleted layout with the Blank layout + if (!existingLayout) + { + LayoutModel blankLayout = MainWindowSettingsModel.TemplateModels[(int)LayoutType.Blank]; + settings.ZonesetUuid = blankLayout.Uuid; + settings.Type = blankLayout.Type; + settings.ZoneCount = blankLayout.TemplateZoneCount; + settings.SensitivityRadius = blankLayout.SensitivityRadius; + + // grid layout settings, just resetting them + settings.ShowSpacing = false; + settings.Spacing = 0; + } + bool unused = true; foreach (Monitor monitor in monitors) { @@ -1028,16 +1067,6 @@ namespace FancyZonesEditor.Utils (monitor.Device.VirtualDesktopId == layout.Device.VirtualDesktop || layout.Device.VirtualDesktop == DefaultVirtualDesktopGuid)) { - var settings = new LayoutSettings - { - ZonesetUuid = layout.AppliedLayout.Uuid, - ShowSpacing = layout.AppliedLayout.ShowSpacing, - Spacing = layout.AppliedLayout.Spacing, - Type = JsonTagToLayoutType(layout.AppliedLayout.Type), - ZoneCount = layout.AppliedLayout.ZoneCount, - SensitivityRadius = layout.AppliedLayout.SensitivityRadius, - }; - monitor.Settings = settings; unused = false; break; diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs index 9332eee813..b5bee39a8a 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs @@ -239,7 +239,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests // Act // Using en-us culture to have a fixed number style - var result = engine.Interpret(input, new CultureInfo("en-us"), out _); + var result = engine.Interpret(input, new CultureInfo("en-us", false), out _); // Assert Assert.IsNotNull(result); diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/NumberTranslatorTests.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/NumberTranslatorTests.cs index e3e57966f7..e4c3d8365e 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/NumberTranslatorTests.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/NumberTranslatorTests.cs @@ -46,7 +46,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests public void Translate_ThrowError_WhenCalledNull(string input) { // Arrange - var translator = NumberTranslator.Create(new CultureInfo("de-DE"), new CultureInfo("en-US")); + var translator = NumberTranslator.Create(new CultureInfo("de-DE", false), new CultureInfo("en-US", false)); // Act Assert.ThrowsException(() => translator.Translate(input)); @@ -58,7 +58,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests public void Translate_WhenCalledEmpty(string input) { // Arrange - var translator = NumberTranslator.Create(new CultureInfo("de-DE"), new CultureInfo("en-US")); + var translator = NumberTranslator.Create(new CultureInfo("de-DE", false), new CultureInfo("en-US", false)); // Act var result = translator.Translate(input); @@ -76,7 +76,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests public void Translate_NoErrors_WhenCalled(string input, string expectedResult) { // Arrange - var translator = NumberTranslator.Create(new CultureInfo("de-DE"), new CultureInfo("en-US")); + var translator = NumberTranslator.Create(new CultureInfo("de-DE", false), new CultureInfo("en-US", false)); // Act var result = translator.Translate(input); @@ -95,7 +95,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests public void TranslateBack_NoErrors_WhenCalled(string input, string expectedResult) { // Arrange - var translator = NumberTranslator.Create(new CultureInfo("de-DE"), new CultureInfo("en-US")); + var translator = NumberTranslator.Create(new CultureInfo("de-DE", false), new CultureInfo("en-US", false)); // Act var result = translator.TranslateBack(input); @@ -113,7 +113,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests public void Translate_RemoveNumberGroupSeparator_WhenCalled(string decimalSeparator, string groupSeparator, string input, string expectedResult) { // Arrange - var sourceCulture = new CultureInfo("en-US") + var sourceCulture = new CultureInfo("en-US", false) { NumberFormat = { @@ -121,7 +121,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests NumberGroupSeparator = groupSeparator, }, }; - var translator = NumberTranslator.Create(sourceCulture, new CultureInfo("en-US")); + var translator = NumberTranslator.Create(sourceCulture, new CultureInfo("en-US", false)); // Act var result = translator.Translate(input); @@ -137,7 +137,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests public void Translate_NoRemovalOfLeadingZeroesOnEdgeCases(string input, string expectedResult) { // Arrange - var translator = NumberTranslator.Create(new CultureInfo("de-de"), new CultureInfo("en-US")); + var translator = NumberTranslator.Create(new CultureInfo("de-de", false), new CultureInfo("en-US", false)); // Act var result = translator.Translate(input); diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Components/NetworkConnectionProperties.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Components/NetworkConnectionProperties.cs index c681ae0e03..d806efdb7a 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Components/NetworkConnectionProperties.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Components/NetworkConnectionProperties.cs @@ -143,15 +143,13 @@ namespace Microsoft.PowerToys.Run.Plugin.System.Components /// List containing all network adapters internal static List GetList() { - List list = new List(); - - var interfaces = NetworkInterface.GetAllNetworkInterfaces().Where(x => x.NetworkInterfaceType != NetworkInterfaceType.Loopback && x.GetPhysicalAddress() != null); - foreach (NetworkInterface i in interfaces) - { - list.Add(new NetworkConnectionProperties(i)); - } - - return list; + var interfaces = NetworkInterface.GetAllNetworkInterfaces() + .Where(x => x.NetworkInterfaceType != NetworkInterfaceType.Loopback && x.GetPhysicalAddress() != null) + .Select(i => new NetworkConnectionProperties(i)) + .OrderByDescending(i => i.IPv4) // list IPv4 first + .ThenBy(i => i.IPv6Primary) // then IPv6 + .ToList(); + return interfaces; } /// diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests/ImageTests.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests/ImageTests.cs index a33b622d80..094e525852 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests/ImageTests.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests/ImageTests.cs @@ -24,9 +24,9 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests // Set culture to 'en-us' originalCulture = CultureInfo.CurrentCulture; - CultureInfo.CurrentCulture = new CultureInfo("en-us"); + CultureInfo.CurrentCulture = new CultureInfo("en-us", false); originalUiCulture = CultureInfo.CurrentUICulture; - CultureInfo.CurrentUICulture = new CultureInfo("en-us"); + CultureInfo.CurrentUICulture = new CultureInfo("en-us", false); } [DataTestMethod] diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests/QueryTests.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests/QueryTests.cs index 1ebb638df9..8fbcaf41e7 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests/QueryTests.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests/QueryTests.cs @@ -25,9 +25,9 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests // Set culture to 'en-us' originalCulture = CultureInfo.CurrentCulture; - CultureInfo.CurrentCulture = new CultureInfo("en-us"); + CultureInfo.CurrentCulture = new CultureInfo("en-us", false); originalUiCulture = CultureInfo.CurrentUICulture; - CultureInfo.CurrentUICulture = new CultureInfo("en-us"); + CultureInfo.CurrentUICulture = new CultureInfo("en-us", false); } [DataTestMethod] diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests/StringParserTests.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests/StringParserTests.cs index 4bbe90620b..322592a457 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests/StringParserTests.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests/StringParserTests.cs @@ -20,9 +20,9 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests { // Set culture to 'en-us' originalCulture = CultureInfo.CurrentCulture; - CultureInfo.CurrentCulture = new CultureInfo("en-us"); + CultureInfo.CurrentCulture = new CultureInfo("en-us", false); originalUiCulture = CultureInfo.CurrentUICulture; - CultureInfo.CurrentUICulture = new CultureInfo("en-us"); + CultureInfo.CurrentUICulture = new CultureInfo("en-us", false); } [DataTestMethod] diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests/TimeDateResultTests.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests/TimeDateResultTests.cs index 08931e0d57..f0f43267ee 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests/TimeDateResultTests.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests/TimeDateResultTests.cs @@ -21,14 +21,22 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests { // Set culture to 'en-us' originalCulture = CultureInfo.CurrentCulture; - CultureInfo.CurrentCulture = new CultureInfo("en-us"); + CultureInfo.CurrentCulture = new CultureInfo("en-us", false); originalUiCulture = CultureInfo.CurrentUICulture; - CultureInfo.CurrentUICulture = new CultureInfo("en-us"); + CultureInfo.CurrentUICulture = new CultureInfo("en-us", false); } - private DateTime GetDateTimeForTest() + private DateTime GetDateTimeForTest(bool embedUtc = false) { - return new DateTime(2022, 03, 02, 22, 30, 45); + var dateTime = new DateTime(2022, 03, 02, 22, 30, 45); + if (embedUtc) + { + return DateTime.SpecifyKind(dateTime, DateTimeKind.Utc); + } + else + { + return dateTime; + } } [DataTestMethod] @@ -181,8 +189,8 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests public void UtcFormatsWithShortTimeAndShortDate(string formatLabel, string expectedFormat) { // Setup - var helperResults = AvailableResultsList.GetList(true, false, false, GetDateTimeForTest()); - var expectedResult = GetDateTimeForTest().ToUniversalTime().ToString(expectedFormat, CultureInfo.CurrentCulture); + var helperResults = AvailableResultsList.GetList(true, false, false, GetDateTimeForTest(true)); + var expectedResult = GetDateTimeForTest().ToString(expectedFormat, CultureInfo.CurrentCulture); // Act var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase)); @@ -201,8 +209,8 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests public void UtcFormatsWithShortTimeAndLongDate(string formatLabel, string expectedFormat) { // Setup - var helperResults = AvailableResultsList.GetList(true, false, true, GetDateTimeForTest()); - var expectedResult = GetDateTimeForTest().ToUniversalTime().ToString(expectedFormat, CultureInfo.CurrentCulture); + var helperResults = AvailableResultsList.GetList(true, false, true, GetDateTimeForTest(true)); + var expectedResult = GetDateTimeForTest().ToString(expectedFormat, CultureInfo.CurrentCulture); // Act var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase)); @@ -221,8 +229,8 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests public void UtcFormatsWithLongTimeAndShortDate(string formatLabel, string expectedFormat) { // Setup - var helperResults = AvailableResultsList.GetList(true, true, false, GetDateTimeForTest()); - var expectedResult = GetDateTimeForTest().ToUniversalTime().ToString(expectedFormat, CultureInfo.CurrentCulture); + var helperResults = AvailableResultsList.GetList(true, true, false, GetDateTimeForTest(true)); + var expectedResult = GetDateTimeForTest().ToString(expectedFormat, CultureInfo.CurrentCulture); // Act var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase)); @@ -241,8 +249,8 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests public void UtcFormatsWithLongTimeAndLongDate(string formatLabel, string expectedFormat) { // Setup - var helperResults = AvailableResultsList.GetList(true, true, true, GetDateTimeForTest()); - var expectedResult = GetDateTimeForTest().ToUniversalTime().ToString(expectedFormat, CultureInfo.CurrentCulture); + var helperResults = AvailableResultsList.GetList(true, true, true, GetDateTimeForTest(true)); + var expectedResult = GetDateTimeForTest().ToString(expectedFormat, CultureInfo.CurrentCulture); // Act var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase)); diff --git a/src/modules/peek/Peek.FilePreviewer/Previewers/Helpers/BitmapHelper.cs b/src/modules/peek/Peek.FilePreviewer/Previewers/Helpers/BitmapHelper.cs index 6f0391a0e6..30cb971ee6 100644 --- a/src/modules/peek/Peek.FilePreviewer/Previewers/Helpers/BitmapHelper.cs +++ b/src/modules/peek/Peek.FilePreviewer/Previewers/Helpers/BitmapHelper.cs @@ -18,6 +18,7 @@ namespace Peek.FilePreviewer.Previewers.Helpers public static async Task GetBitmapFromHBitmapAsync(IntPtr hbitmap, bool isSupportingTransparency, CancellationToken cancellationToken) { Bitmap? bitmap = null; + Bitmap? tempBitmapForDeletion = null; try { @@ -32,7 +33,8 @@ namespace Peek.FilePreviewer.Previewers.Helpers var transparentBitmap = new Bitmap(bitmapData.Width, bitmapData.Height, bitmapData.Stride, PixelFormat.Format32bppArgb, bitmapData.Scan0); - bitmap.Dispose(); + // Can't dispose of original bitmap yet as that causes crashes on png files. Saving it for later disposal after saving to stream. + tempBitmapForDeletion = bitmap; bitmap = transparentBitmap; } @@ -53,6 +55,7 @@ namespace Peek.FilePreviewer.Previewers.Helpers finally { bitmap?.Dispose(); + tempBitmapForDeletion?.Dispose(); // delete HBitmap to avoid memory leaks NativeMethods.DeleteObject(hbitmap); diff --git a/src/modules/poweraccent/PowerAccent.Core/Languages.cs b/src/modules/poweraccent/PowerAccent.Core/Languages.cs index 94ea3f2174..b5b1ca2647 100644 --- a/src/modules/poweraccent/PowerAccent.Core/Languages.cs +++ b/src/modules/poweraccent/PowerAccent.Core/Languages.cs @@ -83,52 +83,37 @@ namespace PowerAccent.Core // All private static string[] GetDefaultLetterKeyALL(LetterKey letter) { - return letter switch - { - LetterKey.VK_0 => new[] { "₀", "⁰" }, - LetterKey.VK_1 => new[] { "₁", "¹" }, - LetterKey.VK_2 => new[] { "₂", "²" }, - LetterKey.VK_3 => new[] { "₃", "³" }, - LetterKey.VK_4 => new[] { "₄", "⁴" }, - LetterKey.VK_5 => new[] { "₅", "⁵" }, - LetterKey.VK_6 => new[] { "₆", "⁶" }, - LetterKey.VK_7 => new[] { "₇", "⁷" }, - LetterKey.VK_8 => new[] { "₈", "⁸" }, - LetterKey.VK_9 => new[] { "₉", "⁹" }, - LetterKey.VK_A => new[] { "á", "à", "ä", "â", "ă", "å", "α", "ā", "ą", "ȧ", "ã", "ǎ", "æ" }, - LetterKey.VK_B => new[] { "ḃ", "β" }, - LetterKey.VK_C => new[] { "ç", "ć", "ĉ", "č", "ċ", "¢", "χ", "°C", "©", "ℂ" }, - LetterKey.VK_D => new[] { "ď", "ḍ", "ḋ", "đ", "δ", "ð" }, - LetterKey.VK_E => new[] { "é", "è", "ê", "ë", "ě", "ē", "ę", "ė", "ε", "η", "€", "∈" }, - LetterKey.VK_F => new[] { "ƒ", "ḟ", "°F" }, - LetterKey.VK_G => new[] { "ğ", "ģ", "ǧ", "ġ", "ĝ", "ǥ", "γ" }, - LetterKey.VK_H => new[] { "ḣ", "ĥ", "ħ" }, - LetterKey.VK_I => new[] { "ï", "î", "í", "ì", "ī", "į", "ı", "İ", "ι", "ǐ" }, - LetterKey.VK_J => new[] { "ĵ" }, - LetterKey.VK_K => new[] { "ķ", "ǩ", "κ" }, - LetterKey.VK_L => new[] { "ĺ", "ľ", "ļ", "ł", "₺", "λ" }, - LetterKey.VK_M => new[] { "ṁ", "μ" }, - LetterKey.VK_N => new[] { "ñ", "ń", "ŋ", "ň", "ņ", "ṅ", "ⁿ", "ν", "ℕ" }, - LetterKey.VK_O => new[] { "ô", "ó", "ö", "ő", "ò", "ō", "ȯ", "ø", "õ", "œ", "ω", "ο", "ǒ" }, - LetterKey.VK_P => new[] { "ṗ", "₽", "π", "φ", "ψ", "℗" }, - LetterKey.VK_Q => new[] { "ℚ" }, - LetterKey.VK_R => new[] { "ŕ", "ř", "ṙ", "₹", "ρ", "®", "ℝ" }, - LetterKey.VK_S => new[] { "ś", "ş", "š", "ș", "ṡ", "ŝ", "ß", "σ", "$", "\u00A7" }, - LetterKey.VK_T => new[] { "ţ", "ť", "ț", "ṫ", "ŧ", "θ", "τ", "þ", "™" }, - LetterKey.VK_U => new[] { "û", "ú", "ü", "ŭ", "ű", "ù", "ů", "ū", "ų", "ǔ", "υ", "ǖ", "ǘ", "ǚ", "ǜ" }, - LetterKey.VK_V => new[] { "V̇" }, - LetterKey.VK_W => new[] { "ẇ", "ŵ", "₩" }, - LetterKey.VK_X => new[] { "ẋ", "ξ", "×" }, - LetterKey.VK_Y => new[] { "ÿ", "ŷ", "ý", "ẏ" }, - LetterKey.VK_Z => new[] { "ź", "ž", "ż", "ʒ", "ǯ", "ζ", "ℤ" }, - LetterKey.VK_COMMA => new[] { "¿", "¡", "∙", "₋", "⁻", "–", "≤", "≥", "≠", "≈", "≙", "±", "₊", "⁺" }, - LetterKey.VK_PERIOD => new[] { "\u0300", "\u0301", "\u0302", "\u0303", "\u0304", "\u0308", "\u030C" }, - LetterKey.VK_MINUS => new[] { "~", "‐", "‑", "‒", "–", "—", "―", "⁓", "−", "⸺", "⸻" }, - LetterKey.VK_SLASH_ => new[] { "÷" }, - LetterKey.VK_DIVIDE_ => new[] { "÷" }, - LetterKey.VK_MULTIPLY_ => new[] { "×", "⋅" }, - _ => Array.Empty(), - }; + // would be even better to loop through Languages and call these functions dynamically, but I don't know how to do that! + return GetDefaultLetterKeyCA(letter) + .Union(GetDefaultLetterKeyCUR(letter)) + .Union(GetDefaultLetterKeyCY(letter)) + .Union(GetDefaultLetterKeyCZ(letter)) + .Union(GetDefaultLetterKeyGA(letter)) + .Union(GetDefaultLetterKeyGD(letter)) + .Union(GetDefaultLetterKeyDE(letter)) + .Union(GetDefaultLetterKeyEST(letter)) + .Union(GetDefaultLetterKeyFR(letter)) + .Union(GetDefaultLetterKeyHR(letter)) + .Union(GetDefaultLetterKeyHE(letter)) + .Union(GetDefaultLetterKeyHU(letter)) + .Union(GetDefaultLetterKeyIS(letter)) + .Union(GetDefaultLetterKeyIT(letter)) + .Union(GetDefaultLetterKeyKU(letter)) + .Union(GetDefaultLetterKeyLT(letter)) + .Union(GetDefaultLetterKeyMK(letter)) + .Union(GetDefaultLetterKeyMI(letter)) + .Union(GetDefaultLetterKeyNL(letter)) + .Union(GetDefaultLetterKeyNO(letter)) + .Union(GetDefaultLetterKeyPI(letter)) + .Union(GetDefaultLetterKeyPL(letter)) + .Union(GetDefaultLetterKeyPT(letter)) + .Union(GetDefaultLetterKeyRO(letter)) + .Union(GetDefaultLetterKeySK(letter)) + .Union(GetDefaultLetterKeySP(letter)) + .Union(GetDefaultLetterKeySR(letter)) + .Union(GetDefaultLetterKeySV(letter)) + .Union(GetDefaultLetterKeyTK(letter)) + .ToArray(); } // Currencies (source: https://www.eurochange.co.uk/travel-money/world-currency-abbreviations-symbols-and-codes-travel-money) diff --git a/src/modules/powerrename/PowerRenameUILib/PowerRenameXAML/MainWindow.xaml b/src/modules/powerrename/PowerRenameUILib/PowerRenameXAML/MainWindow.xaml index 5b2d4d1832..cecbeea866 100644 --- a/src/modules/powerrename/PowerRenameUILib/PowerRenameXAML/MainWindow.xaml +++ b/src/modules/powerrename/PowerRenameUILib/PowerRenameXAML/MainWindow.xaml @@ -503,7 +503,6 @@ diff --git a/src/modules/powerrename/PowerRenameUILib/PowerRenameXAML/MainWindow.xaml.cpp b/src/modules/powerrename/PowerRenameUILib/PowerRenameXAML/MainWindow.xaml.cpp index f3ced290b3..15d542bb52 100644 --- a/src/modules/powerrename/PowerRenameUILib/PowerRenameXAML/MainWindow.xaml.cpp +++ b/src/modules/powerrename/PowerRenameUILib/PowerRenameXAML/MainWindow.xaml.cpp @@ -282,6 +282,7 @@ namespace winrt::PowerRenameUI::implementation } button_rename().IsEnabled(false); + toggleButton_enumItems().IsChecked(true); InitAutoComplete(); SearchReplaceChanged(); InvalidateItemListViewState(); diff --git a/src/modules/registrypreview/RegistryPreviewUI/Strings/en-US/Resources.resw b/src/modules/registrypreview/RegistryPreviewUI/Strings/en-US/Resources.resw index ec92378548..6b766a6570 100644 --- a/src/modules/registrypreview/RegistryPreviewUI/Strings/en-US/Resources.resw +++ b/src/modules/registrypreview/RegistryPreviewUI/Strings/en-US/Resources.resw @@ -178,6 +178,9 @@ Open Key + + Save As + Save as… diff --git a/src/settings-ui/Settings.UI.Library/FileLocksmithLocalProperties.cs b/src/settings-ui/Settings.UI.Library/FileLocksmithLocalProperties.cs index 61f6864872..f998e5b4dd 100644 --- a/src/settings-ui/Settings.UI.Library/FileLocksmithLocalProperties.cs +++ b/src/settings-ui/Settings.UI.Library/FileLocksmithLocalProperties.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Text.Json; +using System.Text.Json.Serialization; using Microsoft.PowerToys.Settings.UI.Library.Interfaces; namespace Microsoft.PowerToys.Settings.UI.Library @@ -14,6 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library ExtendedContextMenuOnly = false; } + [JsonPropertyName("showInExtendedContextMenu")] public bool ExtendedContextMenuOnly { get; set; } public string ToJsonString() diff --git a/src/settings-ui/Settings.UI.Library/FindMyMouseProperties.cs b/src/settings-ui/Settings.UI.Library/FindMyMouseProperties.cs index d30b9307b8..ba97a590d7 100644 --- a/src/settings-ui/Settings.UI.Library/FindMyMouseProperties.cs +++ b/src/settings-ui/Settings.UI.Library/FindMyMouseProperties.cs @@ -8,9 +8,14 @@ namespace Microsoft.PowerToys.Settings.UI.Library { public class FindMyMouseProperties { + public HotkeySettings DefaultActivationShortcut => new HotkeySettings(true, false, false, true, 0x46); + [JsonPropertyName("activation_method")] public IntProperty ActivationMethod { get; set; } + [JsonPropertyName("activation_shortcut")] + public HotkeySettings ActivationShortcut { get; set; } + [JsonPropertyName("do_not_activate_on_game_mode")] public BoolProperty DoNotActivateOnGameMode { get; set; } @@ -41,6 +46,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library public FindMyMouseProperties() { ActivationMethod = new IntProperty(0); + ActivationShortcut = DefaultActivationShortcut; DoNotActivateOnGameMode = new BoolProperty(true); BackgroundColor = new StringProperty("#000000"); SpotlightColor = new StringProperty("#FFFFFF"); diff --git a/src/settings-ui/Settings.UI.Library/FindMyMouseSettings.cs b/src/settings-ui/Settings.UI.Library/FindMyMouseSettings.cs index cd65372cdd..921bd62992 100644 --- a/src/settings-ui/Settings.UI.Library/FindMyMouseSettings.cs +++ b/src/settings-ui/Settings.UI.Library/FindMyMouseSettings.cs @@ -18,7 +18,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library { Name = ModuleName; Properties = new FindMyMouseProperties(); - Version = "1.0"; + Version = "1.1"; } public string GetModuleName() @@ -29,6 +29,17 @@ namespace Microsoft.PowerToys.Settings.UI.Library // This can be utilized in the future if the settings.json file is to be modified/deleted. public bool UpgradeSettingsConfiguration() { + if (Version == "1.0") + { + if (Properties.ActivationMethod.Value == 1) + { + Properties.ActivationMethod = new IntProperty(2); + } + + Version = "1.1"; + return true; + } + return false; } } diff --git a/src/settings-ui/Settings.UI/Converters/FindMyMouseActivationShakeMouseIntToVisibilityConverter.cs b/src/settings-ui/Settings.UI/Converters/FindMyMouseActivationIntToVisibilityConverter.cs similarity index 58% rename from src/settings-ui/Settings.UI/Converters/FindMyMouseActivationShakeMouseIntToVisibilityConverter.cs rename to src/settings-ui/Settings.UI/Converters/FindMyMouseActivationIntToVisibilityConverter.cs index d4539fe5dc..080de07713 100644 --- a/src/settings-ui/Settings.UI/Converters/FindMyMouseActivationShakeMouseIntToVisibilityConverter.cs +++ b/src/settings-ui/Settings.UI/Converters/FindMyMouseActivationIntToVisibilityConverter.cs @@ -3,26 +3,20 @@ // See the LICENSE file in the project root for more information. using System; +using System.Globalization; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Data; namespace Microsoft.PowerToys.Settings.UI.Converters { - public sealed class FindMyMouseActivationShakeMouseIntToVisibilityConverter : IValueConverter + public sealed class FindMyMouseActivationIntToVisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { - var activationShake = (int)value; + var selectedActivation = (int)value; + var expectedActivation = int.Parse(parameter as string, CultureInfo.InvariantCulture); - // Assumes 1 is the index for the shake mouse option in the activation method combo box - if (activationShake == 1) - { - return Visibility.Visible; - } - else - { - return Visibility.Collapsed; - } + return selectedActivation == expectedActivation ? Visibility.Visible : Visibility.Collapsed; } public object ConvertBack(object value, Type targetType, object parameter, string language) diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/AwakePage.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/Views/AwakePage.xaml.cs index 2079c73eae..25822b303e 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/AwakePage.xaml.cs +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/AwakePage.xaml.cs @@ -182,6 +182,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views public void RefreshEnabledState() { + UpdateEnabledState(_generalSettingsRepository.SettingsConfig.Enabled.Awake); ViewModel.RefreshEnabledState(); } } diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/MouseUtilsPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/MouseUtilsPage.xaml index 77ee711c07..db8db47282 100644 --- a/src/settings-ui/Settings.UI/SettingsXAML/Views/MouseUtilsPage.xaml +++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/MouseUtilsPage.xaml @@ -3,6 +3,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls" + xmlns:converters="using:Microsoft.PowerToys.Settings.UI.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:labs="using:CommunityToolkit.Labs.WinUI" xmlns:localConverters="using:Microsoft.PowerToys.Settings.UI.Converters" @@ -11,7 +12,9 @@ AutomationProperties.LandmarkType="Main" mc:Ignorable="d"> - + + + + + Visibility="{x:Bind Mode=OneWay, Path=ViewModel.FindMyMouseActivationMethod, Converter={StaticResource FindMyMouseActivationIntToVisibilityConverter}, ConverterParameter=2}"> + + + - - + +