-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
Very slow frame rate and ImGui::MouseDoubleClicked #71
Comments
(A) The change itself to easy but I'm concerned about breaking the API for people who update to newer version of the library. I may bundle a couple of API breaking changes all-together. The problem will breaking the API is that even if the "fix" is trivial it makes people less inclined to stay up to date so there's a balance to find here In particular it seems that some gestures on MacOS creates mouse clicks that are very short (probably sending a click event and a release event in a short amount of time). The OpenGL example added those lines as a workaround to cope with it: But the system should be revamped to not miss events. (B) |
A different approach is to render the application's contents to a separate buffer, at 0fps (or at any desirable fps). |
Exactly! I have done it in windows and osx, integrating with MFC (or pure WinAPI) and Cocoa (with CVDisplayLink for the ones interested). The key is to trigger a redraw operation only when "something happens". For example on windows I'm subclassing the WndProc and simply triggering a redraw every time I receive a message that might change the visual state (Mouse Events, Window Resize Events, KeyDown/Up/Char Events, background erase etc.). I also trigger anytime I receive an IO message from application async io loop (may not apply to you case if you're using Sync IO). |
I wouldn't call it "working like a retained UI", it is still quite different. It's probably cool if you have the sort of application that requires idling. There is the possibility that past a certain update frequency from the network it'll be always running at max speed and that may be problematic for your use case. Perhaps local inputs events vs network inputs can be treated differently. I am working on menus at the moment and I need to add a timer to facilitate moving between menus (when menus appears/disappears immediately it is easy while dragging from a hovered item to a submenu to hover something else). I suppose what you want to do when you get user inputs is to keep the app running at stable frame-rate for 1 or 2 seconds past each input, so interactive elements that are based on timer will work. If your only aim if you have idle application when not being used that could be a viable workaround. |
Oh, I know that retained mode ui only redraw specific section of a window, with dirty rects etc. while here we're always redrawing everything when we need. Oh and regarding the update frequency from the network, I've already experienced this problem and already solved by delaying the first re-render with a timer that starts after the first IO event is arrived. |
You asked (here #126 (comment) ) "Please expose the "next timer due" value somewhere in the api, so it's easy to schedule a refresh in idle/event driven re-drawing scenarios. If you will take the time to do that, also include the text cursor timer as well (one just needs the min of the two)." About including the text cursor, that would mean that whenever a text field is active your application would stay awake. So if you clicked a text field, etc. and alt-tabbed somewhere else it would stay awake, probably not what you want here? We need to differentiate animations that have timers that have an effect interactions with those which don't. |
I would say that if you clicked a text field and alt-tabed somewhere else, the correct behaviour for the app is to stay awake. Maybe I'm missing something, but I don't get why it could be useful to differentiate animations that effect interactions and those which don't, and I don't want the beautiful ImGui api to became too complex! :) |
Maybe we could simplify this by creating a 2-event queue, like storing "XWasRecentlyPressed" + "XWasRecentlyReleased" instead of "XIsPressed"? |
I think it's better to close this very old issue I started many years ago... |
Better late than never, Dear ImGui 1.87 WIP now uses a new IO api (e.g. See e.g.
Also see #4858 for a general overview (we'll improve this topic soon). |
That was accidentally reopened in my 2022 message, closing again - incidentally was oldest open issue :) |
This is actually still a valid issue that defeat the input queue because double-click is handled by comparing imgui frame times. |
Hi everybody. Many compliments for the project! That's what I was looking for...
I'm new to ImGui (and to Github thanx to ImGui), so please be patient with me...
Now the issue:
I've found out that when I clamp the frame rate of my application to save CPU/GPU usage, double clicks stop working.
That's probably caused to the fact that ImGui::NewFrame() is called less frequently and the ImGui::MouseDoubleClickTime is too small to catch double clicks in these cases.
I've been able to work around the issue by using my own variables, catching double click events myself and refeeding the ImGui::MouseDoubleClicked array with them soon after ImGui::NewFrame().
This works, but maybe we could add a variable to tell ImGui we're going to set the ImGui::MouseDoubleClicked array directly ourself and ImGui should skip updating it inside ImGui::NewFrame(), can't we?
Another think I would like to know is whether or not ImGui can be used at zero frame per seconds.
I mean in 3D editor-like applications, where a postUpdate() should be called only as a response to some action by the user (e.g. dragging a window and stuff like that). That's the main reason why I've tried clamping the frame rate in the first place (currently I've tested it at 10 fps: ImGui works well with the double click fix, it's only not very smooth when dragging a window).
P.S. I'm using openGL on Ubuntu Linux 64 bit, but that shouldn't make any difference.
P.S.2. Actually another minor issue happened when working at low frame rates with my fix: in the demo project I wasn't able to minimize the "Debug" window (double clicking its title bar). All the other windows work as expected. And if I add the ImGui::Begin()/End() when creating it PLUS a name different from "Debug" it starts working again.
The text was updated successfully, but these errors were encountered: