Commit Graph

4074 Commits

Author SHA1 Message Date
Enrico Giordani
d2201cbb79
[SG] change suppress key code (#6750) 2020-09-22 13:12:19 +02:00
Clint Rutkas
934949725b
FxCop and StyleCop for SVG thumbnail (#6757)
* FxCop work for SvgThumbnail

* enabling stylecop
2020-09-21 19:44:12 -07:00
Clint Rutkas
57972c6653
Update README.md 2020-09-21 13:43:23 -07:00
ryanbodrug-microsoft
0f6428eed0
User/ryanbod/mock settings disk access (#6188)
* 1) Making Directory Methods private.
2) Removing the CreateDirectory / DeleteDirectory functionality from all Settings Unit Tests.

* Abstracting disk access via IIOProvider to be able to provide mocks for unit tests instead of writing to disk.   This also prevents developers who are running unit tests from interfering with the PowerToys settings on their local dev box.

* Dependency Injecting stub SettingsUtils for all tests

* Removing ISettingsUtils from constructors of objects that need to be deserialized (ColorPickerSettings/PowerLauncherSettings) as this breaks System.Text.Json

* Removing unused namespace reference

* Removing redifined mock

* As per PR feedback.  Stub Settings utils should work with any settings type if the intent is to compile / avoid null ref exceptions.

Strangely when implementing this fix it became apparent that a stub settings isn't enough, and disk access needed to be mocked.  I can't explain why the tests were passing previously.

* Leveraging GetMockIOProviderForSaveLoadExists
2020-09-21 10:14:44 -07:00
Ivan Stošić
6e89ef62e4
[Launcher] Kill the Launcher immediately (#6747)
* Kill the Launcher immediately

* Also rename the shared file
2020-09-21 13:51:30 +02:00
Ivan Stošić
b266e336b5
[Launcher] Use a keyboard hook in the runner to invoke the Launcher (#6660)
* Added a keyboard hook to the runner

* Update RootKeyboardHook

* Enable reading the whole JsonObject property

* Renamed RootKeyboardHook to CentralizedKeyboardHook

* Fixed build break, changed callback return type to bool

* Added Hotkey struct which somehow went missing

+ Cherry-pick fixes

* Reorganized the kb hook

* Basic version works

* Various fixes

* Finishing touches

* Fix potential threading issue

* int -> size_t

* Add default initializers to the Hotkey struct

* Added a suggested comment

* Unified a constant

* Use C# classes instead of native calls for sync

* Added a claryfing comment

* Use std::move

* Renamed a method

* Possible fix for compilation errors

* Fix a regression

* Show a message on failure

* Added DISABLE_LOWLEVEL_HOOK support

* Allow running Launcher as standalone

* Rename string constants
2020-09-21 12:44:16 +02:00
Arjun Balgovind
e135153c45
[Keyboard Manager] Fix focusable elements should have different names accessibility issue (#6672)
* Add listview

* Added row index to accessible names

* Cleanup rowIndex

* Fixed accessibility issue with ComboBox

* Updated comments
2020-09-18 17:12:37 -07:00
Divyansh Srivastava
28cae124d1
Nit fix in logging (#6708) 2020-09-18 13:32:28 -07:00
Clint Rutkas
94d8b4a122
rerouting to Log class vs custom logic (#6688) 2020-09-18 12:58:52 -07:00
Arjun Balgovind
ce835418cb
Enable localization on all folders under PowerToys root (#6692)
* Changed to repo root

* Removed backslash

* Revert testing change

* Add comment
2020-09-18 10:27:59 -07:00
vldmr11080
3aa7a52c21
[FancyZones] Initial improvements in FancyZones exception handling (#6063)
* Initial improvements in FancyZones exception handling

* Add callback

* Disable FancyZones if error durign loading data occurrs

* Remove logs

* Add resource strings

* Add 1sec retry when failure during initialization occurs

* Rephrase error descriptions

* Error handling during loading of module in runner

* Pass error handling on the runner

* Remove unneeded string

* Remove unnedeed changes
2020-09-18 15:18:01 +02:00
yuyoyuppe
2bc3480396 common: fix trim functions for wchar_t 2020-09-18 13:33:02 +03:00
Remy Blok
7893f387d5
[FancyZones] Configurable sensitivity radius (#6554)
* Add the setting for the Sensitivity Radius to JSON and the Editor
Use the setting when determining Zones to highligh

* Fix FanzyZones unit tests
Add test for Json upgrade

* Updated texts in FancyZone Editor
More Text to Resources / Use Resources

* Added constant for default of Sensitivity Radius

* When installing from scratch of when a new device is added set the sensitivity radius to the default.
Move all the constant values to a single namespace

* restore correct formatting

Co-authored-by: Remy Blok <remy.blok@prodware.nl>
2020-09-18 09:16:06 +02:00
Divyansh Srivastava
00187269de
handle error in Packaged program loading (#6674) 2020-09-17 16:17:02 -07:00
Roy
b3833fcf1a
[PowerToys Run] Add Suport for Commandline arguments in Program Plugin (#5791)
* Implemented possibility to add commandline arguments in the Program Plugin

* Add missing return statement inc ommandArgumentParser loop

* Fix typos

* Fix Additional Typo

* Changed -c to /c to make it a valid cmd argument

* Added small comment about importance of order in _programArgumentParsers

Co-authored-by: Roy <royvou@hotmailcom>
2020-09-17 15:39:28 -07:00
Aaron Junker
923972dd49
Update contributing.md (#6636)
* Update contributing.md

* Update contributing.md
2020-09-17 15:06:40 -07:00
Arjun Balgovind
f19bad3761
Revert "[FxCop] Telemetry.csproj" (#6690)
* Revert "marking all warnings (#6642)"

This reverts commit b0f0940534.

* Added warning comment
2020-09-17 14:02:25 -07:00
stefansjfw
b5cc24fcff
[FancyZones] Remove migration from registry logic and delete registry data if present (#6657)
* Remove migration from registry logic

* Address PR comments
2020-09-17 20:57:44 +02:00
yuyoyuppe
d414d52156 localization: move localizable strings to .resw for runner/bootstrapper 2020-09-17 20:32:18 +03:00
Clint Rutkas
85c0eaa598
Update readme.md (#6670) 2020-09-16 14:27:37 -07:00
Clint Rutkas
d409a71000
Getting FxCop online (#6668) 2020-09-16 12:26:58 -07:00
Clint Rutkas
0a716c253b
Upgrade nuget packages (#6641)
* upgrade mahapps

* update nlog

* all launcher packages now updated

* tests and Setting UI

* markdown

* removing unneeded DLL now from nuget update
2020-09-16 12:24:21 -07:00
Clint Rutkas
13fd6bd6e1
[FxCop] Svg preview handler (#6647)
* Adjusting namespace

* Getting FxCop working e2e
2020-09-16 12:24:07 -07:00
Clint Rutkas
b0f0940534
marking all warnings (#6642) 2020-09-16 12:23:50 -07:00
Clint Rutkas
dc284d9cbb
Clean up some unused dependencies, nlog and some newtonsoft (#6650)
* remove nlog

* removing unused referecnes to newtonsoft
2020-09-16 11:36:52 -07:00
Clint Rutkas
0a86360948
Fxcop markdown preview handler (#6646)
* migrating namespace conflict

* Fixing all errors

* removing todo

* tweak wxs
2020-09-16 11:15:34 -07:00
Divyansh Srivastava
e49900f927
Fix sync issue in SelectedItem (#6582) 2020-09-16 09:59:04 -07:00
Arjun Balgovind
5e301133ff
[Settings] Fix settings process not terminating on closing settings while minimized (#6626)
* Added code to set CoreWindow to visible on closing while minimized

* Changed to environment.exit
2020-09-16 09:47:43 -07:00
Aaron Junker
5b684cca9a
Update style.md (#6323) 2020-09-15 11:24:55 -07:00
stefansjfw
3d36779e19
[FancyZones] Do not zone window if it should be maximized (#6619)
* Do not zone window if it should be maximized

* Update comment

* Remove uneeded field

* Address PR comment
2020-09-15 13:03:17 +02:00
Enrico Giordani
eaf54ca525
Fix typo in URL (#6630) 2020-09-15 12:38:34 +02:00
Arjun Balgovind
25f93e8b94
Fix for issue 3886 (#6585) 2020-09-14 13:12:02 -07:00
Arjun Balgovind
7328aa7df5
Fixed Visibility property changed invoked on clicking away from PT Run (#6588) 2020-09-14 13:10:56 -07:00
Divyansh Srivastava
d75dd71848
Fix for null reference exception (#6589) 2020-09-14 11:03:17 -07:00
Ivan Stošić
3d5c790fb6
[FZ Editor] Improved a function in GridData.cs (#6565)
* Improved a function in GridData.cs

* Allocate the extra values proportionally

* Refactor a constant
2020-09-14 10:05:28 +02:00
Clint Rutkas
5af88de27b
tweaking text and adding in headers (#6586) 2020-09-11 17:10:51 -07:00
Clint Rutkas
997a7bc60f
adding in trim (#6584) 2020-09-11 16:15:18 -07:00
Arjun Balgovind
bfbd7b53a1
Unregister key delays on closing KBM windows (#6583) 2020-09-11 15:16:34 -07:00
Alekhya
1dec80902d
unify the name as it is present in the plugin.json file (#6547) 2020-09-11 13:45:32 -07:00
Alekhya
0478d99aac
To catch URI Format Exception in PT Run (#6580)
* add a catch block for uri format exceptions

* Added link to watson crash
2020-09-11 13:04:25 -07:00
stefansjfw
db9677bb4a
[FancyZones] Do not zone window if it merges with other window (#6549)
* Do not zone window if it merges with other window (e.g. merge Chrome tab into other Chrome window

* Small move of func call

* Address PR comment

* remove include

* Address PR comment 2
2020-09-11 12:35:43 +02:00
Ivan Stošić
0e32edb603
[FancyZones] Use Ctrl+Win+Alt+arrows to Expand/shrink windows to adjacent zones (#6446)
* Added an Alt key hook

* Refactor a block of code into a method

* Again refactored existing code

* Apparently Win+Alt does not reach FancyZones

* Using Ctrl+alt instead of Win+alt for now

* It works

* Fixed VD change

* Remove unused member

* Fix compilation error

* Enable shrinking

* Fixed comments in .h files

* Remove newline

* Refactored a function into two

The next task is to simplify their code.

* Updated a comment

* Update a variable name

* Reverted to the old implementation of directional move

* More refactoring

* Remove space

* Fixed windows getting stuck

* Changed function name
2020-09-11 11:32:45 +02:00
Arjun Balgovind
82e1be2839
[Launcher] Categorize Lnk files in program plugin correctly as per the target file type (#6348)
* Updated UnregisteredApps code

* Added file type checking code and Folder and File classifications

* Added more file formats

* Removed run as admin for lnk folders

* Added script files as executable and changed hashset to case insensitive

* Removed runasadmin for generic files

* Removed FileTypes enum

* Extended ApplicationTypes enum

* Fix file format error

* Cleaned use of ApplicationType enum to public and match AppType and used ApplicationType in OnAppRenamed

* Modify tests to use ApplicationType enum

* Added tests for new App types

* Modified dummy appref

* Mock Directory.Exists and add tests for GetAppTypeFromPath

* Combined tests
2020-09-10 15:06:37 -07:00
Arjun Balgovind
ab8bec8866
[KBM] Prevent keyboard manager crash when index is not found (#6488)
* Added Sleep(5000) for repro

* Added check to prevent kbm crash for index not found

* Add more safeguards
2020-09-10 11:31:49 -07:00
Arjun Balgovind
3b8fa8b4ce
Fixed KBM shortcut remapping not working after using Japanese IME (#6450) 2020-09-10 10:46:33 -07:00
ryanbodrug-microsoft
c4cb3df306
Adding FxCop to Microsoft.Plugin.WindowWalker (#6260)
* Adding FxCop to Microsoft.Plugin.WindowWalker

* Delete WindowResult.cs -- Fix for CA1812 WindowResult is an internal class that is apparently never instantiated. If so, remove the code from the assembly. If this class is intended to contain only static members, make it static (Shared in Visual Basic).

* Fix for CA1806 UpdateOpenWindowsList calls EnumWindows but does not use the HRESULT or error code that the method returns. This could lead to unexpected behavior in error conditions or low-resource situations. Use the result in a conditional statement, assign the result to a variable, or pass it as an argument to another method.

* Fix for: CA1066 Type Microsoft.Plugin.WindowWalker.Components.InteropAndHelpers.RECT should implement IEquatable<T> because it overrides Equals

* Fix for:  CA1052 Type 'FuzzyMatching' is a static holder type but is neither static nor NotInheritable

* Suppress for CA1069 - These values are defined in
https://docs.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles.

CA1069 The enum member 'WS_EX_LTRREADING' has the same constant value '0' as member 'WS_EX_LEFT'
CA1069 The enum member 'WS_EX_RIGHTSCROLLBAR' has the same constant value '0' as member 'WS_EX_LEFT'

* Supress CA1069

Code Description
CA1069 The enum member 'SWP_NOREPOSITION' has the same constant value '512' as member 'SWP_NOOWNERZORDER'
CA1069 The enum member 'SWP_FRAMECHANGED' has the same constant value '32' as member 'SWP_DRAWFRAME'

* Suprress CA1069 for ShowWindow values.  See

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow

CA1069 The enum member 'ShowMaximized' has the same constant value '3' as member 'Maximize'

* Fix code formatting error

* Fix for CA2235: Making POINT serializable

CA2235 Field MinPosition is a member of type WINDOWPLACEMENT which is serializable but is of type Microsoft.Plugin.WindowWalker.Components.InteropAndHelpers.POINT which is not serializable
CA2235 Field MaxPosition is a member of type WINDOWPLACEMENT which is serializable but is of type Microsoft.Plugin.WindowWalker.Components.InteropAndHelpers.POINT which is not serializable

* Fix CA2235 Making RECT serializable

CA2235 Field NormalPosition is a member of type WINDOWPLACEMENT which is serializable but is of type Microsoft.Plugin.WindowWalker.Components.InteropAndHelpers.RECT which is not serializable

* Fixes for CA2101 Specify marshaling for P/Invoke string arguments.

* Fixes for CA2007 Consider calling ConfigureAwait on the awaited task

* Fixes for the following (CA1822 / CA1801):
CA1822 Member 'OnOpenWindowsUpdate' does not access instance data and can be marked as static
Code Description
CA1801 Parameter value of method add_OnOpenWindowsUpdate is never used. Remove the parameter or use it in the method body.
CA1801 Parameter value of method remove_OnOpenWindowsUpdate is never used. Remove the parameter or use it in the method body.

* Fix: CA1710 Rename OpenWindowsUpdateHandler to end in 'EventHandler'

* Fix CA1822 Member 'GetProcessIDFromWindowHandle' does not access instance data and can be marked as static

* Fix CA1062 In externally visible method 'List<int> FuzzyMatching.FindBestFuzzyMatch(string text, string searchText)', validate parameter 'searchText' is non-null before using it. If appropriate, throw an ArgumentNullException when the argument is null or add a Code Contract precondition asserting non-null argument.

* Fixes for CA1304 The behavior of 'string.ToLower()' could vary based on the current user's locale settings.

CA1304 The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'FuzzyMatching.FindBestFuzzyMatch(string, string)' with a call to 'string.ToLower(CultureInfo)'.

Code Description
CA1304 The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'FuzzyMatching.FindBestFuzzyMatch(string, string)' with a call to 'string.ToLower(CultureInfo)'.

* Supressing warning for CA1814: Prefer jagged arrays over multidimensional however this might be something to consider if needing to optimize the window walker search.

* Fix: CA1062 In externally visible method 'List<List<int>> FuzzyMatching.GetAllMatchIndexes(bool[,] matches)', validate parameter 'matches' is non-null before using it. If appropriate, throw an ArgumentNullException when the argument is null or add a Code Contract precondition asserting non-null argument.

* Fix for CA1062 In externally visible method 'int FuzzyMatching.CalculateScoreForMatches(List<int> matches)', validate parameter 'matches' is non-null before using it. If appropriate, throw an ArgumentNullException when the argument is null or add a Code Contract precondition asserting non-null argument.

* Fixes for CA1806 Calls x...  but does not use the HRESULT or error code that the method returns. This could lead to unexpected behavior in error conditions or low-resource situations. Use the result in a conditional statement, assign the result to a variable, or pass it as an argument to another method.

Using discard for methods that return void, and checking the hresult before returning parameters.

* Fix for CA1820 Test for empty strings using 'string.Length' property or 'string.IsNullOrEmpty' method instead of an Equality check

* Supress CA1031 Modify 'get_WindowIcon' to catch a more specific allowed exception type, or rethrow the exception

* Code Description
CA1062 In externally visible method 'List<Result> Main.Query(Query query)', validate parameter 'query' is non-null before using it. If appropriate, throw an ArgumentNullException when the argument is null or add a Code Contract precondition asserting non-null argument.

* Fixes For CA1304 The behavior of 'string.ToUpper()' could vary based on the current user's locale settings.

CA1304 The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'SearchController.SearchText.set' with a call to 'string.ToLower(CultureInfo)'.
CA1304 The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Window.ProcessName.get' with a call to 'string.ToLower(CultureInfo)'.
CA1304 The behavior of 'string.ToLower()' could vary based on the current user's locale settings. Replace this call in 'Window.SwitchToWindow()' with a call to 'string.ToLower(CultureInfo)'.
CA1304 The behavior of 'string.ToUpper()' could vary based on the current user's locale settings. Replace this call in 'Window.ToString()' with a call to 'string.ToUpper(CultureInfo)'.
CA1307 The behavior of 'string.Equals(string?)' could vary based on the current user's locale settings. Replace this call in 'Microsoft.Plugin.WindowWalker.Components.Window.SwitchToWindow()' with a call to 'string.Equals(string?, System.StringComparison)'.

* Fix: CA1710 Rename SearchResultUpdateHandler to end in 'EventHandler'

* Fix CA1060 Move pinvokes to native methods class

* Fix: CS0067 The event 'OpenWindows.OnOpenWindowsUpdateEventHandler' is never used

1) Remove SearchController::OpenWindowsUpdateHandler(object sender, SearchResultUpdateEventArgs e) as it wasn't being called and was redundant with Update Search Text.
2) In Main.cs calling UpdateOpenWindowsList before UpdateSearchText so that the latest enumerated windows will be called.
3) Removing unused OnOpenWindowsUpdateEventHandler and related code.

* Revert "Fixes for CA2101 Specify marshaling for P/Invoke string arguments."

This reverts commit b3dfe07915.

* Fixing CA2101 by turning off best fit mapping for methods that require ANSI marshalling.

See: https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2101?view=vs-2019

* Previous fix for CA1806 misunderstood int result as hresult.  The actual return value is number of characters written.
NativeMethods.GetWindowText(hwnd, titleBuffer, sizeOfTitle);

* Previous fix for CA1806 misunderstood int result as hresult.  The actual return value is number of characters written.

NativeMethods.GetClassName(Hwnd, windowClassName, windowClassName.MaxCapacity);

* Removing unused window code.  This was done instead of validating fxcop changes in WindowIcon.

* Fixing typos in Window.cs (charachter -> character)
2020-09-10 09:44:22 -07:00
Alekhya
efd5c33a92
set object before using it (#6497) 2020-09-10 09:44:10 -07:00
Niels Laute
f589103f5d
Change searchbox order to make text selectable (#6400)
Co-authored-by: Niels Laute <niels9001@hotmail.com>
2020-09-10 09:42:20 -07:00
vldmr11080
19175e9bde
Introduce several fallback scenarios when obtaining GUID for current virtual desktop (#6534) 2020-09-10 14:42:36 +02:00
P-Storm
3137aaa660
Create unit tests for Calculator plugin (#6356)
* Refactored logic and made it unit testable

* Changes after code review

* Added to build steps, and modified bracket to new class with unittest. Validates complexer cases now.

Co-authored-by: p-storm <paul.de.man@gmail.com>
2020-09-09 20:01:30 -07:00