[metacity/wip/muktupavels/work-areas-v3: 170/170] workspace: ignore middle struts calculating screen workarea



commit bf1c1005f6c418fc539433b6dd128223e3bdea4a
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sun Jun 17 02:47:15 2018 +0300

    workspace: ignore middle struts calculating screen workarea

 src/core/boxes.c     | 22 ++++++++++++++++++++--
 src/core/testboxes.c |  5 ++++-
 src/core/workspace.c |  6 ++++--
 src/include/boxes.h  |  3 ++-
 4 files changed, 30 insertions(+), 6 deletions(-)
---
diff --git a/src/core/boxes.c b/src/core/boxes.c
index eb70a507..5032090f 100644
--- a/src/core/boxes.c
+++ b/src/core/boxes.c
@@ -518,7 +518,8 @@ compare_rect_areas (gconstpointer a, gconstpointer b)
 GList*
 meta_rectangle_get_minimal_spanning_set_for_region (
   const MetaRectangle *basic_rect,
-  const GSList  *all_struts)
+  const GSList        *all_struts,
+  gboolean             skip_middle_struts)
 {
   /* NOTE FOR OPTIMIZERS: This function *might* be somewhat slow,
    * especially due to the call to merge_spanning_rects_in_region() (which
@@ -580,7 +581,24 @@ meta_rectangle_get_minimal_spanning_set_for_region (
   for (strut_iter = all_struts; strut_iter; strut_iter = strut_iter->next)
     {
       GList *rect_iter;
-      MetaRectangle *strut_rect = &((MetaEdge *)strut_iter->data)->rect;
+      MetaEdge *strut = (MetaEdge *) strut_iter->data;
+      MetaRectangle *strut_rect = &strut->rect;
+
+      if (skip_middle_struts &&
+          strut->edge_type == META_EDGE_MONITOR)
+        {
+          if ((strut->side_type == META_SIDE_LEFT &&
+               strut_rect->x != basic_rect->x) ||
+              (strut->side_type == META_SIDE_RIGHT &&
+               strut_rect->x + strut_rect->width != basic_rect->width) ||
+              (strut->side_type == META_SIDE_TOP &&
+               strut_rect->y != basic_rect->y) ||
+              (strut->side_type == META_SIDE_BOTTOM &&
+               strut_rect->y + strut_rect->height != basic_rect->height))
+            {
+              continue;
+            }
+        }
 
       tmp_list = ret;
       ret = NULL;
diff --git a/src/core/testboxes.c b/src/core/testboxes.c
index 08f53862..de4c2e3a 100644
--- a/src/core/testboxes.c
+++ b/src/core/testboxes.c
@@ -290,7 +290,10 @@ get_screen_region (int which)
   ret = NULL;
 
   struts = get_strut_list (which);
-  ret = meta_rectangle_get_minimal_spanning_set_for_region (&basic_rect, struts);
+  ret = meta_rectangle_get_minimal_spanning_set_for_region (&basic_rect,
+                                                            struts,
+                                                            FALSE);
+
   free_strut_list (struts);
 
   return ret;
diff --git a/src/core/workspace.c b/src/core/workspace.c
index ff353a21..fd56e3de 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -646,12 +646,14 @@ ensure_work_areas_validated (MetaWorkspace *workspace)
       workspace->monitor_region[i] =
         meta_rectangle_get_minimal_spanning_set_for_region (
           &workspace->screen->monitor_infos[i].rect,
-          workspace->all_struts);
+          workspace->all_struts,
+          FALSE);
     }
   workspace->screen_region =
     meta_rectangle_get_minimal_spanning_set_for_region (
       &workspace->screen->rect,
-      workspace->all_struts);
+      workspace->all_struts,
+      TRUE);
 
   /* STEP 3: Get the work areas (region-to-maximize-to) for the screen and
    *         monitors.
diff --git a/src/include/boxes.h b/src/include/boxes.h
index 4999595b..f75bbcad 100644
--- a/src/include/boxes.h
+++ b/src/include/boxes.h
@@ -149,7 +149,8 @@ void meta_rectangle_resize_with_gravity (const MetaRectangle *old_rect,
  */
 GList*   meta_rectangle_get_minimal_spanning_set_for_region (
                                          const MetaRectangle *basic_rect,
-                                         const GSList        *all_struts);
+                                         const GSList        *all_struts,
+                                         gboolean             skip_middle_struts);
 
 /* Expand all rectangles in region by the given amount on each side */
 GList*   meta_rectangle_expand_region   (GList               *region,


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