[mutter/wip/gbsneto/tiling-improvements: 7/8] window: Split retrieving and calculating tile areas



commit 80a6a4a4996ad7d2516f9da27c340b4063fd3d17
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sat Jun 17 22:24:03 2017 -0300

    window: Split retrieving and calculating tile areas
    
    There are many edge cases that must be taken into account
    when reporting an area when tiling. For example: previewing
    a window uses the new preview tile mode, and must ignore
    touching edges, while the tiling constraint must retrieve
    the exact value of the final tiling state.
    
    Thus, it is inappropriate to calculate the tiled window
    area in meta_window_get_current_tile_area(), for this
    function's semantic is to just retrieve the current tile
    area.
    
    This patch splits calculating and retriving the tile area,
    and thus makes the tiling constraint work again, for the
    reported size is the actual tile size.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=645153

 src/core/screen.c         |    5 ++++-
 src/core/stack.c          |    2 +-
 src/core/window-private.h |   16 ++++++++++------
 src/core/window.c         |   40 ++++++++++++++++++++++++----------------
 4 files changed, 39 insertions(+), 24 deletions(-)
---
diff --git a/src/core/screen.c b/src/core/screen.c
index e9a3b7f..0213f8c 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -1432,7 +1432,10 @@ meta_screen_update_tile_preview_timeout (gpointer data)
       int monitor;
 
       monitor = meta_window_get_current_tile_monitor_number (window);
-      meta_window_get_current_tile_area (window, &tile_rect);
+      meta_window_get_tile_area_for_mode (window,
+                                          &tile_rect,
+                                          window->preview_tile_mode,
+                                          window->tile_mode);
       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 2792ae3..66c59a3 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, FALSE);
+      window->tile_match = meta_window_compute_tile_match (window, window->tile_mode, FALSE);
       tmp = tmp->next;
     }
 
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 26a5d68..a831e07 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -659,9 +659,13 @@ void meta_window_get_work_area_for_logical_monitor (MetaWindow         *window,
                                                     MetaLogicalMonitor *logical_monitor,
                                                     MetaRectangle      *area);
 
-int meta_window_get_current_tile_monitor_number (MetaWindow *window);
-void meta_window_get_current_tile_area         (MetaWindow    *window,
-                                                MetaRectangle *tile_area);
+int meta_window_get_current_tile_monitor_number (MetaWindow    *window);
+void meta_window_get_tile_area_for_mode         (MetaWindow    *window,
+                                                 MetaRectangle *tile_area,
+                                                 MetaTileMode   tile_mode,
+                                                 MetaTileMode   previous_mode);
+void meta_window_get_current_tile_area          (MetaWindow    *window,
+                                                 MetaRectangle *tile_area);
 
 
 gboolean meta_window_same_application (MetaWindow *window,
@@ -703,9 +707,9 @@ void meta_window_on_all_workspaces_changed (MetaWindow *window);
 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    ignore_edges);
+MetaWindow* meta_window_compute_tile_match (MetaWindow   *window,
+                                            MetaTileMode  current_mode,
+                                            gboolean      ignore_edges);
 
 gboolean meta_window_updates_are_frozen (MetaWindow *window);
 
diff --git a/src/core/window.c b/src/core/window.c
index e70b9bd..f52ab45 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, TRUE);
+  tile_match_window = meta_window_compute_tile_match (window, window->tile_mode, TRUE);
   window->tile_match = tile_match_window;
 
   meta_window_get_work_area_current_monitor (window, &monitor_area);
@@ -6409,23 +6409,20 @@ meta_window_get_current_tile_monitor_number (MetaWindow *window)
 }
 
 void
-meta_window_get_current_tile_area (MetaWindow    *window,
-                                   MetaRectangle *tile_area)
+meta_window_get_tile_area_for_mode (MetaWindow    *window,
+                                    MetaRectangle *tile_area,
+                                    MetaTileMode   tile_mode,
+                                    MetaTileMode   previous_mode)
 {
   MetaRectangle monitor_area;
-  MetaTileMode tile_mode;
   MetaWindow *tile_match_window;
-  gboolean preview;
   gint borders_height = 0;
   gint borders_width = 0;
 
-  g_return_if_fail (window->tile_mode != META_TILE_NONE || window->preview_tile_mode != META_TILE_NONE);
-
-  preview = window->preview_tile_mode != META_TILE_NONE;
+  g_return_if_fail (tile_mode != META_TILE_NONE);
 
   /* 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, TRUE);
+  tile_match_window = meta_window_compute_tile_match (window, tile_mode, TRUE);
 
   meta_window_get_work_area_current_monitor (window, &monitor_area);
 
@@ -6456,6 +6453,11 @@ meta_window_get_current_tile_area (MetaWindow    *window,
       /* When maximized, cover the entire width*/
       tile_area->width = monitor_area.width;
     }
+  else if ((previous_mode == META_TILE_LEFT  && tile_mode == META_TILE_RIGHT) ||
+           (previous_mode == META_TILE_RIGHT && tile_mode == META_TILE_LEFT))
+    {
+      tile_area->width = monitor_area.width - tile_area->width;
+    }
   else
     {
       /* Assume half of the work area of the current monitor */
@@ -6466,6 +6468,15 @@ meta_window_get_current_tile_area (MetaWindow    *window,
     tile_area->x = monitor_area.x + monitor_area.width - tile_area->width - borders_width;
 }
 
+void
+meta_window_get_current_tile_area (MetaWindow    *window,
+                                   MetaRectangle *tile_area)
+{
+  g_return_if_fail (window->tile_mode != META_TILE_NONE);
+
+  *tile_area = window->tile_rect;
+}
+
 gboolean
 meta_window_same_application (MetaWindow *window,
                               MetaWindow *other_window)
@@ -7569,20 +7580,17 @@ meta_window_get_tile_match (MetaWindow *window)
 }
 
 MetaWindow *
-meta_window_compute_tile_match (MetaWindow *window,
-                                gboolean    preview,
-                                gboolean    ignore_edges)
+meta_window_compute_tile_match (MetaWindow   *window,
+                                MetaTileMode  current_mode,
+                                gboolean      ignore_edges)
 {
   MetaWindow *match;
   MetaStack *stack;
-  MetaTileMode current_mode;
   MetaTileMode match_tile_mode = META_TILE_NONE;
 
   if (window->shaded || window->minimized)
     return NULL;
 
-  current_mode = preview ? window->preview_tile_mode : window->tile_mode;
-
   if (current_mode == META_TILE_LEFT)
     match_tile_mode = META_TILE_RIGHT;
   else if (current_mode == META_TILE_RIGHT)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]