xwayland: notify correct window stacking order to xwayland

Before this commit, when a normal window is raised, xwayland thought it's
above always-on-top (AOT) windows even though it's actually below AOT
windows in the scene. This means mouse scroll events may be unexpectedly
sent to normal windows below AOT windows even when the cursor is hovering
over a AOT window.

So this commit fixes it by notifying the correct stacking order (where AOT
windows are placed above normal windows) to xwayland every time the
stacking order is updated.

Other benefits of this commit are:
- It makes the code more readable and predictable by aggregating logic
  about stacking order management in xwayland (e.g. shaded windows or
  windows in other workspaces should be notified to xwayland as being
  placed at the bottom).
- As server->last_raised_view is removed in the previous commit, we were
  notifying the stacking order to xwayland every time a window with dialog
  windows is clicked (not when clicking a topmost window without dialogs,
  due to some optimization in wlroots). This commit fixes this by caching
  the window stacking order in xwayland_view->stacking_order and notifying
  it to xwayland only when it's updated.
This commit is contained in:
tokyo4j 2025-03-25 16:01:54 +09:00 committed by Hiroaki Yamamoto
parent de49054d75
commit 81204b0537
7 changed files with 112 additions and 116 deletions

View file

@ -59,6 +59,9 @@ struct xwayland_view {
struct view base;
struct wlr_xwayland_surface *xwayland_surface;
/* Used to detect stacking order updates */
int stacking_order;
/* Events unique to XWayland views */
struct wl_listener associate;
struct wl_listener dissociate;