Use utility functions to convert between frame and client rectangles
There are extensive places in the code where we convert between the client rectangle and the frame rectangle. Instead of manually doing it use new helper functions on MetaWindow and the existing meta_window_get_outer_rect(). This fixes a number of bugs where the computation was being done incorrectly, most of these bugs are with the recently added custom frame extents, but some relate to invisible borders or even simply to confusion between the window and frame rectangle. Switch the placement code to place the frame rectangle rather than the client window - this simplifies things considerably. https://bugzilla.gnome.org/show_bug.cgi?id=707194
This commit is contained in:
@ -204,10 +204,10 @@ static void place_window_if_needed (MetaWindow *window,
|
||||
ConstraintInfo *info);
|
||||
static void update_onscreen_requirements (MetaWindow *window,
|
||||
ConstraintInfo *info);
|
||||
static void extend_by_frame (MetaRectangle *rect,
|
||||
const MetaFrameBorders *borders);
|
||||
static void unextend_by_frame (MetaRectangle *rect,
|
||||
const MetaFrameBorders *borders);
|
||||
static void extend_by_frame (MetaWindow *window,
|
||||
MetaRectangle *rect);
|
||||
static void unextend_by_frame (MetaWindow *window,
|
||||
MetaRectangle *rect);
|
||||
static inline void get_size_limits (const MetaWindow *window,
|
||||
const MetaFrameBorders *borders,
|
||||
gboolean include_frame,
|
||||
@ -519,10 +519,11 @@ place_window_if_needed(MetaWindow *window,
|
||||
!window->minimized &&
|
||||
!window->fullscreen)
|
||||
{
|
||||
MetaRectangle placed_rect = info->orig;
|
||||
MetaRectangle placed_rect;
|
||||
MetaWorkspace *cur_workspace;
|
||||
const MetaMonitorInfo *monitor_info;
|
||||
|
||||
meta_window_get_outer_rect (window, &placed_rect);
|
||||
meta_window_place (window, info->borders, info->orig.x, info->orig.y,
|
||||
&placed_rect.x, &placed_rect.y);
|
||||
did_placement = TRUE;
|
||||
@ -541,6 +542,7 @@ place_window_if_needed(MetaWindow *window,
|
||||
meta_workspace_get_onmonitor_region (cur_workspace,
|
||||
monitor_info->number);
|
||||
|
||||
meta_window_frame_rect_to_client_rect (window, &placed_rect, &placed_rect);
|
||||
|
||||
info->current.x = placed_rect.x;
|
||||
info->current.y = placed_rect.y;
|
||||
@ -649,7 +651,7 @@ update_onscreen_requirements (MetaWindow *window,
|
||||
/* The require onscreen/on-single-monitor and titlebar_visible
|
||||
* stuff is relative to the outer window, not the inner
|
||||
*/
|
||||
extend_by_frame (&info->current, info->borders);
|
||||
extend_by_frame (window, &info->current);
|
||||
|
||||
/* Update whether we want future constraint runs to require the
|
||||
* window to be on fully onscreen.
|
||||
@ -698,27 +700,21 @@ update_onscreen_requirements (MetaWindow *window,
|
||||
}
|
||||
|
||||
/* Don't forget to restore the position of the window */
|
||||
unextend_by_frame (&info->current, info->borders);
|
||||
unextend_by_frame (window, &info->current);
|
||||
}
|
||||
|
||||
static void
|
||||
extend_by_frame (MetaRectangle *rect,
|
||||
const MetaFrameBorders *borders)
|
||||
extend_by_frame (MetaWindow *window,
|
||||
MetaRectangle *rect)
|
||||
{
|
||||
rect->x -= borders->visible.left;
|
||||
rect->y -= borders->visible.top;
|
||||
rect->width += borders->visible.left + borders->visible.right;
|
||||
rect->height += borders->visible.top + borders->visible.bottom;
|
||||
meta_window_client_rect_to_frame_rect (window, rect, rect);
|
||||
}
|
||||
|
||||
static void
|
||||
unextend_by_frame (MetaRectangle *rect,
|
||||
const MetaFrameBorders *borders)
|
||||
unextend_by_frame (MetaWindow *window,
|
||||
MetaRectangle *rect)
|
||||
{
|
||||
rect->x += borders->visible.left;
|
||||
rect->y += borders->visible.top;
|
||||
rect->width -= borders->visible.left + borders->visible.right;
|
||||
rect->height -= borders->visible.top + borders->visible.bottom;
|
||||
meta_window_frame_rect_to_client_rect (window, rect, rect);
|
||||
}
|
||||
|
||||
static inline void
|
||||
@ -778,13 +774,13 @@ constrain_modal_dialog (MetaWindow *window,
|
||||
*/
|
||||
|
||||
child_rect = info->current;
|
||||
extend_by_frame (&child_rect, info->borders);
|
||||
extend_by_frame (window, &child_rect);
|
||||
|
||||
meta_window_get_outer_rect (parent, &parent_rect);
|
||||
|
||||
child_rect.x = parent_rect.x + (parent_rect.width / 2 - child_rect.width / 2);
|
||||
child_rect.y = parent_rect.y + (parent_rect.height / 2 - child_rect.height / 2);
|
||||
unextend_by_frame (&child_rect, info->borders);
|
||||
unextend_by_frame (window, &child_rect);
|
||||
x = child_rect.x;
|
||||
y = child_rect.y;
|
||||
|
||||
@ -851,14 +847,14 @@ constrain_maximization (MetaWindow *window,
|
||||
active_workspace_struts = window->screen->active_workspace->all_struts;
|
||||
|
||||
target_size = info->current;
|
||||
extend_by_frame (&target_size, info->borders);
|
||||
extend_by_frame (window, &target_size);
|
||||
meta_rectangle_expand_to_avoiding_struts (&target_size,
|
||||
&info->entire_monitor,
|
||||
direction,
|
||||
active_workspace_struts);
|
||||
}
|
||||
/* Now make target_size = maximized size of client window */
|
||||
unextend_by_frame (&target_size, info->borders);
|
||||
unextend_by_frame (window, &target_size);
|
||||
|
||||
/* Check min size constraints; max size constraints are ignored for maximized
|
||||
* windows, as per bug 327543.
|
||||
@ -917,7 +913,7 @@ constrain_tiling (MetaWindow *window,
|
||||
* use an external function for the actual calculation
|
||||
*/
|
||||
meta_window_get_current_tile_area (window, &target_size);
|
||||
unextend_by_frame (&target_size, info->borders);
|
||||
unextend_by_frame (window, &target_size);
|
||||
|
||||
/* Check min size constraints; max size constraints are ignored as for
|
||||
* maximized windows.
|
||||
@ -1267,7 +1263,7 @@ do_screen_and_monitor_relative_constraints (
|
||||
/* Determine whether constraint applies; exit if it doesn't */
|
||||
how_far_it_can_be_smushed = info->current;
|
||||
get_size_limits (window, info->borders, TRUE, &min_size, &max_size);
|
||||
extend_by_frame (&info->current, info->borders);
|
||||
extend_by_frame (window, &info->current);
|
||||
|
||||
if (info->action_type != ACTION_MOVE)
|
||||
{
|
||||
@ -1287,7 +1283,7 @@ do_screen_and_monitor_relative_constraints (
|
||||
&info->current);
|
||||
if (exit_early || constraint_satisfied || check_only)
|
||||
{
|
||||
unextend_by_frame (&info->current, info->borders);
|
||||
unextend_by_frame (window, &info->current);
|
||||
return constraint_satisfied;
|
||||
}
|
||||
|
||||
@ -1311,7 +1307,7 @@ do_screen_and_monitor_relative_constraints (
|
||||
info->fixed_directions,
|
||||
&info->current);
|
||||
|
||||
unextend_by_frame (&info->current, info->borders);
|
||||
unextend_by_frame (window, &info->current);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user