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:
parent
f4b79441fa
commit
9ebbf83e95
@ -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,7 +534,8 @@ get_start_rect_for_resize (MetaWindow *window,
|
||||
}
|
||||
|
||||
static void
|
||||
place_window_if_needed(MetaWindow *window,
|
||||
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
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
void meta_window_constrain (MetaWindow *window,
|
||||
MetaMoveResizeFlags flags,
|
||||
MetaPlaceFlag place_flags,
|
||||
MetaGravity resize_gravity,
|
||||
const MtkRectangle *orig,
|
||||
MtkRectangle *new,
|
||||
|
@ -385,6 +385,7 @@ window_place_centered (MetaWindow *window)
|
||||
|
||||
static void
|
||||
avoid_being_obscured_as_second_modal_dialog (MetaWindow *window,
|
||||
MetaPlaceFlag flags,
|
||||
int *x,
|
||||
int *y)
|
||||
{
|
||||
@ -408,7 +409,7 @@ avoid_being_obscured_as_second_modal_dialog (MetaWindow *window,
|
||||
|
||||
/* denied_focus_and_not_transient is only set when focus_window != NULL */
|
||||
|
||||
if (window->denied_focus_and_not_transient &&
|
||||
if (flags & META_PLACE_FLAG_DENIED_FOCUS_AND_NOT_TRANSIENT &&
|
||||
window->type == META_WINDOW_MODAL_DIALOG &&
|
||||
#ifdef HAVE_X11_CLIENT
|
||||
meta_window_x11_same_application (window, focus_window) &&
|
||||
@ -762,6 +763,7 @@ find_windows_relevant_for_placement (MetaWindow *window)
|
||||
|
||||
void
|
||||
meta_window_place (MetaWindow *window,
|
||||
MetaPlaceFlag flags,
|
||||
int x,
|
||||
int y,
|
||||
int *new_x,
|
||||
@ -862,7 +864,7 @@ meta_window_place (MetaWindow *window,
|
||||
{
|
||||
meta_topic (META_DEBUG_PLACEMENT,
|
||||
"Not placing window with PROGRAM_POSITION or USER_POSITION set");
|
||||
avoid_being_obscured_as_second_modal_dialog (window, &x, &y);
|
||||
avoid_being_obscured_as_second_modal_dialog (window, flags, &x, &y);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
@ -897,7 +899,7 @@ meta_window_place (MetaWindow *window,
|
||||
"Centered window %s over transient parent",
|
||||
window->desc);
|
||||
|
||||
avoid_being_obscured_as_second_modal_dialog (window, &x, &y);
|
||||
avoid_being_obscured_as_second_modal_dialog (window, flags, &x, &y);
|
||||
|
||||
goto done;
|
||||
}
|
||||
@ -976,7 +978,7 @@ meta_window_place (MetaWindow *window,
|
||||
* if at all possible. This is guaranteed to only be called if the
|
||||
* focus_window is non-NULL, and we try to avoid that window.
|
||||
*/
|
||||
if (window->denied_focus_and_not_transient)
|
||||
if (flags & META_PLACE_FLAG_DENIED_FOCUS_AND_NOT_TRANSIENT)
|
||||
{
|
||||
MetaWindow *focus_window;
|
||||
gboolean found_fit;
|
||||
|
@ -29,6 +29,7 @@ void meta_window_process_placement (MetaWindow *window,
|
||||
int *rel_y);
|
||||
|
||||
void meta_window_place (MetaWindow *window,
|
||||
MetaPlaceFlag place_flags,
|
||||
int x,
|
||||
int y,
|
||||
int *new_x,
|
||||
|
@ -72,6 +72,13 @@ typedef enum
|
||||
META_MOVE_RESIZE_CONSTRAIN = 1 << 13,
|
||||
} MetaMoveResizeFlags;
|
||||
|
||||
typedef enum _MetaPlaceFlag
|
||||
{
|
||||
META_PLACE_FLAG_NONE = 0,
|
||||
META_PLACE_FLAG_FORCE_MOVE = 1 << 0,
|
||||
META_PLACE_FLAG_DENIED_FOCUS_AND_NOT_TRANSIENT = 1 << 1,
|
||||
} MetaPlaceFlag;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
META_MOVE_RESIZE_RESULT_MOVED = 1 << 0,
|
||||
@ -515,9 +522,6 @@ struct _MetaWindow
|
||||
/* Have we placed this window? */
|
||||
guint placed : 1;
|
||||
|
||||
/* Is this not a transient of the focus window which is being denied focus? */
|
||||
guint denied_focus_and_not_transient : 1;
|
||||
|
||||
/* Has this window not ever been shown yet? */
|
||||
guint showing_for_first_time : 1;
|
||||
|
||||
@ -801,6 +805,7 @@ void meta_window_set_urgent (MetaWindow *window,
|
||||
|
||||
void meta_window_move_resize_internal (MetaWindow *window,
|
||||
MetaMoveResizeFlags flags,
|
||||
MetaPlaceFlag place_flags,
|
||||
MetaGravity gravity,
|
||||
MtkRectangle frame_rect);
|
||||
|
||||
@ -819,7 +824,7 @@ void meta_window_emit_size_changed (MetaWindow *window);
|
||||
MetaPlacementRule *meta_window_get_placement_rule (MetaWindow *window);
|
||||
|
||||
void meta_window_force_placement (MetaWindow *window,
|
||||
gboolean force_move);
|
||||
MetaPlaceFlag flags);
|
||||
|
||||
void meta_window_force_restore_shortcuts (MetaWindow *window,
|
||||
ClutterInputDevice *source);
|
||||
|
@ -1065,7 +1065,6 @@ meta_window_constructed (GObject *object)
|
||||
/* if already mapped we don't want to do the placement thing;
|
||||
* override-redirect windows are placed by the app */
|
||||
window->placed = ((window->mapped && !window->hidden) || window->override_redirect);
|
||||
window->denied_focus_and_not_transient = FALSE;
|
||||
window->unmanaging = FALSE;
|
||||
window->withdrawn = FALSE;
|
||||
window->initial_workspace_set = FALSE;
|
||||
@ -2070,7 +2069,7 @@ window_would_be_covered_by_always_above_window (MetaWindow *window)
|
||||
|
||||
void
|
||||
meta_window_force_placement (MetaWindow *window,
|
||||
gboolean force_move)
|
||||
MetaPlaceFlag place_flags)
|
||||
{
|
||||
MetaMoveResizeFlags flags;
|
||||
|
||||
@ -2090,11 +2089,12 @@ meta_window_force_placement (MetaWindow *window,
|
||||
flags = (META_MOVE_RESIZE_MOVE_ACTION |
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_CONSTRAIN);
|
||||
if (force_move)
|
||||
if (place_flags & META_PLACE_FLAG_FORCE_MOVE)
|
||||
flags |= META_MOVE_RESIZE_FORCE_MOVE;
|
||||
|
||||
meta_window_move_resize_internal (window,
|
||||
flags,
|
||||
place_flags,
|
||||
META_GRAVITY_NORTH_WEST,
|
||||
window->unconstrained_rect);
|
||||
window->calc_placement = FALSE;
|
||||
@ -2104,11 +2104,6 @@ meta_window_force_placement (MetaWindow *window,
|
||||
* still get placed when they are ultimately shown.
|
||||
*/
|
||||
window->placed = TRUE;
|
||||
|
||||
/* Don't want to accidentally reuse the fact that we had been denied
|
||||
* focus in any future constraints unless we're denied focus again.
|
||||
*/
|
||||
window->denied_focus_and_not_transient = FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -2225,7 +2220,7 @@ implement_showing (MetaWindow *window,
|
||||
* see #751887
|
||||
*/
|
||||
if (!window->placed && window_has_buffer (window))
|
||||
meta_window_force_placement (window, FALSE);
|
||||
meta_window_force_placement (window, META_PLACE_FLAG_NONE);
|
||||
|
||||
meta_window_hide (window);
|
||||
|
||||
@ -2258,6 +2253,7 @@ meta_window_show (MetaWindow *window)
|
||||
gboolean needs_stacking_adjustment;
|
||||
MetaWindow *focus_window;
|
||||
gboolean notify_demands_attention = FALSE;
|
||||
MetaPlaceFlag place_flags = META_PLACE_FLAG_NONE;
|
||||
|
||||
meta_topic (META_DEBUG_WINDOW_STATE,
|
||||
"Showing window %s, iconic: %d placed: %d",
|
||||
@ -2294,7 +2290,7 @@ meta_window_show (MetaWindow *window)
|
||||
{
|
||||
needs_stacking_adjustment = TRUE;
|
||||
if (!window->placed)
|
||||
window->denied_focus_and_not_transient = TRUE;
|
||||
place_flags |= META_PLACE_FLAG_DENIED_FOCUS_AND_NOT_TRANSIENT;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2314,7 +2310,7 @@ meta_window_show (MetaWindow *window)
|
||||
window->maximize_vertically_after_placement = TRUE;
|
||||
}
|
||||
}
|
||||
meta_window_force_placement (window, FALSE);
|
||||
meta_window_force_placement (window, place_flags);
|
||||
}
|
||||
|
||||
if (needs_stacking_adjustment)
|
||||
@ -2779,6 +2775,7 @@ meta_window_maximize (MetaWindow *window,
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_STATE_CHANGED |
|
||||
META_MOVE_RESIZE_CONSTRAIN),
|
||||
META_PLACE_FLAG_NONE,
|
||||
META_GRAVITY_NORTH_WEST,
|
||||
window->unconstrained_rect);
|
||||
}
|
||||
@ -3064,6 +3061,7 @@ meta_window_tile (MetaWindow *window,
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_STATE_CHANGED |
|
||||
META_MOVE_RESIZE_CONSTRAIN),
|
||||
META_PLACE_FLAG_NONE,
|
||||
META_GRAVITY_NORTH_WEST,
|
||||
window->unconstrained_rect);
|
||||
}
|
||||
@ -3276,6 +3274,7 @@ meta_window_unmaximize (MetaWindow *window,
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_STATE_CHANGED |
|
||||
META_MOVE_RESIZE_UNMAXIMIZE),
|
||||
META_PLACE_FLAG_NONE,
|
||||
META_GRAVITY_NORTH_WEST,
|
||||
target_rect);
|
||||
|
||||
@ -3374,6 +3373,7 @@ meta_window_make_fullscreen (MetaWindow *window)
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_STATE_CHANGED |
|
||||
META_MOVE_RESIZE_CONSTRAIN),
|
||||
META_PLACE_FLAG_NONE,
|
||||
META_GRAVITY_NORTH_WEST,
|
||||
window->unconstrained_rect);
|
||||
}
|
||||
@ -3422,6 +3422,7 @@ meta_window_unmake_fullscreen (MetaWindow *window)
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_STATE_CHANGED |
|
||||
META_MOVE_RESIZE_UNFULLSCREEN),
|
||||
META_PLACE_FLAG_NONE,
|
||||
META_GRAVITY_NORTH_WEST,
|
||||
target_rect);
|
||||
|
||||
@ -3628,6 +3629,7 @@ meta_window_reposition (MetaWindow *window)
|
||||
(META_MOVE_RESIZE_MOVE_ACTION |
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_CONSTRAIN),
|
||||
META_PLACE_FLAG_NONE,
|
||||
META_GRAVITY_NORTH_WEST,
|
||||
window->rect);
|
||||
}
|
||||
@ -3839,6 +3841,7 @@ meta_window_update_monitor (MetaWindow *window,
|
||||
void
|
||||
meta_window_move_resize_internal (MetaWindow *window,
|
||||
MetaMoveResizeFlags flags,
|
||||
MetaPlaceFlag place_flags,
|
||||
MetaGravity gravity,
|
||||
MtkRectangle frame_rect)
|
||||
{
|
||||
@ -3930,6 +3933,7 @@ meta_window_move_resize_internal (MetaWindow *window,
|
||||
|
||||
meta_window_constrain (window,
|
||||
flags,
|
||||
place_flags,
|
||||
gravity,
|
||||
&old_rect,
|
||||
&constrained_rect,
|
||||
@ -4063,7 +4067,11 @@ meta_window_move_frame (MetaWindow *window,
|
||||
flags = ((user_op ? META_MOVE_RESIZE_USER_ACTION : 0) |
|
||||
META_MOVE_RESIZE_MOVE_ACTION |
|
||||
META_MOVE_RESIZE_CONSTRAIN);
|
||||
meta_window_move_resize_internal (window, flags, META_GRAVITY_NORTH_WEST, rect);
|
||||
meta_window_move_resize_internal (window,
|
||||
flags,
|
||||
META_PLACE_FLAG_NONE,
|
||||
META_GRAVITY_NORTH_WEST,
|
||||
rect);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -4123,6 +4131,7 @@ meta_window_move_between_rects (MetaWindow *window,
|
||||
META_MOVE_RESIZE_MOVE_ACTION |
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_CONSTRAIN),
|
||||
META_PLACE_FLAG_NONE,
|
||||
META_GRAVITY_NORTH_WEST,
|
||||
window->unconstrained_rect);
|
||||
}
|
||||
@ -4157,7 +4166,11 @@ meta_window_move_resize_frame (MetaWindow *window,
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_CONSTRAIN);
|
||||
|
||||
meta_window_move_resize_internal (window, flags, META_GRAVITY_NORTH_WEST, rect);
|
||||
meta_window_move_resize_internal (window,
|
||||
flags,
|
||||
META_PLACE_FLAG_NONE,
|
||||
META_GRAVITY_NORTH_WEST,
|
||||
rect);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4276,7 +4289,11 @@ meta_window_resize_frame_with_gravity (MetaWindow *window,
|
||||
flags = ((user_op ? META_MOVE_RESIZE_USER_ACTION : 0) |
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_CONSTRAIN);
|
||||
meta_window_move_resize_internal (window, flags, gravity, rect);
|
||||
meta_window_move_resize_internal (window,
|
||||
flags,
|
||||
META_PLACE_FLAG_NONE,
|
||||
gravity,
|
||||
rect);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -471,7 +471,7 @@ xdg_toplevel_set_maximized (struct wl_client *client,
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
meta_window_force_placement (window, TRUE);
|
||||
meta_window_force_placement (window, META_PLACE_FLAG_FORCE_MOVE);
|
||||
meta_window_maximize (window, META_MAXIMIZE_BOTH);
|
||||
}
|
||||
|
||||
|
@ -1266,7 +1266,11 @@ meta_window_wayland_finish_move_resize (MetaWindow *window,
|
||||
gravity = meta_resize_gravity_from_grab_op (meta_window_drag_get_grab_op (window_drag));
|
||||
else
|
||||
gravity = META_GRAVITY_STATIC;
|
||||
meta_window_move_resize_internal (window, flags, gravity, rect);
|
||||
meta_window_move_resize_internal (window,
|
||||
flags,
|
||||
META_PLACE_FLAG_NONE,
|
||||
gravity,
|
||||
rect);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1292,6 +1296,7 @@ meta_window_place_with_placement_rule (MetaWindow *window,
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_PLACEMENT_CHANGED |
|
||||
META_MOVE_RESIZE_CONSTRAIN),
|
||||
META_PLACE_FLAG_NONE,
|
||||
META_GRAVITY_NORTH_WEST,
|
||||
window->unconstrained_rect);
|
||||
window->calc_placement = FALSE;
|
||||
|
@ -544,7 +544,11 @@ meta_window_apply_session_info (MetaWindow *window,
|
||||
|
||||
adjust_for_gravity (window, FALSE, gravity, &rect);
|
||||
meta_window_client_rect_to_frame_rect (window, &rect, &rect);
|
||||
meta_window_move_resize_internal (window, flags, gravity, rect);
|
||||
meta_window_move_resize_internal (window,
|
||||
flags,
|
||||
META_PLACE_FLAG_NONE,
|
||||
gravity,
|
||||
rect);
|
||||
}
|
||||
}
|
||||
|
||||
@ -624,7 +628,11 @@ meta_window_x11_initialize_state (MetaWindow *window)
|
||||
|
||||
adjust_for_gravity (window, TRUE, gravity, &rect);
|
||||
meta_window_client_rect_to_frame_rect (window, &rect, &rect);
|
||||
meta_window_move_resize_internal (window, flags, gravity, rect);
|
||||
meta_window_move_resize_internal (window,
|
||||
flags,
|
||||
META_PLACE_FLAG_NONE,
|
||||
gravity,
|
||||
rect);
|
||||
}
|
||||
|
||||
meta_window_x11_update_shape_region (window);
|
||||
@ -2911,7 +2919,11 @@ meta_window_move_resize_request (MetaWindow *window,
|
||||
|
||||
adjust_for_gravity (window, TRUE, gravity, &rect);
|
||||
meta_window_client_rect_to_frame_rect (window, &rect, &rect);
|
||||
meta_window_move_resize_internal (window, flags, gravity, rect);
|
||||
meta_window_move_resize_internal (window,
|
||||
flags,
|
||||
META_PLACE_FLAG_NONE,
|
||||
gravity,
|
||||
rect);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user