Return-To-The-Roots / s25client

Return To The Roots (Settlers II(R) Clone)
http://www.rttr.info
GNU General Public License v2.0
470 stars 75 forks source link

Fix high DPI issue on macOS #1648

Open tiennou opened 4 months ago

tiennou commented 4 months ago

The bug is described in #1621, and is about the game using only the bottom-left corner of the window to draw, and the mouse cursor bounding box not being correct (so you can't access Settings > Graphics, as it gets clamped by the bottom of the screen).

The first commit fixes the rendering to be full-screen again, but the mouse cursor is still "locked" into the top-left corner (but the buttons work). The second make the mouse cursor move properly by scaling its position with the DPI, but that makes the buttons active area all wrong, and I can't see where the hit-testing is actually happening.

Flamefire commented 4 months ago

The second make the mouse cursor move properly by scaling its position with the DPI, but that makes the buttons active area all wrong, and I can't see where the hit-testing is actually happening.

The problem here is that you are not correcting the mouse-move/click/drag operations. See e.g. https://github.com/Return-To-The-Roots/s25client/blob/73acea701915e0b857482af6006cfb9342925032/extras/videoDrivers/SDL2/VideoSDL2.cpp#L401 or search this file for mouse_xy.pos =

I suspect you don't need the 2nd commit here and just can remove the getGuiScale().screenToView from VideoSDL2, but haven't fully checked that. It just looks like you basically undo the scaling by screenToView with * dpiScale which sounds like the scaling is wrong in the first place.