gtk4-layer-shell icon indicating copy to clipboard operation
gtk4-layer-shell copied to clipboard

Fix protocol error caused by sending xdg_shell configure events too early

Open Ferdi265 opened this issue 1 year ago • 3 comments

This PR fixes issue #34.

Sending xdg_toplevel->configure and xdg_surface->configure before receiving zwlr_layer_shell_surface_v1->configure causes GTK to think the surface is already configured and can result in GTK attaching a buffer too early. This causes a protocol error as buffers can only be attached to surfaces that have been configured.

See more in the discussion of the linked issue.

Ferdi265 avatar Sep 17 '24 22:09 Ferdi265

Note: this doesn't completely fix the issue. Testing with the SwayOSD GTK4 port shows that changing output scale sometimes still leads to protocol errors after hiding and showing the window again. I suppose this doesn't only have to do with the initial configure, but likely all configures. Needs further debugging.

Crash log

It looks like the second time (with a new layer_surface but the same wl_surface) there is no configure event and GTK attaches a buffer anyway, need to add logging from inside gtk4-layer-shell again to confirm this.

Ferdi265 avatar Sep 17 '24 22:09 Ferdi265

Note: this doesn't completely fix the issue. Testing with the SwayOSD GTK4 port shows that changing output scale sometimes still leads to protocol errors after hiding and showing the window again

I failed to notice that a zwlr_layer_surface can get destroyed and recreated during the lifetime of a gtk4_layer_shell layer_surface. Resetting the has_initial_layer_shell_configure flag when creating a new zwlr_layer_surface fixes the issue.

Ferdi265 avatar Sep 20 '24 23:09 Ferdi265

Should be ok to review now.

Ferdi265 avatar Sep 20 '24 23:09 Ferdi265