Skip to content

Commit

Permalink
[PT Run/FancyZones] Exclude Launcher from zonable windows improvement (
Browse files Browse the repository at this point in the history
…#9071)

* excluding launcher from fancy zones setting GWL_STYLE WS_POPUP 


fix WS_POPUP type

* Migrate spelling-0.0.19 changes from main

* rebase fix

* fix spellcheck

Co-authored-by: Dustin L. Howett <duhowett@microsoft.com>
  • Loading branch information
davidegiacometti and DHowett committed Dec 21, 2021
1 parent dc08987 commit 57cdae7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/modules/fancyzones/FancyZonesLib/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
// Non-Localizable strings
namespace NonLocalizable
{
const wchar_t PowerToysAppPowerLauncher[] = L"POWERTOYS.POWERLAUNCHER.EXE";
const wchar_t PowerToysAppFZEditor[] = L"POWERTOYS.FANCYZONESEDITOR.EXE";
const wchar_t SplashClassName[] = L"MsoSplash";
}
Expand Down Expand Up @@ -45,10 +44,6 @@ namespace
{
return false;
}
if (find_app_name_in_path(processPath, { NonLocalizable::PowerToysAppPowerLauncher }))
{
return false;
}
if (find_app_name_in_path(processPath, { NonLocalizable::PowerToysAppFZEditor }))
{
return false;
Expand Down
11 changes: 11 additions & 0 deletions src/modules/launcher/PowerLauncher/Helper/WindowsInteropHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public static class WindowsInteropHelper
private const int GWL_STYLE = -16; // WPF's Message code for Title Bar's Style
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1310:Field names should not contain underscore", Justification = "Matching COM")]
private const int WS_SYSMENU = 0x80000; // WPF's Message code for System Menu
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1310:Field names should not contain underscore", Justification = "Matching COM")]
private const int WS_POPUP = 1 << 31; // 0x80000000
private static IntPtr _hwnd_shell;
private static IntPtr _hwnd_desktop;

Expand Down Expand Up @@ -169,6 +171,15 @@ public static void DisableControlBox(Window win)
_ = NativeMethods.SetWindowLong(hwnd, GWL_STYLE, NativeMethods.GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
}

/// <summary>
/// Set WS_POPUP to make FancyZones ignoring the Window
/// </summary>
public static void SetPopupStyle(Window win)
{
var hwnd = new WindowInteropHelper(win).Handle;
_ = NativeMethods.SetWindowLong(hwnd, GWL_STYLE, NativeMethods.GetWindowLong(hwnd, GWL_STYLE) | WS_POPUP);
}

/// <summary>
/// Transforms pixels to Device Independent Pixels used by WPF
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions src/modules/launcher/PowerLauncher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ private void SendSettingsTelemetry()
PowerToysTelemetry.Log.WriteEvent(telemetryEvent);
}

protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
WindowsInteropHelper.SetPopupStyle(this);
}

private void CheckForFirstDelete(object sender, ElapsedEventArgs e)
{
if (_firstDeleteTimer != null)
Expand Down

0 comments on commit 57cdae7

Please sign in to comment.