[mutter/wip/gbsneto/tiling-improvements: 9/9] window: Also consider touching edges for matching tiled windows



commit b0c826a80db616ddd9d0efe0ac3ff9643a7f5a9d
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/stack.c          |    2 +-
 src/core/window-private.h |    3 ++-
 src/core/window.c         |   19 ++++++++++++++++---
 3 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/src/core/stack.c b/src/core/stack.c
index 3ee5c74..2792ae3 100644
--- a/src/core/stack.c
+++ b/src/core/stack.c
@@ -269,7 +269,7 @@ meta_stack_update_window_tile_matches (MetaStack     *stack,
     {
       MetaWindow *window = tmp->data;
 
-      window->tile_match = meta_window_compute_tile_match (window, FALSE);
+      window->tile_match = meta_window_compute_tile_match (window, FALSE, FALSE);
       tmp = tmp->next;
     }
 
diff --git a/src/core/window-private.h b/src/core/window-private.h
index cc94469..26a5d68 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -704,7 +704,8 @@ gboolean meta_window_should_attach_to_parent (MetaWindow *window);
 gboolean meta_window_can_tile_side_by_side   (MetaWindow *window);
 
 MetaWindow* meta_window_compute_tile_match (MetaWindow *window,
-                                            gboolean    preview);
+                                            gboolean    preview,
+                                            gboolean    ignore_edges);
 
 gboolean meta_window_updates_are_frozen (MetaWindow *window);
 
diff --git a/src/core/window.c b/src/core/window.c
index 482e94b..e70b9bd 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -2900,7 +2900,7 @@ meta_window_update_tile_state_internal (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_window = meta_window_compute_tile_match (window, FALSE);
+  tile_match_window = meta_window_compute_tile_match (window, FALSE, TRUE);
   window->tile_match = tile_match_window;
 
   meta_window_get_work_area_current_monitor (window, &monitor_area);
@@ -6425,7 +6425,7 @@ meta_window_get_current_tile_area (MetaWindow    *window,
 
   /* If we are previewing, don't change the actual tile mode */
   tile_mode = preview ? window->preview_tile_mode : window->tile_mode;
-  tile_match_window = meta_window_compute_tile_match (window, preview);
+  tile_match_window = meta_window_compute_tile_match (window, preview, TRUE);
 
   meta_window_get_work_area_current_monitor (window, &monitor_area);
 
@@ -7570,7 +7570,8 @@ meta_window_get_tile_match (MetaWindow *window)
 
 MetaWindow *
 meta_window_compute_tile_match (MetaWindow *window,
-                                gboolean    preview)
+                                gboolean    preview,
+                                gboolean    ignore_edges)
 {
   MetaWindow *match;
   MetaStack *stack;
@@ -7607,6 +7608,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)
         {
@@ -7640,6 +7644,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 (!ignore_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]