[mutter] constraints: Don't use intersection when sliding with custom rule



commit 00b4556051345f0e7cbf714f24100b3ee8cc5ddb
Author: Jonas Ådahl <jadahl gmail com>
Date:   Fri Mar 15 18:01:50 2019 +0100

    constraints: Don't use intersection when sliding with custom rule
    
    If an intersection is empty, the (x, y) coordinates are undefined, so
    just use the work area and in-progress constrained window rect when
    sliding according to the SLIDE_X or SLIDE_Y custom placement rule.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/496

 src/core/constraints.c | 40 ++++++++++++++++++++++++++++++++--------
 1 file changed, 32 insertions(+), 8 deletions(-)
---
diff --git a/src/core/constraints.c b/src/core/constraints.c
index d468c2d92..117131b15 100644
--- a/src/core/constraints.c
+++ b/src/core/constraints.c
@@ -910,18 +910,42 @@ constrain_custom_rule (MetaWindow         *window,
   if (current_rule.constraint_adjustment &
       META_PLACEMENT_CONSTRAINT_ADJUSTMENT_SLIDE_X)
     {
-      if (info->current.x != intersection.x)
-        info->current.x = intersection.x;
-      else if (info->current.width != intersection.width)
-        info->current.x -= info->current.width - intersection.width;
+      int current_x2;
+      int work_area_monitor_x2;
+
+      current_x2 = info->current.x + info->current.width;
+      work_area_monitor_x2 = (info->work_area_monitor.x +
+                              info->work_area_monitor.width);
+
+      if (current_x2 > work_area_monitor_x2)
+        {
+          info->current.x = MAX (info->work_area_monitor.x,
+                                 work_area_monitor_x2 - info->current.width);
+        }
+      else if (info->current.x < info->work_area_monitor.x)
+        {
+          info->current.x = info->work_area_monitor.x;
+        }
     }
   if (current_rule.constraint_adjustment &
       META_PLACEMENT_CONSTRAINT_ADJUSTMENT_SLIDE_Y)
     {
-      if (info->current.y != intersection.y)
-        info->current.y = intersection.y;
-      else if (info->current.height != intersection.height)
-        info->current.y -= info->current.height - intersection.height;
+      int current_y2;
+      int work_area_monitor_y2;
+
+      current_y2 = info->current.y + info->current.height;
+      work_area_monitor_y2 = (info->work_area_monitor.y +
+                              info->work_area_monitor.height);
+
+      if (current_y2 > work_area_monitor_y2)
+        {
+          info->current.y = MAX (info->work_area_monitor.y,
+                                 work_area_monitor_y2 - info->current.height);
+        }
+      else if (info->current.y < info->work_area_monitor.y)
+        {
+          info->current.y = info->work_area_monitor.y;
+        }
     }
 
   meta_rectangle_intersect (&info->current, &info->work_area_monitor,


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