SDL icon indicating copy to clipboard operation
SDL copied to clipboard

renderer: Don't reset viewport on window move

Open Axilot opened this issue 3 years ago • 11 comments

Stop resetting the viewport on window move

Fixes #5949

Axilot avatar Aug 02 '22 09:08 Axilot

@flibitijibibo , does this conflict with https://github.com/libsdl-org/SDL/commit/cb8163081685fd97deba3c800bb8f10841b555a1?

slouken avatar Aug 02 '22 13:08 slouken

It does but just barely - we need this case to happen when moving the window causes a DPI change (moving from a 100% display to a 200% display for example), we don't need it in any other case.

flibitijibibo avatar Aug 02 '22 13:08 flibitijibibo

It does but just barely - we need this case to happen when moving the window causes a DPI change (moving from a 100% display to a 200% display for example), we don't need it in any other case.

Maybe we need a window "display changed" event instead?

slouken avatar Aug 02 '22 13:08 slouken

That would definitely be helpful, and we might be able to do it at a high level too:

https://github.com/FNA-XNA/FNA/blob/master/src/FNAPlatform/SDL2_FNAPlatform.cs#L1026

flibitijibibo avatar Aug 02 '22 13:08 flibitijibibo

It seems like what we actually want to do is rescale the viewport relative to the previous window size? e.g. if the viewport was the bottom half of the window, the new viewport would be the bottom half of the new window, etc.

slouken avatar Aug 02 '22 13:08 slouken

It seems like what we actually want to do is rescale the viewport relative to the previous window size? e.g. if the viewport was the bottom half of the window, the new viewport would be the bottom half of the new window, etc.

I see.

Axilot avatar Aug 02 '22 13:08 Axilot

But what if the window is half-way on display 1 and half-way on display 2?

Axilot avatar Aug 02 '22 13:08 Axilot

My instinct is we need to scale the viewport from what it was to the new DPI, or this is going to be broken, which is going to need a more-complex PR (I don't think we need a new event for this case, but maybe I'm wrong).

icculus avatar Aug 02 '22 14:08 icculus

But what if the window is half-way on display 1 and half-way on display 2?

It depends on the system. Windows will pick the center of the window and wherever that is, that is the display used for DPI scaling. macOS will scale each portion of the window individually based on the display it covers. For our purposes, we'll do the same as Windows, where a window will use the display covered by the center of the window.

slouken avatar Aug 02 '22 17:08 slouken

But what if the window is half-way on display 1 and half-way on display 2?

It depends on the system. Windows will pick the center of the window and wherever that is, that is the display used for DPI scaling. macOS will scale each portion of the window individually based on the display it covers. For our purposes, we'll do the same as Windows, where a window will use the display covered by the center of the window.

Confirming that Wayland does it the Windows way as well.

flibitijibibo avatar Aug 02 '22 17:08 flibitijibibo

@icculus, we shouldn't punt on this for 2.24.0

slouken avatar Aug 05 '22 19:08 slouken

Turns out we already have the foundation to fix this, so I'm going to take care of this now.

@Axilot, thanks for the patch, it helped us work out the actual bug!

flibitijibibo avatar Aug 12 '22 20:08 flibitijibibo