[compiz] Patch to wobbly snap for outputs

Mike Cook mcook at novell.com
Fri Dec 8 11:09:56 PST 2006


Here's a patch to wobbly.c to handle edge snapping with multiple outputs...

Also, I tweaked the window edge snapping to include dock window types, to
support the case where dock windows may be on the inner edges of multiple
monitors (and thus currently ignored as struts in the output workarea setup).

I personally think we should include these "inner" struts when calculating the
workarea for each output (which also helps window maximizing), and only
ignore them in the screen workarea case (for the _NET_WORKAREA hint).

Any reason that wouldn't make sense?

...MC
-------------- next part --------------
--- plugins/wobbly.c
+++ plugins/wobbly.c
@@ -510,6 +510,9 @@ findNextWestEdge (CompWindow *w,
     int e, end;
     int x;
 
+    int        output;
+    XRectangle workArea;
+
     start = -65535.0f;
     end   =  65535.0f;
 
@@ -518,15 +521,20 @@ findNextWestEdge (CompWindow *w,
 
     x = object->position.x + w->output.left - w->input.left;
 
-    if (x >= w->screen->workArea.x)
+    output = outputDeviceForPoint (w->screen, x, object->position.y);
+    workArea = w->screen->outputDev[output].workArea;
+
+    if (x >= workArea.x)
     {
 	CompWindow *p;
 
-	v1 = w->screen->workArea.x;
+	v1 = workArea.x;
 
 	for (p = w->screen->windows; p; p = p->next)
 	{
-	    if (p->invisible || w == p || p->type != CompWindowTypeNormalMask)
+	    if (p->invisible || w == p ||
+		    (p->type != CompWindowTypeNormalMask &&
+		     p->type != CompWindowTypeDockMask))
 		continue;
 
 	    s = p->attrib.y - p->output.top;
@@ -566,7 +574,7 @@ findNextWestEdge (CompWindow *w,
     }
     else
     {
-	v2 = w->screen->workArea.x;
+	v2 = workArea.x;
     }
 
     v1 = v1 - w->output.left + w->input.left;
@@ -594,6 +602,9 @@ findNextEastEdge (CompWindow *w,
     int e, end;
     int x;
 
+    int        output;
+    XRectangle workArea; 
+
     start = -65535.0f;
     end   =  65535.0f;
 
@@ -602,15 +613,20 @@ findNextEastEdge (CompWindow *w,
 
     x = object->position.x - w->output.right + w->input.right;
 
-    if (x <= w->screen->workArea.x + w->screen->workArea.width)
+    output = outputDeviceForPoint (w->screen, x, object->position.y);
+    workArea = w->screen->outputDev[output].workArea;
+
+    if (x <= workArea.x + workArea.width)
     {
 	CompWindow *p;
 
-	v1 = w->screen->workArea.x + w->screen->workArea.width;
+	v1 = workArea.x + workArea.width;
 
 	for (p = w->screen->windows; p; p = p->next)
 	{
-	    if (p->invisible || w == p || p->type != CompWindowTypeNormalMask)
+	    if (p->invisible || w == p ||
+		    (p->type != CompWindowTypeNormalMask &&
+		     p->type != CompWindowTypeDockMask))
 		continue;
 
 	    s = p->attrib.y - p->output.top;
@@ -650,7 +666,7 @@ findNextEastEdge (CompWindow *w,
     }
     else
     {
-	v2 = w->screen->workArea.x + w->screen->workArea.width;
+	v2 = workArea.x + workArea.width;
     }
 
     v1 = v1 + w->output.right - w->input.right;
@@ -678,6 +694,9 @@ findNextNorthEdge (CompWindow *w,
     int e, end;
     int y;
 
+    int        output;
+    XRectangle workArea;
+
     start = -65535.0f;
     end   =  65535.0f;
 
@@ -686,15 +705,20 @@ findNextNorthEdge (CompWindow *w,
 
     y = object->position.y + w->output.top - w->input.top;
 
-    if (y >= w->screen->workArea.y)
+    output = outputDeviceForPoint (w->screen, object->position.x, y);
+    workArea = w->screen->outputDev[output].workArea;
+
+    if (y >= workArea.y)
     {
 	CompWindow *p;
 
-	v1 = w->screen->workArea.y;
+	v1 = workArea.y;
 
 	for (p = w->screen->windows; p; p = p->next)
 	{
-	    if (p->invisible || w == p || p->type != CompWindowTypeNormalMask)
+	    if (p->invisible || w == p ||
+		    (p->type != CompWindowTypeNormalMask &&
+		     p->type != CompWindowTypeDockMask))
 		continue;
 
 	    s = p->attrib.x - p->output.left;
@@ -734,7 +758,7 @@ findNextNorthEdge (CompWindow *w,
     }
     else
     {
-	v2 = w->screen->workArea.y;
+	v2 = workArea.y;
     }
 
     v1 = v1 - w->output.top + w->input.top;
@@ -762,6 +786,9 @@ findNextSouthEdge (CompWindow *w,
     int e, end;
     int y;
 
+    int        output;
+    XRectangle workArea;
+
     start = -65535.0f;
     end   =  65535.0f;
 
@@ -770,15 +797,20 @@ findNextSouthEdge (CompWindow *w,
 
     y = object->position.y - w->output.bottom + w->input.bottom;
 
-    if (y <= w->screen->workArea.y + w->screen->workArea.height)
+    output = outputDeviceForPoint (w->screen, object->position.x, y);
+    workArea = w->screen->outputDev[output].workArea;
+
+    if (y <= workArea.y + workArea.height)
     {
 	CompWindow *p;
 
-	v1 = w->screen->workArea.y + w->screen->workArea.height;
+	v1 = workArea.y + workArea.height;
 
 	for (p = w->screen->windows; p; p = p->next)
 	{
-	    if (p->invisible || w == p || p->type != CompWindowTypeNormalMask)
+	    if (p->invisible || w == p ||
+		    (p->type != CompWindowTypeNormalMask &&
+		     p->type != CompWindowTypeDockMask))
 		continue;
 
 	    s = p->attrib.x - p->output.left;
@@ -818,7 +850,7 @@ findNextSouthEdge (CompWindow *w,
     }
     else
     {
-	v2 = w->screen->workArea.y + w->screen->workArea.height;
+	v2 = workArea.y + workArea.height;
     }
 
     v1 = v1 + w->output.bottom - w->input.bottom;


More information about the compiz mailing list