[mutter/wip/gbsneto/tiling-improvements: 14/14] window: Also consider touching edges for matching tiled windows
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/gbsneto/tiling-improvements: 14/14] window: Also consider touching edges for matching tiled windows
- Date: Wed, 12 Jul 2017 02:14:56 +0000 (UTC)
commit 1bbd71d2814bc8cd35ae3ee072978abfff05c900
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Jun 15 21:29:48 2017 -0300
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. The touching
edges, however, are not always considered. They obey the following
rules:
* After successfully resizing or moving, touching edges are
considered.
* When previewing the tile (i.e. when dragging the window to a
corner), touching borders are ignored.
* When actually tiling the window, touching edges are also ignored.
https://bugzilla.gnome.org/show_bug.cgi?id=645153
src/core/constraints.c | 2 ++
src/core/screen.c | 1 +
src/core/stack.c | 3 ++-
src/core/window-private.h | 4 +++-
src/core/window.c | 23 ++++++++++++++++++++---
5 files changed, 28 insertions(+), 5 deletions(-)
---
diff --git a/src/core/constraints.c b/src/core/constraints.c
index 1fa572d..558e43d 100644
--- a/src/core/constraints.c
+++ b/src/core/constraints.c
@@ -947,6 +947,7 @@ constrain_maximization (MetaWindow *window,
META_TILE_MAXIMIZED,
window->tile_mode,
window->monitor->number,
+ FALSE,
&target_size);
}
else if (META_WINDOW_MAXIMIZED (window))
@@ -1038,6 +1039,7 @@ constrain_tiling (MetaWindow *window,
window->tile_mode,
window->tile_mode,
window->tile_monitor_number,
+ TRUE,
&target_size);
/* Check min size constraints; max size constraints are ignored as for
diff --git a/src/core/screen.c b/src/core/screen.c
index 5aa99cc..fdef233 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -1435,6 +1435,7 @@ meta_screen_update_tile_preview_timeout (gpointer data)
window->preview_tile_mode,
window->tile_mode,
monitor,
+ FALSE,
&tile_rect);
meta_compositor_show_tile_preview (screen->display->compositor,
window, &tile_rect, monitor);
diff --git a/src/core/stack.c b/src/core/stack.c
index 01fdc4b..835c024 100644
--- a/src/core/stack.c
+++ b/src/core/stack.c
@@ -271,7 +271,8 @@ meta_stack_update_window_tile_matches (MetaStack *stack,
window->tile_match = meta_window_compute_tile_match (window,
window->tile_mode,
- window->monitor->number);
+ window->monitor->number,
+ TRUE);
tmp = tmp->next;
}
diff --git a/src/core/window-private.h b/src/core/window-private.h
index fc6a398..e40a15a 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -662,6 +662,7 @@ void meta_window_get_tile_area_for_mode (MetaWindow *window,
MetaTileMode mode,
MetaTileMode previous_mode,
guint monitor_number,
+ gboolean consider_edges,
MetaRectangle *tile_area);
@@ -706,7 +707,8 @@ gboolean meta_window_can_tile_side_by_side (MetaWindow *window);
MetaWindow* meta_window_compute_tile_match (MetaWindow *window,
MetaTileMode current_mode,
- gint target_monitor);
+ gint target_monitor,
+ gboolean consider_edges);
gboolean meta_window_updates_are_frozen (MetaWindow *window);
diff --git a/src/core/window.c b/src/core/window.c
index b5d86b2..6947dee 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -2897,6 +2897,7 @@ meta_window_calculate_area_for_tile_mode (MetaWindow *window,
MetaTileMode mode,
MetaTileMode previous_mode,
gint monitor_number,
+ gboolean consider_edges,
MetaRectangle *rect)
{
MetaRectangle monitor_area;
@@ -2906,7 +2907,7 @@ meta_window_calculate_area_for_tile_mode (MetaWindow *window,
/* When tiling a window, the new matching tile window is not yet synchronized,
* so we must do that now manually. It is not necessary to recompute all windows'
* tile matches, just the current one */
- tile_match = meta_window_compute_tile_match (window, mode, monitor_number);
+ tile_match = meta_window_compute_tile_match (window, mode, monitor_number, consider_edges);
meta_window_get_work_area_for_monitor (window, monitor_number, &monitor_area);
@@ -2981,9 +2982,10 @@ meta_window_tile (MetaWindow *window,
mode,
window->tile_mode,
monitor_number,
+ FALSE,
&new_rect);
- window->tile_match = meta_window_compute_tile_match (window, mode, monitor_number);
+ window->tile_match = meta_window_compute_tile_match (window, mode, monitor_number, FALSE);
/* Track the previous mode */
window->previous_tile_mode = window->tile_mode;
@@ -6410,6 +6412,7 @@ meta_window_get_tile_area_for_mode (MetaWindow *window,
MetaTileMode mode,
MetaTileMode previous_mode,
guint monitor_number,
+ gboolean consider_edges,
MetaRectangle *tile_area)
{
g_return_if_fail (mode != META_TILE_NONE);
@@ -6418,6 +6421,7 @@ meta_window_get_tile_area_for_mode (MetaWindow *window,
mode,
previous_mode,
monitor_number,
+ consider_edges,
tile_area);
}
@@ -7526,7 +7530,8 @@ meta_window_get_tile_match (MetaWindow *window)
MetaWindow *
meta_window_compute_tile_match (MetaWindow *window,
MetaTileMode current_mode,
- gint target_monitor)
+ gint target_monitor,
+ gboolean consider_edges)
{
MetaWindow *match;
MetaStack *stack;
@@ -7562,6 +7567,9 @@ meta_window_compute_tile_match (MetaWindow *window,
{
MetaWindow *above, *bottommost, *topmost;
MetaRectangle above_rect, bottommost_rect, topmost_rect;
+ gint threshold;
+
+ threshold = meta_prefs_get_drag_threshold ();
if (meta_stack_windows_cmp (window->screen->stack, match, window) > 0)
{
@@ -7595,6 +7603,15 @@ meta_window_compute_tile_match (MetaWindow *window,
meta_rectangle_overlap (&above_rect, &topmost_rect))
return NULL;
}
+
+ /* If we're not ignoring the edges (i.e. the window effectively resized or
+ * changed workspaces) then check if windows really match.
+ */
+ if (consider_edges &&
+ window->tile_match != match &&
+ ABS (topmost_rect.x - bottommost_rect.x - bottommost_rect.width) > threshold &&
+ ABS (bottommost_rect.x - topmost_rect.x - topmost_rect.width) > threshold)
+ return NULL;
}
return match;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]