-
Notifications
You must be signed in to change notification settings - Fork 769
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
Batch updating the keyboard state / regrabbing keys #4367
base: next
Are you sure you want to change the base?
Conversation
This testcases causes 5000 keyboard events to be generated, meaning that i3 (needlessly) updates the keymap 5000 times. This currently takes about 13 seconds on my computer. This may or may not be a testcase for i3#3924. I am not sure. Signed-off-by: Uli Schlachter <psychon@znc.in>
No behavioural changes intended. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit moves two more cases to the regrab_keys() helper function. This is not just a straight forward refactoring since the order of things is different for RG_LOAD_KEYMAP_AND_TRANSLATE before and after this commit. While I do not think this makes much of a difference, I still did this in its extra commit for bisectability. Signed-off-by: Uli Schlachter <psychon@znc.in>
Instead of updating the keyboard state and regrabbing all the keys immediately when requested, this simply starts an ev idle watcher. This has the effect of batching updates: When multiple updates are requested during a main loop iteration, only one update is actually done. This fixes the new test case that I just added. This might or might not fix i3#3924. Signed-off-by: Uli Schlachter <psychon@znc.in>
Hrm. The test definitely needs some more work. It just failed locally for me and I have no idea why:
Someone who knows perl & the test suite is invited to look at this and improve it somehow (a good first step would be to improve the error message to include the value of Also, another test failed on Travis, but I cannot reproduce this locally.
A random guess would be: The test uses Urgh. Another synchronisation issue that I stepped into. :-( Edit: Actually, its worse than that. The test (de)activates num lock, which means that keys are regrabbed. What prevents the following sequence of events?
The above is quite unlikely in the current tests since all the xtest requests should be sent with a single Perhaps this needs a |
This adds a test case that tests that i3 does something quickly. With current
next
, the test needs 13 seconds on my computer and fails. That's not quick. The following commits fix this by batching "the keyboard changed"-stuff: Instead of executing this code once per event we receive, this is now only done once per main loop iteration.This might or might not fix #3924 (no idea - I only tested with my new test case), hence CC @sammko
Also, I have no clue how to write test cases. I do not really know perl and I did not figure out the numbering scheme (thus went with 600). Perhaps this even has to handle the case "
xmodmap
is not installed" somehow? Dunno.The test uses a time limit of two seconds because
time()
only provides second granularity. Limiting this to one second could cause failures where the current time isx.99999
when the test starts and(x+1).000001
when the test finishes. This would already look like a one second time difference. Allowing two seconds thus seemed the safest option to me.Finally: IMO I am using way too many static variables for this, but let's see what you guys say about this.