Fixed dialog placement on a multiple-display setup.#614
Conversation
|
Thank you @Micheus ! I hope this will help users with some non-traditional monitor setups to avoid some extra dialog reposition work. |
There was a problem hiding this comment.
Pull Request Overview
This PR improves dialog placement on multi-display setups by detecting the display under the mouse pointer to compute better positions and adjusts centering behavior when multiple monitors are present.
- Added display-aware logic to
set_position(mouse, Dialog)for correct positioning with display geometry and scaling. - Updated
set_position(center, Dialog)to usecenterOnParentwhen more than one display is connected.
|
I'm just testing copilot |
|
I have let co-pilot review this, fix stuff that seems valid and write when your are done, or nothing needs fixing. |
A Discord user, Aleks M, reported an issue with his setup, which included two displays (one horizontal and one vertical). When the dialog was invoked with the mouse near the left border of the vertical display, the dialog was cut off. To address this, I updated the code to evaluate which display the mouse was on, and used its geometry to compute the optimal position for showing the dialog. This solution worked well; however, in cases where the display uses scaling (via the OS), the dialog's position can still vary slightly, sometimes ending up farther from the mouse pointer than expected. I also addressed an issue with the option to display centered dialogs. On multiple displays, the dialog could sometimes be positioned across the frame of the displays, resulting in only half of it being visible on each display, which was quite annoying.
d5b3d4e to
c8bba19
Compare
|
The clamping math just needs cleanup — the bounds A cleaner implementation would be: Xd = clamp(Xm - 100, X, XMax - Wd), where clamp(V, Min, Max) -> max(Min, min(Max, V)). This eliminates all the conditional branches entirely. |
A Discord user, Aleks M, reported an issue with his setup, which included two displays (one horizontal and one vertical). When the dialog was invoked with the mouse near the left border of the vertical display, the dialog was cut off.
To address this, I updated the code to evaluate which display the mouse was on, and used its geometry to compute the optimal position for showing the dialog. This solution worked well; however, in cases where the display uses scaling (via the OS), the dialog's position can still vary slightly, sometimes ending up farther from the mouse pointer than expected.
I also addressed an issue with the option to display centred dialogs. On multiple displays, the dialog could sometimes be positioned across the frame of the displays, resulting in only half of it being visible on each display, which was quite annoying.
NOTE: Fixed dialog placement on a multiple-display setup. Thanks to Aleks M.
Issue reported

Results for dialog placement (Issue when exists a scaled display and better locations)



Result for the centred window (before and after)
