mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
don't flicker the windows so much bub
This commit is contained in:
@@ -46,16 +46,6 @@ public sealed partial class DockViewModel : IDisposable,
|
||||
SetupBands();
|
||||
}
|
||||
|
||||
// private static string[] _startCommands = [
|
||||
// "com.microsoft.cmdpal.windowwalker.dockband",
|
||||
// ];
|
||||
|
||||
// private static string[] _endCommands = [
|
||||
// "com.crloewen.performanceMonitor.dockband",
|
||||
// "com.microsoft.cmdpal.clipboardHistory.Band",
|
||||
// "com.zadjii.virtualDesktops.band",
|
||||
// "com.microsoft.cmdpal.timedate.dockband",
|
||||
// ];
|
||||
private void SetupBands()
|
||||
{
|
||||
Logger.LogDebug($"Setting up dock bands");
|
||||
|
||||
@@ -51,7 +51,7 @@ internal sealed class Window
|
||||
var sizeOfTitle = NativeMethods.GetWindowTextLength(hwnd);
|
||||
if (sizeOfTitle++ > 0)
|
||||
{
|
||||
StringBuilder titleBuffer = new StringBuilder(sizeOfTitle);
|
||||
var titleBuffer = new StringBuilder(sizeOfTitle);
|
||||
var numCharactersWritten = NativeMethods.GetWindowText(hwnd, titleBuffer, sizeOfTitle);
|
||||
if (numCharactersWritten == 0)
|
||||
{
|
||||
@@ -260,7 +260,7 @@ internal sealed class Window
|
||||
/// <returns>The state (minimized, maximized, etc..) of the window</returns>
|
||||
internal WindowSizeState GetWindowSizeState()
|
||||
{
|
||||
NativeMethods.GetWindowPlacement(Hwnd, out WINDOWPLACEMENT placement);
|
||||
NativeMethods.GetWindowPlacement(Hwnd, out var placement);
|
||||
|
||||
switch (placement.ShowCmd)
|
||||
{
|
||||
@@ -332,7 +332,7 @@ internal sealed class Window
|
||||
/// <returns>Class name</returns>
|
||||
private static string GetWindowClassName(IntPtr hwnd)
|
||||
{
|
||||
StringBuilder windowClassName = new StringBuilder(300);
|
||||
var windowClassName = new StringBuilder(300);
|
||||
var numCharactersWritten = NativeMethods.GetClassName(hwnd, windowClassName, windowClassName.MaxCapacity);
|
||||
|
||||
if (numCharactersWritten == 0)
|
||||
@@ -384,7 +384,7 @@ internal sealed class Window
|
||||
{
|
||||
new Task(() =>
|
||||
{
|
||||
EnumWindowsProc callbackptr = new EnumWindowsProc((IntPtr hwnd, IntPtr lParam) =>
|
||||
var callbackptr = new EnumWindowsProc((IntPtr hwnd, IntPtr lParam) =>
|
||||
{
|
||||
// Every uwp app main window has at least three child windows. Only the one we are interested in has a class starting with "Windows.UI.Core." and is assigned to the real app process.
|
||||
// (The other ones have a class name that begins with the string "ApplicationFrame".)
|
||||
@@ -410,4 +410,21 @@ internal sealed class Window
|
||||
return _handlesToProcessCache[hWindow];
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is Window other)
|
||||
{
|
||||
return this.hwnd == other.hwnd &&
|
||||
this.Title == other.Title &&
|
||||
this.Visible == other.Visible;
|
||||
}
|
||||
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,12 @@ public class SettingsManager : JsonSettingsManager, ISettingsInterface
|
||||
Resources.windowwalker_SettingUseWindowIcon_Description,
|
||||
true);
|
||||
|
||||
private readonly ToggleSetting _showTitlesOnDock = new(
|
||||
Namespaced(nameof(ShowTitlesOnDock)),
|
||||
Resources.windowwalker_SettingShowTitlesOnDock,
|
||||
Resources.windowwalker_SettingShowTitlesOnDock_Description,
|
||||
true);
|
||||
|
||||
public bool ResultsFromVisibleDesktopOnly { get => _resultsFromVisibleDesktopOnly.Value; set => _resultsFromVisibleDesktopOnly.Value = value; }
|
||||
|
||||
public bool SubtitleShowPid => _subtitleShowPid.Value;
|
||||
@@ -98,6 +104,8 @@ public class SettingsManager : JsonSettingsManager, ISettingsInterface
|
||||
|
||||
public bool ShowSubtitles { get; set; } = true;
|
||||
|
||||
public bool ShowTitlesOnDock { get => _showTitlesOnDock.Value; set => _showTitlesOnDock.Value = value; }
|
||||
|
||||
internal static string SettingsJsonPath()
|
||||
{
|
||||
var directory = Utilities.BaseSettingsPath("Microsoft.CmdPal");
|
||||
@@ -121,6 +129,7 @@ public class SettingsManager : JsonSettingsManager, ISettingsInterface
|
||||
Settings.Add(_hideExplorerSettingInfo);
|
||||
Settings.Add(_inMruOrder);
|
||||
Settings.Add(_useWindowIcon);
|
||||
Settings.Add(_showTitlesOnDock);
|
||||
|
||||
// Load settings from file upon initialization
|
||||
LoadSettings();
|
||||
|
||||
@@ -9,14 +9,17 @@ using Microsoft.CmdPal.Ext.WindowWalker.Helpers;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Properties;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
using Microsoft.UI.Dispatching;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.WindowWalker.Pages;
|
||||
|
||||
internal sealed partial class WindowWalkerListPage : DynamicListPage, IDisposable
|
||||
{
|
||||
private readonly List<WindowWalkerListItem> _results = new();
|
||||
private readonly SettingsManager _settingsManager;
|
||||
private readonly SearchController _searchController;
|
||||
private System.Threading.CancellationTokenSource _cancellationTokenSource = new();
|
||||
private DispatcherQueue _updateWindowsQueue = DispatcherQueueController.CreateOnDedicatedThread().DispatcherQueue;
|
||||
|
||||
private bool _disposed;
|
||||
|
||||
@@ -36,12 +39,20 @@ internal sealed partial class WindowWalkerListPage : DynamicListPage, IDisposabl
|
||||
Title = Resources.window_walker_top_level_command_title,
|
||||
Subtitle = Resources.windowwalker_NoResultsMessage,
|
||||
};
|
||||
|
||||
Query(string.Empty);
|
||||
}
|
||||
|
||||
public override void UpdateSearchText(string oldSearch, string newSearch) =>
|
||||
RaiseItemsChanged(0);
|
||||
public override void UpdateSearchText(string oldSearch, string newSearch)
|
||||
{
|
||||
_updateWindowsQueue.TryEnqueue(() =>
|
||||
{
|
||||
Query(newSearch);
|
||||
});
|
||||
}
|
||||
|
||||
public List<WindowWalkerListItem> Query(string query)
|
||||
// public List<WindowWalkerListItem> Query(string query)
|
||||
public void Query(string query)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(query);
|
||||
|
||||
@@ -54,10 +65,24 @@ internal sealed partial class WindowWalkerListPage : DynamicListPage, IDisposabl
|
||||
_searchController.UpdateSearchText(query);
|
||||
var searchControllerResults = _searchController.SearchMatches;
|
||||
|
||||
return ResultHelper.GetResultList(searchControllerResults, !string.IsNullOrEmpty(query), _settingsManager);
|
||||
var newListItems = ResultHelper.GetResultList(searchControllerResults, !string.IsNullOrEmpty(query), _settingsManager);
|
||||
var oldCount = _results.Count;
|
||||
var newCount = newListItems.Count;
|
||||
ListHelpers.InPlaceUpdateList(_results, newListItems, out var removedItems);
|
||||
if (newCount == oldCount && removedItems.Count == 0)
|
||||
{
|
||||
// do nothing - windows didn't change
|
||||
}
|
||||
else
|
||||
{
|
||||
RaiseItemsChanged(_results.Count);
|
||||
}
|
||||
}
|
||||
|
||||
public override IListItem[] GetItems() => Query(SearchText).ToArray();
|
||||
public override IListItem[] GetItems()
|
||||
{
|
||||
return _results.ToArray();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
@@ -79,6 +104,7 @@ internal sealed partial class WindowWalkerListPage : DynamicListPage, IDisposabl
|
||||
|
||||
internal void RaiseItemsChanged()
|
||||
{
|
||||
base.RaiseItemsChanged();
|
||||
// base.RaiseItemsChanged();
|
||||
Query(SearchText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Microsoft.CmdPal.Ext.WindowWalker.Properties {
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class Resources {
|
||||
@@ -375,6 +375,24 @@ namespace Microsoft.CmdPal.Ext.WindowWalker.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Dock: Show window titles.
|
||||
/// </summary>
|
||||
public static string windowwalker_SettingShowTitlesOnDock {
|
||||
get {
|
||||
return ResourceManager.GetString("windowwalker_SettingShowTitlesOnDock", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Show the window titles on windows in the dock.
|
||||
/// </summary>
|
||||
public static string windowwalker_SettingShowTitlesOnDock_Description {
|
||||
get {
|
||||
return ResourceManager.GetString("windowwalker_SettingShowTitlesOnDock_Description", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to This information is only shown in subtitle and tool tip, if you have at least two desktops..
|
||||
/// </summary>
|
||||
|
||||
@@ -241,4 +241,10 @@
|
||||
<data name="windowwalker_SettingUseWindowIcon_Description" xml:space="preserve">
|
||||
<value>Show the actual window icon instead of the process icon</value>
|
||||
</data>
|
||||
<data name="windowwalker_SettingShowTitlesOnDock" xml:space="preserve">
|
||||
<value>Dock: Show window titles</value>
|
||||
</data>
|
||||
<data name="windowwalker_SettingShowTitlesOnDock_Description" xml:space="preserve">
|
||||
<value>Show the window titles on windows in the dock</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -41,24 +41,6 @@ public partial class WindowWalkerCommandsProvider : CommandProvider, IExtendedAt
|
||||
],
|
||||
};
|
||||
_bandItem = new WindowsDockBand();
|
||||
|
||||
// var testSettings = new SettingsManager();
|
||||
// testSettings.HideExplorerSettingInfo = true;
|
||||
// testSettings.InMruOrder = false;
|
||||
// testSettings.ResultsFromVisibleDesktopOnly = true;
|
||||
// testSettings.UseWindowIcon = true;
|
||||
// testSettings.ShowSubtitles = false;
|
||||
// var testPage = new WindowWalkerListPage(testSettings);
|
||||
// testPage.Id = "com.microsoft.cmdpal.windowwalker.dockband";
|
||||
|
||||
// _bandItem = new CommandItem(testPage)
|
||||
// {
|
||||
// Title = Resources.window_walker_top_level_command_title,
|
||||
// Subtitle = Resources.windowwalker_name,
|
||||
// MoreCommands = [
|
||||
// new CommandContextItem(Settings.SettingsPage),
|
||||
// ],
|
||||
// };
|
||||
}
|
||||
|
||||
public override ICommandItem[] TopLevelCommands() => [_windowWalkerPageItem];
|
||||
@@ -91,6 +73,7 @@ internal sealed partial class WindowsDockBand : CommandItem
|
||||
testSettings.ResultsFromVisibleDesktopOnly = true;
|
||||
testSettings.UseWindowIcon = true;
|
||||
testSettings.ShowSubtitles = false;
|
||||
testSettings.ShowTitlesOnDock = SettingsManager.Instance.ShowTitlesOnDock;
|
||||
var testPage = new WindowWalkerListPage(testSettings);
|
||||
testPage.Id = "com.microsoft.cmdpal.windowwalker.dockband";
|
||||
_page = testPage;
|
||||
|
||||
@@ -2,11 +2,6 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Commands;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Components;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
@@ -24,4 +19,24 @@ internal sealed partial class WindowWalkerListItem : ListItem
|
||||
{
|
||||
_window = window;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is WindowWalkerListItem other)
|
||||
{
|
||||
if (this._window is null)
|
||||
{
|
||||
return other._window is null;
|
||||
}
|
||||
|
||||
return this._window.Equals(other._window);
|
||||
}
|
||||
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user