Skip to content

Commit

Permalink
[FancyZones]Don't automatically snap context menus (#28956)
Browse files Browse the repository at this point in the history
* check tabstop

* revert

* check popup thickframe

* Revert "check popup thickframe"

* added HasThickFrame

* popup check

* spellcheck
  • Loading branch information
SeraphimaZykova committed Oct 2, 2023
1 parent 59fb08c commit 11f30f9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/modules/fancyzones/FancyZonesLib/FancyZones.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <FancyZonesLib/VirtualDesktop.h>
#include <FancyZonesLib/WindowKeyboardSnap.h>
#include <FancyZonesLib/WindowMouseSnap.h>
#include <FancyZonesLib/WindowUtils.h>
#include <FancyZonesLib/WorkArea.h>
#include <FancyZonesLib/WorkAreaConfiguration.h>

Expand Down Expand Up @@ -394,6 +395,15 @@ void FancyZones::WindowCreated(HWND window) noexcept
return;
}

// Hotfix
// Avoid automatically moving popup windows, as they can be just popup menus.
bool isPopup = FancyZonesWindowUtils::IsPopupWindow(window);
bool hasThickFrame = FancyZonesWindowUtils::HasThickFrame(window);
if (isPopup && !hasThickFrame)
{
return;
}

// Avoid already stamped (zoned) windows
const bool isZoned = !FancyZonesWindowProperties::RetrieveZoneIndexProperty(window).empty();
if (isZoned)
Expand Down
6 changes: 6 additions & 0 deletions src/modules/fancyzones/FancyZonesLib/WindowUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ bool FancyZonesWindowUtils::IsPopupWindow(HWND window) noexcept
return ((style & WS_POPUP) == WS_POPUP);
}

bool FancyZonesWindowUtils::HasThickFrame(HWND window) noexcept
{
auto style = GetWindowLong(window, GWL_STYLE);
return ((style & WS_THICKFRAME) == WS_THICKFRAME);
}

bool FancyZonesWindowUtils::HasThickFrameAndMinimizeMaximizeButtons(HWND window) noexcept
{
auto style = GetWindowLong(window, GWL_STYLE);
Expand Down
1 change: 1 addition & 0 deletions src/modules/fancyzones/FancyZonesLib/WindowUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace FancyZonesWindowUtils
bool HasVisibleOwner(HWND window) noexcept;
bool IsStandardWindow(HWND window);
bool IsPopupWindow(HWND window) noexcept;
bool HasThickFrame(HWND window) noexcept;
bool HasThickFrameAndMinimizeMaximizeButtons(HWND window) noexcept;
bool IsProcessOfWindowElevated(HWND window); // If HWND is already dead, we assume it wasn't elevated

Expand Down

0 comments on commit 11f30f9

Please sign in to comment.