RFR: 8301616: Drag & maximize to another monitor places window incorrectly (Windows)

Nikita Gubarkov duke at openjdk.org
Thu Feb 9 21:45:42 UTC 2023


On Fri, 3 Feb 2023 06:09:50 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>> Maximized bounds are treated as absolute virtual screen coordinates, when maximized, window will be reshaped to that specific bounds no matter what monitor it is currently on. That is, when dragging to fullscreen from monitor 1 to 2 while maximized bound are in 1st monitor, it will just jump back and maximize there.
>> Also when maximized bounds are set, window looks awful on Win11 with caption looking wider than client area, but that's another topic.
>> So I found that my fix breaks maximized bounds logic - window jumps somewhere outside the monitor.
>> I guess we can apply this `AwtWindow::CheckWindowDPIChange()` jump for maximized windows, but only for those components which are overriden by maximized bounds (not `Integer.MAX_VALUE`).
>
>> I guess we can apply this AwtWindow::CheckWindowDPIChange() jump for maximized windows, but only for those components which are overriden by maximized bounds (not Integer.MAX_VALUE).
> 
> Do you mean apply "CheckWindowDPIChange" to all windows, except maximized in full screen(Integer.MAX_VALUE)? It sounds good, I guess it is not possible to do that in Windows 10. So that change should not break something.
> 
> I wonder what is the order of events the Windows send to the application, at what moment do we get the maximization/zoom property - after the drag to the second screen or before?

To be clear: window will be maximized if you drag it near the top of the monitor and release there.
So you drag the window, cross the monitor border, all DPI-related stuff gets updated, you drag it to the top of the second screen, release the button, it maximizes.
My fix works for me because window is maximized before trying to fit its bounds in `CheckWindowDPIChange()`, here are some last messages from my test:


`WM_WINDOWPOSCHANGING` - here we see IsZoomed=true for the first time
`WM_GETMINMAXINFO`
`WM_NCCALCSIZE`
`WM_NCPAINT`
`WM_ERASEBKGND`
`WM_WINDOWPOSCHANGED`
`WM_MOVE`
`WM_SIZE`
`WM_EXITSIZEMOVE` - here we call `CheckWindowDPIChange()`

However [it is reported](https://youtrack.jetbrains.com/issue/JBR-5238/Drag-to-fullscreen#focus=Comments-27-6834787.0-0) that this fix doesn't work when dragging maximized window to maximized on another monitor.
I have no idea what's the difference, because when you start dragging maximized window, it's restored right then and the final behavior shouldn't be any different from dragging non-maximized one, but maybe I'm missing something.

-------------

PR: https://git.openjdk.org/jdk/pull/12367



More information about the client-libs-dev mailing list