window: Make the caller decide when to constrain
There were some magic conditions that decided when meta_window_constrain() was to be called or not. Reasoning about and changing these conditions were complicated, and in practice the caller knows when constraining should be done. Lets change things by adding a 'constrain' flag to the move-resize flags that makes this clearer. This way we can, if needed, have better control of when a window is constrained or not without leaking that logic into the generic to-constrain-or-not expression. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2338>
This commit is contained in:
parent
6238099bac
commit
f4645b0a37
4 changed files with 38 additions and 20 deletions
|
@ -73,6 +73,7 @@ typedef enum
|
|||
META_MOVE_RESIZE_FORCE_UPDATE_MONITOR = 1 << 10,
|
||||
META_MOVE_RESIZE_PLACEMENT_CHANGED = 1 << 11,
|
||||
META_MOVE_RESIZE_WAYLAND_CLIENT_RESIZE = 1 << 12,
|
||||
META_MOVE_RESIZE_CONSTRAIN = 1 << 13,
|
||||
} MetaMoveResizeFlags;
|
||||
|
||||
typedef enum
|
||||
|
|
|
@ -2120,7 +2120,9 @@ meta_window_force_placement (MetaWindow *window,
|
|||
*/
|
||||
window->calc_placement = TRUE;
|
||||
|
||||
flags = META_MOVE_RESIZE_MOVE_ACTION | META_MOVE_RESIZE_RESIZE_ACTION;
|
||||
flags = (META_MOVE_RESIZE_MOVE_ACTION |
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_CONSTRAIN);
|
||||
if (force_move)
|
||||
flags |= META_MOVE_RESIZE_FORCE_MOVE;
|
||||
|
||||
|
@ -2681,7 +2683,8 @@ meta_window_maximize (MetaWindow *window,
|
|||
meta_window_move_resize_internal (window,
|
||||
(META_MOVE_RESIZE_MOVE_ACTION |
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_STATE_CHANGED),
|
||||
META_MOVE_RESIZE_STATE_CHANGED |
|
||||
META_MOVE_RESIZE_CONSTRAIN),
|
||||
META_GRAVITY_NORTH_WEST,
|
||||
window->unconstrained_rect);
|
||||
}
|
||||
|
@ -2949,7 +2952,8 @@ meta_window_tile (MetaWindow *window,
|
|||
meta_window_move_resize_internal (window,
|
||||
(META_MOVE_RESIZE_MOVE_ACTION |
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_STATE_CHANGED),
|
||||
META_MOVE_RESIZE_STATE_CHANGED |
|
||||
META_MOVE_RESIZE_CONSTRAIN),
|
||||
META_GRAVITY_NORTH_WEST,
|
||||
window->unconstrained_rect);
|
||||
|
||||
|
@ -3275,7 +3279,8 @@ meta_window_make_fullscreen (MetaWindow *window)
|
|||
meta_window_move_resize_internal (window,
|
||||
(META_MOVE_RESIZE_MOVE_ACTION |
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_STATE_CHANGED),
|
||||
META_MOVE_RESIZE_STATE_CHANGED |
|
||||
META_MOVE_RESIZE_CONSTRAIN),
|
||||
META_GRAVITY_NORTH_WEST,
|
||||
window->unconstrained_rect);
|
||||
}
|
||||
|
@ -3581,7 +3586,8 @@ meta_window_reposition (MetaWindow *window)
|
|||
{
|
||||
meta_window_move_resize_internal (window,
|
||||
(META_MOVE_RESIZE_MOVE_ACTION |
|
||||
META_MOVE_RESIZE_RESIZE_ACTION),
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_CONSTRAIN),
|
||||
META_GRAVITY_NORTH_WEST,
|
||||
window->rect);
|
||||
}
|
||||
|
@ -3855,10 +3861,7 @@ meta_window_move_resize_internal (MetaWindow *window,
|
|||
|
||||
constrained_rect = unconstrained_rect;
|
||||
temporary_rect = window->rect;
|
||||
if (flags & (META_MOVE_RESIZE_MOVE_ACTION | META_MOVE_RESIZE_RESIZE_ACTION) &&
|
||||
!(flags & META_MOVE_RESIZE_WAYLAND_FINISH_MOVE_RESIZE) &&
|
||||
!(flags & (META_MOVE_RESIZE_UNMAXIMIZE | META_MOVE_RESIZE_UNFULLSCREEN)) &&
|
||||
window->monitor)
|
||||
if (flags & META_MOVE_RESIZE_CONSTRAIN && window->monitor)
|
||||
{
|
||||
MetaRectangle old_rect;
|
||||
meta_window_get_frame_rect (window, &old_rect);
|
||||
|
@ -3989,7 +3992,9 @@ meta_window_move_frame (MetaWindow *window,
|
|||
|
||||
g_return_if_fail (!window->override_redirect);
|
||||
|
||||
flags = (user_op ? META_MOVE_RESIZE_USER_ACTION : 0) | META_MOVE_RESIZE_MOVE_ACTION;
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -4020,9 +4025,10 @@ meta_window_move_between_rects (MetaWindow *window,
|
|||
window->saved_rect.y = window->unconstrained_rect.y;
|
||||
|
||||
meta_window_move_resize_internal (window,
|
||||
move_resize_flags |
|
||||
META_MOVE_RESIZE_MOVE_ACTION |
|
||||
META_MOVE_RESIZE_RESIZE_ACTION,
|
||||
(move_resize_flags |
|
||||
META_MOVE_RESIZE_MOVE_ACTION |
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_CONSTRAIN),
|
||||
META_GRAVITY_NORTH_WEST,
|
||||
window->unconstrained_rect);
|
||||
}
|
||||
|
@ -4052,7 +4058,10 @@ meta_window_move_resize_frame (MetaWindow *window,
|
|||
|
||||
g_return_if_fail (!window->override_redirect);
|
||||
|
||||
flags = (user_op ? META_MOVE_RESIZE_USER_ACTION : 0) | META_MOVE_RESIZE_MOVE_ACTION | META_MOVE_RESIZE_RESIZE_ACTION;
|
||||
flags = ((user_op ? META_MOVE_RESIZE_USER_ACTION : 0) |
|
||||
META_MOVE_RESIZE_MOVE_ACTION |
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_CONSTRAIN);
|
||||
|
||||
meta_window_move_resize_internal (window, flags, META_GRAVITY_NORTH_WEST, rect);
|
||||
}
|
||||
|
@ -4161,7 +4170,9 @@ meta_window_resize_frame_with_gravity (MetaWindow *window,
|
|||
meta_window_update_tile_fraction (window, w, h);
|
||||
}
|
||||
|
||||
flags = (user_op ? META_MOVE_RESIZE_USER_ACTION : 0) | META_MOVE_RESIZE_RESIZE_ACTION;
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1119,7 +1119,8 @@ meta_window_place_with_placement_rule (MetaWindow *window,
|
|||
meta_window_move_resize_internal (window,
|
||||
(META_MOVE_RESIZE_MOVE_ACTION |
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_PLACEMENT_CHANGED),
|
||||
META_MOVE_RESIZE_PLACEMENT_CHANGED |
|
||||
META_MOVE_RESIZE_CONSTRAIN),
|
||||
META_GRAVITY_NORTH_WEST,
|
||||
window->unconstrained_rect);
|
||||
window->calc_placement = FALSE;
|
||||
|
|
|
@ -507,7 +507,9 @@ meta_window_apply_session_info (MetaWindow *window,
|
|||
window->size_hints.win_gravity = info->gravity;
|
||||
gravity = window->size_hints.win_gravity;
|
||||
|
||||
flags = META_MOVE_RESIZE_MOVE_ACTION | META_MOVE_RESIZE_RESIZE_ACTION;
|
||||
flags = (META_MOVE_RESIZE_MOVE_ACTION |
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_CONSTRAIN);
|
||||
|
||||
adjust_for_gravity (window, FALSE, gravity, &rect);
|
||||
meta_window_client_rect_to_frame_rect (window, &rect, &rect);
|
||||
|
@ -575,7 +577,10 @@ meta_window_x11_manage (MetaWindow *window)
|
|||
rect.width = window->size_hints.width;
|
||||
rect.height = window->size_hints.height;
|
||||
|
||||
flags = META_MOVE_RESIZE_CONFIGURE_REQUEST | META_MOVE_RESIZE_MOVE_ACTION | META_MOVE_RESIZE_RESIZE_ACTION;
|
||||
flags = (META_MOVE_RESIZE_CONFIGURE_REQUEST |
|
||||
META_MOVE_RESIZE_MOVE_ACTION |
|
||||
META_MOVE_RESIZE_RESIZE_ACTION |
|
||||
META_MOVE_RESIZE_CONSTRAIN);
|
||||
|
||||
adjust_for_gravity (window, TRUE, gravity, &rect);
|
||||
meta_window_client_rect_to_frame_rect (window, &rect, &rect);
|
||||
|
@ -2700,9 +2705,9 @@ meta_window_move_resize_request (MetaWindow *window,
|
|||
*/
|
||||
flags = META_MOVE_RESIZE_CONFIGURE_REQUEST;
|
||||
if (value_mask & (CWX | CWY))
|
||||
flags |= META_MOVE_RESIZE_MOVE_ACTION;
|
||||
flags |= META_MOVE_RESIZE_MOVE_ACTION | META_MOVE_RESIZE_CONSTRAIN;
|
||||
if (value_mask & (CWWidth | CWHeight))
|
||||
flags |= META_MOVE_RESIZE_RESIZE_ACTION;
|
||||
flags |= META_MOVE_RESIZE_RESIZE_ACTION | META_MOVE_RESIZE_CONSTRAIN;
|
||||
|
||||
if (flags & (META_MOVE_RESIZE_MOVE_ACTION | META_MOVE_RESIZE_RESIZE_ACTION))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue