A Smörgåsbord of Problems

submited by
Style Pass
2023-01-24 09:30:07

For the past several days, while combating another flu, I've been polishing Lagrange's dev branch for the v1.15 release. Preparing for a release typically involves solving a series of small(ish) problems. Here's a sampling of what I encountered this time.

Operating systems have fundamental differences when it comes to windowing and event processing. I do most of my development on macOS, so a bunch of small issues typically pop up when testing on Windows, Linux, and *BSD.

SOLUTION: When using a high-resolution mouse with SDL, you receive each and every high-resolution coordinate change as a separate event. This means that you may receive 30 motion events per frame. This is nice and good for a fast-paced game, but for a traditional desktop app it's entirely pointless to handle more than one mouse motion event per frame.

In this case, those 30 motion events each resized the sidebar, rearranged widgets in the window, and reallocated scroll content buffers for both the sidebar and the document area. By the time this was done, the event queue had already grown by several new motion events. The event loop would continue processing motion events without ever breaking for redraw.

Leave a Comment