* Fix horizontal scrolling regression (fixes #7404) The old issue #2218 was actually a bug in SDL, fixed on X11 in version 2.0.18 and on Wayland in version 2.0.20. The hardcoded workaround in pull #2481 (commit4bc4373
) caused a regression in fixed SDL versions. This fix is similar to the workaround in widelands/widelands#5394 committed as widelands/widelands@67db32a. Tested with SDL 2.0.14 and 2.28.5. * Make mouse handler use same coordinate signs as map Also fix mouse_wheel_*() virtual method calls, which have been wrong in the X axis since commitdfe2f33
(and unused since commitc912f7e
).
This commit is contained in:
parent
28cea58aff
commit
ab4001d5b9
2 changed files with 30 additions and 8 deletions
|
@ -232,11 +232,33 @@ void controller_base::handle_event(const SDL_Event& event)
|
|||
break;
|
||||
|
||||
case SDL_MOUSEWHEEL:
|
||||
#if defined(_WIN32) || defined(__APPLE__)
|
||||
mh_base.mouse_wheel(-event.wheel.x, event.wheel.y, is_browsing());
|
||||
#else
|
||||
mh_base.mouse_wheel(event.wheel.x, event.wheel.y, is_browsing());
|
||||
// Down and right are positive in Wesnoth's map.
|
||||
// Up and right are positive in SDL_MouseWheelEvent on all
|
||||
// platforms:
|
||||
// https://wiki.libsdl.org/SDL2/SDL_MouseWheelEvent
|
||||
// Except right is wrongly negative on X11 in SDL < 2.0.18:
|
||||
// https://github.com/libsdl-org/SDL/pull/4700
|
||||
// https://github.com/libsdl-org/SDL/commit/515b7e9
|
||||
// and on Wayland in SDL < 2.0.20:
|
||||
// https://github.com/libsdl-org/SDL/commit/3e1b3bc
|
||||
// Fixes issue #7404, which is a regression caused by pull #2481
|
||||
// that fixed issue #2218.
|
||||
{
|
||||
int xmul = 1;
|
||||
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||
const char* video_driver = SDL_GetCurrentVideoDriver();
|
||||
SDL_version ver;
|
||||
SDL_GetVersion(&ver);
|
||||
if(video_driver != nullptr && ver.major <= 2 && ver.minor <= 0) {
|
||||
if(std::strcmp(video_driver, "x11") == 0 && ver.patch < 18) {
|
||||
xmul = -1;
|
||||
} else if(std::strcmp(video_driver, "wayland") == 0 && ver.patch < 20) {
|
||||
xmul = -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
mh_base.mouse_wheel(xmul * event.wheel.x, -event.wheel.y, is_browsing());
|
||||
}
|
||||
break;
|
||||
|
||||
case TIMER_EVENT:
|
||||
|
|
|
@ -371,9 +371,9 @@ void mouse_handler_base::mouse_wheel(int scrollx, int scrolly, bool browse)
|
|||
CKey pressed;
|
||||
// Alt + mousewheel do an 90° rotation on the scroll direction
|
||||
if(pressed[SDLK_LALT] || pressed[SDLK_RALT]) {
|
||||
gui().scroll(-movey, -movex);
|
||||
gui().scroll(movey, movex);
|
||||
} else {
|
||||
gui().scroll(-movex, -movey);
|
||||
gui().scroll(movex, movey);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -384,9 +384,9 @@ void mouse_handler_base::mouse_wheel(int scrollx, int scrolly, bool browse)
|
|||
}
|
||||
|
||||
if(scrolly < 0) {
|
||||
mouse_wheel_down(x, y, browse);
|
||||
} else if(scrolly > 0) {
|
||||
mouse_wheel_up(x, y, browse);
|
||||
} else if(scrolly > 0) {
|
||||
mouse_wheel_down(x, y, browse);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue