mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-10 21:41:51 +02:00
[FancyZones] Popup behavior fix (#18270)
* virtual desktop check * refactoring * unified check
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
#include <FancyZonesLib/FancyZonesData/CustomLayouts.h>
|
#include <FancyZonesLib/FancyZonesData/CustomLayouts.h>
|
||||||
#include <FancyZonesLib/FancyZonesData/LayoutHotkeys.h>
|
#include <FancyZonesLib/FancyZonesData/LayoutHotkeys.h>
|
||||||
#include <FancyZonesLib/FancyZonesData/LayoutTemplates.h>
|
#include <FancyZonesLib/FancyZonesData/LayoutTemplates.h>
|
||||||
|
#include <FancyZonesLib/FancyZonesWindowProcessing.h>
|
||||||
#include <FancyZonesLib/FancyZonesWindowProperties.h>
|
#include <FancyZonesLib/FancyZonesWindowProperties.h>
|
||||||
#include <FancyZonesLib/FancyZonesWinHookEventIDs.h>
|
#include <FancyZonesLib/FancyZonesWinHookEventIDs.h>
|
||||||
#include <FancyZonesLib/MonitorUtils.h>
|
#include <FancyZonesLib/MonitorUtils.h>
|
||||||
@@ -376,28 +377,12 @@ void FancyZones::WindowCreated(HWND window) noexcept
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto desktopId = VirtualDesktop::instance().GetDesktopId(window);
|
if (!FancyZonesWindowProcessing::IsProcessable(window))
|
||||||
if (desktopId.has_value() && *desktopId != VirtualDesktop::instance().GetCurrentVirtualDesktopId())
|
|
||||||
{
|
|
||||||
// Switch between virtual desktops results with posting same windows messages that also indicate
|
|
||||||
// creation of new window. We need to check if window being processed is on currently active desktop.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Avoid processing splash screens, already stamped (zoned) windows, or those windows
|
|
||||||
// that belong to excluded applications list.
|
|
||||||
const bool isSplashScreen = FancyZonesWindowUtils::IsSplashScreen(window);
|
|
||||||
if (isSplashScreen)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool windowMinimized = IsIconic(window);
|
|
||||||
if (windowMinimized)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Avoid already stamped (zoned) windows
|
||||||
const bool isZoned = !FancyZonesWindowProperties::RetrieveZoneIndexProperty(window).empty();
|
const bool isZoned = !FancyZonesWindowProperties::RetrieveZoneIndexProperty(window).empty();
|
||||||
if (isZoned)
|
if (isZoned)
|
||||||
{
|
{
|
||||||
@@ -1245,6 +1230,12 @@ void FancyZones::UpdateZoneSets() noexcept
|
|||||||
bool FancyZones::ShouldProcessSnapHotkey(DWORD vkCode) noexcept
|
bool FancyZones::ShouldProcessSnapHotkey(DWORD vkCode) noexcept
|
||||||
{
|
{
|
||||||
auto window = GetForegroundWindow();
|
auto window = GetForegroundWindow();
|
||||||
|
|
||||||
|
if (!FancyZonesWindowProcessing::IsProcessable(window))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (FancyZonesSettings::settings().overrideSnapHotkeys && FancyZonesWindowUtils::IsCandidateForZoning(window))
|
if (FancyZonesSettings::settings().overrideSnapHotkeys && FancyZonesWindowUtils::IsCandidateForZoning(window))
|
||||||
{
|
{
|
||||||
HMONITOR monitor = WorkAreaKeyFromWindow(window);
|
HMONITOR monitor = WorkAreaKeyFromWindow(window);
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
<ClInclude Include="FancyZonesData\Layout.h" />
|
<ClInclude Include="FancyZonesData\Layout.h" />
|
||||||
<ClInclude Include="FancyZonesData\LayoutDefaults.h" />
|
<ClInclude Include="FancyZonesData\LayoutDefaults.h" />
|
||||||
<ClInclude Include="FancyZonesData\LayoutTemplates.h" />
|
<ClInclude Include="FancyZonesData\LayoutTemplates.h" />
|
||||||
|
<ClInclude Include="FancyZonesWindowProcessing.h" />
|
||||||
<ClInclude Include="FancyZonesWinHookEventIDs.h" />
|
<ClInclude Include="FancyZonesWinHookEventIDs.h" />
|
||||||
<ClInclude Include="GenericKeyHook.h" />
|
<ClInclude Include="GenericKeyHook.h" />
|
||||||
<ClInclude Include="FancyZonesData.h" />
|
<ClInclude Include="FancyZonesData.h" />
|
||||||
|
|||||||
@@ -129,6 +129,9 @@
|
|||||||
<ClInclude Include="LayoutConfigurator.h">
|
<ClInclude Include="LayoutConfigurator.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="FancyZonesWindowProcessing.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="pch.cpp">
|
<ClCompile Include="pch.cpp">
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <FancyZonesLib/VirtualDesktop.h>
|
||||||
|
#include <FancyZonesLib/WindowUtils.h>
|
||||||
|
|
||||||
|
namespace FancyZonesWindowProcessing
|
||||||
|
{
|
||||||
|
inline bool IsProcessable(HWND window) noexcept
|
||||||
|
{
|
||||||
|
const bool isSplashScreen = FancyZonesWindowUtils::IsSplashScreen(window);
|
||||||
|
if (isSplashScreen)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool windowMinimized = IsIconic(window);
|
||||||
|
if (windowMinimized)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Switch between virtual desktops results with posting same windows messages that also indicate
|
||||||
|
// creation of new window. We need to check if window being processed is on currently active desktop.
|
||||||
|
// For windows that FancyZones shouldn't process (start menu, tray, popup menus)
|
||||||
|
// VirtualDesktopManager is unable to retrieve virtual desktop id and returns an error.
|
||||||
|
auto desktopId = VirtualDesktop::instance().GetDesktopId(window);
|
||||||
|
if (!desktopId.has_value() || (desktopId.has_value() && *desktopId != VirtualDesktop::instance().GetCurrentVirtualDesktopId()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -201,7 +201,7 @@ std::optional<GUID> VirtualDesktop::GetDesktopId(HWND window) const
|
|||||||
if (m_vdManager && m_vdManager->IsWindowOnCurrentVirtualDesktop(window, &isWindowOnCurrentDesktop) == S_OK && isWindowOnCurrentDesktop)
|
if (m_vdManager && m_vdManager->IsWindowOnCurrentVirtualDesktop(window, &isWindowOnCurrentDesktop) == S_OK && isWindowOnCurrentDesktop)
|
||||||
{
|
{
|
||||||
// Filter windows such as Windows Start Menu, Task Switcher, etc.
|
// Filter windows such as Windows Start Menu, Task Switcher, etc.
|
||||||
if (m_vdManager->GetWindowDesktopId(window, &id) == S_OK && id != GUID_NULL)
|
if (m_vdManager->GetWindowDesktopId(window, &id) == S_OK)
|
||||||
{
|
{
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "FancyZonesData/AppZoneHistory.h"
|
#include "FancyZonesData/AppZoneHistory.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "WorkArea.h"
|
#include "WorkArea.h"
|
||||||
|
#include <FancyZonesLib/FancyZonesWindowProcessing.h>
|
||||||
#include <FancyZonesLib/WindowUtils.h>
|
#include <FancyZonesLib/WindowUtils.h>
|
||||||
|
|
||||||
// Non-Localizable strings
|
// Non-Localizable strings
|
||||||
@@ -60,6 +61,11 @@ WindowMoveHandler::WindowMoveHandler(const std::function<void()>& keyUpdateCallb
|
|||||||
|
|
||||||
void WindowMoveHandler::MoveSizeStart(HWND window, HMONITOR monitor, POINT const& ptScreen, const std::unordered_map<HMONITOR, winrt::com_ptr<IWorkArea>>& workAreaMap) noexcept
|
void WindowMoveHandler::MoveSizeStart(HWND window, HMONITOR monitor, POINT const& ptScreen, const std::unordered_map<HMONITOR, winrt::com_ptr<IWorkArea>>& workAreaMap) noexcept
|
||||||
{
|
{
|
||||||
|
if (!FancyZonesWindowProcessing::IsProcessable(window))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!FancyZonesWindowUtils::IsCandidateForZoning(window) || WindowMoveHandlerUtils::IsCursorTypeIndicatingSizeEvent())
|
if (!FancyZonesWindowUtils::IsCandidateForZoning(window) || WindowMoveHandlerUtils::IsCursorTypeIndicatingSizeEvent())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user