window: Also consider touching edges for matching tiled windows

When computing a potential match for a tiled window, there is a
chance we face the case where 2 windows really complement each
other's tile mode (i.e. left and right) but they have different
sizes, and their borders don't really touch each other.

In that case, the current code would mistakenly assume they're
tile matches, and would resize them with either a hole or an
overlapping area between windows. This is clearly a misbehavior
that is a consequence of the previous assumptions pre-resizable
tiles.

This patch adapts the tile match algorithm to also consider the
touching edges when computing the matching tile, unless:

 * the window is not currently tiled (for example when computing
   the tile preview)
 * the window is currently resized in tandem with an existing
   tile match

https://bugzilla.gnome.org/show_bug.cgi?id=645153

bar
This commit is contained in:
Georges Basile Stavracas Neto 2017-06-15 21:29:48 -03:00
parent e76a0f564c
commit a1c39e142d

View File

@ -7682,6 +7682,23 @@ meta_window_find_tile_match (MetaWindow *window,
meta_window_get_frame_rect (bottommost, &bottommost_rect);
meta_window_get_frame_rect (topmost, &topmost_rect);
/*
* If we are looking for a tile match while actually being tiled,
* rather than a match for a potential tile mode, then discard
* windows with too much gap or overlap
*/
if (window->tile_mode == current_mode &&
!(meta_grab_op_is_resizing (window->display->grab_op) &&
window->display->grab_window == window &&
window->tile_match != NULL))
{
int threshold = meta_prefs_get_drag_threshold ();
if (ABS (topmost_rect.x - bottommost_rect.x - bottommost_rect.width) > threshold &&
ABS (bottommost_rect.x - topmost_rect.x - topmost_rect.width) > threshold)
return NULL;
}
/*
* If there's a window stacked in between which is partially visible
* behind the topmost tile we don't consider the tiles to match.