xwayland: flush XCB connection to mitigate race between Raise and input
Some checks are pending
labwc.github.io / notify (push) Waiting to run

This commit is contained in:
John Lindgren 2025-12-02 13:33:07 -05:00 committed by Consolatis
parent c4277ab507
commit d748dc78bc
3 changed files with 24 additions and 0 deletions

View file

@ -77,5 +77,7 @@ void xwayland_update_workarea(struct server *server);
void xwayland_reset_cursor(struct server *server);
void xwayland_flush(struct server *server);
#endif /* HAVE_XWAYLAND */
#endif /* LABWC_XWAYLAND_H */

View file

@ -35,6 +35,7 @@
#if HAVE_XWAYLAND
#include <wlr/xwayland.h>
#include "xwayland.h"
#endif
struct view *
@ -2247,6 +2248,17 @@ view_move_to_front(struct view *view)
move_to_front(view);
}
#if HAVE_XWAYLAND
/*
* view_move_to_front() is typically called on each mouse press
* via Raise action. This means we are restacking windows just
* about at the same time we send the mouse press input to the
* X server, and creates a race where the mouse press could go
* to an incorrect X window depending on timing. To mitigate the
* race, perform an explicit flush after restacking.
*/
xwayland_flush(view->server);
#endif
cursor_update_focus(view->server);
desktop_update_top_layer_visibility(view->server);
}

View file

@ -1438,3 +1438,13 @@ xwayland_update_workarea(struct server *server)
};
wlr_xwayland_set_workareas(server->xwayland, &workarea, 1);
}
void
xwayland_flush(struct server *server)
{
if (!server->xwayland || !server->xwayland->xwm) {
return;
}
xcb_flush(wlr_xwayland_get_xwm_connection(server->xwayland));
}