-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Horizontal scrolling is backwards in imgui_impl_win32 and imgui_impl_sdl #4019
Comments
Ah, I bet #3394 was the same issue but they blamed the wrong thing. The Also this reminded me I meant to check on my laptop too for the sake of sanity. I can confirm its trackpad acts the same as my desktop's mouse. (GLFW matches other apps, Win32 and SDL are backwards.) |
…ornut#4019) Backends: SDL: Fixed lack of mouse wheel acceleration.
Can confirm that inverting x axis on SDL/Win32 works as expected. This also works properly on MacOS when holding SHIFT (92b7b1f caused some problems regarding that). While testing this i noticed that for some reason wheel acceleration was disabled. Allowing SDL to accelerate wheel does not seem to have any unwanted effects and makes wheel behave consistently in imgui and native applications, so i included that change in commit linked above as well. |
@rokups I believe "wheel acceleration" should be left to a separate discussion and PR, it's probably not a simple topic to handle as the amount are not well defined across platforms/backends. It'd be useful to report how those mouse wheel values are generated by SDL for every platform. It's difficult to test a way to natively send MOUSEWHEELH events here, and Mac mouse drivers on drivers have options to invert the axis making things more confusing. Additionally I'm unsure all OS scroll the same way depending on mouse.
That should be enough of a hint to suggest we might be overlooking something. I think we need a wider range of tests done across platforms (+ bonus checking if third-party drivers involved have invert options). That person basically says SDL and GLFW works the same for them, and now we are inverting SDL but not GLFW. We are missing something. SHIFT+vertical wheel also needs testing separately from horizontal wheel. |
I split wheel acceleration to separate commit. I also verified behavior on all three OS. Windows: does not have a concept of wheel acceleration. Modifying wheel speed in OS settings has no effect on scrolling speed, event always returns +1/-1. End result: no change compared to current behavior. tl;dr; acceleration change only improves usability on MacOS and changes nothing on windows (SDL bug?) and linux (lacking desktop environment). Edit: Forgot to mention SHIFT+vertical. Currently this is broken on MacOS, because we delegate axis swapping to OS function. Inverting |
We are dealing with three distrinct bugs.
As a result we get:
I submitted a PR to SDL to fix inverted events in X11 backend: libsdl-org/SDL#4700. |
See open Dear ImGUI issue: ocornut/imgui#4019 This patches it for macOS in the local copy of imgui_impl_sdl.
Ignore the table/data here and refer to XLS file in subsequent post.Extra data (will add more as I test on my PC laptop with a touchpad) Someone recently wondered why the SDL backend clamping mouse wheel inputs to -1/+1 (thread #6081) I didn't have a good answer yet as this clamping was added many years ago. Interestingly, I tested the SDL2+Emscripten example and confirmed odd findings, namely that the scale of wheel values reported on Emscripten vary depending on the browser. I also tested GLFW+Emscripten and got same values. Misc
I also noticed SDL 2.0.18 added "preciseX/preciseY" fields so I am also testing those, but they are not available in Emscripten latest.
*EDITED 4 times. added glfw+emscripten, added windows info with mouse that has horizontal inputs + with touchpad. |
Are these data the raw value per event, or are they accumulated over a period of time? I've seen that slow scrolls become heavily batched/under-sampled on some systems (e.g. Native macOS), so it's probably necessary to accumulate for an apples-to-apples comparison. |
Per event. Notes:
About GLFW:
Note opening thread message:
A per the scary table above, further notes:
Question:
|
FYI there's no action needed; other than the two questions above (for people who can run Unity or Unreal on two platforms). I've gathered good data and will add more soon and then attempt some fixes for the horizontal direction issues. |
Is it possible then that the event rates are different, in addition to the event scaling? I'll dive in soon and try to reproduce some of your findings, or at least make sure these match my previous measurements |
… with hasPreciseScrollingDeltas==false (e.g. non-Apple mices). Ref #4019 for details provided in .XLS sheet, although not strictly related to main issue topic. + Rename Emscripten demo titles to make SDL visible.
I have pushed 3617a96 fixing most issues discussed here. Remaining issues IHMO:
Attached my data reworked and converted to an Excel sheet. Please ignore table posted a few posts above as this sheet is more complete and more accurate. Wheeling Notes 2023-02-01.xlsx Thank you ! |
Duh i also accidentally pushed a WIP example for GLFW+Emscripten which i didn’t intend to include in that commit (reason: somehow git stashes don’t stash new files unless staged). So expect that to be removed or massaged later, perhaps folded into existing examples. |
You can use |
…iding by 100.0f on Emscripten. (#4019, #6096, #1463) Ref libsdl-org/SDL#10454 (comment)
Version/Branch of Dear ImGui:
Version: current
master
, currentdocking
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_win32.cpp + imgui_impl_dx11.cpp
Back-ends: imgui_impl_sdl.cpp + imgui_impl_dx11.cpp
Compiler: MSVC 19.28.29913 x64 (Visual Studio 2019 16.9.3)
Operating System: Windows 10 x64 20H2 (19042.867)
My Issue/Question:
The horizontal scrolling direction in Dear ImGui with the Win32/SDL backends is backwards when compared to other Windows applications. It is correct with the imgui_impl_glfw backend. This issue is observable in the official examples. (I specifically tested
example_glfw_opengl3
,example_sdl_directx11
, andexample_win32_directx12
.)For the sake of clarity, I am going to describe scrolling in terms of what the scrollbar's grabber does in response to you moving the mouse wheel.
a. Open content which is too wide for the screen or resize the window so a horizontal scrollbar appears.
b. Press right on the scroll wheel. The grabber moves to the right.
c. Press left on the scroll wheel. The grabber moves to the left.
example_win32_directx12
a. In the demo window, expand
Layout & Scrolling
and thenScrolling b. Uncheck
Track`c. In one of the horizontal scrolling examples...
d. Press right on the scroll wheel. The grabber moves to the left.
e. Press left on the scroll wheel. The grabber moves to the right.
example_sdl_directx11
, same result.example_glfw_opengl3
:a. When pressing right on the scroll wheel, The grabber moves to the right.
b. When pressing left on the scroll wheel, The grabber moves to the left.
As you can see,
example_win32_directx12
/example_sdl_directx11
are backwards from what would be expected when compared to other Windows apps as well asexample_glfw_opengl3
.Screenshots/Video
This issue is difficult to convey in screenshots/video. I believe it should be apparent from following the steps above.
Standalone, minimal, complete and verifiable example:
This issue reproduces in the Dear ImGui examples without changes.
Root cause
This issue essentially happens because Dear ImGui treats
MouseWheelH
in the positive as being a scroll to the left. (Which mirrors positiveMouseWheel
being a scroll up.)However, both
WM_MOUSEHWHEEL
andSDL_MouseWheelEvent.y
are defined as positive being a scroll to the right. (GLFWscrollfun
does not say, but it's apparently the opposite. Probably to make it consistent withyoffset
which is positive up for all three.)Proposed fix
The easiest fix would be to document the expectation for both
ImGuiIO::MouseWheel
andImGuiIO::MouseWheelH
, and flip them in the affected backends.Additionally, the horizontal scrolling in
ImGui::UpdateMouseWheel
could also be flipped to match the convention of SDL/Windows. If this is done, I think it needs to be done by flipping theMouseWheelH
read rather than flipping the call toSetScrollX
as the latter would affect shift scrollings. (In my opinion, the current shift scrolling is intuitive. There's not a lot of precedent for this interaction on Windows, but Photoshop and Dear ImGui both move the grabber left if I use control/shift+scroll up.)The downside of modifying
ImGui::UpdateMouseWheel
is that it could potentially break custom backends. Although since the direction ofMouseWheelH
wasn't defined before, it's possible this bug is present in many custom backends as well. (I actually originally discovered this issue in my own custom backend since I expected positive right.)The text was updated successfully, but these errors were encountered: