[compiz] Patch to wobbly snap for outputs

Mike Cook mcook at novell.com
Mon Dec 18 10:03:56 PST 2006


On Mon, Dec 18, 2006 at  9:50 AM, David Reveman wrote: 
> -            if (y1 < pBox- >y2 && y2 > pBox- >y1)
> +           /* consider strut if start/end overlaps box, size ends in box,
> +              and edge is outside box or both edge & size in same output
> +              (in order to handle struts across multiple outputs) */
> +           if (y1 < pBox- >y2 && y2 > pBox- >y1 && x2 < pBox- >x2 &&
> +               (x1 < pBox- >x1 ||
> +                   outputDeviceForPoint(w- >screen, x1, y1) ==
> +                   outputDeviceForPoint(w- >screen, x2- 1, y2- 1)))
> 
> The "x2 < pBox- >x2"  check makes a lost of sense. However I fail to see
> why this:
> 
> +               (x1 < pBox- >x1 ||
> +                   outputDeviceForPoint(w- >screen, x1, y1) ==
> +                   outputDeviceForPoint(w- >screen, x2- 1, y2- 1))
> 
> check is necessary. We already know that "x2 < pBox- >x2" so the only
> struts that are rejected from this check is those that are partially
> outside the box vertically and why we would want to reject those?

Since we know the strut ends within the box, that secondary check is
meant to handle the two basic cases of a smaller box (such as for an
output workarea) to allow a strut which starts outside it, and for a larger
box (such as for the screen workarea) to ignore any internal struts which
cross over multiple outputs.

I do see I forgot to set the values in the output point check to within the
box, so it would be better to constrain the non-interesting coords to be
within box coords something like:
> +               (x1 < pBox- >x1 ||
> +                   outputDeviceForPoint(w- >screen, x1, pBox->y1) ==
> +                   outputDeviceForPoint(w- >screen, x2- 1, pBox->y1))

I've attached an updated patch (not including the fix I think you already
have) that should take care of that.  Do you see anything I'm missing?

...MC
-------------- next part --------------
--- src/screen.c
+++ src/screen.c
@@ -2680,7 +2680,13 @@ computeWorkareaForBox (CompScreen *s,
 	    x2 = x1 + w->struts->left.width;
 	    y2 = y1 + w->struts->left.height;
 
-	    if (y1 < pBox->y2 && y2 > pBox->y1)
+	    /* consider strut if start/end overlaps box, size ends in box,
+	       and edge is outside box or both edge & size in same output
+	       (in order to handle struts across multiple outputs) */
+	    if (y1 < pBox->y2 && y2 > pBox->y1 && x2 < pBox->x2 &&
+		(x1 < pBox->x1 ||
+		    outputDeviceForPoint(w->screen, x1, pBox->y1) ==
+		    outputDeviceForPoint(w->screen, x2-1, pBox->y1)))
 	    {
 		if (x2 > strutX1)
 		    strutX1 = x2;
@@ -2691,7 +2697,10 @@ computeWorkareaForBox (CompScreen *s,
 	    x2 = x1 + w->struts->right.width;
 	    y2 = y1 + w->struts->right.height;
 
-	    if (y1 < pBox->y2 && y2 > pBox->y1)
+	    if (y1 < pBox->y2 && y2 > pBox->y1 && x1 > pBox->x1 &&
+		(x2 > pBox->x2 ||
+		    outputDeviceForPoint(w->screen, x1, pBox->y1) ==
+		    outputDeviceForPoint(w->screen, x2-1, pBox->y1)))
 	    {
 		if (x1 < strutX2)
 		    strutX2 = x1;
@@ -2702,7 +2710,10 @@ computeWorkareaForBox (CompScreen *s,
 	    x2 = x1 + w->struts->top.width;
 	    y2 = y1 + w->struts->top.height;

-	    if (x1 < pBox->x2 && x2 > pBox->x1)
+	    if (x1 < pBox->x2 && x2 > pBox->x1 && y2 < pBox->y2 &&
+		(y1 < pBox->y1 ||
+		    outputDeviceForPoint(w->screen, pBox->x1, y1) ==
+		    outputDeviceForPoint(w->screen, pBox->x1, y2-1)))
 	    {
 		if (y2 > strutY1)
 		    strutY1 = y2;
@@ -2713,7 +2724,10 @@ computeWorkareaForBox (CompScreen *s,
 	    x2 = x1 + w->struts->bottom.width;
 	    y2 = y1 + w->struts->bottom.height;
 
-	    if (x1 < pBox->x2 && x2 > pBox->x1)
+	    if (x1 < pBox->x2 && x2 > pBox->x1 && y1 > pBox->y1 &&
+		(y2 > pBox->y2 ||
+		    outputDeviceForPoint(w->screen, pBox->x1, y1) ==
+		    outputDeviceForPoint(w->screen, pBox->x1, y2-1)))
 	    {
 		if (y1 < strutY2)
 		    strutY2 = y1;


More information about the compiz mailing list