-
-
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
Fix horizontal scrolling with touchpad devices #3795
base: master
Are you sure you want to change the base?
Conversation
…urther wheeling events to parent window, if children window has interest for scroll-x)
Hello, Thanks for reporting this. I initially misunderstood the issue on my first read but now I realize that the scrolling events being dispatched to two windows is indeed wrong. Will fix this :)
The purpose of the test is to climb up the parent hierarchy until we are stopped by those flags. Your change locks the flags to the first immediately hovered window which seems like a very different behavior. Don't worry about reworking/fixing it, we'll be looking at this very shortly (along with other mouse-wheel related changes). Thanks a lot! |
0c1e5bd
to
bb6a60b
Compare
8b83e0a
to
d735066
Compare
Hi, I have read recent discussions in #4559 ; My most recent comment (of today) in #4559 should be read, before this one comment here. My #3795 above contained three "proposals"/"fixes" : 1) "Simplify the 2 lines calculating const float: wheel_y and wheel_x"......You seem to already have figured out this, by "factoring" the "?:" operation and removed the duplicate "g.IO.MouseWheel" which occured at the version I then had. 2) "Replace a frequent calculus by its own boolean"......Which I think would still be relevant today, because I think it would really simplify readability of the code still exhibing the problem. This proposal is to simply "sed" replacing, without changing applied "logic":
(new-lined just so that you see that the boolean contained the same thing than the original code). Lines 3871 to 3876 in 612b787
Applying this would really simplify the "readability" of the condition tested in the while Loop at line 3874. I agree that my original proposal may have skip the fact that the "boolean evaluation" (evaluate the expression) should be eval'ed (set) at each run of the loop, so probably something like:
So above I just :
This is ugly but it's an example just to show that it's just a "sed replace" of some "text" (and the WHILE loop modified to continue/break to be sure to correctly set the boolean which was previously set "anonymously" in the condition of the loop itself. This uglyness is easily fixable : just negate the proposed "IF" and make it break if the negated == true, otherwise just "window = parent" and then "naturally" (implicitly) "continue" (by not breaking...) :
(yeah, replace "IF NEGATION" above by "if !", that was for emphasis.) I think that would reaaally simplify intention of the code at Line 3874 and 3876 Lines 3871 to 3876 in 612b787
And of course it would also be applied at the same test for X below : Lines 3888 to 3890 in 612b787
This would really for code readability (factoring) of this section, which currently somewhat hampers fixing the code issue of the behavior described in #3795. 3) The bug fix......Following up on this one in another comment below.. |
3) The bug fix...Regarding Lines 3871 to 3882 in 612b787
It still has the same issue. As soon as you "inevitably" move your finger on Y, the "wheel locked window" ( You will as such be "locked out" of your capability to "scroll on X", and you will recover only if you raise your finger and wait the amount of time "unlocking" the "wheel locked window" as done by ImGui. Concretely, this is really nearly impossible to scroll on X on a touchpad. The PatchWell, the core of the problem is that the logic is first applied to Y, then to X. It has some senses when, as @ocornut said, there is "two streams" of independent values, like when you for real have 2 physical scrolls, the human user could be sufficiently intelligent to understand to not scroll both at the same time when this problem occurs. My original patch proposal above (fdbce6c), which should be read in "diff mode" of "side-by-side" so as not to go crazy,
My patch aimed to:
If the widget has interest for only one of the two scrolling axes, the second axe will be ignored, which is probably the better situation. (it will NOT be bubbled up to the parent). I'm not sure that it would be a bug, I think that maybe it's a feature. My patch does not seem far behind "master" and the logic change (merging the 2 loops) seems to be possibly applied easily. |
I should also add that, as one of the other issues explained, there is a quicker way to test the behavior with the "demo":
On a MBP Pro 13" August 2020, this is nearly impossible to scroll on X. You somewhat just achieve it by luck with ~10 pixels max at each try, by trying to have a steady hand/finger, and moving your finger only on X, which is superhard. |
b3b85d8
to
0755767
Compare
c817acb
to
8d39063
Compare
Hi, I updated my branch :) Please consider merging this request, I beg you. Scrolling does not work AT ALL in some conditions on MacBooks with touchpad. Since at the very least February 2021 (my original request), but I guess since way more time. Just try on a Macbook scrollpad the following :
As soon as you add many more "5 entries" up to to the a scrollbar on Y appears, the problem disappear. My branch (and the following patch) fixes that. The caveat is both event (scroll Y AND scroll X) will STOP bubbling up as soon as a window has interest / utility. The diff is :
But the diff is somewhat un-readable unless in "split view". The result of applying it is :
|
Hello, The PR doesn't address the reported issue that the
The problem I see presently is that most/many windows will have (ScrollMax.x > 0.0f), which is not very noticeable in most case, and not often taken advantage of, and the change effectively disable the bubbling back to parent when using a regular mouse wheel. So imagine this situation:
ImGui::Begin("Window A");
for (int n = 0; n < 10; n++)
ImGui::Text("%*s some contents", n, "");
ImGui::BeginChild("Child B", ImVec2(0.0f, 200.0f), true);
ImGui::Text("this is a long line of text. this is a long line of text. this is a long line of text. this is a long line of text. ");
ImGui::EndChild();
for (int n = 0; n < 10; n++)
ImGui::Text("%*s some contents", n, "");
ImGui::End(); With the proposed change, vertical wheeling while over Child B doesn't bubble back Window A anymore. While it's not as problematic as your current issue, it is problematic and I was hoping this would get resolved. |
Could you add in IMGUI_DEBUG_LOG("MouseWheel X:%.3f Y:%.3f\n", wheel_x, wheel_y); And record logs of:
I am trying to understand is MacOS does some filtering/axis locking at all.
OK I now understand another aspect/subtly of this bug which I previously didn't see. |
|
Thanks for additional thoughts.
Maybe backends could handle that indeed.
If we end up needing to use an heuristic, the heuristic will be at the level of how/where to decide scrolling based on raw wheel events but should never affect raw wheel events, so I believe this particular thing is not an issue. (PS: I'm currently installing Xcode on my brother's Macbook hoping to be to be able to test things. Last year I did buy a Trackpad following discussions, but it ended up being terrible at doing any form of scrolling, and definitively doesn't do both axis simultaneously) |
Okay I found some webpage I tested one year ago to try to figure out some stuff : Here are my observations on macOS / Safari :
IF I'm already at the bottom of the "Simple Inner" AND I left the trackpad alone roughly ~200-300ms, That's not some advanced heuristics, only that the scroll-Y is bubbled up if were are already at the bottom
NOW, when I shrink Safari on X so that scrollbars appear on X ; To change the "elected" main axis (the only one receiving movement), you :
In a single, continuous movement, if you were staring to move vertically (and it scrolled only on Y), and then started (in the SAME continuous movement) to now move primarily horizontally, then the scrollable region, after maybe 100-200ms will now stop ALL vertical movement to only do horizontal movement. I observe the same behaviour with macOS + Chrome with no noticeable difference. Maybe I should try with a non-WebKit browser this webpage to figure out if this behaviour is WebKit-specific or some macOS per-application configuration... |
I re-enabled the "demo window" inside the main.cpp. Indeed after 10 seconds, there is 600 "MouseWheel" log lines. |
commit e74a50f Author: Andrew D. Zonenberg <azonenberg@drawersteak.com> Date: Wed Sep 28 08:19:34 2022 -0700 Added GetGlyphRangesGreek() helper for Greek & Coptic glyph range. (ocornut#5676, ocornut#5727) commit d17627b Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 17:38:41 2022 +0200 InputText: leave state->Flags uncleared for the purpose of backends emitting an on-screen keyboard for passwords. (ocornut#5724) commit 0a7054c Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 17:00:45 2022 +0200 Backends: Win32: Convert WM_CHAR values with MultiByteToWideChar() when window class was registered as MBCS (not Unicode). (ocornut#5725, ocornut#1807, ocornut#471, ocornut#2815, ocornut#1060) commit a229a7f Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 16:57:09 2022 +0200 Examples: Win32: Always use RegisterClassW() to ensure windows are Unicode. (ocornut#5725) commit e0330c1 Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 14:54:38 2022 +0200 Fonts, Text: Fixed wrapped-text not doing a fast-forward on lines above the clipping region. (ocornut#5720) which would result in an abnormal number of vertices created. commit 4d4889b Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 12:42:06 2022 +0200 Refactor CalcWordWrapPositionA() to take on the responsability of minimum character display. Add CalcWordWrapNextLineStartA(), simplify caller code. Should be no-op but incrementing IMGUI_VERSION_NUM just in case. Preparing for ocornut#5720 commit 5c4426c Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 12:22:34 2022 +0200 Demo: Fixed Log & Console from losing scrolling position with Auto-Scroll when child is clipped. (ocornut#5721) commit 12c0246 Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 12:07:43 2022 +0200 Removed support for 1.42-era IMGUI_DISABLE_INCLUDE_IMCONFIG_H / IMGUI_INCLUDE_IMCONFIG_H. (ocornut#255) commit 73efcec Author: ocornut <omar@miracleworld.net> Date: Tue Sep 27 22:21:47 2022 +0200 Examples: disable GL related warnings on Mac + amend to ignore list. commit a725db1 Author: ocornut <omarcornut@gmail.com> Date: Tue Sep 27 18:47:20 2022 +0200 Comments for flags discoverability + add to debug log (ocornut#3795, ocornut#4559) commit 325299f Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 14 15:46:27 2022 +0200 Backends: OpenGL: Add ability to #define IMGUI_IMPL_OPENGL_DEBUG. (ocornut#4468, ocornut#4825, ocornut#4832, ocornut#5127, ocornut#5655, ocornut#5709) commit 56c3eae Author: ocornut <omarcornut@gmail.com> Date: Tue Sep 27 14:24:21 2022 +0200 ImDrawList: asserting on incorrect value for CurveTessellationTol (ocornut#5713) commit 04316bd Author: ocornut <omarcornut@gmail.com> Date: Mon Sep 26 16:32:09 2022 +0200 ColorEdit3: fixed id collision leading to an assertion. (ocornut#5707) commit c261dac Author: ocornut <omarcornut@gmail.com> Date: Mon Sep 26 14:50:46 2022 +0200 Demo: moved ShowUserGuide() lower in the file, to make main demo entry point more visible + fix using IMGUI_DEBUG_LOG() macros in if/else. commit 51bbc70 Author: ocornut <omarcornut@gmail.com> Date: Mon Sep 26 14:44:26 2022 +0200 Backends: SDL: Disable SDL 2.0.22 new "auto capture" which prevents drag and drop across windows, and don't capture mouse when drag and dropping. (ocornut#5710) commit 7a9045d Author: ocornut <omarcornut@gmail.com> Date: Mon Sep 26 11:55:07 2022 +0200 Backends: WGPU: removed Emscripten version check (currently failing on CI, ensure why, and tbh its redundant/unnecessary with changes of wgpu api nowadays) commit 83a0030 Author: ocornut <omarcornut@gmail.com> Date: Mon Sep 26 10:33:44 2022 +0200 Added ImGuiMod_Shortcut which is ImGuiMod_Super on Mac and ImGuiMod_Ctrl otherwise. (ocornut#456) commit fd408c9 Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 22 18:58:33 2022 +0200 Renamed and merged keyboard modifiers key enums and flags into a same set:. ImGuiKey_ModXXX -> ImGuiMod_XXX and ImGuiModFlags_XXX -> ImGuiMod_XXX. (ocornut#4921, ocornut#456) Changed signature of GetKeyChordName() to use ImGuiKeyChord. Additionally SetActiveIdUsingAllKeyboardKeys() doesn't set ImGuiKey_ModXXX but we never need/use those and the system will be changed in upcoming commits. # Conflicts: # imgui_demo.cpp
commit cc5058e Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 29 21:59:32 2022 +0200 IO: Filter duplicate input events during the AddXXX() calls. (ocornut#5599, ocornut#4921) commit fac8295 Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 29 21:31:36 2022 +0200 IO: remove ImGuiInputEvent::IgnoredAsSame (revert part of 839c310), will filter earlier in next commit. (ocornut#5599) Making it a separate commit as this leads to much indentation change. commit 9e7f460 Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 29 20:42:45 2022 +0200 Fixed GetKeyName() for ImGuiMod_XXX values, made invalid MousePos display in log nicer. (ocornut#4921, ocornut#456) Amend fd408c9 commit 0749453 Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 29 19:51:54 2022 +0200 Menus, Nav: Fixed not being able to close a menu with Left arrow when parent is not a popup. (ocornut#5730) commit 9f6aae3 Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 29 19:48:27 2022 +0200 Nav: Fixed race condition pressing Esc during popup opening frame causing crash. commit bd2355a Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 29 19:25:26 2022 +0200 Menus, Nav: Fixed using left/right navigation when appending to an existing menu (multiple BeginMenu() call with same names). (ocornut#1207) commit 3532ed1 Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 29 18:07:35 2022 +0200 Menus, Nav: Fixed keyboard/gamepad navigation occasionally erroneously landing on menu-item in parent when the parent is not a popup. (ocornut#5730) Replace BeginMenu/MenuItem swapping g.NavWindow with a more adequate ImGuiItemFlags_NoWindowHoverableCheck. Expecting more subtle issues to stem from this. Note that NoWindowHoverableCheck is not supported by IsItemHovered() but then IsItemHovered() on BeginMenu() never worked: fix should be easy in BeginMenu() + add test is IsItemHovered(), will do later commit d5d7050 Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 29 17:26:52 2022 +0200 Various comments As it turns out, functions like IsItemHovered() won't work on an open BeginMenu() because LastItemData is overriden by BeginPopup(). Probably an easy fix. commit e74a50f Author: Andrew D. Zonenberg <azonenberg@drawersteak.com> Date: Wed Sep 28 08:19:34 2022 -0700 Added GetGlyphRangesGreek() helper for Greek & Coptic glyph range. (ocornut#5676, ocornut#5727) commit d17627b Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 17:38:41 2022 +0200 InputText: leave state->Flags uncleared for the purpose of backends emitting an on-screen keyboard for passwords. (ocornut#5724) commit 0a7054c Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 17:00:45 2022 +0200 Backends: Win32: Convert WM_CHAR values with MultiByteToWideChar() when window class was registered as MBCS (not Unicode). (ocornut#5725, ocornut#1807, ocornut#471, ocornut#2815, ocornut#1060) commit a229a7f Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 16:57:09 2022 +0200 Examples: Win32: Always use RegisterClassW() to ensure windows are Unicode. (ocornut#5725) commit e0330c1 Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 14:54:38 2022 +0200 Fonts, Text: Fixed wrapped-text not doing a fast-forward on lines above the clipping region. (ocornut#5720) which would result in an abnormal number of vertices created. commit 4d4889b Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 12:42:06 2022 +0200 Refactor CalcWordWrapPositionA() to take on the responsability of minimum character display. Add CalcWordWrapNextLineStartA(), simplify caller code. Should be no-op but incrementing IMGUI_VERSION_NUM just in case. Preparing for ocornut#5720 commit 5c4426c Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 12:22:34 2022 +0200 Demo: Fixed Log & Console from losing scrolling position with Auto-Scroll when child is clipped. (ocornut#5721) commit 12c0246 Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 12:07:43 2022 +0200 Removed support for 1.42-era IMGUI_DISABLE_INCLUDE_IMCONFIG_H / IMGUI_INCLUDE_IMCONFIG_H. (ocornut#255) commit 73efcec Author: ocornut <omar@miracleworld.net> Date: Tue Sep 27 22:21:47 2022 +0200 Examples: disable GL related warnings on Mac + amend to ignore list. commit a725db1 Author: ocornut <omarcornut@gmail.com> Date: Tue Sep 27 18:47:20 2022 +0200 Comments for flags discoverability + add to debug log (ocornut#3795, ocornut#4559) commit 325299f Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 14 15:46:27 2022 +0200 Backends: OpenGL: Add ability to #define IMGUI_IMPL_OPENGL_DEBUG. (ocornut#4468, ocornut#4825, ocornut#4832, ocornut#5127, ocornut#5655, ocornut#5709) commit 56c3eae Author: ocornut <omarcornut@gmail.com> Date: Tue Sep 27 14:24:21 2022 +0200 ImDrawList: asserting on incorrect value for CurveTessellationTol (ocornut#5713) commit 04316bd Author: ocornut <omarcornut@gmail.com> Date: Mon Sep 26 16:32:09 2022 +0200 ColorEdit3: fixed id collision leading to an assertion. (ocornut#5707) commit c261dac Author: ocornut <omarcornut@gmail.com> Date: Mon Sep 26 14:50:46 2022 +0200 Demo: moved ShowUserGuide() lower in the file, to make main demo entry point more visible + fix using IMGUI_DEBUG_LOG() macros in if/else. commit 51bbc70 Author: ocornut <omarcornut@gmail.com> Date: Mon Sep 26 14:44:26 2022 +0200 Backends: SDL: Disable SDL 2.0.22 new "auto capture" which prevents drag and drop across windows, and don't capture mouse when drag and dropping. (ocornut#5710) commit 7a9045d Author: ocornut <omarcornut@gmail.com> Date: Mon Sep 26 11:55:07 2022 +0200 Backends: WGPU: removed Emscripten version check (currently failing on CI, ensure why, and tbh its redundant/unnecessary with changes of wgpu api nowadays) commit 83a0030 Author: ocornut <omarcornut@gmail.com> Date: Mon Sep 26 10:33:44 2022 +0200 Added ImGuiMod_Shortcut which is ImGuiMod_Super on Mac and ImGuiMod_Ctrl otherwise. (ocornut#456) commit fd408c9 Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 22 18:58:33 2022 +0200 Renamed and merged keyboard modifiers key enums and flags into a same set:. ImGuiKey_ModXXX -> ImGuiMod_XXX and ImGuiModFlags_XXX -> ImGuiMod_XXX. (ocornut#4921, ocornut#456) Changed signature of GetKeyChordName() to use ImGuiKeyChord. Additionally SetActiveIdUsingAllKeyboardKeys() doesn't set ImGuiKey_ModXXX but we never need/use those and the system will be changed in upcoming commits. # Conflicts: # imgui.cpp # imgui.h # imgui_demo.cpp
commit 5884219 Author: cfillion <cfillion@users.noreply.github.com> Date: Wed Sep 28 23:37:39 2022 -0400 imgui_freetype: Assert if bitmap size exceed chunk size to avoid buffer overflow. (ocornut#5731) commit f2a522d Author: ocornut <omarcornut@gmail.com> Date: Fri Sep 30 15:43:27 2022 +0200 ImDrawList: Not using alloca() anymore, lift single polygon size limits. (ocornut#5704, ocornut#1811) commit cc5058e Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 29 21:59:32 2022 +0200 IO: Filter duplicate input events during the AddXXX() calls. (ocornut#5599, ocornut#4921) commit fac8295 Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 29 21:31:36 2022 +0200 IO: remove ImGuiInputEvent::IgnoredAsSame (revert part of 839c310), will filter earlier in next commit. (ocornut#5599) Making it a separate commit as this leads to much indentation change. commit 9e7f460 Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 29 20:42:45 2022 +0200 Fixed GetKeyName() for ImGuiMod_XXX values, made invalid MousePos display in log nicer. (ocornut#4921, ocornut#456) Amend fd408c9 commit 0749453 Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 29 19:51:54 2022 +0200 Menus, Nav: Fixed not being able to close a menu with Left arrow when parent is not a popup. (ocornut#5730) commit 9f6aae3 Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 29 19:48:27 2022 +0200 Nav: Fixed race condition pressing Esc during popup opening frame causing crash. commit bd2355a Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 29 19:25:26 2022 +0200 Menus, Nav: Fixed using left/right navigation when appending to an existing menu (multiple BeginMenu() call with same names). (ocornut#1207) commit 3532ed1 Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 29 18:07:35 2022 +0200 Menus, Nav: Fixed keyboard/gamepad navigation occasionally erroneously landing on menu-item in parent when the parent is not a popup. (ocornut#5730) Replace BeginMenu/MenuItem swapping g.NavWindow with a more adequate ImGuiItemFlags_NoWindowHoverableCheck. Expecting more subtle issues to stem from this. Note that NoWindowHoverableCheck is not supported by IsItemHovered() but then IsItemHovered() on BeginMenu() never worked: fix should be easy in BeginMenu() + add test is IsItemHovered(), will do later commit d5d7050 Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 29 17:26:52 2022 +0200 Various comments As it turns out, functions like IsItemHovered() won't work on an open BeginMenu() because LastItemData is overriden by BeginPopup(). Probably an easy fix. commit e74a50f Author: Andrew D. Zonenberg <azonenberg@drawersteak.com> Date: Wed Sep 28 08:19:34 2022 -0700 Added GetGlyphRangesGreek() helper for Greek & Coptic glyph range. (ocornut#5676, ocornut#5727) commit d17627b Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 17:38:41 2022 +0200 InputText: leave state->Flags uncleared for the purpose of backends emitting an on-screen keyboard for passwords. (ocornut#5724) commit 0a7054c Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 17:00:45 2022 +0200 Backends: Win32: Convert WM_CHAR values with MultiByteToWideChar() when window class was registered as MBCS (not Unicode). (ocornut#5725, ocornut#1807, ocornut#471, ocornut#2815, ocornut#1060) commit a229a7f Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 16:57:09 2022 +0200 Examples: Win32: Always use RegisterClassW() to ensure windows are Unicode. (ocornut#5725) commit e0330c1 Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 14:54:38 2022 +0200 Fonts, Text: Fixed wrapped-text not doing a fast-forward on lines above the clipping region. (ocornut#5720) which would result in an abnormal number of vertices created. commit 4d4889b Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 12:42:06 2022 +0200 Refactor CalcWordWrapPositionA() to take on the responsability of minimum character display. Add CalcWordWrapNextLineStartA(), simplify caller code. Should be no-op but incrementing IMGUI_VERSION_NUM just in case. Preparing for ocornut#5720 commit 5c4426c Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 12:22:34 2022 +0200 Demo: Fixed Log & Console from losing scrolling position with Auto-Scroll when child is clipped. (ocornut#5721) commit 12c0246 Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 28 12:07:43 2022 +0200 Removed support for 1.42-era IMGUI_DISABLE_INCLUDE_IMCONFIG_H / IMGUI_INCLUDE_IMCONFIG_H. (ocornut#255) commit 73efcec Author: ocornut <omar@miracleworld.net> Date: Tue Sep 27 22:21:47 2022 +0200 Examples: disable GL related warnings on Mac + amend to ignore list. commit a725db1 Author: ocornut <omarcornut@gmail.com> Date: Tue Sep 27 18:47:20 2022 +0200 Comments for flags discoverability + add to debug log (ocornut#3795, ocornut#4559) commit 325299f Author: ocornut <omarcornut@gmail.com> Date: Wed Sep 14 15:46:27 2022 +0200 Backends: OpenGL: Add ability to #define IMGUI_IMPL_OPENGL_DEBUG. (ocornut#4468, ocornut#4825, ocornut#4832, ocornut#5127, ocornut#5655, ocornut#5709) commit 56c3eae Author: ocornut <omarcornut@gmail.com> Date: Tue Sep 27 14:24:21 2022 +0200 ImDrawList: asserting on incorrect value for CurveTessellationTol (ocornut#5713) commit 04316bd Author: ocornut <omarcornut@gmail.com> Date: Mon Sep 26 16:32:09 2022 +0200 ColorEdit3: fixed id collision leading to an assertion. (ocornut#5707) commit c261dac Author: ocornut <omarcornut@gmail.com> Date: Mon Sep 26 14:50:46 2022 +0200 Demo: moved ShowUserGuide() lower in the file, to make main demo entry point more visible + fix using IMGUI_DEBUG_LOG() macros in if/else. commit 51bbc70 Author: ocornut <omarcornut@gmail.com> Date: Mon Sep 26 14:44:26 2022 +0200 Backends: SDL: Disable SDL 2.0.22 new "auto capture" which prevents drag and drop across windows, and don't capture mouse when drag and dropping. (ocornut#5710) commit 7a9045d Author: ocornut <omarcornut@gmail.com> Date: Mon Sep 26 11:55:07 2022 +0200 Backends: WGPU: removed Emscripten version check (currently failing on CI, ensure why, and tbh its redundant/unnecessary with changes of wgpu api nowadays) commit 83a0030 Author: ocornut <omarcornut@gmail.com> Date: Mon Sep 26 10:33:44 2022 +0200 Added ImGuiMod_Shortcut which is ImGuiMod_Super on Mac and ImGuiMod_Ctrl otherwise. (ocornut#456) commit fd408c9 Author: ocornut <omarcornut@gmail.com> Date: Thu Sep 22 18:58:33 2022 +0200 Renamed and merged keyboard modifiers key enums and flags into a same set:. ImGuiKey_ModXXX -> ImGuiMod_XXX and ImGuiModFlags_XXX -> ImGuiMod_XXX. (ocornut#4921, ocornut#456) Changed signature of GetKeyChordName() to use ImGuiKeyChord. Additionally SetActiveIdUsingAllKeyboardKeys() doesn't set ImGuiKey_ModXXX but we never need/use those and the system will be changed in upcoming commits. # Conflicts: # docs/CHANGELOG.txt # imgui.h # imgui_demo.cpp
Sorry for late reply and thanks for the careful investigation and details.
Any luck with that?
This part of fixed with 80a870a (slight refactor) + c7d3d22 (mitigation/fix for #4559), but this main issue remains totally open. Unfortunately PR as this will conflict (rebase/fix if you want to further investigate, but not strictly needed). Also unfortunately, this issue is tricky enough it's not easy to get back to it after some time.
(1) I tweaked the logic in 80a870a. Notice it's not only a timer change: previously timer was not reset on further wheeling (which seemed very weird) now it is reset. TBH maybe now that it is reset on wheeling we should lower down that value much more (intuitively maybe 0.5f~0.8f may be better). (2) Bubbling-up for same axis (when already at min/max) is something we should add indeed. Not the core of this issue but would be good. Can be developed separately. Based on the discussions and data points above here's what I think we should do:
When needing to determine locked window for wheeling.
Once locked:
Additional heuristic to detect mouse type:
Same axis bubbling-up
What do you think? Going to start writing a little test bed for this (I'll have to write it blind as I don't have access to the Mac right now). |
WIP branch Will update branch over time but first push has: This aims to implement (1) (2) (3) (4) but not well tested yet. |
I reworked this as fe07694 (same branch), it now handles selecting a main axis.
Would appreciate test impressions and perhaps a review. I haven't run that on a Mac yet. |
I worry that a long trail of small/inertia mouse-wheel events may unnecessary prevent changing axis when the axis change leads to a target window change, so may need to rework that. If the axis change is on a same window it'll however work fast. Unfortunately that means another refactor.. |
Hello, thanks for all your work, and I'm really sorry to not have answered quicker :( I tested against upstream/features/mouse_wheeling_target_3795 c41f267
Regarding (2) the "edge direction WIP"/ "scrolling_past_limits" :
Kind Regards, 8<---8<---8<--- BTW it seems that you "adopted" the terminology of naming things "bubbling" / "bubble up".
|
… also gets reset whenever scrolling again (ocornut#2604) + small refactor Somehow interesting for (ocornut#3795, ocornut#4559). sorry this will break PR for 3795 but we got the info.
…ly from touch pad events) are incorrectly locking scrolling in a parent window. (ocornut#4559, ocornut#3795, ocornut#2604)
… misc refactor (ocornut#2604, ocornut#3795, ocornut#4559) The refactor are designed to minimize the diff for changes needed for ocornut#3795
(1)
The same timer is currently used to lock the window itself (in a situation where e.g. you are vertically scrolling in parent and temporarily have mouse over a child which could accept vertical scrolling). I don't think that timer can be reduced to significantly lower amount (e.g. 0.2 seconds).
(2)
What I currently did was to modulate the time increase for small (sub-pixel) wheel amounts: (committed a582d92) static void LockWheelingWindow(ImGuiWindow* window, float wheel_amount)
{
ImGuiContext& g = *GImGui;
if (window)
g.WheelingWindowReleaseTimer = ImMin(g.WheelingWindowReleaseTimer + ImAbs(wheel_amount) * WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER, WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER);
else
g.WheelingWindowReleaseTimer = NULL The axis is still locked during that inertia but this avoid the extra +WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER delay.
(3) I initially reworked the per-axis average to not be framerate dependent, changing: // Maintain a rough average of moving magnitude on both axises
// FIXME: should by based on wall clock time rather than frame-counter
g.WheelingAxisAvg.x = ImExponentialMovingAverage(g.WheelingAxisAvg.x, ImAbs(wheel.x), 30);
g.WheelingAxisAvg.y = ImExponentialMovingAverage(g.WheelingAxisAvg.y, ImAbs(wheel.y), 30); To a rough equivalent: // Maintain a rough average of moving magnitude on both axises
g.WheelingAxisAvgAccum += ImVec2(ImAbs(wheel.x), ImAbs(wheel.y));
g.WheelingAxisAvgAccumTimer += g.IO.DeltaTime;
while (g.WheelingAxisAvgAccumTimer >= 1.0f / 30.0f)
{
g.WheelingAxisAvg.x = ImExponentialMovingAverage(g.WheelingAxisAvg.x, g.WheelingAxisAvgAccum.x, 15);
g.WheelingAxisAvg.y = ImExponentialMovingAverage(g.WheelingAxisAvg.y, g.WheelingAxisAvgAccum.y, 15);
g.WheelingAxisAvgAccumTimer -= 1.0f / 30.0f;
g.WheelingAxisAvgAccum = ImVec2(0.0f, 0.0f);
} Since the average are only compared to each other the exact delay doesn't matter. However I realized this was wrong as our expectation is to use the average for Frame N+1 comparison. Then I realized the whole Frame N+1 idea described in #3795 (comment) and implemented in the branch is incorrect, as on very fast / unthrottled framerates it is unlikely the OS would submit wheel events at same rate.
(4)
I hoped to finish this for 1.89 but unfortunately it's becoming too risky to commit before tagging, but hope to get back to this asap. |
I have pushed 87caf27 already which is essentially the version discussed in my last message. |
Replying to myself: (3)
It may not be a problem since in all the "ambiguous" data sets above (= both axises non-zero on frame 0) the next event (frame 1 in your data set) confirms the major axis of frame 0. So assuming Frame 1 event appears on Frame 10 with high-framerate, it may not be much of a problem. But this yet has to be tested properly at very high frame-rate. (4.B) Another thing, while doing some casual testing on Mac one noticeable issue was, with this setup:
Here we'd like to eventually start scrolling Child B. It is a sort of "opposite" situation as point (4), going from Parent to Child instead of Child to Parent. |
Description
Fix scroll-x on touchpad
The standalone imgui "demo" exhibit the faulty behavior.
Table & columns
->Advanced
; OpenOptions
Table
is not "full" y-wise and thus y-scrollbar disappearinner width
to go beyond the width so that x-scrollbar appearYou are now in a situation with a
Table
havingx-scrollbar
but noty-scrollbar
.You can of course easily recreate the same situation in homemade code. Just fill a
Table
with large lignes (number of columns), small number of items.With a touchpad (at least on Mac), the
x-scrollbar
is 99% unusable.The x-scrollbar can be moved left/right ONLY IF we very very carefully (and with difficulty) touch the touchpad so that the operating system only issue a +/- on the x-axis and 0 on the y-axis.
Because the
Table
is not interested for scroll-y, the event is being "bubbled up" to the parent window.It mess with the code which would have taken interest in the
x-scroll
on behalf of theTable
.Expected behavior
I guess that when the user has a mouse with two scroll wheels, the users can easily choose to "scroll only on X and be neutral (0) on Y".
But I have a hard time figuring out any situation where an user would really wish to AT THE SAME TIME scrolling on two different widgets (parent and children).
I guess that the expected behavior are rather:
FIX of the pull request
If children window has interest for scroll-x, the fix prevent bubbling scroll-y events and lock further wheeling events to parent window.
The code changes of the pull request are including 3 components ;
The first 2 changes below should not change the "logic" of the code, they are for readability only.
The 3 change below should fix the bug.
1) Simplify the 2 lines calculating
const float
:wheel_y
andwheel_x
.The two artimethic operations are being factorized to their simpler form.
The results should be 100% the same than before, if I'm right, it's only some boolean arithmetics.
Those two calculations are also moved at the top of the
diff
, the patch needing those resuls early.2) Replace a frequent calculus by its own boolean
I replaced:
(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs)
everywherebool noScroll
in replacements3) The bug fix
The patch aim to stop bubbling the event as soon as a widget has interest for either scroll-x or scroll-y.
If the widget has interest for only one of the two scrolling axes, the second one will be ignored, which is probably the better situation.
I do not pretend to have inside knowledge of the internal of imgui.
I think I still have respected the intention of the original code.
In the case where the widget has no interest for one of the two scrolling axes, I guess a flag could also be introduced which would enable/disable bubbling up the ignored event to the parent window.
But it would probably require to split the
StartLockWheelingWindow
subsystem for the two axes.