view: avoid restacking when view (or a sub-view) is already in front

Currently, every click within a sub-view results in first restacking
the parent view in front, and then the sub-view. This is unnecessary
and has caused issues in the past, such as with Xaw popups (which
we've worked around in d748dc78bc by adding an xcb_flush()).

It would be better not to do the unnecessary restacking at all.
This commit is contained in:
John Lindgren 2026-01-18 23:56:13 -05:00
parent ee7376421c
commit 2a96c4cdaf

View file

@ -2232,6 +2232,18 @@ void
view_move_to_front(struct view *view)
{
assert(view);
struct server *server = view->server;
assert(!wl_list_empty(&server->views));
/*
* Check whether the view is already in front, or is the root
* parent of the view in front (in which case we don't want to
* raise it in front of its sub-view).
*/
struct view *front = wl_container_of(server->views.next, front, link);
if (view == front || view == view_get_root(front)) {
return;
}
struct view *root = view_get_root(view);
assert(root);