Skip to content

wayland: Reset Toplevel::surfaceId after surface is created

Vlad Zahorodnii requested to merge work/zzag/xwayland-fix-unmap into master

Xwayland will re-create the wl_surface object if the X11 window is unmapped and mapped. That, and the fact that the order in which the WL_SURFACE_ID client message event is received and the wl_surface object is created is undefined can cause the following bug:

  • WL_SURFACE_ID is received
  • the old wl_surface object is destroyed, m_surfaceId is reset to 0
  • new wl_surface is created but because m_surfaceId is 0, it won't be associated with the x11 window

This change ensures that kwin will associate the wl_surface with x11 window by making it not reset cached surface id when the old wl_surface is destroyed.

However, we cannot leave m_surfaceId as is because wayland aggressively re-uses object ids so kwin can associate wrong surface with x11 window.

To prevent that, this change also makes Toplevel::setSurface() reset cached surface id.

CCBUG: 442936 CCBUG: 426069


Xwayland can re-create the wl_surface if the window has been previously unmapped.

BUG: 442936 BUG: 426069

Edited by Vlad Zahorodnii

Merge request reports