core/window: Move size hints to dedicated function

https://gitlab.gnome.org/GNOME/mutter/merge_requests/801#note_676932
This commit is contained in:
Christian Rauch 2020-01-04 21:03:53 +00:00 committed by Jonas Ådahl
parent 20519a1486
commit 3faea8532c

View File

@ -3273,6 +3273,15 @@ unmaximize_window_before_freeing (MetaWindow *window)
#endif #endif
} }
static void
meta_window_maybe_apply_size_hints (MetaWindow *window,
MetaRectangle *target_rect)
{
meta_window_frame_rect_to_client_rect (window, target_rect, target_rect);
ensure_size_hints_satisfied (target_rect, &window->size_hints);
meta_window_client_rect_to_frame_rect (window, target_rect, target_rect);
}
void void
meta_window_unmaximize (MetaWindow *window, meta_window_unmaximize (MetaWindow *window,
MetaMaximizeFlags directions) MetaMaximizeFlags directions)
@ -3299,6 +3308,7 @@ meta_window_unmaximize (MetaWindow *window,
MetaRectangle target_rect; MetaRectangle target_rect;
MetaRectangle work_area; MetaRectangle work_area;
MetaRectangle old_frame_rect, old_buffer_rect; MetaRectangle old_frame_rect, old_buffer_rect;
gboolean has_target_size;
meta_window_get_work_area_for_monitor (window, window->monitor->number, &work_area); meta_window_get_work_area_for_monitor (window, window->monitor->number, &work_area);
meta_window_get_frame_rect (window, &old_frame_rect); meta_window_get_frame_rect (window, &old_frame_rect);
@ -3371,12 +3381,9 @@ meta_window_unmaximize (MetaWindow *window,
* saved_rect invalid. #329152 * saved_rect invalid. #329152
* Do not enforce limits, if no previous 'saved_rect' has been stored. * Do not enforce limits, if no previous 'saved_rect' has been stored.
*/ */
if (target_rect.width > 0 && target_rect.height > 0) has_target_size = (target_rect.width > 0 && target_rect.height > 0);
{ if (has_target_size)
meta_window_frame_rect_to_client_rect (window, &target_rect, &target_rect); meta_window_maybe_apply_size_hints (window, &target_rect);
ensure_size_hints_satisfied (&target_rect, &window->size_hints);
meta_window_client_rect_to_frame_rect (window, &target_rect, &target_rect);
}
meta_compositor_size_change_window (window->display->compositor, window, meta_compositor_size_change_window (window->display->compositor, window,
META_SIZE_CHANGE_UNMAXIMIZE, META_SIZE_CHANGE_UNMAXIMIZE,
@ -3517,6 +3524,7 @@ meta_window_unmake_fullscreen (MetaWindow *window)
if (window->fullscreen) if (window->fullscreen)
{ {
MetaRectangle old_frame_rect, old_buffer_rect, target_rect; MetaRectangle old_frame_rect, old_buffer_rect, target_rect;
gboolean has_target_size;
meta_topic (META_DEBUG_WINDOW_OPS, meta_topic (META_DEBUG_WINDOW_OPS,
"Unfullscreening %s", window->desc); "Unfullscreening %s", window->desc);
@ -3532,12 +3540,9 @@ meta_window_unmake_fullscreen (MetaWindow *window)
* saved_rect invalid. #329152 * saved_rect invalid. #329152
* Do not enforce limits, if no previous 'saved_rect' has been stored. * Do not enforce limits, if no previous 'saved_rect' has been stored.
*/ */
if (target_rect.width > 0 && target_rect.height > 0) has_target_size = (target_rect.width > 0 && target_rect.height > 0);
{ if (has_target_size)
meta_window_frame_rect_to_client_rect (window, &target_rect, &target_rect); meta_window_maybe_apply_size_hints (window, &target_rect);
ensure_size_hints_satisfied (&target_rect, &window->size_hints);
meta_window_client_rect_to_frame_rect (window, &target_rect, &target_rect);
}
/* Need to update window->has_resize_func before we move_resize() /* Need to update window->has_resize_func before we move_resize()
*/ */