Compare commits

...

7 Commits

Author SHA1 Message Date
Jaime Bernardo
dbde5e3854 [Runner]remove hotkeyEx when disabling a module (#15944) 2022-02-02 12:18:45 +00:00
Heiko
bed7f2a240 [PTRun]WindowWalker: remove IsCloaked check (#15943) 2022-02-02 12:04:36 +00:00
Jaime Bernardo
73a6f76610 [MouseUtils]check queue dispatcher initialization (#15948) 2022-02-02 12:04:21 +00:00
Jaime Bernardo
9d70f784a2 [PTRun]Remove Wox plugin install dead code/deps (#15869) 2022-02-02 12:04:11 +00:00
Stefan Markovic
4ded7132a5 If process elevated and --dont-elevate arg - run non elevated (#15920) 2022-02-02 12:03:59 +00:00
Stefan Markovic
b469b87d75 [runner] Save settings on closing only when PT was actually running (#15926)
i.e. Don't save if PT was only scheduling a restart
2022-02-02 12:03:47 +00:00
Niels Laute
12f9239889 [Settings] UX bugfixes (#15848)
* Update AlwaysOnTopPage.xaml

* Update VideoConference.xaml
2022-02-02 12:03:32 +00:00
15 changed files with 50 additions and 274 deletions

View File

@@ -173,7 +173,6 @@
"HelixToolkit.Core.Wpf.dll",
"Mages.Core.dll",
"JetBrains.Annotations.dll",
"ICSharpCode.SharpZipLib.dll",
"NLog.Extensions.Logging.dll",
"concrt140_app.dll",
"msvcp140_1_app.dll",

View File

@@ -148,7 +148,7 @@
Impersonate="yes"
Return="asyncNoWait"
FileKey="PowerToys.exe"
ExeCommand="" />
ExeCommand="--dont-elevate" />
<CustomAction
Id="TerminateProcesses"
@@ -1379,7 +1379,7 @@
<Component Id="launcherInstallComponent" Directory="LauncherInstallFolder" Guid="5E688DB4-C522-4268-BA54-ED1CDFFE9DB6">
<File Source="$(var.BinX64Dir)modules\Launcher\PowerToys.Launcher.dll" />
<?foreach File in concrt140_app.dll;e_sqlite3.dll;ICSharpCode.SharpZipLib.dll;JetBrains.Annotations.dll;Mages.Core.dll;Microsoft.Search.Interop.dll;Mono.Cecil.dll;Mono.Cecil.Mdb.dll;Mono.Cecil.Pdb.dll;Mono.Cecil.Rocks.dll;msvcp140_1_app.dll;msvcp140_2_app.dll;msvcp140_app.dll;NLog.dll;NLog.Extensions.Logging.dll;PowerToys.PowerLauncher.deps.json;PowerToys.PowerLauncher.dll;PowerToys.PowerLauncher.exe;Microsoft.Xaml.Behaviors.dll;System.Text.Json.dll;PowerToys.PowerLauncher.runtimeconfig.json;System.Data.OleDb.dll;UnitsNet.dll;vcamp140_app.dll;vccorlib140_app.dll;vcomp140_app.dll;vcruntime140_1_app.dll;vcruntime140_app.dll;Wox.Infrastructure.dll;Wox.Plugin.dll;PowerToys.Interop.dll;PowerToys.ManagedTelemetry.dll;PowerToys.PowerLauncher.Telemetry.dll;Microsoft.Data.Sqlite.dll;SQLitePCLRaw.batteries_v2.dll;SQLitePCLRaw.core.dll;SQLitePCLRaw.provider.e_sqlite3.dll;Microsoft.Extensions.Configuration.Abstractions.dll;Microsoft.Extensions.Configuration.Binder.dll;Microsoft.Extensions.Configuration.dll;Microsoft.Extensions.DependencyInjection.Abstractions.dll;Microsoft.Extensions.DependencyInjection.dll;Microsoft.Extensions.Logging.Abstractions.dll;Microsoft.Extensions.Logging.dll;Microsoft.Extensions.Options.dll;Microsoft.Extensions.Primitives.dll;ControlzEx.dll;PowerToys.ManagedCommon.dll;System.IO.Abstractions.dll;PowerToys.Common.UI.dll;System.ServiceProcess.ServiceController.dll;Microsoft.Toolkit.Uwp.Notifications.dll;ModernWpf.Controls.dll;ModernWpf.dll;WinRT.Runtime.dll;Microsoft.Windows.SDK.NET.dll?>
<?foreach File in concrt140_app.dll;e_sqlite3.dll;JetBrains.Annotations.dll;Mages.Core.dll;Microsoft.Search.Interop.dll;Mono.Cecil.dll;Mono.Cecil.Mdb.dll;Mono.Cecil.Pdb.dll;Mono.Cecil.Rocks.dll;msvcp140_1_app.dll;msvcp140_2_app.dll;msvcp140_app.dll;NLog.dll;NLog.Extensions.Logging.dll;PowerToys.PowerLauncher.deps.json;PowerToys.PowerLauncher.dll;PowerToys.PowerLauncher.exe;Microsoft.Xaml.Behaviors.dll;System.Text.Json.dll;PowerToys.PowerLauncher.runtimeconfig.json;System.Data.OleDb.dll;UnitsNet.dll;vcamp140_app.dll;vccorlib140_app.dll;vcomp140_app.dll;vcruntime140_1_app.dll;vcruntime140_app.dll;Wox.Infrastructure.dll;Wox.Plugin.dll;PowerToys.Interop.dll;PowerToys.ManagedTelemetry.dll;PowerToys.PowerLauncher.Telemetry.dll;Microsoft.Data.Sqlite.dll;SQLitePCLRaw.batteries_v2.dll;SQLitePCLRaw.core.dll;SQLitePCLRaw.provider.e_sqlite3.dll;Microsoft.Extensions.Configuration.Abstractions.dll;Microsoft.Extensions.Configuration.Binder.dll;Microsoft.Extensions.Configuration.dll;Microsoft.Extensions.DependencyInjection.Abstractions.dll;Microsoft.Extensions.DependencyInjection.dll;Microsoft.Extensions.Logging.Abstractions.dll;Microsoft.Extensions.Logging.dll;Microsoft.Extensions.Options.dll;Microsoft.Extensions.Primitives.dll;ControlzEx.dll;PowerToys.ManagedCommon.dll;System.IO.Abstractions.dll;PowerToys.Common.UI.dll;System.ServiceProcess.ServiceController.dll;Microsoft.Toolkit.Uwp.Notifications.dll;ModernWpf.Controls.dll;ModernWpf.dll;WinRT.Runtime.dll;Microsoft.Windows.SDK.NET.dll?>
<File Id="File_$(var.File)" Source="$(var.BinX64Dir)modules\launcher\$(var.File)" />
<?endforeach?>
<File Source="$(var.BinX64Dir)Settings\PowerToys.Settings.UI.Lib.dll" />

View File

@@ -598,6 +598,12 @@ public:
else
{
// Runtime objects already created. Should update in the owner thread.
if (m_dispatcherQueueController == nullptr)
{
Logger::warn("Tried accessing the dispatch queue controller before it was initialized.");
// No dispatcher Queue Controller? Means initialization still hasn't run, so settings will be applied then.
return;
}
auto dispatcherQueue = m_dispatcherQueueController.DispatcherQueue();
FindMyMouseSettings localSettings = settings;
bool enqueueSucceeded = dispatcherQueue.TryEnqueue([=]() {

View File

@@ -277,6 +277,12 @@ void InclusiveCrosshairs::ApplySettings(InclusiveCrosshairsSettings& settings, b
if (applyToRunTimeObjects)
{
// Runtime objects already created. Should update in the owner thread.
if (m_dispatcherQueueController == nullptr)
{
Logger::warn("Tried accessing the dispatch queue controller before it was initialized.");
// No dispatcher Queue Controller? Means initialization still hasn't run, so settings will be applied then.
return;
}
auto dispatcherQueue = m_dispatcherQueueController.DispatcherQueue();
InclusiveCrosshairsSettings localSettings = settings;
bool enqueueSucceeded = dispatcherQueue.TryEnqueue([=]() {

View File

@@ -92,10 +92,12 @@ namespace Microsoft.Plugin.WindowWalker.Components
{
// To hide (not add) preloaded uwp app windows that are invisible to the user we check the cloak state in DWM to be "none". (Issue #13637.)
// (If user asking to see these windows again we can add an optional plugin setting in the future.)
if (!newWindow.IsCloaked)
{
windows.Add(newWindow);
}
// [@htcfreek, 2022-02-01: Removed the IsCloaked check to list windows from virtual desktops other than the current one again (#15887). In a second PR I will fix it re-implement it with improved code again.]
// if (!newWindow.IsCloaked)
// {
windows.Add(newWindow);
// }
}
return true;

View File

@@ -1,232 +0,0 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.IO;
using System.IO.Abstractions;
using System.Reflection;
using System.Text.Json;
using System.Windows;
using ICSharpCode.SharpZipLib.Zip;
using Wox.Plugin;
using Wox.Plugin.Logger;
namespace PowerLauncher.Plugin
{
internal class PluginInstaller
{
private static readonly IFileSystem FileSystem = new FileSystem();
private static readonly IPath Path = FileSystem.Path;
private static readonly IFile File = FileSystem.File;
private static readonly IDirectory Directory = FileSystem.Directory;
internal static void Install(string path)
{
if (File.Exists(path))
{
string tempFolder = Path.Combine(Path.GetTempPath(), "wox\\plugins");
if (Directory.Exists(tempFolder))
{
Directory.Delete(tempFolder, true);
}
UnZip(path, tempFolder, true);
string iniPath = Path.Combine(tempFolder, "plugin.json");
if (!File.Exists(iniPath))
{
MessageBox.Show("Install failed: plugin config is missing");
return;
}
PluginMetadata plugin = GetMetadataFromJson(tempFolder);
if (plugin?.Name == null)
{
MessageBox.Show("Install failed: plugin config is invalid");
return;
}
string pluginFolderPath = Constant.PluginsDirectory;
// Using Ordinal since this is part of a path
string newPluginName = plugin.Name
.Replace("/", "_", StringComparison.Ordinal)
.Replace("\\", "_", StringComparison.Ordinal)
.Replace(":", "_", StringComparison.Ordinal)
.Replace("<", "_", StringComparison.Ordinal)
.Replace(">", "_", StringComparison.Ordinal)
.Replace("?", "_", StringComparison.Ordinal)
.Replace("*", "_", StringComparison.Ordinal)
.Replace("|", "_", StringComparison.Ordinal)
+ "-" + Guid.NewGuid();
string newPluginPath = Path.Combine(pluginFolderPath, newPluginName);
string content = $"Do you want to install following plugin?{Environment.NewLine}{Environment.NewLine}" +
$"Name: {plugin.Name}{Environment.NewLine}" +
$"Version: {plugin.Version}{Environment.NewLine}" +
$"Author: {plugin.Author}";
PluginPair existingPlugin = PluginManager.GetPluginForId(plugin.ID);
if (existingPlugin != null)
{
content = $"Do you want to update following plugin?{Environment.NewLine}{Environment.NewLine}" +
$"Name: {plugin.Name}{Environment.NewLine}" +
$"Old Version: {existingPlugin.Metadata.Version}" +
$"{Environment.NewLine}New Version: {plugin.Version}" +
$"{Environment.NewLine}Author: {plugin.Author}";
}
var result = MessageBox.Show(content, "Install plugin", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
if (existingPlugin != null && Directory.Exists(existingPlugin.Metadata.PluginDirectory))
{
// when plugin is in use, we can't delete them. That's why we need to make plugin folder a random name
File.Create(Path.Combine(existingPlugin.Metadata.PluginDirectory, "NeedDelete.txt")).Close();
}
UnZip(path, newPluginPath, true);
Directory.Delete(tempFolder, true);
// existing plugins could be loaded by the application,
// if we try to delete those kind of plugins, we will get a error that indicate the
// file is been used now.
// current solution is to restart wox. Ugly.
// if (MainWindow.Initialized)
// {
// Plugins.Initialize();
// }
if (MessageBox.Show($"You have installed plugin {plugin.Name} successfully.{Environment.NewLine} Restart Wox to take effect?", "Install plugin", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
{
PluginManager.API.RestartApp();
}
}
}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Suppressing this to enable FxCop. We are logging the exception, and going forward general exceptions should not be caught")]
private static PluginMetadata GetMetadataFromJson(string pluginDirectory)
{
string configPath = Path.Combine(pluginDirectory, "plugin.json");
PluginMetadata metadata;
if (!File.Exists(configPath))
{
return null;
}
try
{
metadata = JsonSerializer.Deserialize<PluginMetadata>(File.ReadAllText(configPath));
metadata.PluginDirectory = pluginDirectory;
}
catch (Exception e)
{
string error = $"Parse plugin config {configPath} failed: json format is not valid";
Log.Exception(error, e, MethodBase.GetCurrentMethod().DeclaringType);
#if DEBUG
{
throw new Exception(error);
}
#else
return null;
#endif
}
if (!AllowedLanguage.IsAllowed(metadata.Language))
{
string error = $"Parse plugin config {configPath} failed: invalid language {metadata.Language}";
#if DEBUG
{
throw new Exception(error);
}
#else
return null;
#endif
}
if (!File.Exists(metadata.ExecuteFilePath))
{
string error = $"Parse plugin config {configPath} failed: ExecuteFile {metadata.ExecuteFilePath} didn't exist";
#if DEBUG
{
throw new Exception(error);
}
#else
return null;
#endif
}
return metadata;
}
/// <summary>
/// unzip
/// </summary>
/// <param name="zippedFile">The zipped file.</param>
/// <param name="strDirectory">The STR directory.</param>
/// <param name="overWrite">overwrite</param>
private static void UnZip(string zippedFile, string strDirectory, bool overWrite)
{
if (string.IsNullOrEmpty(strDirectory))
{
strDirectory = Directory.GetCurrentDirectory();
}
// Using Ordinal since this is a path
if (!strDirectory.EndsWith("\\", StringComparison.Ordinal))
{
strDirectory += "\\";
}
using (ZipInputStream s = new ZipInputStream(File.OpenRead(zippedFile)))
{
ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null)
{
string directoryName = string.Empty;
string pathToZip = string.Empty;
pathToZip = theEntry.Name;
if (!string.IsNullOrEmpty(pathToZip))
{
directoryName = Path.GetDirectoryName(pathToZip) + "\\";
}
string fileName = Path.GetFileName(pathToZip);
Directory.CreateDirectory(strDirectory + directoryName);
if (!string.IsNullOrEmpty(fileName))
{
if ((File.Exists(strDirectory + directoryName + fileName) && overWrite) || (!File.Exists(strDirectory + directoryName + fileName)))
{
using (Stream streamWriter = File.Create(strDirectory + directoryName + fileName))
{
byte[] data = new byte[2048];
while (true)
{
int size = s.Read(data, 0, data.Length);
if (size > 0)
{
streamWriter.Write(data, 0, size);
}
else
{
break;
}
}
streamWriter.Close();
}
}
}
}
s.Close();
}
}
}
}

View File

@@ -165,11 +165,6 @@ namespace PowerLauncher.Plugin
}
}
public static void InstallPlugin(string path)
{
PluginInstaller.Install(path);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Suppressing this to enable FxCop. We are logging the exception, and going forward general exceptions should not be caught")]
public static List<Result> QueryForPlugin(PluginPair pair, Query query, bool delayedExecution = false)
{

View File

@@ -103,7 +103,6 @@
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.2" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.19" />
<PackageReference Include="ModernWpfUI" Version="0.9.4" />
<PackageReference Include="SharpZipLib" Version="1.2.0" />
<PackageReference Include="System.Runtime" Version="4.3.1" />
<PackageReference Include="Microsoft.VCRTForwarders.140" Version="1.0.6" />
<PackageReference Include="System.Data.OleDb" Version="4.7.1" />

View File

@@ -103,11 +103,6 @@ namespace Wox
});
}
public void InstallPlugin(string path)
{
Application.Current.Dispatcher.Invoke(() => PluginManager.InstallPlugin(path));
}
public List<PluginPair> GetAllPlugins()
{
return PluginManager.AllPlugins.ToList();

View File

@@ -64,12 +64,6 @@ namespace Wox.Plugin
/// <param name="iconPath">Message icon path (relative path to your plugin folder)</param>
void ShowMsg(string title, string subTitle = "", string iconPath = "", bool useMainWindowAsOwner = true);
/// <summary>
/// Install Wox plugin
/// </summary>
/// <param name="path">Plugin path (ends with .wox)</param>
void InstallPlugin(string path);
/// <summary>
/// Get all loaded plugins
/// </summary>

View File

@@ -149,7 +149,8 @@ void apply_general_settings(const json::JsonObject& general_configs, bool save)
{
continue;
}
const bool module_inst_enabled = modules().at(name)->is_enabled();
PowertoyModule& powertoy = modules().at(name);
const bool module_inst_enabled = powertoy->is_enabled();
const bool target_enabled = value.GetBoolean();
if (module_inst_enabled == target_enabled)
{
@@ -157,12 +158,14 @@ void apply_general_settings(const json::JsonObject& general_configs, bool save)
}
if (target_enabled)
{
modules().at(name)->enable();
powertoy->enable();
}
else
{
modules().at(name)->disable();
powertoy->disable();
}
// Sync the hotkey state with the module state, so it can be removed for disabled modules.
powertoy.UpdateHotkeyEx();
}
}
@@ -221,6 +224,7 @@ void start_enabled_powertoys()
if (!powertoys_to_disable.contains(name))
{
powertoy->enable();
powertoy.UpdateHotkeyEx();
}
}
}

View File

@@ -386,11 +386,21 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
apply_general_settings(general_settings, false);
int rvalue = 0;
const bool elevated = is_process_elevated();
if ((elevated ||
if (elevated && cmdLine.find("--dont-elevate") != std::string::npos &&
general_settings.GetNamedBoolean(L"run_elevated", false) == false) {
schedule_restart_as_non_elevated();
result = 0;
}
else if ((elevated ||
general_settings.GetNamedBoolean(L"run_elevated", false) == false ||
cmdLine.find("--dont-elevate") != std::string::npos))
{
result = runner(elevated, open_settings, settings_window, openOobe);
// Save settings on closing
auto general_settings = get_general_settings();
PTSettingsHelper::save_general_settings(general_settings.to_json());
}
else
{
@@ -405,10 +415,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
result = -1;
}
// Save settings on closing
auto general_settings = get_general_settings();
PTSettingsHelper::save_general_settings(general_settings.to_json());
// We need to release the mutexes to be able to restart the application
if (msi_mutex)
{

View File

@@ -74,11 +74,12 @@ void PowertoyModule::UpdateHotkeyEx()
{
CentralizedHotkeys::UnregisterHotkeysForModule(pt_module->get_key());
auto container = pt_module->GetHotkeyEx();
if (container.has_value())
if (container.has_value() && pt_module->is_enabled())
{
auto hotkey = container.value();
auto modulePtr = pt_module.get();
auto action = [modulePtr](WORD modifiersMask, WORD vkCode) {
Logger::trace(L"{} hotkey Ex is invoked from Centralized keyboard hook", modulePtr->get_key());
modulePtr->OnHotkeyEx();
};

View File

@@ -106,7 +106,7 @@
<controls:Setting x:Uid="AlwaysOnTop_ExcludedApps" Icon="&#xECE4;" Style="{StaticResource ExpanderHeaderSettingStyle}"/>
</controls:SettingExpander.Header>
<controls:SettingExpander.Content>
<TextBox x:Uid="FancyZones_ExcludedApps_TextBoxControl"
<TextBox x:Uid="AlwaysOnTop_ExcludedApps_TextBoxControl"
Margin="{StaticResource ExpanderSettingMargin}"
Text="{x:Bind Mode=TwoWay, Path=ViewModel.ExcludedApps, UpdateSourceTrigger=PropertyChanged}"
ScrollViewer.VerticalScrollBarVisibility ="Visible"

View File

@@ -19,13 +19,7 @@
<controls:SettingsPageControl.ModuleContent>
<StackPanel Orientation="Vertical">
<muxc:InfoBar
Severity="Warning"
x:Uid="VideoConference_RunAsAdminRequired"
IsOpen="True"
IsTabStop="True"
IsClosable="False"
Visibility="{Binding Mode=OneWay, Path=IsElevated, Converter={StaticResource BoolToVisibilityConverter}}" />
<controls:Setting x:Uid="VideoConference_Enable" IsEnabled="{ Binding Mode=OneWay, Path=IsElevated }">
<controls:Setting.Icon>
<BitmapIcon UriSource="ms-appx:///Assets/FluentIcons/FluentIconsVideoConferenceMute.png" ShowAsMonochrome="False" />
@@ -34,7 +28,14 @@
<ToggleSwitch IsOn="{Binding Mode=TwoWay, Path=IsEnabled}" x:Uid="ToggleSwitch"/>
</controls:Setting.ActionContent>
</controls:Setting>
<muxc:InfoBar
Severity="Warning"
x:Uid="VideoConference_RunAsAdminRequired"
IsOpen="True"
IsTabStop="True"
IsClosable="False"
Visibility="{Binding Mode=OneWay, Path=IsElevated, Converter={StaticResource BoolToVisibilityConverter}}" />
<controls:SettingsGroup x:Uid="VideoConference_Shortcuts" IsEnabled="{Binding Mode=OneWay, Path=IsEnabled}">
<controls:Setting x:Uid="VideoConference_CameraAndMicrophoneMuteHotkeyControl_Header">
<controls:Setting.ActionContent>