Linux/Wayland: respond to KWin compositor pings to prevent window des…#634
Merged
scottdraves merged 1 commit intoMay 21, 2026
Conversation
…aturation On KDE/KWin Wayland sessions the app window would lose colour saturation after a few seconds of playback. KWin periodically sends an xdg_wm_base ping event and desaturates any window that does not pong back promptly. The pong handler (onXdgWmBasePing → xdg_wm_base_pong) was already wired up correctly, but it never fired because the per-frame pump in checkEvents() only called wl_display_dispatch_pending(), which drains events already in the in-memory queue without reading from the Wayland socket. KWin's ping bytes sat unread on the fd, no pong was sent, and KWin concluded the app was frozen. Fix: replace the bare wl_display_dispatch_pending() call with the documented prepare_read / poll / read_events (or cancel_read) / dispatch_pending idiom. A non-blocking poll(timeout=0) on the Wayland socket fd is performed each frame; if data is available the socket is drained into the event queue before dispatching. This ensures pings are seen and pongs are sent every frame without ever blocking the render loop. Also move #include <poll.h> out of the inner HAVE_LIBDECOR guard into the enclosing HAVE_WAYLAND block, since it is now needed for all Wayland builds regardless of libdecor. Mac and Windows builds are unaffected (all changes are inside #ifdef HAVE_WAYLAND). Fixes e-dream-ai#628. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
Just a quick note, after testing this dockerfile on a fresh Fedora KDE install I found that I had to add python3 and python-is-python3 to the container for the build process to complete. The appimage produced by the following dockerfile works well and no longer reported that it was unresponsive. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…aturation
On KDE/KWin Wayland sessions the app window would lose colour saturation after a few seconds of playback. KWin periodically sends an xdg_wm_base ping event and desaturates any window that does not pong back promptly.
The pong handler (onXdgWmBasePing → xdg_wm_base_pong) was already wired up correctly, but it never fired because the per-frame pump in checkEvents() only called wl_display_dispatch_pending(), which drains events already in the in-memory queue without reading from the Wayland socket. KWin's ping bytes sat unread on the fd, no pong was sent, and KWin concluded the app was frozen.
Fix: replace the bare wl_display_dispatch_pending() call with the documented prepare_read / poll / read_events (or cancel_read) / dispatch_pending idiom. A non-blocking poll(timeout=0) on the Wayland socket fd is performed each frame; if data is available the socket is drained into the event queue before dispatching. This ensures pings are seen and pongs are sent every frame without ever blocking the render loop.
Also move #include <poll.h> out of the inner HAVE_LIBDECOR guard into the enclosing HAVE_WAYLAND block, since it is now needed for all Wayland builds regardless of libdecor.
Mac and Windows builds are unaffected (all changes are inside #ifdef HAVE_WAYLAND).
Fixes #628.