xwayland: rework setting initial geometry from surface

The basic idea is to set the initial geometry from the surface exactly
once, just before we need it, i.e. either (1) when mapping the view or
(2) right before processing an initial maximize/fullscreen request.

I've consolidated various parts of the initial geometry setup to take
place at this point (in ensure_initial_geometry_and_output()).

The main motivation is to have a valid, adjusted floating geometry for
the view *before* saving the natural geometry when processing an initial
maximize/fullscreen request. This reduces code duplication and addresses
a FIXME in set_initial_position(), as well as fixing an issue where the
natural geometry could exceed the usable output area.

Some other minor changes:

- The initial output is now set directly from the surface geometry if
  the "application/user-set position" hint is given. This is unlikely
  to matter in practice, but theoretically an initially maximized view
  could now appear on a different (application-chosen) output.

- Floating view size is now constrained to the usable area even if a
  position hint is set. It seemed inconsistent that `xterm -g 200x200`
  was constrained but `xterm -g 200x200+0+0` was not.
This commit is contained in:
John Lindgren 2026-03-10 14:35:36 -04:00 committed by Johan Malm
parent d4ad27e636
commit 9903331995
2 changed files with 81 additions and 93 deletions

View file

@ -39,6 +39,7 @@ struct xwayland_view {
struct view base;
struct wlr_xwayland_surface *xwayland_surface;
bool focused_before_map;
bool initial_geometry_set;
/* Events unique to XWayland views */
struct wl_listener associate;