christolliday / limn

Experimental cross platform GUI library
Other
404 stars 19 forks source link

Fix flickering when resizing the window #36

Closed Diggsey closed 6 years ago

Diggsey commented 6 years ago

The back-buffer must be updated before processing the next window event, or else the window flickers whilst resizing.

christolliday commented 6 years ago

Hey thanks for the PR!

I'm guessing you're seeing the flickering on Windows? I just tested it on Windows and saw the window flickering there, and this does fix it.

On X11 there is no flickering which is why I haven't seen this issue. Unfortunately this change also causes an issue on X11 where the layout updating lags way behind redrawing, not sure why this only happens on X11 to be honest, but it looks much worse than the flickering I've seen on Windows.

I'm going to close this because of the X11 issue, and because the work I think needs to be done is more substantial, I just opened #38 to outline what I think is needed, let me know if you have any input on that issue.

Diggsey commented 6 years ago

@christolliday I can see the issue on X11 you are referring to, but for me it happens both with and without this change. I believe it's caused by the use of events_loop.run_forever, which will block until some event is received: in this case, it's possible to resize the window, and then the layout doesn't update until the mouse is moved (causing an event).

christolliday commented 6 years ago

That is weird.. Yeah run_forever will block waiting for an event, except the resize event should trigger the layout update events which should all be handled before drawing and before putting the event loop to sleep again.

For me it doesn't completely stop until a mouse event is received, it's only delayed by a lot, and only with this change. Not sure why it would stop entirely on your end, I'm guessing it's another winit bug but I could be wrong.

Diggsey commented 6 years ago

Yeah, I'm hoping to get this PR merged: https://github.com/tomaka/winit/pull/237 which will simplify the event loop a lot, or at least will when the new API is exposed via a second PR.