Feature/window placement engine#14372
Feature/window placement engine#14372marangonico wants to merge 6 commits intovassalengine:masterfrom
Conversation
… prevent snap-back to primary display
…e's window size handling
|
PMD violations should be fixed now |
|
When opening Help->Vassal Quick Start it opens as a tiny window. Just the header with the close button visible and virtually no window panel. Also seems to happen with module help windows that are html documents. Window height and width reset to minimums? |
Thanks for pointing it out, I hadn’t noticed. |
|
@rlament |
|
Thanks for the reports, Ray. Indeed, there are still some edge cases to look into that I hadn’t noticed. I’ve set the PR to draft until further testing is completed. P.S. By the way, the issue you mentioned with the Fire in the Blue module does not occur on my system, even after deleting the preferences |
With the latest commit, the help window opens to a reasonable size. I did stumble upon the steps to reproduce with the previous version of the code.
The order can be reversed. The second window opens up not sized. Just the title bar with an X. It seems that there is some dependency between them. |
| Prefs.getGlobalPrefs().addOption(option); | ||
|
|
||
| helper.setup(this, contents); | ||
|
|
There was a problem hiding this comment.
addOption() eventually invokes setFrameBounds() and in there it uses the position and size of the frame from V_Global. helper.setup() sets the window size based on the screen bounds since the pack() function doesn't produce reasonable dimensions. It is checking one frame for monitor determination but using another for the actual display.

Summary
This PR improves window and dialog placement in multi-monitor configurations, including setups with non-aligned desktop offsets. Windows and dialogs now open on the most appropriate monitor, remain fully visible, and no longer “snap back” to the primary display.
The issue was reproduced on Linux + KDE; the changes have been tested on Linux + KDE and Windows.
What changes
PositionOptionin all modes, with bounds persisted under"BoundsOfGameModule"and sensible defaults.PlayerWindow(or another suitable owner) and are centered on the same monitor as their parent when no saved bounds exist.SwingUtils.ensureOnScreenclamps windows to the screen with the largest intersection (or nearest one), preventing reassignment to the primary monitor.Result
Adresses: