bvschaik / julius

An open source re-implementation of Caesar III
GNU Affero General Public License v3.0
2.79k stars 311 forks source link

Scaling breaks right mouse button drag scrolling #698

Closed hmkemppainen closed 1 year ago

hmkemppainen commented 1 year ago

Steps to reproduce:

0) Launch Julius (latest master or latest release) 1) Go to options and set display scale to 200% 2) Start a new game, and scroll by right click and drag in the world

What happens is that when you lift the mouse button, the cursor warps towards the bottom/right and may initiate an edge scroll, depending on where the cursor initially was when you pressed RMB down.

This is caused by system_mouse_set_relative_mode() retrieving unscaled coordinates from SDL and later passing them to system_set_mouse_position(), which scales the coordinates.

Since the goal here is to just store and restore cursor position before & after drag, I'd propose just using SDL_GetGlobalMouseState() and SDL_WarpMouseGlobal() and avoiding the scaling wrapper entirely. However, I'm not sure global warp is supported on all relevant platforms..

crudelios commented 1 year ago

I could swear this was fixed...

Maybe I only fixed it in Augustus? I'll test.

hmkemppainen commented 1 year ago

Indeed, there seems to be a fix in Augustus.

https://github.com/Keriew/augustus/commit/6bec6110ee1794d39024c40f5e8442951e0d1aaf

bvschaik commented 1 year ago

Thanks for looking that up! I have cherry-picked the commit to Julius.