Fix menu positioning on monitors with negative coordinates - #834
Open
MissinLinkk05551 wants to merge 1 commit into
Open
Fix menu positioning on monitors with negative coordinates#834MissinLinkk05551 wants to merge 1 commit into
MissinLinkk05551 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes context-menu and tooltip positioning on monitors that use negative virtual-screen coordinates, such as a secondary monitor positioned above or to the left of the primary monitor.
Problem
Some positioning calculations treated monitor coordinates as though every monitor started at
(0, 0).For example, a scrolling menu was vertically centered with:
wp->y = (ctx->_rcMonitor.height() - wnd->height) / 2;That works only when the monitor begins at
Y=0.On a monitor positioned above the primary display, such as:
the calculation produces a positive Y coordinate, which can place the menu on the primary monitor instead of the monitor where it was invoked.
Tooltip boundary checks also treated any negative X or Y value as invalid, even though negative coordinates are valid within the Windows virtual desktop.
Changes
_rcMonitor.topwhen vertically centering scrolling menus._rcMonitor.bottominstead of monitor height._rcMonitor.leftinstead of global zero._rcMonitor.topinstead of global zero.Testing
Tested on Windows 11 Pro 25H2 build 26200.8875 with two monitors at 100% scaling:
Before this change, with the secondary monitor stacked above the primary monitor, the context menu opened on the primary monitor.
After this change, the context menu opens on the correct monitor where it was invoked.
The project was built successfully using:
with zero build errors.
Related issues
Related to #774 and #692.