diff --git a/src/core/constraints.c b/src/core/constraints.c index 58bdd3cd6..4017ecbe0 100644 --- a/src/core/constraints.c +++ b/src/core/constraints.c @@ -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 diff --git a/src/core/constraints.h b/src/core/constraints.h index 87ea47284..3960a366a 100644 --- a/src/core/constraints.h +++ b/src/core/constraints.h @@ -27,6 +27,7 @@ void meta_window_constrain (MetaWindow *window, MetaMoveResizeFlags flags, + MetaPlaceFlag place_flags, MetaGravity resize_gravity, const MtkRectangle *orig, MtkRectangle *new, diff --git a/src/core/place.c b/src/core/place.c index 078cea510..feb5c4cbf 100644 --- a/src/core/place.c +++ b/src/core/place.c @@ -384,9 +384,10 @@ window_place_centered (MetaWindow *window) } static void -avoid_being_obscured_as_second_modal_dialog (MetaWindow *window, - int *x, - int *y) +avoid_being_obscured_as_second_modal_dialog (MetaWindow *window, + MetaPlaceFlag flags, + int *x, + int *y) { /* We can't center this dialog if it was denied focus and it * overlaps with the focus window and this dialog is modal and this @@ -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; diff --git a/src/core/place.h b/src/core/place.h index 7e8887c75..d29e71105 100644 --- a/src/core/place.h +++ b/src/core/place.h @@ -28,8 +28,9 @@ void meta_window_process_placement (MetaWindow *window, int *rel_x, int *rel_y); -void meta_window_place (MetaWindow *window, - int x, - int y, - int *new_x, - int *new_y); +void meta_window_place (MetaWindow *window, + MetaPlaceFlag place_flags, + int x, + int y, + int *new_x, + int *new_y); diff --git a/src/core/window-private.h b/src/core/window-private.h index f9b2aa024..d13b23c2b 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -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); @@ -818,8 +823,8 @@ 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); +void meta_window_force_placement (MetaWindow *window, + MetaPlaceFlag flags); void meta_window_force_restore_shortcuts (MetaWindow *window, ClutterInputDevice *source); diff --git a/src/core/window.c b/src/core/window.c index 576c3d3b2..3e06108e0 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -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; @@ -2069,8 +2068,8 @@ window_would_be_covered_by_always_above_window (MetaWindow *window) } void -meta_window_force_placement (MetaWindow *window, - gboolean force_move) +meta_window_force_placement (MetaWindow *window, + 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 diff --git a/src/wayland/meta-wayland-xdg-shell.c b/src/wayland/meta-wayland-xdg-shell.c index 277c2bbc8..523f0900c 100644 --- a/src/wayland/meta-wayland-xdg-shell.c +++ b/src/wayland/meta-wayland-xdg-shell.c @@ -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); } diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c index 0c53883e6..f3e05b13f 100644 --- a/src/wayland/meta-window-wayland.c +++ b/src/wayland/meta-window-wayland.c @@ -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; diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index adf5075a9..d02427f9e 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -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); } }