Skip to content

Close the window "more options" menu when the cursor leaves - #493

Open
SQReder wants to merge 1 commit into
FancyWM:mainfrom
SQReder:feat/close-more-menu
Open

SQReder wants to merge 1 commit into
FancyWM:mainfrom
SQReder:feat/close-more-menu

Conversation

@SQReder

@SQReder SQReder commented Sep 21, 2026 •

Copy link
Copy Markdown

Context

The "more options" menu of the window actions bar (add floating rule for process / window class) is very hard to dismiss without picking an item, and can stay on screen after its window is gone.

The overlay window is created with WS_EX_NOACTIVATE, so the ContextMenu never gets a deactivation to close itself on. The existing workaround closes it from a MouseLeave handler that is only attached after the cursor has entered the menu, so a menu the cursor never entered stays open indefinitely. Nothing closed it when the control was removed either.

Changes

  • While the menu is open, poll the real cursor location (150 ms) and close the menu once the cursor has been outside both the menu and its button for two consecutive ticks. IsMouseOver cannot be used here: the open menu captures the mouse, and WPF then reports the capturing element as the one under the cursor.
  • Close the menu when the TilingWindow control is unloaded.
  • Keep the actions bar visible while the menu is open (TilingWindowViewModel.IsMenuOpen), and re-evaluate its visibility from the current cursor location when the menu closes, since the cursor may be resting far away by then.
  • Remove the visual-tree based MouseEnter/MouseLeave workaround.

Verification

  • dotnet build FancyWM.GUI (Debug) — 0 errors.
  • Manual: open the menu, move the cursor away and keep it still — the menu closes after ~300 ms and the bar hides with it; hover a menu item outside the bar's reveal area — the bar stays visible; items remain clickable.
  • Closing the owning window while the menu is open was not exercised manually.
  • Unit tests were not run locally.

Risks

  • A slow cursor path from the button to the menu across the gap between them could close the menu if it takes longer than ~300 ms; this did not happen in manual use.
  • Touches the same method as the "position window actions over the actual window" PR; whichever lands second will need a trivial rebase.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@SQReder

SQReder commented Sep 21, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

The overlay window never activates, so the context menu gets no
deactivation to dismiss itself on. It was closed from a MouseLeave
handler that was only attached after the cursor had entered the menu,
so a menu the cursor never entered stayed open indefinitely, even
after its window was gone.

Poll the real cursor location while the menu is open and close it once
the cursor has left both the menu and its button. IsMouseOver cannot be
used because the open menu captures the mouse. Also close the menu when
the control is unloaded, and keep the actions bar visible for as long
as the menu is open.
@SQReder
SQReder force-pushed the feat/close-more-menu branch from 7824f7f to fe15212 Compare September 21, 2026 15:32
github-actions Bot added a commit that referenced this pull request Sep 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant