Skip to content

Commit

Permalink
add ratelimit to main event loop
Browse files Browse the repository at this point in the history
Signed-off-by: Dušan Uverić <[email protected]>
  • Loading branch information
uvera committed May 6, 2021
1 parent 142003c commit 8136222
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion instantwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3875,11 +3875,19 @@ void
run(void)
{
XEvent ev;
int ratelimit = 200;
int currentrate = 0;
/* main event loop */
XSync(dpy, False);
while (running && !XNextEvent(dpy, &ev))
if (handler[ev.type] && XEventsQueued(dpy, QueuedAlready) < 125)
{
currentrate = XEventsQueued(dpy, QueuedAlready);
if (handler[ev.type] && currentrate < ratelimit)
{
handler[ev.type](&ev); /* call handler */
ratelimit = currentrate > 150 ? 10 : 200;
}
}
}

void
Expand Down

0 comments on commit 8136222

Please sign in to comment.