Skip to content

Fix menu positioning on monitors with negative coordinates - #834

Open
MissinLinkk05551 wants to merge 1 commit into
moudey:mainfrom
MissinLinkk05551:fix-stacked-monitor-coordinates
Open

Fix menu positioning on monitors with negative coordinates#834
MissinLinkk05551 wants to merge 1 commit into
moudey:mainfrom
MissinLinkk05551:fix-stacked-monitor-coordinates

Conversation

@MissinLinkk05551

Copy link
Copy Markdown

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:

top    = -900
bottom = 0

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

  • Include _rcMonitor.top when vertically centering scrolling menus.
  • Compare the menu bottom against _rcMonitor.bottom instead of monitor height.
  • Clamp tooltip X against _rcMonitor.left instead of global zero.
  • Clamp tooltip Y against _rcMonitor.top instead of global zero.

Testing

Tested on Windows 11 Pro 25H2 build 26200.8875 with two monitors at 100% scaling:

Primary:   X=0, Y=0,    1366x768
Secondary: X=0, Y=-900, 1440x900

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:

Release|x64

with zero build errors.

Related issues

Related to #774 and #692.

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