window: Add place flags

Replace a boolean argument and a temporary MetaWindow struct field with
a `MetaPlaceFlag` passed where relevant. This includes
`meta_window_move_resize_internal()` and `meta_window_constrain()`, as
placement may happen during constraining, and also
`meta_window_force_placement()`.

The struct field (denied_focus_and_not_transient) was only ever set in
meta_window_show(), before meta_window_force_placement(), and
immediately unset as a side effect of that. In .._show() we'll always
force placement if the window wasn't already placed, and in
meta_window_constrain(), we'd only ever call meta_window_place() if the
window wasn't already placed, meaning the variable would only ever be
relevant during `meta_window_show()`. Having it as a flag makes that
relationship and temporary state clearer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3879>
This commit is contained in:
Jonas Ådahl
2024-07-11 14:23:26 +02:00
committed by Sebastian Wick
parent f4b79441fa
commit 9ebbf83e95
9 changed files with 88 additions and 41 deletions

View File

@ -220,6 +220,7 @@ static void setup_constraint_info (MetaBackend *backend,
const MtkRectangle *orig,
MtkRectangle *new);
static void place_window_if_needed (MetaWindow *window,
MetaPlaceFlag place_flags,
ConstraintInfo *info);
static void update_onscreen_requirements (MetaWindow *window,
ConstraintInfo *info);
@ -292,6 +293,7 @@ do_all_constraints (MetaWindow *window,
void
meta_window_constrain (MetaWindow *window,
MetaMoveResizeFlags flags,
MetaPlaceFlag place_flags,
MetaGravity resize_gravity,
const MtkRectangle *orig,
MtkRectangle *new,
@ -319,7 +321,7 @@ meta_window_constrain (MetaWindow *window,
resize_gravity,
orig,
new);
place_window_if_needed (window, &info);
place_window_if_needed (window, place_flags, &info);
while (!satisfied && priority <= PRIORITY_MAXIMUM) {
gboolean check_only = TRUE;
@ -532,8 +534,9 @@ get_start_rect_for_resize (MetaWindow *window,
}
static void
place_window_if_needed(MetaWindow *window,
ConstraintInfo *info)
place_window_if_needed (MetaWindow *window,
MetaPlaceFlag place_flags,
ConstraintInfo *info)
{
gboolean did_placement;
@ -576,7 +579,8 @@ place_window_if_needed(MetaWindow *window,
}
else
{
meta_window_place (window, orig_rect.x, orig_rect.y,
meta_window_place (window, place_flags,
orig_rect.x, orig_rect.y,
&placed_rect.x, &placed_rect.y);
/* placing the window may have changed the monitor. Find the